Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
AMReX_MFParallelFor.H
Go to the documentation of this file.
1#ifndef AMREX_MF_PARALLEL_FOR_H_
2#define AMREX_MF_PARALLEL_FOR_H_
3#include <AMReX_Config.H>
4
6#include <AMReX_TypeTraits.H>
7
8#ifdef AMREX_USE_GPU
10#else
12#endif
13
14namespace amrex {
15
16struct TileSize {
18 explicit TileSize (IntVect const& ts) noexcept : tile_size(ts) {}
19};
20
22 bool dynamic;
23 explicit DynamicTiling (bool f) noexcept : dynamic(f) {}
24};
25
26namespace experimental {
27
43template <typename MF, typename F>
44std::enable_if_t<IsFabArray<MF>::value>
45ParallelFor (MF const& mf, F&& f)
46{
47 detail::ParallelFor(mf, IntVect(0), FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
48}
49
66template <int MT, typename MF, typename F>
67std::enable_if_t<IsFabArray<MF>::value>
68ParallelFor (MF const& mf, F&& f)
69{
70#ifdef AMREX_USE_GPU
71 detail::ParallelFor<MT>(mf, IntVect(0), FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
72#else
73 detail::ParallelFor(mf, IntVect(0), FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
74#endif
75}
76
93template <typename MF, typename F>
94std::enable_if_t<IsFabArray<MF>::value>
95ParallelFor (MF const& mf, IntVect const& ng, F&& f)
96{
97 detail::ParallelFor(mf, ng, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
98}
99
117template <int MT, typename MF, typename F>
118std::enable_if_t<IsFabArray<MF>::value>
119ParallelFor (MF const& mf, IntVect const& ng, F&& f)
120{
121#ifdef AMREX_USE_GPU
122 detail::ParallelFor<MT>(mf, ng, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
123#else
124 detail::ParallelFor(mf, ng, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
125#endif
126}
127
145template <typename MF, typename F>
146std::enable_if_t<IsFabArray<MF>::value>
147ParallelFor (MF const& mf, IntVect const& ng, int ncomp, F&& f)
148{
149 detail::ParallelFor(mf, ng, ncomp, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
150}
151
170template <int MT, typename MF, typename F>
171std::enable_if_t<IsFabArray<MF>::value>
172ParallelFor (MF const& mf, IntVect const& ng, int ncomp, F&& f)
173{
174#ifdef AMREX_USE_GPU
175 detail::ParallelFor<MT>(mf, ng, ncomp, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
176#else
177 detail::ParallelFor(mf, ng, ncomp, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
178#endif
179}
180
198template <typename MF, typename F>
199std::enable_if_t<IsFabArray<MF>::value>
200ParallelFor (MF const& mf, TileSize const& ts, F&& f)
201{
202 detail::ParallelFor(mf, IntVect(0), ts.tile_size, false, std::forward<F>(f));
203}
204
223template <int MT, typename MF, typename F>
224std::enable_if_t<IsFabArray<MF>::value>
225ParallelFor (MF const& mf, TileSize const& ts, F&& f)
226{
227#ifdef AMREX_USE_GPU
228 detail::ParallelFor<MT>(mf, IntVect(0), ts.tile_size, false, std::forward<F>(f));
229#else
230 detail::ParallelFor(mf, IntVect(0), ts.tile_size, false, std::forward<F>(f));
231#endif
232}
233
252template <typename MF, typename F>
253std::enable_if_t<IsFabArray<MF>::value>
254ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, F&& f)
255{
256 detail::ParallelFor(mf, ng, ts.tile_size, false, std::forward<F>(f));
257}
258
278template <int MT, typename MF, typename F>
279std::enable_if_t<IsFabArray<MF>::value>
280ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, F&& f)
281{
282#ifdef AMREX_USE_GPU
283 detail::ParallelFor<MT>(mf, ng, ts.tile_size, false, std::forward<F>(f));
284#else
285 detail::ParallelFor(mf, ng, ts.tile_size, false, std::forward<F>(f));
286#endif
287}
288
308template <typename MF, typename F>
309std::enable_if_t<IsFabArray<MF>::value>
310ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, F&& f)
311{
312 detail::ParallelFor(mf, ng, ncomp, ts.tile_size, false, std::forward<F>(f));
313}
314
335template <int MT, typename MF, typename F>
336std::enable_if_t<IsFabArray<MF>::value>
337ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, F&& f)
338{
339#ifdef AMREX_USE_GPU
340 detail::ParallelFor<MT>(mf, ng, ncomp, ts.tile_size, false, std::forward<F>(f));
341#else
342 detail::ParallelFor(mf, ng, ncomp, ts.tile_size, false, std::forward<F>(f));
343#endif
344}
345
365template <typename MF, typename F>
366std::enable_if_t<IsFabArray<MF>::value>
367ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, DynamicTiling dt, F&& f)
368{
369 detail::ParallelFor(mf, ng, ts.tile_size, dt.dynamic, std::forward<F>(f));
370}
371
392template <typename MF, typename F>
393std::enable_if_t<IsFabArray<MF>::value>
394ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts,
395 DynamicTiling dt, F&& f)
396{
397 detail::ParallelFor(mf, ng, ncomp, ts.tile_size, dt.dynamic, std::forward<F>(f));
398}
399
420template <int MT, typename MF, typename F>
421std::enable_if_t<IsFabArray<MF>::value>
422ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts,
423 DynamicTiling dt, F&& f)
424{
425#ifdef AMREX_USE_GPU
426 detail::ParallelFor<MT>(mf, ng, ts.tile_size, dt.dynamic, std::forward<F>(f));
427#else
428 detail::ParallelFor(mf, ng, ts.tile_size, dt.dynamic, std::forward<F>(f));
429#endif
430}
431
453template <int MT, typename MF, typename F>
454std::enable_if_t<IsFabArray<MF>::value>
455ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts,
456 DynamicTiling dt, F&& f)
457{
458#ifdef AMREX_USE_GPU
459 detail::ParallelFor<MT>(mf, ng, ncomp, ts.tile_size, dt.dynamic, std::forward<F>(f));
460#else
461 detail::ParallelFor(mf, ng, ncomp, ts.tile_size, dt.dynamic, std::forward<F>(f));
462#endif
463}
464
465}
466
468
469}
470
471#endif
static AMREX_EXPORT IntVect mfiter_tile_size
Default tilesize in MFIter.
Definition AMReX_FabArrayBase.H:288
std::enable_if_t< IsFabArray< MF >::value > ParallelFor(MF const &mf, IntVect const &nghost, int ncomp, IntVect const &, bool, F const &f)
Definition AMReX_MFParallelForG.H:75
std::enable_if_t< IsFabArray< MF >::value > ParallelFor(MF const &mf, F &&f)
ParallelFor for MultiFab/FabArray.
Definition AMReX_MFParallelFor.H:45
Definition AMReX_Amr.cpp:49
std::enable_if_t< std::is_integral_v< T > > ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:191
IntVectND< AMREX_SPACEDIM > IntVect
Definition AMReX_BaseFwd.H:30
Definition AMReX_MFParallelFor.H:21
DynamicTiling(bool f) noexcept
Definition AMReX_MFParallelFor.H:23
bool dynamic
Definition AMReX_MFParallelFor.H:22
Definition AMReX_MFParallelFor.H:16
TileSize(IntVect const &ts) noexcept
Definition AMReX_MFParallelFor.H:18
IntVect tile_size
Definition AMReX_MFParallelFor.H:17