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
196template <typename Op, typename T, typename FAB, typename F,
197 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
198T
199ParReduce (TypeList<Op> operation_list, TypeList<T> type_list,
200 FabArray<FAB> const& fa, IntVect const& nghost, int ncomp, F&& f)
201{
202 amrex::ignore_unused(operation_list,type_list);
203 ReduceOps<Op> reduce_op;
204 ReduceData<T> reduce_data(reduce_op);
205 reduce_op.eval(fa, nghost, ncomp, reduce_data, std::forward<F>(f));
206 auto const& hv = reduce_data.value(reduce_op);
207 return amrex::get<0>(hv);
208}
209
244template <typename... Ops, typename... Ts, typename FAB, typename F,
245 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
246typename ReduceData<Ts...>::Type
247ParReduce (TypeList<Ops...> operation_list, TypeList<Ts...> type_list,
248 FabArray<FAB> const& fa, F&& f)
249{
250 return ParReduce(operation_list, type_list, fa, IntVect(0), std::forward<F>(f));
251}
252
289template <typename Op, typename T, typename FAB, typename F,
290 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
291T
292ParReduce (TypeList<Op> operation_list, TypeList<T> type_list,
293 FabArray<FAB> const& fa, F&& f)
294{
295 return ParReduce(operation_list, type_list, fa, IntVect(0), std::forward<F>(f));
296}
297
298}
299#endif
An Array of FortranArrayBox(FAB)-like Objects.
Definition AMReX_FabArray.H:350
Definition AMReX_Reduce.H:453
Type value()
Definition AMReX_Reduce.H:488
Definition AMReX_Reduce.H:612
std::enable_if_t< IsFabArray< MF >::value > eval(MF const &mf, IntVect const &nghost, D &reduce_data, F &&f)
Definition AMReX_Reduce.H:746
Definition AMReX_Amr.cpp:49
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:139
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
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:33
Struct for holding types.
Definition AMReX_TypeList.H:13