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
5#include <AMReX_Concepts.H>
7#include <AMReX_TypeTraits.H>
8
9#ifdef AMREX_USE_GPU
11#else
13#endif
14
15namespace amrex {
16
17struct TileSize {
19 explicit TileSize (IntVect const& ts) noexcept : tile_size(ts) {}
20};
21
23 bool dynamic;
24 explicit DynamicTiling (bool f) noexcept : dynamic(f) {}
25};
26
42template <FabArrayType MF, typename F>
43void
44ParallelFor (MF const& mf, F&& f)
45{
46 detail::ParallelFor_doit(mf, IntVect(0), FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
47}
48
65template <int MT, FabArrayType MF, typename F>
66void
67ParallelFor (MF const& mf, F&& f)
68{
69#ifdef AMREX_USE_GPU
70 detail::ParallelFor_doit<MT>(mf, IntVect(0), 1, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
71#else
72 detail::ParallelFor_doit(mf, IntVect(0), FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
73#endif
74}
75
92template <FabArrayType MF, typename F>
93void
94ParallelFor (MF const& mf, IntVect const& ng, F&& f)
95{
96 detail::ParallelFor_doit(mf, ng, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
97}
98
116template <int MT, FabArrayType MF, typename F>
117void
118ParallelFor (MF const& mf, IntVect const& ng, F&& f)
119{
120#ifdef AMREX_USE_GPU
121 detail::ParallelFor_doit<MT>(mf, ng, 1, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
122#else
123 detail::ParallelFor_doit(mf, ng, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
124#endif
125}
126
144template <FabArrayType MF, typename F>
145void
146ParallelFor (MF const& mf, IntVect const& ng, int ncomp, F&& f)
147{
148 detail::ParallelFor_doit(mf, ng, ncomp, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
149}
150
169template <int MT, FabArrayType MF, typename F>
170void
171ParallelFor (MF const& mf, IntVect const& ng, int ncomp, F&& f)
172{
173#ifdef AMREX_USE_GPU
174 detail::ParallelFor_doit<MT>(mf, ng, ncomp, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
175#else
176 detail::ParallelFor_doit(mf, ng, ncomp, FabArrayBase::mfiter_tile_size, false, std::forward<F>(f));
177#endif
178}
179
197template <FabArrayType MF, typename F>
198void
199ParallelFor (MF const& mf, TileSize const& ts, F&& f)
200{
201 detail::ParallelFor_doit(mf, IntVect(0), ts.tile_size, false, std::forward<F>(f));
202}
203
222template <int MT, FabArrayType MF, typename F>
223void
224ParallelFor (MF const& mf, TileSize const& ts, F&& f)
225{
226#ifdef AMREX_USE_GPU
227 detail::ParallelFor_doit<MT>(mf, IntVect(0), 1, ts.tile_size, false, std::forward<F>(f));
228#else
229 detail::ParallelFor_doit(mf, IntVect(0), ts.tile_size, false, std::forward<F>(f));
230#endif
231}
232
251template <FabArrayType MF, typename F>
252void
253ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, F&& f)
254{
255 detail::ParallelFor_doit(mf, ng, ts.tile_size, false, std::forward<F>(f));
256}
257
277template <int MT, FabArrayType MF, typename F>
278void
279ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, F&& f)
280{
281#ifdef AMREX_USE_GPU
282 detail::ParallelFor_doit<MT>(mf, ng, 1, ts.tile_size, false, std::forward<F>(f));
283#else
284 detail::ParallelFor_doit(mf, ng, ts.tile_size, false, std::forward<F>(f));
285#endif
286}
287
307template <FabArrayType MF, typename F>
308void
309ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, F&& f)
310{
311 detail::ParallelFor_doit(mf, ng, ncomp, ts.tile_size, false, std::forward<F>(f));
312}
313
334template <int MT, FabArrayType MF, typename F>
335void
336ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, F&& f)
337{
338#ifdef AMREX_USE_GPU
339 detail::ParallelFor_doit<MT>(mf, ng, ncomp, ts.tile_size, false, std::forward<F>(f));
340#else
341 detail::ParallelFor_doit(mf, ng, ncomp, ts.tile_size, false, std::forward<F>(f));
342#endif
343}
344
364template <FabArrayType MF, typename F>
365void
366ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, DynamicTiling dt, F&& f)
367{
368 detail::ParallelFor_doit(mf, ng, ts.tile_size, dt.dynamic, std::forward<F>(f));
369}
370
391template <FabArrayType MF, typename F>
392void
393ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts,
394 DynamicTiling dt, F&& f)
395{
396 detail::ParallelFor_doit(mf, ng, ncomp, ts.tile_size, dt.dynamic, std::forward<F>(f));
397}
398
419template <int MT, FabArrayType MF, typename F>
420void
421ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts,
422 DynamicTiling dt, F&& f)
423{
424#ifdef AMREX_USE_GPU
425 detail::ParallelFor_doit<MT>(mf, ng, 1, ts.tile_size, dt.dynamic, std::forward<F>(f));
426#else
427 detail::ParallelFor_doit(mf, ng, ts.tile_size, dt.dynamic, std::forward<F>(f));
428#endif
429}
430
452template <int MT, FabArrayType MF, typename F>
453void
454ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts,
455 DynamicTiling dt, F&& f)
456{
457#ifdef AMREX_USE_GPU
458 detail::ParallelFor_doit<MT>(mf, ng, ncomp, ts.tile_size, dt.dynamic, std::forward<F>(f));
459#else
460 detail::ParallelFor_doit(mf, ng, ncomp, ts.tile_size, dt.dynamic, std::forward<F>(f));
461#endif
462}
463
464}
465
466#endif
static IntVect mfiter_tile_size
Default tilesize in MFIter.
Definition AMReX_FabArrayBase.H:289
Definition AMReX_Amr.cpp:50
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:202
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:33
Definition AMReX_MFParallelFor.H:22
DynamicTiling(bool f) noexcept
Definition AMReX_MFParallelFor.H:24
bool dynamic
Definition AMReX_MFParallelFor.H:23
Definition AMReX_MFParallelFor.H:17
TileSize(IntVect const &ts) noexcept
Definition AMReX_MFParallelFor.H:19
IntVect tile_size
Definition AMReX_MFParallelFor.H:18