3 #include <AMReX_Config.H>
11 namespace loop_detail {
15 template <
typename F, std::size_t...Ns,
class...Args>
18 noexcept -> decltype(
f(0, 0, 0, args...))
20 f(iv[0], 0, 0, args...);
23 template <
typename F, std::size_t...Ns,
class...Args>
26 noexcept -> decltype(
f(0, 0, 0, args...))
28 f(iv[0], iv[1], 0, args...);
31 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
34 noexcept -> decltype(
f(iv, args...))
39 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
42 noexcept -> decltype(
f(iv[Ns]..., args...))
44 f(iv[Ns]..., args...);
49 template <
typename F,
int dim>
59 template <
typename F,
int dim>
69 template <
typename F, std::size_t...Ns,
class...Args>
72 noexcept -> decltype(
f(0, 0, 0, args...))
74 f(iv[0], 0, 0, args...);
77 template <
typename F, std::size_t...Ns,
class...Args>
80 noexcept -> decltype(
f(0, 0, 0, args...))
82 f(iv[0], iv[1], 0, args...);
85 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
88 noexcept -> decltype(
f(iv, args...))
93 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
96 noexcept -> decltype(
f(iv[Ns]..., args...))
98 f(iv[Ns]..., args...);
103 template <
typename F,
int dim>
113 template <
typename F,
int dim>
127 for (
int k = lo.z; k <= hi.z; ++k) {
128 for (
int j = lo.y; j <= hi.y; ++j) {
129 for (
int i = lo.x; i <= hi.x; ++i) {
139 for (
int n = 0; n < ncomp; ++n) {
140 for (
int k = lo.z; k <= hi.z; ++k) {
141 for (
int j = lo.y; j <= hi.y; ++j) {
142 for (
int i = lo.x; i <= hi.x; ++i) {
152 for (
int k = lo.z; k <= hi.z; ++k) {
153 for (
int j = lo.y; j <= hi.y; ++j) {
155 for (
int i = lo.x; i <= hi.x; ++i) {
165 for (
int n = 0; n < ncomp; ++n) {
166 for (
int k = lo.z; k <= hi.z; ++k) {
167 for (
int j = lo.y; j <= hi.y; ++j) {
169 for (
int i = lo.x; i <= hi.x; ++i) {
174 namespace loop_detail {
176 template <
int idim,
typename L,
int dim>
180 if constexpr (idim == 1) {
181 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
184 }
else if constexpr (idim == 2) {
185 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
186 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
189 }
else if constexpr (idim == 3) {
190 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
191 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
192 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
196 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
204 template <
class F,
int dim>
212 loop_detail::Loop_impND<dim>(
f, lo, hi, iv);
215 namespace loop_detail {
217 template <
int idim,
typename L,
int dim>
221 if constexpr (idim == 1) {
222 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
225 }
else if constexpr (idim == 2) {
226 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
227 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
230 }
else if constexpr (idim == 3) {
231 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
232 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
233 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
237 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
245 template <
class F,
int dim>
253 for (
int n = 0; n < ncomp; ++n) {
254 loop_detail::Loop_impND<dim>(
f, lo, hi, iv, n);
258 namespace loop_detail {
260 template <
int idim,
typename L,
int dim>
264 if constexpr (idim == 1) {
266 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
269 }
else if constexpr (idim == 2) {
270 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
272 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
275 }
else if constexpr (idim == 3) {
276 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
277 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
279 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
283 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
291 template <
class F,
int dim>
299 loop_detail::LoopConcurrent_impND<dim>(
f, lo, hi, iv);
302 namespace loop_detail {
304 template <
int idim,
typename L,
int dim>
308 if constexpr (idim == 1) {
310 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
313 }
else if constexpr (idim == 2) {
314 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
316 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
319 }
else if constexpr (idim == 3) {
320 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
321 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
323 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
327 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
335 template <
class F,
int dim>
343 for (
int n = 0; n < ncomp; ++n) {
344 loop_detail::LoopConcurrent_impND<dim>(
f, lo, hi, iv, n);
357 for (
int k = lo.z; k <= hi.z; ++k) {
358 for (
int j = lo.y; j <= hi.y; ++j) {
359 for (
int i = lo.x; i <= hi.x; ++i) {
368 for (
int n = 0; n < ncomp; ++n) {
369 for (
int k = lo.z; k <= hi.z; ++k) {
370 for (
int j = lo.y; j <= hi.y; ++j) {
371 for (
int i = lo.x; i <= hi.x; ++i) {
380 for (
int k = lo.z; k <= hi.z; ++k) {
381 for (
int j = lo.y; j <= hi.y; ++j) {
383 for (
int i = lo.x; i <= hi.x; ++i) {
392 for (
int n = 0; n < ncomp; ++n) {
393 for (
int k = lo.z; k <= hi.z; ++k) {
394 for (
int j = lo.y; j <= hi.y; ++j) {
396 for (
int i = lo.x; i <= hi.x; ++i) {
401 namespace loop_detail {
403 template <
int idim,
typename L,
int dim>
407 if constexpr (idim == 1) {
408 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
411 }
else if constexpr (idim == 2) {
412 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
413 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
416 }
else if constexpr (idim == 3) {
417 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
418 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
419 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
423 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
431 template <
class F,
int dim>
438 loop_detail::LoopOnCpu_impND<dim>(
f, lo, hi, iv);
441 namespace loop_detail {
443 template <
int idim,
typename L,
int dim>
447 if constexpr (idim == 1) {
448 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
451 }
else if constexpr (idim == 2) {
452 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
453 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
456 }
else if constexpr (idim == 3) {
457 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
458 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
459 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
463 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
471 template <
class F,
int dim>
478 for (
int n = 0; n < ncomp; ++n) {
479 loop_detail::LoopOnCpu_impND<dim>(
f, lo, hi, iv, n);
483 namespace loop_detail {
485 template <
int idim,
typename L,
int dim>
489 if constexpr (idim == 1) {
491 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
494 }
else if constexpr (idim == 2) {
495 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
497 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
500 }
else if constexpr (idim == 3) {
501 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
502 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
504 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
508 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
516 template <
class F,
int dim>
523 loop_detail::LoopConcurrentOnCpu_impND<dim>(
f, lo, hi, iv);
526 namespace loop_detail {
528 template <
int idim,
typename L,
int dim>
532 if constexpr (idim == 1) {
534 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
537 }
else if constexpr (idim == 2) {
538 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
540 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
543 }
else if constexpr (idim == 3) {
544 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
545 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
547 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
551 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
559 template <
class F,
int dim>
566 for (
int n = 0; n < ncomp; ++n) {
567 loop_detail::LoopConcurrentOnCpu_impND<dim>(
f, lo, hi, iv, n);
#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_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:51
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:487
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:178
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:71
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:61
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:105
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:262
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:115
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:17
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:405
Definition: AMReX_Amr.cpp:49
AMREX_ATTRIBUTE_FLATTEN_FOR void LoopOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition: AMReX_Loop.H:355
AMREX_ATTRIBUTE_FLATTEN_FOR void LoopConcurrentOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition: AMReX_Loop.H:378
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:150
AMREX_GPU_HOST_DEVICE AMREX_ATTRIBUTE_FLATTEN_FOR void Loop(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition: AMReX_Loop.H:125
Definition: AMReX_Dim3.H:12