Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
AMReX_MFParallelForC.H
Go to the documentation of this file.
1#ifndef AMREX_MF_PARALLEL_FOR_C_H_
2#define AMREX_MF_PARALLEL_FOR_C_H_
3#include <AMReX_Config.H>
4
5#ifndef AMREX_USE_GPU
6
7#include <AMReX_MFIter.H>
8
10namespace amrex::detail {
11
12template <typename MF, typename F>
13std::enable_if_t<IsFabArray<MF>::value>
14ParallelFor_doit (MF const& mf, IntVect const& nghost, IntVect const& ts, bool dynamic, F const& f)
15{
16#ifdef AMREX_USE_OMP
17#pragma omp parallel
18#endif
19 for (MFIter mfi(mf,MFItInfo().EnableTiling(ts).SetDynamic(dynamic)); mfi.isValid(); ++mfi) {
20 Box const& bx = mfi.growntilebox(nghost);
21 int const lidx = mfi.LocalIndex();
22 const auto lo = amrex::lbound(bx);
23 const auto hi = amrex::ubound(bx);
24 for ( int k = lo.z; k <= hi.z; ++k) {
25 for ( int j = lo.y; j <= hi.y; ++j) {
27 for (int i = lo.x; i <= hi.x; ++i) {
28 f(lidx,i,j,k);
29 }
30 }
31 }
32 }
33}
34
35template <typename MF, typename F>
36std::enable_if_t<IsFabArray<MF>::value>
37ParallelFor_doit (MF const& mf, IntVect const& nghost, int ncomp, IntVect const& ts, bool dynamic, F const& f)
38{
39#ifdef AMREX_USE_OMP
40#pragma omp parallel
41#endif
42 for (MFIter mfi(mf,MFItInfo().EnableTiling(ts).SetDynamic(dynamic)); mfi.isValid(); ++mfi) {
43 Box const& bx = mfi.growntilebox(nghost);
44 int const lidx = mfi.LocalIndex();
45 const auto lo = amrex::lbound(bx);
46 const auto hi = amrex::ubound(bx);
47 for (int n = 0; n < ncomp; ++n) {
48 for ( int k = lo.z; k <= hi.z; ++k) {
49 for ( int j = lo.y; j <= hi.y; ++j) {
51 for (int i = lo.x; i <= hi.x; ++i) {
52 f(lidx,i,j,k,n);
53 }
54 }
55 }
56 }
57 }
58}
59
60}
62
63#endif
64#endif
#define AMREX_PRAGMA_SIMD
Definition AMReX_Extension.H:80
__host__ __device__ Dim3 ubound(Array4< T > const &a) noexcept
Definition AMReX_Array4.H:319
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:27
__host__ __device__ Dim3 lbound(Array4< T > const &a) noexcept
Definition AMReX_Array4.H:312