1 #ifndef AMREX_GPU_LAUNCH_FUNCTS_C_H_
2 #define AMREX_GPU_LAUNCH_FUNCTS_C_H_
3 #include <AMReX_Config.H>
11 template <
typename F,
typename N>
14 noexcept -> decltype(
f(0))
19 template <
typename F,
typename N>
29 template <
typename F, std::size_t...Ns,
class...Args>
32 noexcept -> decltype(
f(0, 0, 0, args...))
34 f(iv[0], 0, 0, args...);
37 template <
typename F, std::size_t...Ns,
class...Args>
40 noexcept -> decltype(
f(0, 0, 0, args...))
42 f(iv[0], iv[1], 0, args...);
45 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
48 noexcept -> decltype(
f(iv, args...))
53 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
56 noexcept -> decltype(
f(iv[Ns]..., args...))
58 f(iv[Ns]..., args...);
63 template <
typename F,
int dim>
73 template <
typename F,
int dim>
81 template <
typename F,
int dim>
91 template <
typename F,
typename T,
int dim>
101 template <
typename F,
typename T,
int dim>
109 template <
typename F,
typename T,
int dim>
119 template<
typename T,
typename L>
122 std::forward<L>(
f)(n);
125 template<
int MT,
typename T,
typename L>
129 std::forward<L>(
f)(n);
132 template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
134 void For (T n, L
const&
f) noexcept
136 for (T i = 0; i < n; ++i) {
141 template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
145 For(n, std::forward<L>(
f));
148 template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
151 For(n, std::forward<L>(
f));
154 template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
158 For(n, std::forward<L>(
f));
161 template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
166 for (T i = 0; i < n; ++i) {
171 template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
178 template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
184 template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
193 template <
int idim,
typename L,
int dim>
197 if constexpr (idim == 1) {
198 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
201 }
else if constexpr (idim == 2) {
202 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
203 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
206 }
else if constexpr (idim == 3) {
207 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
208 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
209 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
213 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
221 template <
typename L,
int dim>
228 detail::For_impND<dim>(
f, lo, hi, iv);
231 template <
int MT,
typename L,
int dim>
235 For(box, std::forward<L>(
f));
238 template <
typename L,
int dim>
241 For(box, std::forward<L>(
f));
244 template <
int MT,
typename L,
int dim>
248 For(box, std::forward<L>(
f));
253 template <
int idim,
typename L,
int dim>
257 if constexpr (idim == 1) {
259 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
262 }
else if constexpr (idim == 2) {
263 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
265 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
268 }
else if constexpr (idim == 3) {
269 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
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;
276 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
284 template <
typename L,
int dim>
291 detail::ParallelFor_impND<dim>(
f, lo, hi, iv);
294 template <
int MT,
typename L,
int dim>
301 template <
typename L,
int dim>
307 template <
int MT,
typename L,
int dim>
316 template <
int idim,
typename L,
typename T,
int dim>
320 if constexpr (idim == 1) {
321 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
324 }
else if constexpr (idim == 2) {
325 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
326 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
329 }
else if constexpr (idim == 3) {
330 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
331 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
332 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
336 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
344 template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
351 for (T n = 0; n < ncomp; ++n) {
352 detail::For_impND<dim>(
f, lo, hi, iv, n);
356 template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
360 For(box, ncomp, std::forward<L>(
f));
363 template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
366 For(box, ncomp, std::forward<L>(
f));
369 template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
373 For(box, ncomp, std::forward<L>(
f));
378 template <
int idim,
typename L,
typename T,
int dim>
382 if constexpr (idim == 1) {
384 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
387 }
else if constexpr (idim == 2) {
388 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
390 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
393 }
else if constexpr (idim == 3) {
394 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
395 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
397 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
401 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
409 template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
416 for (T n = 0; n < ncomp; ++n) {
417 detail::ParallelFor_impND<dim>(
f, lo, hi, iv, n);
421 template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
428 template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
434 template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
441 template <
typename L1,
typename L2,
int dim>
444 For(box1, std::forward<L1>(f1));
445 For(box2, std::forward<L2>(f2));
448 template <
int MT,
typename L1,
typename L2,
int dim>
452 For(box1, std::forward<L1>(f1));
453 For(box2, std::forward<L2>(f2));
456 template <
typename L1,
typename L2,
int dim>
459 For (box1, box2, std::forward<L1>(f1), std::forward<L2>(f2));
462 template <
int MT,
typename L1,
typename L2,
int dim>
466 For (box1, box2, std::forward<L1>(f1), std::forward<L2>(f2));
469 template <
typename L1,
typename L2,
typename L3,
int dim>
472 For(box1, std::forward<L1>(f1));
473 For(box2, std::forward<L2>(f2));
474 For(box3, std::forward<L3>(f3));
477 template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
481 For(box1, std::forward<L1>(f1));
482 For(box2, std::forward<L2>(f2));
483 For(box3, std::forward<L3>(f3));
486 template <
typename L1,
typename L2,
typename L3,
int dim>
489 For(box1, box2, box3, std::forward<L1>(f1), std::forward<L2>(f2), std::forward<L3>(f3));
492 template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
496 For(box1, box2, box3, std::forward<L1>(f1), std::forward<L2>(f2), std::forward<L3>(f3));
499 template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
500 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
501 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
503 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
505 For(box1, ncomp1, std::forward<L1>(f1));
506 For(box2, ncomp2, std::forward<L2>(f2));
509 template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
510 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
511 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
513 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
516 For(box1, ncomp1, std::forward<L1>(f1));
517 For(box2, ncomp2, std::forward<L2>(f2));
520 template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
521 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
522 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
525 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
527 For(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
530 template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
531 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
532 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
535 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
538 For(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
541 template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
542 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
543 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
544 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
547 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
549 For(box1, ncomp1, std::forward<L1>(f1));
550 For(box2, ncomp2, std::forward<L2>(f2));
551 For(box3, ncomp3, std::forward<L3>(f3));
554 template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
555 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
556 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
557 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
560 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
563 For(box1, ncomp1, std::forward<L1>(f1));
564 For(box2, ncomp2, std::forward<L2>(f2));
565 For(box3, ncomp3, std::forward<L3>(f3));
568 template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
569 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
570 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
571 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
575 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
577 For(box1,ncomp1,std::forward<L1>(f1),
578 box2,ncomp2,std::forward<L2>(f2),
579 box3,ncomp3,std::forward<L3>(f3));
582 template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
583 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
584 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
585 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
589 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
592 For(box1,ncomp1,std::forward<L1>(f1),
593 box2,ncomp2,std::forward<L2>(f2),
594 box3,ncomp3,std::forward<L3>(f3));
597 template <
typename L1,
typename L2,
int dim>
604 template <
int MT,
typename L1,
typename L2,
int dim>
612 template <
typename L1,
typename L2,
int dim>
615 ParallelFor(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
618 template <
int MT,
typename L1,
typename L2,
int dim>
622 ParallelFor(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
625 template <
typename L1,
typename L2,
typename L3,
int dim>
633 template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
642 template <
typename L1,
typename L2,
typename L3,
int dim>
645 ParallelFor(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
648 template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
652 ParallelFor(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
655 template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
656 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
657 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
659 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
665 template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
666 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
667 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
669 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
676 template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
677 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
678 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
681 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
684 box2,ncomp2,std::forward<L2>(f2));
687 template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
688 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
689 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
692 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
696 box2,ncomp2,std::forward<L2>(f2));
699 template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
700 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
701 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
702 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
705 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
712 template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
713 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
714 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
715 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
718 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
726 template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
727 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
728 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
729 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
733 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
736 box2, ncomp2, std::forward<L2>(f2),
737 box3, ncomp3, std::forward<L3>(f3));
740 template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
741 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
742 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
743 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
747 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
751 box2, ncomp2, std::forward<L2>(f2),
752 box3, ncomp3, std::forward<L3>(f3));
755 template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
761 template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
768 template <
typename L,
int dim>
774 template <
int MT,
typename L,
int dim>
781 template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
787 template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
794 template <
typename L1,
typename L2,
int dim>
797 ParallelFor(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
800 template <
int MT,
typename L1,
typename L2,
int dim>
804 ParallelFor(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
807 template <
typename L1,
typename L2,
typename L3,
int dim>
809 L1&& f1, L2&& f2, L3&& f3) noexcept
811 ParallelFor(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
814 template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
816 L1&& f1, L2&& f2, L3&& f3) noexcept
819 ParallelFor(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
822 template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
823 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
824 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
826 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
828 ParallelFor(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
831 template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
832 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
833 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
835 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
838 ParallelFor(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
841 template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
842 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
843 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
844 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
847 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
850 box2,ncomp2,std::forward<L2>(f2),
851 box3,ncomp3,std::forward<L3>(f3));
854 template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
855 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
856 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
857 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
860 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
864 box2,ncomp2,std::forward<L2>(f2),
865 box3,ncomp3,std::forward<L3>(f3));
868 template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
871 For(n,std::forward<L>(
f));
874 template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
878 For(n,std::forward<L>(
f));
881 template <
typename L,
int dim>
884 For(box,std::forward<L>(
f));
887 template <
int MT,
typename L,
int dim>
891 For(box,std::forward<L>(
f));
894 template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
897 For(box,ncomp,std::forward<L>(
f));
900 template <
int MT,
typename T,
int dim,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
904 For(box,ncomp,std::forward<L>(
f));
907 template <
typename L1,
typename L2,
int dim>
910 For(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
913 template <
int MT,
typename L1,
typename L2,
int dim>
917 For(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
920 template <
typename L1,
typename L2,
typename L3,
int dim>
922 L1&& f1, L2&& f2, L3&& f3) noexcept
924 For(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
927 template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
929 L1&& f1, L2&& f2, L3&& f3) noexcept
932 For(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
935 template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
936 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
937 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
939 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
941 For(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
944 template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
945 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
946 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
948 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
951 For(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
954 template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
955 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
956 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
957 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
960 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
962 For(box1,ncomp1,std::forward<L1>(f1),
963 box2,ncomp2,std::forward<L2>(f2),
964 box3,ncomp3,std::forward<L3>(f3));
967 template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
968 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
969 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
970 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
973 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
976 For(box1,ncomp1,std::forward<L1>(f1),
977 box2,ncomp2,std::forward<L2>(f2),
978 box3,ncomp3,std::forward<L3>(f3));
981 template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
987 template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
994 template <
typename L,
int dim>
1000 template <
int MT,
typename L,
int dim>
1007 template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1013 template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1020 template <
typename L1,
typename L2,
int dim>
1023 ParallelFor(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
1026 template <
int MT,
typename L1,
typename L2,
int dim>
1030 ParallelFor(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
1033 template <
typename L1,
typename L2,
typename L3,
int dim>
1036 L1&& f1, L2&& f2, L3&& f3) noexcept
1038 ParallelFor(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1041 template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1044 L1&& f1, L2&& f2, L3&& f3) noexcept
1047 ParallelFor(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1050 template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
1051 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1052 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
1055 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
1057 ParallelFor(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
1060 template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
1061 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1062 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
1065 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
1068 ParallelFor(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
1071 template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
1072 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1073 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
1074 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
1078 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
1081 box2,ncomp2,std::forward<L2>(f2),
1082 box3,ncomp3,std::forward<L3>(f3));
1085 template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
1086 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1087 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
1088 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
1092 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
1096 box2,ncomp2,std::forward<L2>(f2),
1097 box3,ncomp3,std::forward<L3>(f3));
1100 template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1103 For(n,std::forward<L>(
f));
1106 template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1110 For(n,std::forward<L>(
f));
1113 template <
typename L,
int dim>
1116 For(box,std::forward<L>(
f));
1119 template <
int MT,
typename L,
int dim>
1123 For(box,std::forward<L>(
f));
1126 template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1129 For(box,ncomp,std::forward<L>(
f));
1132 template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1136 For(box,ncomp,std::forward<L>(
f));
1139 template <
typename L1,
typename L2,
int dim>
1142 For(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
1145 template <
int MT,
typename L1,
typename L2,
int dim>
1149 For(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
1152 template <
typename L1,
typename L2,
typename L3,
int dim>
1155 L1&& f1, L2&& f2, L3&& f3) noexcept
1157 For(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1160 template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1163 L1&& f1, L2&& f2, L3&& f3) noexcept
1166 For(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1169 template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
1170 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1171 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
1174 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
1176 For(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
1179 template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
1180 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1181 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
1184 BoxND<dim> const& box2, T2 ncomp2, L2&& f2) noexcept
1187 For(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
1190 template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
1191 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1192 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
1193 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
1197 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
1199 For(box1,ncomp1,std::forward<L1>(f1),
1200 box2,ncomp2,std::forward<L2>(f2),
1201 box3,ncomp3,std::forward<L3>(f3));
1204 template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
1205 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1206 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
1207 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
1211 BoxND<dim> const& box3, T3 ncomp3, L3&& f3) noexcept
1214 For(box1,ncomp1,std::forward<L1>(f1),
1215 box2,ncomp2,std::forward<L2>(f2),
1216 box3,ncomp3,std::forward<L3>(f3));
1219 template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1223 for (T i = 0; i < n; ++i) {
1230 template <
int idim,
typename L,
int dim>
1234 if constexpr (idim == 1) {
1235 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
1238 }
else if constexpr (idim == 2) {
1239 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
1240 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
1243 }
else if constexpr (idim == 3) {
1244 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
1245 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
1246 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
1250 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
1256 template <
int idim,
typename L,
typename T,
int dim>
1260 if constexpr (idim == 1) {
1261 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
1264 }
else if constexpr (idim == 2) {
1265 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
1266 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
1269 }
else if constexpr (idim == 3) {
1270 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
1271 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
1272 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
1276 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
1284 template <
typename L,
int dim>
1291 detail::ParallelForRNG_impND<dim>(
f, lo, hi, iv);
1294 template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1301 for (T n = 0; n < ncomp; ++n) {
1302 detail::ParallelForRNG_impND<dim>(
f, lo, hi, iv, n);
1306 template <
typename L>
1309 std::forward<L>(
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
A Rectangular Domain on an Integer Lattice.
Definition: AMReX_Box.H:43
Definition: AMReX_GpuKernelInfo.H:8
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_FORCE_INLINE auto call_f_intvect_handler(F const &f, IntVectND< dim > iv) noexcept -> decltype(call_f_intvect_inner(std::make_index_sequence< dim >(), f, iv))
Definition: AMReX_GpuLaunchFunctsC.H:75
AMREX_FORCE_INLINE auto call_f_intvect_ncomp_handler(F const &f, IntVectND< dim > iv, T n) noexcept -> decltype(call_f_intvect_inner(std::make_index_sequence< dim >(), f, iv, n))
Definition: AMReX_GpuLaunchFunctsC.H:103
AMREX_FORCE_INLINE void For_impND(L const &f, IntVectND< dim > const lo, IntVectND< dim > const hi, IntVectND< dim > iv) noexcept
Definition: AMReX_GpuLaunchFunctsC.H:195
AMREX_FORCE_INLINE auto call_f_scalar_handler(F const &f, N i) noexcept -> decltype(f(0))
Definition: AMReX_GpuLaunchFunctsC.H:13
AMREX_FORCE_INLINE void ParallelForRNG_impND(L const &f, IntVectND< dim > const lo, IntVectND< dim > const hi, IntVectND< dim > iv) noexcept
Definition: AMReX_GpuLaunchFunctsC.H:1232
AMREX_FORCE_INLINE void ParallelFor_impND(L const &f, IntVectND< dim > const lo, IntVectND< dim > const hi, IntVectND< dim > iv) noexcept
Definition: AMReX_GpuLaunchFunctsC.H:255
AMREX_FORCE_INLINE auto call_f_intvect_engine(F const &f, IntVectND< dim > iv, RandomEngine engine) noexcept -> decltype(call_f_intvect_inner(std::make_index_sequence< dim >(), f, iv, engine))
Definition: AMReX_GpuLaunchFunctsC.H:65
AMREX_FORCE_INLINE auto call_f_intvect_ncomp_engine(F const &f, IntVectND< dim > iv, T n, RandomEngine engine) noexcept -> decltype(call_f_intvect_inner(std::make_index_sequence< dim >(), f, iv, n, engine))
Definition: AMReX_GpuLaunchFunctsC.H:93
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_GpuLaunchFunctsC.H:31
Definition: AMReX_Amr.cpp:49
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:200
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > ubound_iv(BoxND< dim > const &box) noexcept
Definition: AMReX_Box.H:1789
void launch(T const &n, L &&f) noexcept
Definition: AMReX_GpuLaunchFunctsC.H:120
void HostDeviceFor(T n, L &&f) noexcept
Definition: AMReX_GpuLaunchFunctsC.H:869
void HostDeviceParallelFor(T n, L &&f) noexcept
Definition: AMReX_GpuLaunchFunctsC.H:756
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition: AMReX.H:111
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > lbound_iv(BoxND< dim > const &box) noexcept
Definition: AMReX_Box.H:1780
void single_task(L &&f) noexcept
Definition: AMReX_GpuLaunchFunctsC.H:1307
AMREX_ATTRIBUTE_FLATTEN_FOR void For(T n, L const &f) noexcept
Definition: AMReX_GpuLaunchFunctsC.H:134
AMREX_ATTRIBUTE_FLATTEN_FOR void ParallelForRNG(T n, L const &f) noexcept
Definition: AMReX_GpuLaunchFunctsC.H:1221
Definition: AMReX_FabArrayCommI.H:896
Definition: AMReX_GpuTypes.H:86
Definition: AMReX_RandomEngine.H:57