Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
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
7namespace amrex {
8
45template <typename... Ops, typename... Ts, typename FAB, typename F,
46 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
47typename ReduceData<Ts...>::Type
48ParReduce (TypeList<Ops...> operation_list, TypeList<Ts...> type_list,
49 FabArray<FAB> const& fa, IntVect const& nghost, F&& f)
50{
51 amrex::ignore_unused(operation_list,type_list);
52 ReduceOps<Ops...> reduce_op;
53 ReduceData<Ts...> reduce_data(reduce_op);
54 reduce_op.eval(fa, nghost, reduce_data, std::forward<F>(f));
55 return reduce_data.value(reduce_op);
56}
57
96template <typename Op, typename T, typename FAB, typename F,
97 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
98T
99ParReduce (TypeList<Op> operation_list, TypeList<T> type_list,
100 FabArray<FAB> const& fa, IntVect const& nghost, F&& f)
101{
102 amrex::ignore_unused(operation_list,type_list);
103 ReduceOps<Op> reduce_op;
104 ReduceData<T> reduce_data(reduce_op);
105 reduce_op.eval(fa, nghost, reduce_data, std::forward<F>(f));
106 auto const& hv = reduce_data.value(reduce_op);
107 return amrex::get<0>(hv);
108}
109
148template <typename... Ops, typename... Ts, typename FAB, typename F,
149 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
150typename ReduceData<Ts...>::Type
151ParReduce (TypeList<Ops...> operation_list, TypeList<Ts...> type_list,
152 FabArray<FAB> const& fa, IntVect const& nghost, int ncomp, F&& f)
153{
154 amrex::ignore_unused(operation_list,type_list);
155 ReduceOps<Ops...> reduce_op;
156 ReduceData<Ts...> reduce_data(reduce_op);
157 reduce_op.eval(fa, nghost, ncomp, reduce_data, std::forward<F>(f));
158 return reduce_data.value(reduce_op);
159}
160
195template <typename Op, typename T, typename FAB, typename F,
196 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
197T
198ParReduce (TypeList<Op> operation_list, TypeList<T> type_list,
199 FabArray<FAB> const& fa, IntVect const& nghost, int ncomp, F&& f)
200{
201 amrex::ignore_unused(operation_list,type_list);
202 ReduceOps<Op> reduce_op;
203 ReduceData<T> reduce_data(reduce_op);
204 reduce_op.eval(fa, nghost, ncomp, reduce_data, std::forward<F>(f));
205 auto const& hv = reduce_data.value(reduce_op);
206 return amrex::get<0>(hv);
207}
208
243template <typename... Ops, typename... Ts, typename FAB, typename F,
244 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
245typename ReduceData<Ts...>::Type
246ParReduce (TypeList<Ops...> operation_list, TypeList<Ts...> type_list,
247 FabArray<FAB> const& fa, F&& f)
248{
249 return ParReduce(operation_list, type_list, fa, IntVect(0), std::forward<F>(f));
250}
251
288template <typename Op, typename T, typename FAB, typename F,
289 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
290T
291ParReduce (TypeList<Op> operation_list, TypeList<T> type_list,
292 FabArray<FAB> const& fa, F&& f)
293{
294 return ParReduce(operation_list, type_list, fa, IntVect(0), std::forward<F>(f));
295}
296
297}
298#endif
An Array of FortranArrayBox(FAB)-like Objects.
Definition AMReX_FabArray.H:345
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:433
Definition AMReX_Amr.cpp:49
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:138
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. The reduce result is local and it's the user's responsibility ...
Definition AMReX_ParReduce.H:48
IntVectND< 3 > IntVect
Definition AMReX_BaseFwd.H:30
Struct for holding types.
Definition AMReX_TypeList.H:12