Block-Structured AMR Software Framework
AMReX_ParReduce.H
Go to the documentation of this file.
1 #ifndef AMREX_PAR_REDUCE_H_
2 #define AMREX_PAR_REDUCE_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_Reduce.H>
6 
7 namespace amrex {
8 
44 template <typename... Ops, typename... Ts, typename FAB, typename F,
45  typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
46 typename ReduceData<Ts...>::Type
47 ParReduce (TypeList<Ops...> operation_list, TypeList<Ts...> type_list,
48  FabArray<FAB> const& fa, IntVect const& nghost, F&& f)
49 {
50  amrex::ignore_unused(operation_list,type_list);
51  ReduceOps<Ops...> reduce_op;
52  ReduceData<Ts...> reduce_data(reduce_op);
53  reduce_op.eval(fa, nghost, reduce_data, std::forward<F>(f));
54  return reduce_data.value(reduce_op);
55 }
56 
94 template <typename Op, typename T, typename FAB, typename F,
95  typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
96 T
97 ParReduce (TypeList<Op> operation_list, TypeList<T> type_list,
98  FabArray<FAB> const& fa, IntVect const& nghost, F&& f)
99 {
100  amrex::ignore_unused(operation_list,type_list);
101  ReduceOps<Op> reduce_op;
102  ReduceData<T> reduce_data(reduce_op);
103  reduce_op.eval(fa, nghost, reduce_data, std::forward<F>(f));
104  auto const& hv = reduce_data.value(reduce_op);
105  return amrex::get<0>(hv);
106 }
107 
145 template <typename... Ops, typename... Ts, typename FAB, typename F,
146  typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
147 typename ReduceData<Ts...>::Type
148 ParReduce (TypeList<Ops...> operation_list, TypeList<Ts...> type_list,
149  FabArray<FAB> const& fa, IntVect const& nghost, int ncomp, F&& f)
150 {
151  amrex::ignore_unused(operation_list,type_list);
152  ReduceOps<Ops...> reduce_op;
153  ReduceData<Ts...> reduce_data(reduce_op);
154  reduce_op.eval(fa, nghost, ncomp, reduce_data, std::forward<F>(f));
155  return reduce_data.value(reduce_op);
156 }
157 
191 template <typename Op, typename T, typename FAB, typename F,
192  typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
193 T
194 ParReduce (TypeList<Op> operation_list, TypeList<T> type_list,
195  FabArray<FAB> const& fa, IntVect const& nghost, int ncomp, F&& f)
196 {
197  amrex::ignore_unused(operation_list,type_list);
198  ReduceOps<Op> reduce_op;
199  ReduceData<T> reduce_data(reduce_op);
200  reduce_op.eval(fa, nghost, ncomp, reduce_data, std::forward<F>(f));
201  auto const& hv = reduce_data.value(reduce_op);
202  return amrex::get<0>(hv);
203 }
204 
238 template <typename... Ops, typename... Ts, typename FAB, typename F,
239  typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
240 typename ReduceData<Ts...>::Type
241 ParReduce (TypeList<Ops...> operation_list, TypeList<Ts...> type_list,
242  FabArray<FAB> const& fa, F&& f)
243 {
244  return ParReduce(operation_list, type_list, fa, IntVect(0), std::forward<F>(f));
245 }
246 
282 template <typename Op, typename T, typename FAB, typename F,
283  typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
284 T
285 ParReduce (TypeList<Op> operation_list, TypeList<T> type_list,
286  FabArray<FAB> const& fa, F&& f)
287 {
288  return ParReduce(operation_list, type_list, fa, IntVect(0), std::forward<F>(f));
289 }
290 
291 }
292 #endif
An Array of FortranArrayBox(FAB)-like Objects.
Definition: AMReX_FabArray.H:344
Definition: AMReX_Reduce.H:249
Type value()
Definition: AMReX_Reduce.H:281
Definition: AMReX_Reduce.H:364
std::enable_if_t< IsFabArray< MF >::value > eval(MF const &mf, IntVect const &nghost, D &reduce_data, F &&f)
Definition: AMReX_Reduce.H:441
@ FAB
Definition: AMReX_AmrvisConstants.H:86
static int f(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:44
Definition: AMReX_Amr.cpp:49
ReduceData< Ts... >::Type ParReduce(TypeList< Ops... > operation_list, TypeList< Ts... > type_list, FabArray< FAB > const &fa, IntVect const &nghost, F &&f)
Parallel reduce for MultiFab/FabArray.
Definition: AMReX_ParReduce.H:47
IntVectND< AMREX_SPACEDIM > IntVect
Definition: AMReX_BaseFwd.H:30
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition: AMReX.H:111
Struct for holding types.
Definition: AMReX_TypeList.H:12