Block-Structured AMR Software Framework
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
44template <typename... Ops, typename... Ts, typename FAB, typename F,
45 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
46typename ReduceData<Ts...>::Type
47ParReduce (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
94template <typename Op, typename T, typename FAB, typename F,
95 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
96T
97ParReduce (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
145template <typename... Ops, typename... Ts, typename FAB, typename F,
146 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
147typename ReduceData<Ts...>::Type
148ParReduce (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
191template <typename Op, typename T, typename FAB, typename F,
192 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
193T
194ParReduce (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
238template <typename... Ops, typename... Ts, typename FAB, typename F,
239 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
240typename ReduceData<Ts...>::Type
241ParReduce (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
282template <typename Op, typename T, typename FAB, typename F,
283 typename foo = std::enable_if_t<IsBaseFab<FAB>::value> >
284T
285ParReduce (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
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:127
Struct for holding types.
Definition AMReX_TypeList.H:12