Block-Structured AMR Software Framework
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
10
11template <typename MF, typename F>
12std::enable_if_t<IsFabArray<MF>::value>
13ParallelFor (MF const& mf, IntVect const& nghost, IntVect const& ts, bool dynamic, F const& f)
14{
15#ifdef AMREX_USE_OMP
16#pragma omp parallel
17#endif
18 for (MFIter mfi(mf,MFItInfo().EnableTiling(ts).SetDynamic(dynamic)); mfi.isValid(); ++mfi) {
19 Box const& bx = mfi.growntilebox(nghost);
20 int const lidx = mfi.LocalIndex();
21 const auto lo = amrex::lbound(bx);
22 const auto hi = amrex::ubound(bx);
23 for ( int k = lo.z; k <= hi.z; ++k) {
24 for ( int j = lo.y; j <= hi.y; ++j) {
26 for (int i = lo.x; i <= hi.x; ++i) {
27 f(lidx,i,j,k);
28 }
29 }
30 }
31 }
32}
33
34template <typename MF, typename F>
35std::enable_if_t<IsFabArray<MF>::value>
36ParallelFor (MF const& mf, IntVect const& nghost, int ncomp, IntVect const& ts, bool dynamic, F const& f)
37{
38#ifdef AMREX_USE_OMP
39#pragma omp parallel
40#endif
41 for (MFIter mfi(mf,MFItInfo().EnableTiling(ts).SetDynamic(dynamic)); mfi.isValid(); ++mfi) {
42 Box const& bx = mfi.growntilebox(nghost);
43 int const lidx = mfi.LocalIndex();
44 const auto lo = amrex::lbound(bx);
45 const auto hi = amrex::ubound(bx);
46 for (int n = 0; n < ncomp; ++n) {
47 for ( int k = lo.z; k <= hi.z; ++k) {
48 for ( int j = lo.y; j <= hi.y; ++j) {
50 for (int i = lo.x; i <= hi.x; ++i) {
51 f(lidx,i,j,k,n);
52 }
53 }
54 }
55 }
56 }
57}
58
59}
60
61#endif
62#endif
#define AMREX_PRAGMA_SIMD
Definition AMReX_Extension.H:80
Definition AMReX_MFParallelForG.H:53
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
BoxND< AMREX_SPACEDIM > Box
Definition AMReX_BaseFwd.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 ubound(Array4< T > const &a) noexcept
Definition AMReX_Array4.H:315
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 lbound(Array4< T > const &a) noexcept
Definition AMReX_Array4.H:308
IntVectND< AMREX_SPACEDIM > IntVect
Definition AMReX_BaseFwd.H:30