1#ifndef AMREX_GPU_LAUNCH_FUNCTS_C_H_
2#define AMREX_GPU_LAUNCH_FUNCTS_C_H_
3#include <AMReX_Config.H>
15template<
int WIDTH,
class N=
int>
19 static constexpr int width = WIDTH;
29 template <
typename F,
typename N>
32 noexcept ->
decltype(f(0))
37 template <
typename F,
typename N>
47 template <
typename F, std::size_t...Ns,
class...Args>
50 noexcept -> decltype(f(0, 0, 0, args...))
52 f(iv[0], 0, 0, args...);
55 template <
typename F, std::size_t...Ns,
class...Args>
58 noexcept -> decltype(f(0, 0, 0, args...))
60 f(iv[0], iv[1], 0, args...);
63 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
66 noexcept -> decltype(f(iv, args...))
71 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
74 noexcept -> decltype(f(iv[Ns]..., args...))
76 f(iv[Ns]..., args...);
81 template <
typename F,
int dim>
91 template <
typename F,
int dim>
99 template <
typename F,
int dim>
109 template <
typename F,
typename T,
int dim>
119 template <
typename F,
typename T,
int dim>
127 template <
typename F,
typename T,
int dim>
137template<
typename T,
typename L>
140 std::forward<L>(f)(n);
143template<
int MT,
typename T,
typename L>
147 std::forward<L>(f)(n);
150template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
152void For (T n, L
const& f)
noexcept
154 for (T i = 0; i < n; ++i) {
159template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
160void For (T n, L&& f)
noexcept
163 For(n, std::forward<L>(f));
166template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
169 For(n, std::forward<L>(f));
172template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
176 For(n, std::forward<L>(f));
179template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
184 for (T i = 0; i < n; ++i) {
189template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
204template <
int WIDTH,
typename N,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<N>> >
210 for (; i + WIDTH <= n; i+=WIDTH) {
221template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
227template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
236template <
int idim,
typename L,
int dim>
240 if constexpr (idim == 1) {
241 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
244 }
else if constexpr (idim == 2) {
245 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
246 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
249 }
else if constexpr (idim == 3) {
250 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
251 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
252 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
256 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
264template <
typename L,
int dim>
271 detail::For_impND<dim>(f, lo, hi, iv);
274template <
int MT,
typename L,
int dim>
278 For(box, std::forward<L>(f));
281template <
typename L,
int dim>
284 For(box, std::forward<L>(f));
287template <
int MT,
typename L,
int dim>
291 For(box, std::forward<L>(f));
296template <
int idim,
typename L,
int dim>
300 if constexpr (idim == 1) {
302 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
305 }
else if constexpr (idim == 2) {
306 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
308 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
311 }
else if constexpr (idim == 3) {
312 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
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;
319 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
327template <
typename L,
int dim>
334 detail::ParallelFor_impND<dim>(f, lo, hi, iv);
337template <
int MT,
typename L,
int dim>
344template <
typename L,
int dim>
350template <
int MT,
typename L,
int dim>
359template <
int idim,
typename L,
typename T,
int dim>
363 if constexpr (idim == 1) {
364 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
367 }
else if constexpr (idim == 2) {
368 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
369 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
372 }
else if constexpr (idim == 3) {
373 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
374 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
375 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
379 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
387template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
394 for (T n = 0; n < ncomp; ++n) {
395 detail::For_impND<dim>(f, lo, hi, iv, n);
399template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
403 For(box, ncomp, std::forward<L>(f));
406template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
409 For(box, ncomp, std::forward<L>(f));
412template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
416 For(box, ncomp, std::forward<L>(f));
421template <
int idim,
typename L,
typename T,
int dim>
425 if constexpr (idim == 1) {
427 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
430 }
else if constexpr (idim == 2) {
431 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
433 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
436 }
else if constexpr (idim == 3) {
437 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
438 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
440 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
444 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
452template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
459 for (T n = 0; n < ncomp; ++n) {
460 detail::ParallelFor_impND<dim>(f, lo, hi, iv, n);
464template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
471template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
477template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
484template <
typename L1,
typename L2,
int dim>
487 For(box1, std::forward<L1>(f1));
488 For(box2, std::forward<L2>(f2));
491template <
int MT,
typename L1,
typename L2,
int dim>
495 For(box1, std::forward<L1>(f1));
496 For(box2, std::forward<L2>(f2));
499template <
typename L1,
typename L2,
int dim>
502 For (box1, box2, std::forward<L1>(f1), std::forward<L2>(f2));
505template <
int MT,
typename L1,
typename L2,
int dim>
509 For (box1, box2, std::forward<L1>(f1), std::forward<L2>(f2));
512template <
typename L1,
typename L2,
typename L3,
int dim>
515 For(box1, std::forward<L1>(f1));
516 For(box2, std::forward<L2>(f2));
517 For(box3, std::forward<L3>(f3));
520template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
524 For(box1, std::forward<L1>(f1));
525 For(box2, std::forward<L2>(f2));
526 For(box3, std::forward<L3>(f3));
529template <
typename L1,
typename L2,
typename L3,
int dim>
532 For(box1, box2, box3, std::forward<L1>(f1), std::forward<L2>(f2), std::forward<L3>(f3));
535template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
539 For(box1, box2, box3, std::forward<L1>(f1), std::forward<L2>(f2), std::forward<L3>(f3));
542template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
543 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
544 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
546 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
548 For(box1, ncomp1, std::forward<L1>(f1));
549 For(box2, ncomp2, std::forward<L2>(f2));
552template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
553 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
554 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
556 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
559 For(box1, ncomp1, std::forward<L1>(f1));
560 For(box2, ncomp2, std::forward<L2>(f2));
563template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
564 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
565 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
568 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
570 For(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
573template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
574 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
575 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
578 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
581 For(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
584template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
585 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
586 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
587 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
590 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
592 For(box1, ncomp1, std::forward<L1>(f1));
593 For(box2, ncomp2, std::forward<L2>(f2));
594 For(box3, ncomp3, std::forward<L3>(f3));
597template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
598 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
599 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
600 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
603 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
606 For(box1, ncomp1, std::forward<L1>(f1));
607 For(box2, ncomp2, std::forward<L2>(f2));
608 For(box3, ncomp3, std::forward<L3>(f3));
611template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
612 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
613 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
614 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
618 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
620 For(box1,ncomp1,std::forward<L1>(f1),
621 box2,ncomp2,std::forward<L2>(f2),
622 box3,ncomp3,std::forward<L3>(f3));
625template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
626 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
627 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
628 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
632 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
635 For(box1,ncomp1,std::forward<L1>(f1),
636 box2,ncomp2,std::forward<L2>(f2),
637 box3,ncomp3,std::forward<L3>(f3));
640template <
typename L1,
typename L2,
int dim>
647template <
int MT,
typename L1,
typename L2,
int dim>
655template <
typename L1,
typename L2,
int dim>
658 ParallelFor(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
661template <
int MT,
typename L1,
typename L2,
int dim>
665 ParallelFor(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
668template <
typename L1,
typename L2,
typename L3,
int dim>
676template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
685template <
typename L1,
typename L2,
typename L3,
int dim>
688 ParallelFor(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
691template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
695 ParallelFor(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
698template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
699 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
700 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
702 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
708template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
709 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
710 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
712 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
719template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
720 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
721 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
724 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
727 box2,ncomp2,std::forward<L2>(f2));
730template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
731 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
732 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
735 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
739 box2,ncomp2,std::forward<L2>(f2));
742template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
743 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
744 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
745 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
748 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
755template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
756 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
757 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
758 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
761 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
769template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
770 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
771 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
772 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
776 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
779 box2, ncomp2, std::forward<L2>(f2),
780 box3, ncomp3, std::forward<L3>(f3));
783template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
784 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
785 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
786 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
790 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
794 box2, ncomp2, std::forward<L2>(f2),
795 box3, ncomp3, std::forward<L3>(f3));
798template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
804template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
811template <
typename L,
int dim>
817template <
int MT,
typename L,
int dim>
824template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
830template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
837template <
typename L1,
typename L2,
int dim>
840 ParallelFor(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
843template <
int MT,
typename L1,
typename L2,
int dim>
847 ParallelFor(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
850template <
typename L1,
typename L2,
typename L3,
int dim>
852 L1&& f1, L2&& f2, L3&& f3)
noexcept
854 ParallelFor(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
857template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
859 L1&& f1, L2&& f2, L3&& f3)
noexcept
862 ParallelFor(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
865template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
866 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
867 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
869 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
871 ParallelFor(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
874template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
875 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
876 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
878 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
881 ParallelFor(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
884template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
885 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
886 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
887 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
890 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
893 box2,ncomp2,std::forward<L2>(f2),
894 box3,ncomp3,std::forward<L3>(f3));
897template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
898 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
899 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
900 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
903 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
907 box2,ncomp2,std::forward<L2>(f2),
908 box3,ncomp3,std::forward<L3>(f3));
911template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
914 For(n,std::forward<L>(f));
917template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
921 For(n,std::forward<L>(f));
924template <
typename L,
int dim>
927 For(box,std::forward<L>(f));
930template <
int MT,
typename L,
int dim>
934 For(box,std::forward<L>(f));
937template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
940 For(box,ncomp,std::forward<L>(f));
943template <
int MT,
typename T,
int dim,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
947 For(box,ncomp,std::forward<L>(f));
950template <
typename L1,
typename L2,
int dim>
953 For(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
956template <
int MT,
typename L1,
typename L2,
int dim>
960 For(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
963template <
typename L1,
typename L2,
typename L3,
int dim>
965 L1&& f1, L2&& f2, L3&& f3)
noexcept
967 For(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
970template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
972 L1&& f1, L2&& f2, L3&& f3)
noexcept
975 For(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
978template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
979 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
980 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
982 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
984 For(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
987template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
988 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
989 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
991 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
994 For(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
997template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
998 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
999 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
1000 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
1003 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1005 For(box1,ncomp1,std::forward<L1>(f1),
1006 box2,ncomp2,std::forward<L2>(f2),
1007 box3,ncomp3,std::forward<L3>(f3));
1010template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
1011 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1012 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
1013 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
1016 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1019 For(box1,ncomp1,std::forward<L1>(f1),
1020 box2,ncomp2,std::forward<L2>(f2),
1021 box3,ncomp3,std::forward<L3>(f3));
1024template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1030template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1037template <
typename L,
int dim>
1043template <
int MT,
typename L,
int dim>
1050template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1056template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1063template <
typename L1,
typename L2,
int dim>
1066 ParallelFor(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
1069template <
int MT,
typename L1,
typename L2,
int dim>
1073 ParallelFor(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
1076template <
typename L1,
typename L2,
typename L3,
int dim>
1079 L1&& f1, L2&& f2, L3&& f3)
noexcept
1081 ParallelFor(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1084template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1087 L1&& f1, L2&& f2, L3&& f3)
noexcept
1090 ParallelFor(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1093template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
1094 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1095 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
1098 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1100 ParallelFor(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
1103template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
1104 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1105 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
1108 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1111 ParallelFor(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
1114template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
1115 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1116 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
1117 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
1121 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1124 box2,ncomp2,std::forward<L2>(f2),
1125 box3,ncomp3,std::forward<L3>(f3));
1128template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
1129 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1130 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
1131 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
1135 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1139 box2,ncomp2,std::forward<L2>(f2),
1140 box3,ncomp3,std::forward<L3>(f3));
1143template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1146 For(n,std::forward<L>(f));
1149template <
int MT,
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1153 For(n,std::forward<L>(f));
1156template <
typename L,
int dim>
1159 For(box,std::forward<L>(f));
1162template <
int MT,
typename L,
int dim>
1166 For(box,std::forward<L>(f));
1169template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1172 For(box,ncomp,std::forward<L>(f));
1175template <
int MT,
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1179 For(box,ncomp,std::forward<L>(f));
1182template <
typename L1,
typename L2,
int dim>
1185 For(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
1188template <
int MT,
typename L1,
typename L2,
int dim>
1192 For(box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
1195template <
typename L1,
typename L2,
typename L3,
int dim>
1198 L1&& f1, L2&& f2, L3&& f3)
noexcept
1200 For(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1203template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1206 L1&& f1, L2&& f2, L3&& f3)
noexcept
1209 For(box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1212template <
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
1213 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1214 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
1217 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1219 For(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
1222template <
int MT,
typename T1,
typename T2,
typename L1,
typename L2,
int dim,
1223 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1224 typename M2=std::enable_if_t<std::is_integral_v<T2>> >
1227 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1230 For(box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
1233template <
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
1234 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1235 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
1236 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
1240 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1242 For(box1,ncomp1,std::forward<L1>(f1),
1243 box2,ncomp2,std::forward<L2>(f2),
1244 box3,ncomp3,std::forward<L3>(f3));
1247template <
int MT,
typename T1,
typename T2,
typename T3,
typename L1,
typename L2,
typename L3,
int dim,
1248 typename M1=std::enable_if_t<std::is_integral_v<T1>>,
1249 typename M2=std::enable_if_t<std::is_integral_v<T2>>,
1250 typename M3=std::enable_if_t<std::is_integral_v<T3>> >
1254 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1257 For(box1,ncomp1,std::forward<L1>(f1),
1258 box2,ncomp2,std::forward<L2>(f2),
1259 box3,ncomp3,std::forward<L3>(f3));
1262template <
typename T,
typename L,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1266 for (T i = 0; i < n; ++i) {
1273template <
int idim,
typename L,
int dim>
1277 if constexpr (idim == 1) {
1278 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
1281 }
else if constexpr (idim == 2) {
1282 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
1283 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
1286 }
else if constexpr (idim == 3) {
1287 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
1288 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
1289 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
1293 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
1299template <
int idim,
typename L,
typename T,
int dim>
1303 if constexpr (idim == 1) {
1304 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
1307 }
else if constexpr (idim == 2) {
1308 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
1309 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
1312 }
else if constexpr (idim == 3) {
1313 for (
int i2 = lo[2], h2 = hi[2]; i2 <= h2; ++i2) { iv[2] = i2;
1314 for (
int i1 = lo[1], h1 = hi[1]; i1 <= h1; ++i1) { iv[1] = i1;
1315 for (
int i0 = lo[0], h0 = hi[0]; i0 <= h0; ++i0) { iv[0] = i0;
1319 for (
int id = lo[idim-1], hd = hi[idim-1];
id <= hd; ++id) { iv[idim-1] = id;
1327template <
typename L,
int dim>
1334 detail::ParallelForRNG_impND<dim>(f, lo, hi, iv);
1337template <
typename T,
typename L,
int dim,
typename M=std::enable_if_t<std::is_
integral_v<T>> >
1344 for (T n = 0; n < ncomp; ++n) {
1345 detail::ParallelForRNG_impND<dim>(f, lo, hi, iv, n);
1349template <
typename L>
1352 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:46
Definition AMReX_GpuKernelInfo.H:8
Definition AMReX_IntVect.H:55
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:93
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:121
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:238
AMREX_FORCE_INLINE auto call_f_scalar_handler(F const &f, N i) noexcept -> decltype(f(0))
Definition AMReX_GpuLaunchFunctsC.H:31
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:1275
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:298
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:83
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:111
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:49
Definition AMReX_Amr.cpp:49
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:138
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
__host__ __device__ IntVectND< dim > lbound_iv(BoxND< dim > const &box) noexcept
Definition AMReX_Box.H:1798
void launch(T const &n, L &&f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:138
void HostDeviceFor(T n, L &&f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:912
AMREX_ATTRIBUTE_FLATTEN_FOR void ParallelForSIMD(N n, L const &f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:206
void HostDeviceParallelFor(T n, L &&f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:799
__host__ __device__ IntVectND< dim > ubound_iv(BoxND< dim > const &box) noexcept
Definition AMReX_Box.H:1807
void single_task(L &&f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:1350
AMREX_ATTRIBUTE_FLATTEN_FOR void For(T n, L const &f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:152
AMREX_ATTRIBUTE_FLATTEN_FOR void ParallelForRNG(T n, L const &f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:1264
Definition AMReX_FabArrayCommI.H:1000
Definition AMReX_GpuTypes.H:86
Definition AMReX_RandomEngine.H:72
Definition AMReX_GpuLaunchFunctsC.H:17
static constexpr int width
Definition AMReX_GpuLaunchFunctsC.H:19
N index
Definition AMReX_GpuLaunchFunctsC.H:22