@@ -1059,19 +1059,22 @@ public:
1059
1059
#ifdef AMREX_USE_OMP
1060
1060
#pragma omp parallel
1061
1061
#endif
1062
- for (MFIter mfi (mf,true ); mfi.isValid (); ++mfi) {
1063
- Box const & b = mfi.growntilebox (nghost);
1064
- const int li = mfi.LocalIndex ();
1065
- auto & rr_ref = reduce_data.reference (OpenMP::get_thread_num ());
1066
- auto rr = rr_ref;
1067
- const auto lo = amrex::lbound (b);
1068
- const auto hi = amrex::ubound (b);
1069
- for (int k = lo.z ; k <= hi.z ; ++k) {
1070
- for (int j = lo.y ; j <= hi.y ; ++j) {
1071
- for (int i = lo.x ; i <= hi.x ; ++i) {
1072
- Reduce::detail::for_each_local<0 , ReduceTuple, Ps...>(rr, f (li,i,j,k));
1073
- }}}
1074
- rr_ref = rr;
1062
+ {
1063
+ ReduceTuple rr;
1064
+ Reduce::detail::for_each_init<0 , ReduceTuple, Ps...>(rr);
1065
+ for (MFIter mfi (mf,true ); mfi.isValid (); ++mfi) {
1066
+ Box const & b = mfi.growntilebox (nghost);
1067
+ const int li = mfi.LocalIndex ();
1068
+ const auto lo = amrex::lbound (b);
1069
+ const auto hi = amrex::ubound (b);
1070
+ for (int k = lo.z ; k <= hi.z ; ++k) {
1071
+ for (int j = lo.y ; j <= hi.y ; ++j) {
1072
+ for (int i = lo.x ; i <= hi.x ; ++i) {
1073
+ Reduce::detail::for_each_local<0 , ReduceTuple, Ps...>(rr, f (li,i,j,k));
1074
+ }}}
1075
+ }
1076
+ Reduce::detail::for_each_local<0 , ReduceTuple, Ps...>(
1077
+ reduce_data.reference (OpenMP::get_thread_num ()), rr);
1075
1078
}
1076
1079
}
1077
1080
@@ -1083,39 +1086,44 @@ public:
1083
1086
#ifdef AMREX_USE_OMP
1084
1087
#pragma omp parallel
1085
1088
#endif
1086
- for (MFIter mfi (mf,true ); mfi.isValid (); ++mfi) {
1087
- Box const & b = mfi.growntilebox (nghost);
1088
- const int li = mfi.LocalIndex ();
1089
- auto & rr_ref = reduce_data.reference (OpenMP::get_thread_num ());
1090
- auto rr = rr_ref;
1091
- const auto lo = amrex::lbound (b);
1092
- const auto hi = amrex::ubound (b);
1093
- for (int n = 0 ; n < ncomp; ++n) {
1094
- for (int k = lo.z ; k <= hi.z ; ++k) {
1095
- for (int j = lo.y ; j <= hi.y ; ++j) {
1096
- for (int i = lo.x ; i <= hi.x ; ++i) {
1097
- Reduce::detail::for_each_local<0 , ReduceTuple, Ps...>(rr, f (li,i,j,k,n));
1098
- }}}}
1099
- rr_ref = rr;
1089
+ {
1090
+ ReduceTuple rr;
1091
+ Reduce::detail::for_each_init<0 , ReduceTuple, Ps...>(rr);
1092
+ for (MFIter mfi (mf,true ); mfi.isValid (); ++mfi) {
1093
+ Box const & b = mfi.growntilebox (nghost);
1094
+ const int li = mfi.LocalIndex ();
1095
+ const auto lo = amrex::lbound (b);
1096
+ const auto hi = amrex::ubound (b);
1097
+ for (int n = 0 ; n < ncomp; ++n) {
1098
+ for (int k = lo.z ; k <= hi.z ; ++k) {
1099
+ for (int j = lo.y ; j <= hi.y ; ++j) {
1100
+ for (int i = lo.x ; i <= hi.x ; ++i) {
1101
+ Reduce::detail::for_each_local<0 , ReduceTuple, Ps...>(rr, f (li,i,j,k,n));
1102
+ }}}}
1103
+ }
1104
+ Reduce::detail::for_each_local<0 , ReduceTuple, Ps...>(
1105
+ reduce_data.reference (OpenMP::get_thread_num ()), rr);
1100
1106
}
1101
1107
}
1102
1108
1103
1109
template <typename D, typename F>
1104
1110
void eval (Box const & box, D & reduce_data, F&& f)
1105
1111
{
1106
- auto & rr_ref = reduce_data.reference (OpenMP::get_thread_num ());
1107
- auto rr = rr_ref;
1112
+ using ReduceTuple = typename D::Type;
1113
+ ReduceTuple rr;
1114
+ Reduce::detail::for_each_init<0 , ReduceTuple, Ps...>(rr);
1108
1115
call_f<D>(box, rr, std::forward<F>(f));
1109
- rr_ref = rr;
1116
+ Reduce::detail::for_each_local<0 , ReduceTuple, Ps...>(
1117
+ reduce_data.reference (OpenMP::get_thread_num ()), rr);
1110
1118
}
1111
1119
1112
1120
template <typename N, typename D, typename F,
1113
1121
typename M=std::enable_if_t <std::is_integral_v<N>> >
1114
1122
void eval (Box const & box, N ncomp, D & reduce_data, F const & f)
1115
1123
{
1116
1124
using ReduceTuple = typename D::Type;
1117
- auto & rr_ref = reduce_data. reference ( OpenMP::get_thread_num ()) ;
1118
- auto rr = rr_ref ;
1125
+ ReduceTuple rr ;
1126
+ Reduce::detail::for_each_init< 0 , ReduceTuple, Ps...>(rr) ;
1119
1127
const auto lo = amrex::lbound (box);
1120
1128
const auto hi = amrex::ubound (box);
1121
1129
for (N n = 0 ; n < ncomp; ++n) {
@@ -1124,20 +1132,22 @@ public:
1124
1132
for (int i = lo.x ; i <= hi.x ; ++i) {
1125
1133
Reduce::detail::for_each_local<0 , ReduceTuple, Ps...>(rr, f (i,j,k,n));
1126
1134
}}}}
1127
- rr_ref = rr;
1135
+ Reduce::detail::for_each_local<0 , ReduceTuple, Ps...>(
1136
+ reduce_data.reference (OpenMP::get_thread_num ()), rr);
1128
1137
}
1129
1138
1130
1139
template <typename N, typename D, typename F,
1131
1140
typename M=std::enable_if_t <std::is_integral_v<N>> >
1132
1141
void eval (N n, D & reduce_data, F const & f)
1133
1142
{
1134
1143
using ReduceTuple = typename D::Type;
1135
- auto & rr_ref = reduce_data. reference ( OpenMP::get_thread_num ()) ;
1136
- auto rr = rr_ref ;
1144
+ ReduceTuple rr ;
1145
+ Reduce::detail::for_each_init< 0 , ReduceTuple, Ps...>(rr) ;
1137
1146
for (N i = 0 ; i < n; ++i) {
1138
1147
Reduce::detail::for_each_local<0 , ReduceTuple, Ps...>(rr, f (i));
1139
1148
}
1140
- rr_ref = rr;
1149
+ Reduce::detail::for_each_local<0 , ReduceTuple, Ps...>(
1150
+ reduce_data.reference (OpenMP::get_thread_num ()), rr);
1141
1151
}
1142
1152
1143
1153
template <typename D>
0 commit comments