3 #include <AMReX_Config.H>
10 namespace loop_detail {
14 template <
typename F, std::size_t...Ns,
class...Args>
17 noexcept -> decltype(
f(0, 0, 0, args...))
19 f(iv[0], 0, 0, args...);
22 template <
typename F, std::size_t...Ns,
class...Args>
25 noexcept -> decltype(
f(0, 0, 0, args...))
27 f(iv[0], iv[1], 0, args...);
30 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
33 noexcept -> decltype(
f(iv, args...))
38 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
41 noexcept -> decltype(
f(iv[Ns]..., args...))
43 f(iv[Ns]..., args...);
48 template <
typename F,
int dim>
58 template <
typename F,
int dim>
68 template <
typename F, std::size_t...Ns,
class...Args>
71 noexcept -> decltype(
f(0, 0, 0, args...))
73 f(iv[0], 0, 0, args...);
76 template <
typename F, std::size_t...Ns,
class...Args>
79 noexcept -> decltype(
f(0, 0, 0, args...))
81 f(iv[0], iv[1], 0, args...);
84 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
87 noexcept -> decltype(
f(iv, args...))
92 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
95 noexcept -> decltype(
f(iv[Ns]..., args...))
97 f(iv[Ns]..., args...);
102 template <
typename F,
int dim>
112 template <
typename F,
int dim>
126 for (
int k = lo.z; k <= hi.z; ++k) {
127 for (
int j = lo.y; j <= hi.y; ++j) {
128 for (
int i = lo.x; i <= hi.x; ++i) {
138 for (
int n = 0; n < ncomp; ++n) {
139 for (
int k = lo.z; k <= hi.z; ++k) {
140 for (
int j = lo.y; j <= hi.y; ++j) {
141 for (
int i = lo.x; i <= hi.x; ++i) {
151 for (
int k = lo.z; k <= hi.z; ++k) {
152 for (
int j = lo.y; j <= hi.y; ++j) {
154 for (
int i = lo.x; i <= hi.x; ++i) {
164 for (
int n = 0; n < ncomp; ++n) {
165 for (
int k = lo.z; k <= hi.z; ++k) {
166 for (
int j = lo.y; j <= hi.y; ++j) {
168 for (
int i = lo.x; i <= hi.x; ++i) {
173 namespace loop_detail {
175 template <
int idim,
typename L,
int dim>
179 if constexpr (idim == 1) {
180 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
183 }
else if constexpr (idim == 2) {
184 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
185 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
188 }
else if constexpr (idim == 3) {
189 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
190 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
191 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
195 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
203 template <
class F,
int dim>
211 loop_detail::Loop_impND<dim>(
f, lo, hi, iv);
214 namespace loop_detail {
216 template <
int idim,
typename L,
int dim>
220 if constexpr (idim == 1) {
221 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
224 }
else if constexpr (idim == 2) {
225 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
226 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
229 }
else if constexpr (idim == 3) {
230 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
231 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
232 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
236 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
244 template <
class F,
int dim>
252 for (
int n = 0; n < ncomp; ++n) {
253 loop_detail::Loop_impND<dim>(
f, lo, hi, iv, n);
257 namespace loop_detail {
259 template <
int idim,
typename L,
int dim>
263 if constexpr (idim == 1) {
265 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
268 }
else if constexpr (idim == 2) {
269 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
271 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
274 }
else if constexpr (idim == 3) {
275 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
276 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
278 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
282 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
290 template <
class F,
int dim>
298 loop_detail::LoopConcurrent_impND<dim>(
f, lo, hi, iv);
301 namespace loop_detail {
303 template <
int idim,
typename L,
int dim>
307 if constexpr (idim == 1) {
309 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
312 }
else if constexpr (idim == 2) {
313 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
315 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
318 }
else if constexpr (idim == 3) {
319 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
320 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
322 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
326 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
334 template <
class F,
int dim>
342 for (
int n = 0; n < ncomp; ++n) {
343 loop_detail::LoopConcurrent_impND<dim>(
f, lo, hi, iv, n);
356 for (
int k = lo.z; k <= hi.z; ++k) {
357 for (
int j = lo.y; j <= hi.y; ++j) {
358 for (
int i = lo.x; i <= hi.x; ++i) {
367 for (
int n = 0; n < ncomp; ++n) {
368 for (
int k = lo.z; k <= hi.z; ++k) {
369 for (
int j = lo.y; j <= hi.y; ++j) {
370 for (
int i = lo.x; i <= hi.x; ++i) {
379 for (
int k = lo.z; k <= hi.z; ++k) {
380 for (
int j = lo.y; j <= hi.y; ++j) {
382 for (
int i = lo.x; i <= hi.x; ++i) {
391 for (
int n = 0; n < ncomp; ++n) {
392 for (
int k = lo.z; k <= hi.z; ++k) {
393 for (
int j = lo.y; j <= hi.y; ++j) {
395 for (
int i = lo.x; i <= hi.x; ++i) {
400 namespace loop_detail {
402 template <
int idim,
typename L,
int dim>
406 if constexpr (idim == 1) {
407 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
410 }
else if constexpr (idim == 2) {
411 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
412 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
415 }
else if constexpr (idim == 3) {
416 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
417 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
418 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
422 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
430 template <
class F,
int dim>
437 loop_detail::LoopOnCpu_impND<dim>(
f, lo, hi, iv);
440 namespace loop_detail {
442 template <
int idim,
typename L,
int dim>
446 if constexpr (idim == 1) {
447 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
450 }
else if constexpr (idim == 2) {
451 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
452 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
455 }
else if constexpr (idim == 3) {
456 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
457 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
458 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
462 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
470 template <
class F,
int dim>
477 for (
int n = 0; n < ncomp; ++n) {
478 loop_detail::LoopOnCpu_impND<dim>(
f, lo, hi, iv, n);
482 namespace loop_detail {
484 template <
int idim,
typename L,
int dim>
488 if constexpr (idim == 1) {
490 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
493 }
else if constexpr (idim == 2) {
494 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
496 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
499 }
else if constexpr (idim == 3) {
500 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
501 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
503 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
507 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
515 template <
class F,
int dim>
522 loop_detail::LoopConcurrentOnCpu_impND<dim>(
f, lo, hi, iv);
525 namespace loop_detail {
527 template <
int idim,
typename L,
int dim>
531 if constexpr (idim == 1) {
533 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
536 }
else if constexpr (idim == 2) {
537 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
539 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
542 }
else if constexpr (idim == 3) {
543 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
544 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
546 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
550 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
558 template <
class F,
int dim>
565 for (
int n = 0; n < ncomp; ++n) {
566 loop_detail::LoopConcurrentOnCpu_impND<dim>(
f, lo, hi, iv, n);
584 template<auto I, auto N,
class F>
588 if constexpr (I < N) {
589 f(std::integral_constant<decltype(I), I>());
590 constexpr_for<I+1, N>(
f);
#define AMREX_PRAGMA_SIMD
Definition: AMReX_Extension.H:80
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_ATTRIBUTE_FLATTEN_FOR
Definition: AMReX_Extension.H:151
#define AMREX_INLINE
Definition: AMReX_Extension.H:127
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
A Rectangular Domain on an Integer Lattice.
Definition: AMReX_Box.H:43
Definition: AMReX_IntVect.H:48
static int f(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:44
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE auto call_f_intvect(F const &f, IntVectND< dim > iv) noexcept -> decltype(call_f_intvect_inner(std::make_index_sequence< dim >(), f, iv))
Definition: AMReX_Loop.H:50
AMREX_FORCE_INLINE void LoopConcurrentOnCpu_impND(L const &f, IntVectND< dim > const lo, IntVectND< dim > const hi, IntVectND< dim > iv) noexcept
Definition: AMReX_Loop.H:486
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Loop_impND(L const &f, IntVectND< dim > const lo, IntVectND< dim > const hi, IntVectND< dim > iv) noexcept
Definition: AMReX_Loop.H:177
AMREX_FORCE_INLINE auto call_f_intvect_inner_cpu(std::index_sequence< Ns... >, F const &f, IntVectND< 1 > iv, Args...args) noexcept -> decltype(f(0, 0, 0, args...))
Definition: AMReX_Loop.H:70
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE auto call_f_intvect_ncomp(F const &f, IntVectND< dim > iv, int n) noexcept -> decltype(call_f_intvect_inner(std::make_index_sequence< dim >(), f, iv, 0))
Definition: AMReX_Loop.H:60
AMREX_FORCE_INLINE auto call_f_intvect_cpu(F const &f, IntVectND< dim > iv) noexcept -> decltype(call_f_intvect_inner_cpu(std::make_index_sequence< dim >(), f, iv))
Definition: AMReX_Loop.H:104
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void LoopConcurrent_impND(L const &f, IntVectND< dim > const lo, IntVectND< dim > const hi, IntVectND< dim > iv) noexcept
Definition: AMReX_Loop.H:261
AMREX_FORCE_INLINE auto call_f_intvect_ncomp_cpu(F const &f, IntVectND< dim > iv, int n) noexcept -> decltype(call_f_intvect_inner_cpu(std::make_index_sequence< dim >(), f, iv, 0))
Definition: AMReX_Loop.H:114
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE auto call_f_intvect_inner(std::index_sequence< Ns... >, F const &f, IntVectND< 1 > iv, Args...args) noexcept -> decltype(f(0, 0, 0, args...))
Definition: AMReX_Loop.H:16
AMREX_FORCE_INLINE void LoopOnCpu_impND(L const &f, IntVectND< dim > const lo, IntVectND< dim > const hi, IntVectND< dim > iv) noexcept
Definition: AMReX_Loop.H:404
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE constexpr AMREX_INLINE void constexpr_for(F const &f)
Definition: AMReX_Loop.H:586
AMREX_ATTRIBUTE_FLATTEN_FOR void LoopOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition: AMReX_Loop.H:354
AMREX_ATTRIBUTE_FLATTEN_FOR void LoopConcurrentOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition: AMReX_Loop.H:377
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > ubound_iv(BoxND< dim > const &box) noexcept
Definition: AMReX_Box.H:1789
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > lbound_iv(BoxND< dim > const &box) noexcept
Definition: AMReX_Box.H:1780
AMREX_GPU_HOST_DEVICE AMREX_ATTRIBUTE_FLATTEN_FOR void LoopConcurrent(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition: AMReX_Loop.H:149
AMREX_GPU_HOST_DEVICE AMREX_ATTRIBUTE_FLATTEN_FOR void Loop(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition: AMReX_Loop.H:124
Definition: AMReX_Dim3.H:12