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
41template <typename MF, typename F>
42std::enable_if_t<IsFabArray<MF>::value>
43ParallelFor (MF const& mf, F&& f)
44{
45 detail::ParallelFor_doit(mf, IntVect(0), FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
46}
47
64template <int MT, typename MF, typename F>
65std::enable_if_t<IsFabArray<MF>::value>
66ParallelFor (MF const& mf, F&& f)
67{
68#ifdef AMREX_USE_GPU
69 detail::ParallelFor_doit<MT>(mf, IntVect(0), 1, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
70#else
71 detail::ParallelFor_doit(mf, IntVect(0), FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
72#endif
73}
74
91template <typename MF, typename F>
92std::enable_if_t<IsFabArray<MF>::value>
93ParallelFor (MF const& mf, IntVect const& ng, F&& f)
94{
95 detail::ParallelFor_doit(mf, ng, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
96}
97
115template <int MT, typename MF, typename F>
116std::enable_if_t<IsFabArray<MF>::value>
117ParallelFor (MF const& mf, IntVect const& ng, F&& f)
118{
119#ifdef AMREX_USE_GPU
120 detail::ParallelFor_doit<MT>(mf, ng, 1, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
121#else
122 detail::ParallelFor_doit(mf, ng, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
123#endif
124}
125
143template <typename MF, typename F>
144std::enable_if_t<IsFabArray<MF>::value>
145ParallelFor (MF const& mf, IntVect const& ng, int ncomp, F&& f)
146{
147 detail::ParallelFor_doit(mf, ng, ncomp, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
148}
149
168template <int MT, typename MF, typename F>
169std::enable_if_t<IsFabArray<MF>::value>
170ParallelFor (MF const& mf, IntVect const& ng, int ncomp, F&& f)
171{
172#ifdef AMREX_USE_GPU
173 detail::ParallelFor_doit<MT>(mf, ng, ncomp, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
174#else
175 detail::ParallelFor_doit(mf, ng, ncomp, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
176#endif
177}
178
196template <typename MF, typename F>
197std::enable_if_t<IsFabArray<MF>::value>
198ParallelFor (MF const& mf, TileSize const& ts, F&& f)
199{
200 detail::ParallelFor_doit(mf, IntVect(0), ts.tile_size, false, std::forward<F>(f));
201}
202
221template <int MT, typename MF, typename F>
222std::enable_if_t<IsFabArray<MF>::value>
223ParallelFor (MF const& mf, TileSize const& ts, F&& f)
224{
225#ifdef AMREX_USE_GPU
226 detail::ParallelFor_doit<MT>(mf, IntVect(0), 1, ts.tile_size, false, std::forward<F>(f));
227#else
228 detail::ParallelFor_doit(mf, IntVect(0), ts.tile_size, false, std::forward<F>(f));
229#endif
230}
231
250template <typename MF, typename F>
251std::enable_if_t<IsFabArray<MF>::value>
252ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, F&& f)
253{
254 detail::ParallelFor_doit(mf, ng, ts.tile_size, false, std::forward<F>(f));
255}
256
276template <int MT, typename MF, typename F>
277std::enable_if_t<IsFabArray<MF>::value>
278ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, F&& f)
279{
280#ifdef AMREX_USE_GPU
281 detail::ParallelFor_doit<MT>(mf, ng, 1, ts.tile_size, false, std::forward<F>(f));
282#else
283 detail::ParallelFor_doit(mf, ng, ts.tile_size, false, std::forward<F>(f));
284#endif
285}
286
306template <typename MF, typename F>
307std::enable_if_t<IsFabArray<MF>::value>
308ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, F&& f)
309{
310 detail::ParallelFor_doit(mf, ng, ncomp, ts.tile_size, false, std::forward<F>(f));
311}
312
333template <int MT, typename MF, typename F>
334std::enable_if_t<IsFabArray<MF>::value>
335ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, F&& f)
336{
337#ifdef AMREX_USE_GPU
338 detail::ParallelFor_doit<MT>(mf, ng, ncomp, ts.tile_size, false, std::forward<F>(f));
339#else
340 detail::ParallelFor_doit(mf, ng, ncomp, ts.tile_size, false, std::forward<F>(f));
341#endif
342}
343
363template <typename MF, typename F>
364std::enable_if_t<IsFabArray<MF>::value>
365ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, DynamicTiling dt, F&& f)
366{
367 detail::ParallelFor_doit(mf, ng, ts.tile_size, dt.dynamic, std::forward<F>(f));
368}
369
390template <typename MF, typename F>
391std::enable_if_t<IsFabArray<MF>::value>
392ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts,
393 DynamicTiling dt, F&& f)
394{
395 detail::ParallelFor_doit(mf, ng, ncomp, ts.tile_size, dt.dynamic, std::forward<F>(f));
396}
397
418template <int MT, typename MF, typename F>
419std::enable_if_t<IsFabArray<MF>::value>
420ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts,
421 DynamicTiling dt, F&& f)
422{
423#ifdef AMREX_USE_GPU
424 detail::ParallelFor_doit<MT>(mf, ng, 1, ts.tile_size, dt.dynamic, std::forward<F>(f));
425#else
426 detail::ParallelFor_doit(mf, ng, ts.tile_size, dt.dynamic, std::forward<F>(f));
427#endif
428}
429
451template <int MT, typename MF, typename F>
452std::enable_if_t<IsFabArray<MF>::value>
453ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts,
454 DynamicTiling dt, F&& f)
455{
456#ifdef AMREX_USE_GPU
457 detail::ParallelFor_doit<MT>(mf, ng, ncomp, ts.tile_size, dt.dynamic, std::forward<F>(f));
458#else
459 detail::ParallelFor_doit(mf, ng, ncomp, ts.tile_size, dt.dynamic, std::forward<F>(f));
460#endif
461}
462
463}
464
465#endif
static IntVect mfiter_tile_size
Default tilesize in MFIter.
Definition AMReX_FabArrayBase.H:289
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:193
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:33
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