1#ifndef AMREX_FABARRAY_UTILITY_H_
2#define AMREX_FABARRAY_UTILITY_H_
3#include <AMReX_Config.H>
31template <BaseFabType FAB,
class F>
32typename FAB::value_type
40template <BaseFabType FAB,
class F>
41typename FAB::value_type
42ReduceSum_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
44 using value_type =
typename FAB::value_type;
48#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
50 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
52 const Box& bx = mfi.growntilebox(nghost);
53 auto const& arr = fa.const_array(mfi);
65template <
class OP, BaseFabType FAB,
class F>
66std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
67 std::is_same_v<OP,ReduceOpLogicalOr>,
68 int,
typename FAB::value_type>
69ReduceMF (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
71 using T = std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
72 std::is_same_v<OP,ReduceOpLogicalOr>,
73 int,
typename FAB::value_type>;
74 auto typ = fa.ixType();
75 auto const& ma = fa.const_arrays();
76 return ParReduce(TypeList<OP>{}, TypeList<T>{}, fa, nghost,
77 [=]
AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k)
noexcept -> GpuTuple<T>
83template <
class OP, BaseFabType FAB1, BaseFabType FAB2,
class F>
84std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
85 std::is_same_v<OP,ReduceOpLogicalOr>,
86 int,
typename FAB1::value_type>
87ReduceMF (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2, IntVect
const& nghost, F
const& f)
89 using T = std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
90 std::is_same_v<OP,ReduceOpLogicalOr>,
91 int,
typename FAB1::value_type>;
92 auto typ = fa1.ixType();
93 auto const& ma1 = fa1.const_arrays();
94 auto const& ma2 = fa2.const_arrays();
95 return ParReduce(TypeList<OP>{}, TypeList<T>{}, fa1, nghost,
96 [=]
AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k)
noexcept -> GpuTuple<T>
99 ma1[box_no], ma2[box_no])) };
103template <
class OP, BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
104std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
105 std::is_same_v<OP,ReduceOpLogicalOr>,
106 int,
typename FAB1::value_type>
107ReduceMF (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
108 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F
const& f)
110 using T = std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
111 std::is_same_v<OP,ReduceOpLogicalOr>,
112 int,
typename FAB1::value_type>;
113 auto typ = fa1.ixType();
114 auto const& ma1 = fa1.const_arrays();
115 auto const& ma2 = fa2.const_arrays();
116 auto const& ma3 = fa3.const_arrays();
117 return ParReduce(TypeList<OP>{}, TypeList<T>{}, fa1, nghost,
118 [=]
AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k)
noexcept -> GpuTuple<T>
121 ma1[box_no], ma2[box_no], ma3[box_no])) };
125template <BaseFabType FAB,
class F>
126requires (!amrex::DefinitelyNotHostRunnable<F>::value)
127typename FAB::value_type ReduceSum_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
129 return ReduceSum_host(fa,nghost,std::forward<F>(f));
132template <BaseFabType FAB,
class F>
133requires (amrex::DefinitelyNotHostRunnable<F>::value)
134typename FAB::value_type ReduceSum_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
137 amrex::Abort(
"ReduceSum: Launch Region is off. Device lambda cannot be called by host.");
151template <BaseFabType FAB,
class F>
152typename FAB::value_type
156 return fudetail::ReduceMF<ReduceOpSum>(fa, nghost, std::forward<F>(f));
158 return fudetail::ReduceSum_host_wrapper(fa, nghost, std::forward<F>(f));
170template <BaseFabType FAB,
class F>
171typename FAB::value_type
174 return fudetail::ReduceSum_host(fa, nghost, std::forward<F>(f));
186template <BaseFabType FAB1, BaseFabType FAB2,
class F>
187typename FAB1::value_type
196template <BaseFabType FAB1, BaseFabType FAB2,
class F>
197typename FAB1::value_type
198ReduceSum_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
199 IntVect
const& nghost, F
const& f)
201 using value_type =
typename FAB1::value_type;
205#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
207 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
209 const Box& bx = mfi.growntilebox(nghost);
210 const auto& arr1 = fa1.const_array(mfi);
211 const auto& arr2 = fa2.const_array(mfi);
212 sm += f(bx, arr1, arr2);
223template <BaseFabType FAB1, BaseFabType FAB2,
class F>
224requires (!amrex::DefinitelyNotHostRunnable<F>::value)
225typename FAB1::value_type ReduceSum_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
226 IntVect
const& nghost, F&& f)
228 return ReduceSum_host(fa1,fa2,nghost,std::forward<F>(f));
231template <BaseFabType FAB1, BaseFabType FAB2,
class F>
232requires (amrex::DefinitelyNotHostRunnable<F>::value)
233typename FAB1::value_type ReduceSum_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
234 IntVect
const& nghost, F&& f)
237 amrex::Abort(
"ReduceSum: Launch Region is off. Device lambda cannot be called by host.");
251template <BaseFabType FAB1, BaseFabType FAB2,
class F>
252typename FAB1::value_type
257 return fudetail::ReduceMF<ReduceOpSum>(fa1,fa2,nghost,std::forward<F>(f));
259 return fudetail::ReduceSum_host_wrapper(fa1,fa2,nghost, std::forward<F>(f));
271template <BaseFabType FAB1, BaseFabType FAB2,
class F>
272typename FAB1::value_type
273ReduceSum (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
276 return fudetail::ReduceSum_host(fa1,fa2,nghost,std::forward<F>(f));
289template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
290typename FAB1::value_type
299template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
300typename FAB1::value_type
301ReduceSum_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
302 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F
const& f)
304 using value_type =
typename FAB1::value_type;
308#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
310 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
312 const Box& bx = mfi.growntilebox(nghost);
313 const auto& arr1 = fa1.const_array(mfi);
314 const auto& arr2 = fa2.const_array(mfi);
315 const auto& arr3 = fa3.const_array(mfi);
316 sm += f(bx, arr1, arr2, arr3);
327template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
328requires (!amrex::DefinitelyNotHostRunnable<F>::value)
329typename FAB1::value_type ReduceSum_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
330 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
332 return fudetail::ReduceSum_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
335template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
336requires (amrex::DefinitelyNotHostRunnable<F>::value)
337typename FAB1::value_type ReduceSum_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
338 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
341 amrex::Abort(
"ReduceSum: Launch Region is off. Device lambda cannot be called by host.");
356template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
357typename FAB1::value_type
362 return fudetail::ReduceMF<ReduceOpSum>(fa1,fa2,fa3,nghost,std::forward<F>(f));
364 return fudetail::ReduceSum_host_wrapper(fa1,fa2,fa3,nghost,std::forward<F>(f));
377template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
378typename FAB1::value_type
379ReduceSum (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
380 FabArray<FAB3>
const& fa3,
IntVect const& nghost,
F&& f)
382 return fudetail::ReduceSum_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
397template <BaseFabType FAB,
class F>
398typename FAB::value_type
406template <BaseFabType FAB,
class F>
407typename FAB::value_type
408ReduceMin_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
410 using value_type =
typename FAB::value_type;
411 value_type r = std::numeric_limits<value_type>::max();
414#pragma omp parallel reduction(min:r)
416 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
418 const Box& bx = mfi.growntilebox(nghost);
419 const auto& arr = fa.const_array(mfi);
420 r = std::min(r, f(bx, arr));
430template <BaseFabType FAB,
class F>
431requires (!amrex::DefinitelyNotHostRunnable<F>::value)
432typename FAB::value_type ReduceMin_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
434 return ReduceMin_host(fa,nghost,std::forward<F>(f));
437template <BaseFabType FAB,
class F>
438requires (amrex::DefinitelyNotHostRunnable<F>::value)
439typename FAB::value_type ReduceMin_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
442 amrex::Abort(
"ReduceMin: Launch Region is off. Device lambda cannot be called by host.");
455template <BaseFabType FAB,
class F>
456typename FAB::value_type
460 return fudetail::ReduceMF<ReduceOpMin>(fa, nghost, std::forward<F>(f));
462 return fudetail::ReduceMin_host_wrapper(fa, nghost, std::forward<F>(f));
473template <BaseFabType FAB,
class F>
474typename FAB::value_type
477 return fudetail::ReduceMin_host(fa, nghost, std::forward<F>(f));
489template <BaseFabType FAB1, BaseFabType FAB2,
class F>
490typename FAB1::value_type
498template <BaseFabType FAB1, BaseFabType FAB2,
class F>
499typename FAB1::value_type
500ReduceMin_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
501 IntVect
const& nghost, F
const& f)
503 using value_type =
typename FAB1::value_type;
504 value_type r = std::numeric_limits<value_type>::max();
507#pragma omp parallel reduction(min:r)
509 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
511 const Box& bx = mfi.growntilebox(nghost);
512 const auto& arr1 = fa1.const_array(mfi);
513 const auto& arr2 = fa2.const_array(mfi);
514 r = std::min(r, f(bx, arr1, arr2));
525template <BaseFabType FAB1, BaseFabType FAB2,
class F>
526requires (!amrex::DefinitelyNotHostRunnable<F>::value)
527typename FAB1::value_type ReduceMin_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
528 IntVect
const& nghost, F&& f)
530 return fudetail::ReduceMin_host(fa1,fa2,nghost,std::forward<F>(f));
533template <BaseFabType FAB1, BaseFabType FAB2,
class F>
534requires (amrex::DefinitelyNotHostRunnable<F>::value)
535typename FAB1::value_type ReduceMin_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
536 IntVect
const& nghost, F&& f)
539 amrex::Abort(
"ReduceMin: Launch Region is off. Device lambda cannot be called by host.");
553template <BaseFabType FAB1, BaseFabType FAB2,
class F>
554typename FAB1::value_type
559 return fudetail::ReduceMF<ReduceOpMin>(fa1,fa2,nghost,std::forward<F>(f));
561 return fudetail::ReduceMin_host_wrapper(fa1,fa2,nghost,std::forward<F>(f));
568template <BaseFabType FAB1, BaseFabType FAB2,
class F>
569typename FAB1::value_type
570ReduceMin (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
573 return fudetail::ReduceMin_host(fa1,fa2,nghost,std::forward<F>(f));
580template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
581typename FAB1::value_type
590template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
591typename FAB1::value_type
592ReduceMin_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
593 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F
const& f)
595 using value_type =
typename FAB1::value_type;
596 value_type r = std::numeric_limits<value_type>::max();
599#pragma omp parallel reduction(min:r)
601 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
603 const Box& bx = mfi.growntilebox(nghost);
604 const auto& arr1 = fa1.const_array(mfi);
605 const auto& arr2 = fa2.const_array(mfi);
606 const auto& arr3 = fa3.const_array(mfi);
607 r = std::min(r, f(bx, arr1, arr2, arr3));
618template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
619requires (!amrex::DefinitelyNotHostRunnable<F>::value)
620typename FAB1::value_type ReduceMin_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
621 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
623 return fudetail::ReduceMin_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
626template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
627requires (amrex::DefinitelyNotHostRunnable<F>::value)
628typename FAB1::value_type ReduceMin_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
629 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
632 amrex::Abort(
"ReduceMin: Launch Region is off. Device lambda cannot be called by host.");
641template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
642typename FAB1::value_type
647 return fudetail::ReduceMF<ReduceOpMin>(fa1,fa2,fa3,nghost,std::forward<F>(f));
649 return fudetail::ReduceMin_host_wrapper(fa1,fa2,fa3,nghost,std::forward<F>(f));
656template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
657typename FAB1::value_type
658ReduceMin (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
659 FabArray<FAB3>
const& fa3,
IntVect const& nghost,
F&& f)
661 return fudetail::ReduceMin_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
672template <BaseFabType FAB,
class F>
673typename FAB::value_type
681template <BaseFabType FAB,
class F>
682typename FAB::value_type
683ReduceMax_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
685 using value_type =
typename FAB::value_type;
686 value_type r = std::numeric_limits<value_type>::lowest();
689#pragma omp parallel reduction(max:r)
691 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
693 const Box& bx = mfi.growntilebox(nghost);
694 const auto& arr = fa.const_array(mfi);
695 r = std::max(r, f(bx, arr));
706template <BaseFabType FAB,
class F>
707requires (!amrex::DefinitelyNotHostRunnable<F>::value)
708typename FAB::value_type ReduceMax_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
710 return ReduceMax_host(fa,nghost,std::forward<F>(f));
713template <BaseFabType FAB,
class F>
714requires (amrex::DefinitelyNotHostRunnable<F>::value)
715typename FAB::value_type ReduceMax_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
718 amrex::Abort(
"ReduceMax: Launch Region is off. Device lambda cannot be called by host.");
727template <BaseFabType FAB,
class F>
728typename FAB::value_type
732 return fudetail::ReduceMF<ReduceOpMax>(fa,nghost,std::forward<F>(f));
734 return fudetail::ReduceMax_host_wrapper(fa,nghost,std::forward<F>(f));
741template <BaseFabType FAB,
class F>
742typename FAB::value_type
745 return fudetail::ReduceMax_host(fa,nghost,std::forward<F>(f));
752template <BaseFabType FAB1, BaseFabType FAB2,
class F>
753typename FAB1::value_type
761template <BaseFabType FAB1, BaseFabType FAB2,
class F>
762typename FAB1::value_type
763ReduceMax_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
764 IntVect
const& nghost, F
const& f)
766 using value_type =
typename FAB1::value_type;
767 value_type r = std::numeric_limits<value_type>::lowest();
770#pragma omp parallel reduction(max:r)
772 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
774 const Box& bx = mfi.growntilebox(nghost);
775 const auto& arr1 = fa1.const_array(mfi);
776 const auto& arr2 = fa2.const_array(mfi);
777 r = std::max(r, f(bx, arr1, arr2));
788template <BaseFabType FAB1, BaseFabType FAB2,
class F>
789requires (!amrex::DefinitelyNotHostRunnable<F>::value)
790typename FAB1::value_type ReduceMax_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
791 IntVect
const& nghost, F&& f)
793 return ReduceMax_host(fa1,fa2,nghost,std::forward<F>(f));
796template <BaseFabType FAB1, BaseFabType FAB2,
class F>
797requires (amrex::DefinitelyNotHostRunnable<F>::value)
798typename FAB1::value_type ReduceMax_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
799 IntVect
const& nghost, F&& f)
802 amrex::Abort(
"ReduceMax: Launch Region is off. Device lambda cannot be called by host.");
811template <BaseFabType FAB1, BaseFabType FAB2,
class F>
812typename FAB1::value_type
817 return fudetail::ReduceMF<ReduceOpMax>(fa1,fa2,nghost,std::forward<F>(f));
819 return fudetail::ReduceMax_host_wrapper(fa1,fa2,nghost,std::forward<F>(f));
826template <BaseFabType FAB1, BaseFabType FAB2,
class F>
827typename FAB1::value_type
828ReduceMax (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
831 return fudetail::ReduceMax_host(fa1,fa2,nghost,std::forward<F>(f));
838template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
839typename FAB1::value_type
848template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
849typename FAB1::value_type
850ReduceMax_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
851 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F
const& f)
853 using value_type =
typename FAB1::value_type;
854 value_type r = std::numeric_limits<value_type>::lowest();
857#pragma omp parallel reduction(max:r)
859 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
861 const Box& bx = mfi.growntilebox(nghost);
862 const auto& arr1 = fa1.const_array(mfi);
863 const auto& arr2 = fa2.const_array(mfi);
864 const auto& arr3 = fa3.const_array(mfi);
865 r = std::max(r, f(bx, arr1, arr2, arr3));
876template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
877requires (!amrex::DefinitelyNotHostRunnable<F>::value)
878typename FAB1::value_type ReduceMax_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
879 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
881 return fudetail::ReduceMax_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
884template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
885requires (amrex::DefinitelyNotHostRunnable<F>::value)
886typename FAB1::value_type ReduceMax_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
887 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
890 amrex::Abort(
"ReduceMax: Launch Region is off. Device lambda cannot be called by host.");
899template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
900typename FAB1::value_type
905 return fudetail::ReduceMF<ReduceOpMax>(fa1,fa2,fa3,nghost,std::forward<F>(f));
907 return fudetail::ReduceMax_host_wrapper(fa1,fa2,fa3,nghost,std::forward<F>(f));
914template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
915typename FAB1::value_type
916ReduceMax (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
917 FabArray<FAB3>
const& fa3,
IntVect const& nghost,
F&& f)
919 return fudetail::ReduceMax_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
930template <BaseFabType FAB,
class F>
939template <BaseFabType FAB,
class F>
941ReduceLogicalAnd_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
946#pragma omp parallel reduction(&&:r)
948 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
950 const Box& bx = mfi.growntilebox(nghost);
951 const auto& arr = fa.const_array(mfi);
963template <BaseFabType FAB,
class F>
964requires (!amrex::DefinitelyNotHostRunnable<F>::value)
965bool ReduceLogicalAnd_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
967 return ReduceLogicalAnd_host(fa,nghost,std::forward<F>(f));
970template <BaseFabType FAB,
class F>
971requires (amrex::DefinitelyNotHostRunnable<F>::value)
972bool ReduceLogicalAnd_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
975 amrex::Abort(
"ReduceLogicalAnd: Launch Region is off. Device lambda cannot be called by host.");
984template <BaseFabType FAB,
class F>
989 return fudetail::ReduceMF<ReduceOpLogicalAnd>(fa,nghost,std::forward<F>(f));
991 return fudetail::ReduceLogicalAnd_host_wrapper(fa,nghost,std::forward<F>(f));
998template <BaseFabType FAB,
class F>
1002 return fudetail::ReduceLogicalAnd_host(fa,nghost,std::forward<F>(f));
1009template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1019template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1021ReduceLogicalAnd_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1022 IntVect
const& nghost, F
const& f)
1027#pragma omp parallel reduction(&&:r)
1029 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
1031 const Box& bx = mfi.growntilebox(nghost);
1032 const auto& arr1 = fa1.const_array(mfi);
1033 const auto& arr2 = fa2.const_array(mfi);
1034 r = r && f(bx, arr1, arr2);
1045template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1046requires (!amrex::DefinitelyNotHostRunnable<F>::value)
1047bool ReduceLogicalAnd_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1048 IntVect
const& nghost, F&& f)
1050 return ReduceLogicalAnd_host(fa1,fa2,nghost,std::forward<F>(f));
1053template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1054requires (amrex::DefinitelyNotHostRunnable<F>::value)
1055bool ReduceLogicalAnd_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1056 IntVect
const& nghost, F&& f)
1059 amrex::Abort(
"ReduceLogicalAnd: Luanch Region is off. Device lambda cannot be called by host.");
1068template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1074 return fudetail::ReduceMF<ReduceOpLogicalAnd>(fa1,fa2,nghost,std::forward<F>(f));
1076 return fudetail::ReduceLogicalAnd_host_wrapper(fa1,fa2,nghost,std::forward<F>(f));
1083template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1088 return fudetail::ReduceLogicalAnd_host(fa1,fa2,nghost,std::forward<F>(f));
1099template <BaseFabType FAB,
class F>
1108template <BaseFabType FAB,
class F>
1110ReduceLogicalOr_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
1115#pragma omp parallel reduction(||:r)
1117 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
1119 const Box& bx = mfi.growntilebox(nghost);
1120 const auto& arr = fa.const_array(mfi);
1121 r = r || f(bx, arr);
1132template <BaseFabType FAB,
class F>
1133requires (!amrex::DefinitelyNotHostRunnable<F>::value)
1134bool ReduceLogicalOr_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
1136 return ReduceLogicalOr_host(fa,nghost,std::forward<F>(f));
1139template <BaseFabType FAB,
class F>
1140requires (amrex::DefinitelyNotHostRunnable<F>::value)
1141bool ReduceLogicalOr_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
1144 amrex::Abort(
"ReduceLogicalOr: Launch Region is off. Device lambda cannot be called by host.");
1153template <BaseFabType FAB,
class F>
1158 return fudetail::ReduceMF<ReduceOpLogicalOr>(fa,nghost,std::forward<F>(f));
1160 return fudetail::ReduceLogicalOr_host_wrapper(fa,nghost,std::forward<F>(f));
1167template <BaseFabType FAB,
class F>
1171 return fudetail::ReduceLogicalOr_host(fa,nghost,std::forward<F>(f));
1178template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1188template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1190ReduceLogicalOr_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1191 IntVect
const& nghost, F
const& f)
1196#pragma omp parallel reduction(||:r)
1198 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
1200 const Box& bx = mfi.growntilebox(nghost);
1201 const auto& arr1 = fa1.const_array(mfi);
1202 const auto& arr2 = fa2.const_array(mfi);
1203 r = r || f(bx, arr1, arr2);
1214template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1215requires (!amrex::DefinitelyNotHostRunnable<F>::value)
1216bool ReduceLogicalOr_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1217 IntVect
const& nghost, F&& f)
1219 return fudetail::ReduceLogicalOr_host(fa1,fa2,nghost,std::forward<F>(f));
1222template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1223requires (amrex::DefinitelyNotHostRunnable<F>::value)
1224bool ReduceLogicalOr_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1225 IntVect
const& nghost, F&& f)
1228 amrex::Abort(
"ReeuceLogicalOr: Launch Region is off. Device lambda cannot be called by host.");
1237template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1243 return fudetail::ReduceMF<ReduceOpLogicalOr>(fa1,fa2,nghost,std::forward<F>(f));
1245 return fudetail::ReduceLogicalOr_host_wrapper(fa1,fa2,nghost,std::forward<F>(f));
1252template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1257 return fudetail::ReduceLogicalOr_host(fa1,fa2,nghost,std::forward<F>(f));
1269template <BaseFabType FAB>
1278 int n = (comp >= 0) ? 1 : mf.
nComp();
1281 auto* dp = pv.
data();
1285 *dp = fab(cell, comp);
1287 for (
int i = 0; i < n; ++i) {
1288 dp[i] = fab(cell,i);
1305 <<
": " << *dp <<
'\n';
1307 std::ostringstream ss;
1309 for (
int i = 0; i < n-1; ++i)
1311 ss << dp[i] <<
", ";
1315 <<
": " << ss.view() <<
'\n';
1331template <BaseFabType FAB>
1335 Swap(dst,src,srccomp,dstcomp,numcomp,
IntVect(nghost));
1348template <BaseFabType FAB>
1355 bool explicit_swap =
true;
1357 if (srccomp == dstcomp && dstcomp == 0 && numcomp == src.
nComp() &&
1361 explicit_swap =
false;
1365 if ((dst.
defined(K) && dst[K].nBytesOwned() == 0) ||
1366 (src.
defined(K) && src[K].nBytesOwned() == 0)) {
1367 explicit_swap =
true;
1372 if (!explicit_swap) {
1374 std::swap(dst, src);
1379 auto const& dstma = dst.
arrays();
1380 auto const& srcma = src.
arrays();
1384 const auto tmp = dstma[box_no](i,j,k,n+dstcomp);
1385 dstma[box_no](i,j,k,n+dstcomp) = srcma[box_no](i,j,k,n+srccomp);
1386 srcma[box_no](i,j,k,n+srccomp) = tmp;
1395#pragma omp parallel if (Gpu::notInLaunchRegion())
1399 const Box& bx = mfi.growntilebox(nghost);
1401 auto sfab = src.
array(mfi);
1402 auto dfab = dst.
array(mfi);
1405 const auto tmp = dfab(i,j,k,n+dstcomp);
1406 dfab(i,j,k,n+dstcomp) = sfab(i,j,k,n+srccomp);
1407 sfab(i,j,k,n+srccomp) = tmp;
1416template <BaseFabType FAB>
1424template <BaseFabType FAB>
1430 auto const& dstfa = dst.
arrays();
1435 dstfa[box_no](i,j,k,n+dstcomp) -= srcfa[box_no](i,j,k,n+srccomp);
1444#pragma omp parallel if (Gpu::notInLaunchRegion())
1448 const Box& bx = mfi.growntilebox(nghost);
1451 auto const srcFab = src.
array(mfi);
1452 auto dstFab = dst.
array(mfi);
1455 dstFab(i,j,k,n+dstcomp) -= srcFab(i,j,k,n+srccomp);
1464template <BaseFabType FAB>
1472template <BaseFabType FAB>
1478 auto const& dstfa = dst.
arrays();
1483 dstfa[box_no](i,j,k,n+dstcomp) *= srcfa[box_no](i,j,k,n+srccomp);
1492#pragma omp parallel if (Gpu::notInLaunchRegion())
1496 const Box& bx = mfi.growntilebox(nghost);
1499 auto const srcFab = src.
array(mfi);
1500 auto dstFab = dst.
array(mfi);
1503 dstFab(i,j,k,n+dstcomp) *= srcFab(i,j,k,n+srccomp);
1512template <BaseFabType FAB>
1520template <BaseFabType FAB>
1526 auto const& dstfa = dst.
arrays();
1531 dstfa[box_no](i,j,k,n+dstcomp) /= srcfa[box_no](i,j,k,n+srccomp);
1540#pragma omp parallel if (Gpu::notInLaunchRegion())
1544 const Box& bx = mfi.growntilebox(nghost);
1547 auto const srcFab = src.
array(mfi);
1548 auto dstFab = dst.
array(mfi);
1551 dstFab(i,j,k,n+dstcomp) /= srcFab(i,j,k,n+srccomp);
1559template <BaseFabType FAB>
1567template <BaseFabType FAB>
1573 auto const& fabarr = fa.
arrays();
1577 fabarr[box_no](i,j,k,n+icomp) = std::abs(fabarr[box_no](i,j,k,n+icomp));
1586#pragma omp parallel if (Gpu::notInLaunchRegion())
1590 const Box& bx = mfi.growntilebox(nghost);
1593 auto const& fab = fa.
array(mfi);
1596 fab(i,j,k,n+icomp) = std::abs(fab(i,j,k,n+icomp));
1610template <BaseFabType FAB>
1632template <BaseFabType FAB>
1654template <BaseFabType FAB, BaseFabType IFAB>
1666template <BaseFabType FAB, BaseFabType IFAB>
1675 const int ncomp = fa.
nComp();
1679 auto const& fabarr = fa.
arrays();
1684 if (!ifabarr[box_no](i,j,k)) { fabarr[box_no](i,j,k,n) = 0; }
1693#pragma omp parallel if (Gpu::notInLaunchRegion())
1697 const Box& bx = mfi.tilebox();
1698 auto fab = fa.
array(mfi);
1699 auto const ifab = msk.
array(mfi);
1702 if (!ifab(i,j,k)) { fab(i,j,k,n) = 0; }
1716template <BaseFabType FAB>
1724 fa.
os_temp->ParallelCopy_finish();
1731template <BaseFabType FAB>
1734 int scomp,
int dcomp,
int ncomp)
1740 void* pdst = dst[mfi].dataPtr(dcomp);
1741 void const* psrc = src[mfi].dataPtr(scomp);
1750template <BaseFabType FAB>
1758template <BaseFabType FAB>
1761 int scomp,
int dcomp,
int ncomp)
1767 void* pdst = dst[mfi].dataPtr(dcomp);
1768 void const* psrc = src[mfi].dataPtr(scomp);
1777template <BaseFabType FAB>
1791template <BaseFabType FAB>
1794 typename FAB::value_type value)
1801 constexpr int nofind = std::numeric_limits<int>::lowest();
1814 if (ma[box_no](i,j,k,comp) == value) {
1833 if (arr(i,j,k,comp) == value) {
1844 int const* tmp = aa.copyToHost();
1860 const Box& bx = mfi.growntilebox(nghost);
1864 if (fab(i,j,k,comp) == value) {
1875#if defined(AMREX_USE_OMP) && defined(_OPENMP) && (_OPENMP < 201307 || (defined(__NVCOMPILER) && __NVCOMPILER_MAJOR__ < 23))
1876#pragma omp critical (amrex_indexfromvalue)
1877#elif defined(AMREX_USE_OMP)
1878#pragma omp atomic capture
1885 if (old ==
false) { loc = priv_loc; }
1904template <BaseFabType FAB>
1905typename FAB::value_type
1907 IntVect const& nghost,
bool local =
false)
1910 BL_ASSERT(
x.DistributionMap() ==
y.DistributionMap());
1911 BL_ASSERT(
x.nGrowVect().allGE(nghost) &&
y.nGrowVect().allGE(nghost));
1915 using T =
typename FAB::value_type;
1921 auto const& xma =
x.const_arrays();
1922 auto const& yma =
y.const_arrays();
1926 return xma[box_no](i,j,k,xcomp+n) * yma[box_no](i,j,k,ycomp+n);
1932#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
1936 Box const& bx = mfi.growntilebox(nghost);
1937 auto const& xfab =
x.const_array(mfi);
1938 auto const& yfab =
y.const_array(mfi);
1941 sm += xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
1963template <BaseFabType FAB>
1964typename FAB::value_type
1971 using T =
typename FAB::value_type;
1977 auto const& xma =
x.const_arrays();
1981 auto v = xma[box_no](i,j,k,xcomp+n);
1988#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
1992 Box const& bx = mfi.growntilebox(nghost);
1993 auto const& xfab =
x.const_array(mfi);
1996 auto v = xfab(i,j,k,xcomp+n);
2029template <BaseFabType MFAB, BaseFabType FAB>
2030typename FAB::value_type
2037 BL_ASSERT(
x.nGrowVect().allGE(nghost) &&
y.nGrowVect().allGE(nghost) &&
2042 using T =
typename FAB::value_type;
2049 auto const& xma =
x.const_arrays();
2050 auto const& yma =
y.const_arrays();
2054 auto m = T(mma[box_no](i,j,k));
2056 return (m != 0) ? m * xma[box_no](i,j,k,xcomp+n) * yma[box_no](i,j,k,ycomp+n) : T(0.0);
2059 auto xv = xma[box_no](i,j,k,xcomp+n);
2060 auto yv = yma[box_no](i,j,k,ycomp+n);
2061 xv = (m != 0) ? xv : T(0.0);
2062 yv = (m != 0) ? yv : T(0.0);
2070#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
2074 Box const& bx = mfi.growntilebox(nghost);
2076 auto const& xfab =
x.const_array(mfi);
2077 auto const& yfab =
y.const_array(mfi);
2080 auto m = T(mfab(i,j,k));
2081 sm += m * xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
2108template <BaseFabType MFAB, BaseFabType FAB>
2109typename FAB::value_type
2111 IntVect const& nghost,
bool local =
false)
2119 using T =
typename FAB::value_type;
2126 auto const& xma =
x.const_arrays();
2130 auto m = T(mma[box_no](i,j,k));
2133 auto v = xma[box_no](i,j,k,xcomp+n);
2139 auto v = xma[box_no](i,j,k,xcomp+n);
2140 v = (m != 0) ? v : T(0.0);
2148#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
2152 Box const& bx = mfi.growntilebox(nghost);
2154 auto const& xfab =
x.const_array(mfi);
2157 auto m = T(mfab(i,j,k));
2158 auto v = xfab(i,j,k,xcomp+n);
2173template <MultiFabLike MF>
2174void setVal (MF& dst,
typename MF::value_type val)
2180template <MultiFabLike MF>
2181void setBndry (MF& dst,
typename MF::value_type val,
int scomp,
int ncomp)
2183 dst.setBndry(val, scomp, ncomp);
2187template <MultiFabLike MF>
2188void Scale (MF& dst,
typename MF::value_type val,
int scomp,
int ncomp,
int nghost)
2190 dst.mult(val, scomp, ncomp, nghost);
2194template <MultiFabLike DMF, MultiFabLike SMF>
2195void LocalCopy (DMF& dst, SMF
const& src,
int scomp,
int dcomp,
2196 int ncomp,
IntVect const& nghost)
2198 amrex::Copy(dst, src, scomp, dcomp, ncomp, nghost);
2202template <MultiFabLike MF>
2203void LocalAdd (MF& dst, MF
const& src,
int scomp,
int dcomp,
2204 int ncomp,
IntVect const& nghost)
2206 amrex::Add(dst, src, scomp, dcomp, ncomp, nghost);
2210template <MultiFabLike MF>
2211void Saxpy (MF& dst,
typename MF::value_type a, MF
const& src,
int scomp,
int dcomp,
2212 int ncomp,
IntVect const& nghost)
2214 MF::Saxpy(dst, a, src, scomp, dcomp, ncomp, nghost);
2218template <MultiFabLike MF>
2219void Xpay (MF& dst,
typename MF::value_type a, MF
const& src,
int scomp,
int dcomp,
2220 int ncomp,
IntVect const& nghost)
2222 MF::Xpay(dst, a, src, scomp, dcomp, ncomp, nghost);
2226template <MultiFabLike MF>
2227void Saxpy_Xpay (MF& dst,
typename MF::value_type a_saxpy, MF
const& src_saxpy,
2228 typename MF::value_type a_xpay, MF
const& src_xpay,
int scomp,
int dcomp,
2229 int ncomp,
IntVect const& nghost)
2231 MF::Saxpy_Xpay(dst, a_saxpy, src_saxpy, a_xpay, src_xpay, scomp, dcomp, ncomp, nghost);
2235template <MultiFabLike MF>
2236void Saxpy_Saxpy (MF& dst1,
typename MF::value_type a1, MF
const& src1,
2237 MF& dst2,
typename MF::value_type a2, MF
const& src2,
int scomp,
int dcomp,
2238 int ncomp,
IntVect const& nghost)
2240 MF::Saxpy_Saxpy(dst1, a1, src1, dst2, a2, src2, scomp, dcomp, ncomp, nghost);
2244template <MultiFabLike MF>
2246 MF& dst2,
typename MF::value_type a2, MF
const& src,
int scomp,
int dcomp,
2247 int ncomp,
IntVect const& nghost)
2249 MF::Saypy_Saxpy(dst1, a1, dst2, a2, src, scomp, dcomp, ncomp, nghost);
2253template <MultiFabLike MF>
2255 typename MF::value_type a, MF
const& src_a,
int acomp,
2256 typename MF::value_type b, MF
const& src_b,
int bcomp,
2257 int dcomp,
int ncomp,
IntVect const& nghost)
2259 MF::LinComb(dst, a, src_a, acomp, b, src_b, bcomp, dcomp, ncomp, nghost);
2263template <MultiFabLike MF>
2269 dst.ParallelCopy(src, scomp, dcomp, ncomp, ng_src, ng_dst, period);
2273template <MultiFabLike MF>
2274[[nodiscard]]
typename MF::value_type
2278 return mf.norminf(scomp, ncomp, nghost, local);
2282template <MultiFabLike MF, std::
size_t N>
2285 for (
auto& mf: dst) {
2291template <MultiFabLike MF, std::
size_t N>
2294 for (
auto& mf : dst) {
2300template <MultiFabLike MF, std::
size_t N>
2304 for (
auto& mf : dst) {
2305 mf.
mult(val, scomp, ncomp, nghost);
2310template <MultiFabLike DMF, MultiFabLike SMF, std::
size_t N>
2312 int ncomp,
IntVect const& nghost)
2314 for (std::size_t i = 0; i < N; ++i) {
2315 amrex::Copy(dst[i], src[i], scomp, dcomp, ncomp, nghost);
2320template <MultiFabLike MF, std::
size_t N>
2322 int ncomp,
IntVect const& nghost)
2324 for (std::size_t i = 0; i < N; ++i) {
2325 amrex::Add(dst[i], src[i], scomp, dcomp, ncomp, nghost);
2330template <MultiFabLike MF, std::
size_t N>
2332 Array<MF,N> const& src,
int scomp,
int dcomp,
int ncomp,
2335 for (std::size_t i = 0; i < N; ++i) {
2336 MF::Saxpy(dst[i], a, src[i], scomp, dcomp, ncomp, nghost);
2341template <MultiFabLike MF, std::
size_t N>
2343 Array<MF,N> const& src,
int scomp,
int dcomp,
int ncomp,
2346 for (std::size_t i = 0; i < N; ++i) {
2347 MF::Xpay(dst[i], a, src[i], scomp, dcomp, ncomp, nghost);
2352template <MultiFabLike MF, std::
size_t N>
2354 typename MF::value_type a,
Array<MF,N> const& src_a,
int acomp,
2355 typename MF::value_type b,
Array<MF,N> const& src_b,
int bcomp,
2356 int dcomp,
int ncomp,
IntVect const& nghost)
2358 for (std::size_t i = 0; i < N; ++i) {
2359 MF::LinComb(dst[i], a, src_a[i], acomp, b, src_b[i], bcomp, dcomp, ncomp, nghost);
2364template <MultiFabLike MF, std::
size_t N>
2366 int scomp,
int dcomp,
int ncomp,
2371 for (std::size_t i = 0; i < N; ++i) {
2372 dst[i].ParallelCopy(src[i], scomp, dcomp, ncomp, ng_src, ng_dst, period);
2377template <MultiFabLike MF, std::
size_t N>
2378[[nodiscard]]
typename MF::value_type
2382 auto r =
typename MF::value_type(0);
2383 for (std::size_t i = 0; i < N; ++i) {
2384 auto tmp = mf[i].norminf(scomp, ncomp, nghost,
true);
2385 r = std::max(r,tmp);
2394template <MultiFabLike MF, std::
size_t N>
2398 return mf[0].nComp();
2402template <MultiFabLike MF, std::
size_t N>
2406 return mf[0].nGrowVect();
2410template <MultiFabLike MF, std::
size_t N>
2412[[nodiscard]] BoxArray
const&
2415 return mf[0].boxArray();
2419template <MultiFabLike MF, std::
size_t N>
2421[[nodiscard]] DistributionMapping
const&
2424 return mf[0].DistributionMap();
2435FabArray<BaseFab<int>>
2446 const std::vector<IntVect>& pshifts = period.
shiftIntVect();
2453#pragma omp parallel if (!run_on_gpu)
2456 std::vector< std::pair<int,Box> > isects;
2460 const Box& bx = mask[mfi].
box();
2461 auto const& arr = mask.
array(mfi);
2463 for (
const auto& iv : pshifts)
2466 for (
const auto& is : isects)
2468 Box const& b = is.second-iv;
2469 if (iv == 0 && b == bx) {
continue; }
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:593
#define BL_ASSERT(EX)
Definition AMReX_BLassert.H:39
#define AMREX_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:37
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
Distributed container of FAB objects plus copy and fill utilities.
#define AMREX_HOST_DEVICE_PARALLEL_FOR_4D(...)
Definition AMReX_GpuLaunchMacrosC.nolint.H:111
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
#define AMREX_LOOP_3D(bx, i, j, k, block)
#define AMREX_LOOP_4D(bx, ncomp, i, j, k, n, block)
while parser_exe_t p
Definition AMReX_Parser_Exe_Body.H:33
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Print on all processors of the default communicator.
Definition AMReX_Print.H:113
virtual bool isManaged() const
Check whether it is managed GPU memory.
Definition AMReX_Arena.cpp:99
virtual bool isDevice() const
Check whether it is non-managed GPU device memory.
Definition AMReX_Arena.cpp:111
Reference-counted collection of Boxes.
Definition AMReX_BoxArray.H:681
std::vector< std::pair< int, Box > > intersections(const Box &bx) const
Return all intersections of bx with this BoxArray.
Definition AMReX_BoxArray.cpp:1205
__host__ __device__ bool contains(const IntVectND< dim > &p) const noexcept
Return true if argument is contained within BoxND.
Definition AMReX_Box.H:233
__host__ __device__ bool ok() const noexcept
Return true if high bounds are >= low bounds and the index type is valid.
Definition AMReX_Box.H:229
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:55
IntVect nGrowVect() const noexcept
Definition AMReX_FabArrayBase.H:85
const Vector< int > & IndexArray() const noexcept
Return constant reference to indices in the FabArray that we have access.
Definition AMReX_FabArrayBase.H:121
bool isFusingCandidate() const noexcept
Is this a good candidate for kernel fusing?
Definition AMReX_FabArrayBase.cpp:2795
IndexType ixType() const noexcept
Return index type.
Definition AMReX_FabArrayBase.H:91
const DistributionMapping & DistributionMap() const noexcept
Return constant reference to associated DistributionMapping.
Definition AMReX_FabArrayBase.H:135
@ ADD
Definition AMReX_FabArrayBase.H:432
Box box(int K) const noexcept
Return the Kth Box in the BoxArray. That is, the valid region of the Kth grid.
Definition AMReX_FabArrayBase.H:106
int nComp() const noexcept
Return number of variables (aka components) associated with each point.
Definition AMReX_FabArrayBase.H:88
const BoxArray & boxArray() const noexcept
Return a constant reference to the BoxArray that defines the valid region associated with this FabArr...
Definition AMReX_FabArrayBase.H:100
An Array of FortranArrayBox(FAB)-like Objects.
Definition AMReX_FabArray.H:383
void mult(value_type val, int comp, int num_comp, int nghost=0)
Definition AMReX_FabArray.H:3331
void setBndry(value_type val)
Set all values in the boundary region to val.
Definition AMReX_FabArray.H:2844
std::unique_ptr< FabArray< FAB > > os_temp
Definition AMReX_FabArray.H:1970
const FabFactory< FAB > & Factory() const noexcept
Factory used to create FAB instances for this FabArray.
Definition AMReX_FabArray.H:499
void prefetchToHost(const MFIter &mfi) const noexcept
Request that the FAB selected by iterator mfi be prefetched to host memory, where supported.
Definition AMReX_FabArray.H:620
MultiArray4< typename FabArray< FAB >::value_type > arrays() noexcept
Build, if needed, and return mutable Array4 views for local FABs.
Definition AMReX_FabArray.H:741
void prefetchToDevice(const MFIter &mfi) const noexcept
Request that the FAB selected by iterator mfi be prefetched to device memory, where supported.
Definition AMReX_FabArray.H:636
Arena * arena() const noexcept
Arena configured for allocations by this FabArray.
Definition AMReX_FabArray.H:508
bool defined(int K) const noexcept
Definition AMReX_FabArray.H:2092
MultiArray4< typename FabArray< FAB >::value_type const > const_arrays() const noexcept
Read-only convenience wrapper equivalent to arrays() const.
Definition AMReX_FabArray.H:759
void setVal(value_type val)
Set all components in the entire region of each FAB to val.
Definition AMReX_FabArray.H:3068
Array4< typename FabArray< FAB >::value_type const > array(const MFIter &mfi) const noexcept
Read-only Array4 view for the FAB referenced by iterator mfi.
Definition AMReX_FabArray.H:649
bool hasEBFabFactory() const noexcept
Return whether this FabArray uses an EBFArrayBoxFactory.
Definition AMReX_FabArray.H:521
Array4< typename FabArray< FAB >::value_type const > const_array(const MFIter &mfi) const noexcept
Synonym for array(const MFIter&) that highlights read-only semantics.
Definition AMReX_FabArray.H:677
GPU-compatible tuple.
Definition AMReX_Tuple.H:104
Definition AMReX_GpuBuffer.H:24
__host__ __device__ bool cellCentered() const noexcept
True if the IndexTypeND is CELL based in all directions.
Definition AMReX_IndexType.H:102
__host__ __device__ constexpr bool allGT(const IntVectND< dim > &rhs) const noexcept
Returns true if this is greater than argument for all components. NOTE: This is NOT a strict weak ord...
Definition AMReX_IntVect.H:524
__host__ __device__ constexpr bool allGE(const IntVectND< dim > &rhs) const noexcept
Returns true if this is greater than or equal to argument for all components. NOTE: This is NOT a str...
Definition AMReX_IntVect.H:549
__host__ static __device__ constexpr IntVectND< dim > TheZeroVector() noexcept
Definition AMReX_IntVect.H:778
__host__ static __device__ constexpr IntVectND< dim > TheMinVector() noexcept
Definition AMReX_IntVect.H:848
Iterator for looping ever tiles and boxes of amrex::FabArray based containers.
Definition AMReX_MFIter.H:88
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition AMReX_MFIter.H:176
T * data() noexcept
Definition AMReX_PODVector.H:672
This provides length of period for periodic domains. 0 means it is not periodic in that direction....
Definition AMReX_Periodicity.H:17
static const Periodicity & NonPeriodic() noexcept
Definition AMReX_Periodicity.cpp:52
std::vector< IntVect > shiftIntVect(IntVect const &nghost=IntVect(0)) const
Definition AMReX_Periodicity.cpp:8
Print & SetPrecision(int p)
Definition AMReX_Print.H:86
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
__host__ __device__ BoxND< dim > makeSingleCellBox(int i, int j, int k, IndexTypeND< dim > typ=IndexTypeND< dim >::TheCellType())
Create a single-cell box at coordinates (i,j,k).
Definition AMReX_Box.H:2460
__host__ __device__ BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Return a copy of b grown uniformly by i cells in every direction.
Definition AMReX_Box.H:1328
PODVector< T, PinnedArenaAllocator< T > > PinnedVector
A PODVector that uses the pinned memory arena.
Definition AMReX_GpuContainers.H:48
std::array< T, N > Array
Definition AMReX_Array.H:31
Arena * The_Async_Arena()
Definition AMReX_Arena.cpp:849
void Sum(Gpu::DeviceVector< T > &v, MPI_Comm comm)
Definition AMReX_GpuParallelReduce.H:37
void Max(KeyValuePair< K, V > &vi, MPI_Comm comm)
Definition AMReX_ParallelReduce.H:133
__host__ __device__ void Swap(T &t1, T &t2) noexcept
Definition AMReX_Algorithm.H:110
__host__ __device__ AMREX_FORCE_INLINE T Exch(T *address, T val) noexcept
Definition AMReX_GpuAtomic.H:542
__host__ __device__ AMREX_FORCE_INLINE void AddNoRet(T *sum, T value) noexcept
Definition AMReX_GpuAtomic.H:322
void streamSynchronize() noexcept
Definition AMReX_GpuDevice.H:329
void dtoh_memcpy_async(void *p_h, const void *p_d, const std::size_t sz) noexcept
Definition AMReX_GpuDevice.H:454
bool inLaunchRegion() noexcept
Definition AMReX_GpuControl.H:88
bool inNoSyncRegion() noexcept
Definition AMReX_GpuControl.H:148
void htod_memcpy_async(void *p_d, const void *p_h, const std::size_t sz) noexcept
Definition AMReX_GpuDevice.H:440
MPI_Comm CommunicatorSub() noexcept
sub-communicator for current frame
Definition AMReX_ParallelContext.H:70
Definition AMReX_Amr.cpp:50
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:273
void Copy(FabArray< DFAB > &dst, FabArray< SFAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Definition AMReX_FabArray.H:219
void htod_memcpy(FabArray< FAB > &dst, FabArray< FAB > const &src, int scomp, int dcomp, int ncomp)
Copy selected components of each local FAB, ghost cells included, host-to-device.
Definition AMReX_FabArrayUtility.H:1760
void OverrideSync_nowait(FabArray< FAB > &fa, FabArray< IFAB > const &msk, const Periodicity &period)
Start the masked OverrideSync operation; call OverrideSync_finish() to complete it.
Definition AMReX_FabArrayUtility.H:1668
void Add(FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Definition AMReX_FabArray.H:278
@ F
Definition AMReX_Order.H:7
ReduceData< Ts... >::Type ParReduce(TypeList< Ops... > operation_list, TypeList< Ts... > type_list, FabArray< FAB > const &fa, IntVect const &nghost, F &&f)
Parallel reduce for MultiFab/FabArray. The reduce result is local and it's the user's responsibility ...
Definition AMReX_ParReduce.H:48
void Scale(MF &dst, typename MF::value_type val, int scomp, int ncomp, int nghost)
dst *= val
Definition AMReX_FabArrayUtility.H:2188
BoxArray const & boxArray(FabArrayBase const &fa)
Convenience wrapper that forwards to fa.boxArray().
Definition AMReX_FabArrayBase.cpp:3038
DistributionMapping const & DistributionMap(FabArrayBase const &fa)
Convenience wrapper that forwards to fa.DistributionMap().
Definition AMReX_FabArrayBase.cpp:3043
FAB::value_type Dot(FabArray< FAB > const &x, int xcomp, FabArray< FAB > const &y, int ycomp, int ncomp, IntVect const &nghost, bool local=false)
Compute dot products of two FabArrays.
Definition AMReX_FabArrayUtility.H:1906
void Saxpy_Xpay(MF &dst, typename MF::value_type a_saxpy, MF const &src_saxpy, typename MF::value_type a_xpay, MF const &src_xpay, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst += a_saxpy * src_saxpy followed by dst = src_xpay + a_xpay * dst
Definition AMReX_FabArrayUtility.H:2227
void prefetchToDevice(FabArray< FAB > const &fa, const bool synchronous=true)
Request that managed-memory FAB data be prefetched to the device, where supported.
Definition AMReX_FabArrayUtility.H:1634
FAB::value_type ReduceMin(FabArray< FAB > const &fa, int nghost, F &&f)
Compute the rank-local minimum of a functor, including nghost cells.
Definition AMReX_FabArrayUtility.H:399
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:202
FabArray< BaseFab< int > > OverlapMask(FabArray< FAB > const &fa, IntVect const &nghost, Periodicity const &period)
Return the number of overlapping grown FAB regions at each point.
Definition AMReX_FabArrayUtility.H:2436
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
void prefetchToHost(FabArray< FAB > const &fa, const bool synchronous=true)
Request that managed-memory FAB data be prefetched to the host, where supported.
Definition AMReX_FabArrayUtility.H:1612
bool isMFIterSafe(const FabArrayBase &x, const FabArrayBase &y)
Definition AMReX_MFIter.H:256
int nComp(FabArrayBase const &fa)
Convenience wrapper that forwards to fa.nComp().
Definition AMReX_FabArrayBase.cpp:3028
void Saxpy_Saxpy(MF &dst1, typename MF::value_type a1, MF const &src1, MF &dst2, typename MF::value_type a2, MF const &src2, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst1 += a1 * src1 followed by dst2 += a2 * src2
Definition AMReX_FabArrayUtility.H:2236
IntVect indexFromValue(FabArray< FAB > const &mf, int comp, IntVect const &nghost, typename FAB::value_type value)
Return the index of an arbitrary cell at which component comp equals value.
Definition AMReX_FabArrayUtility.H:1793
void LinComb(MF &dst, typename MF::value_type a, MF const &src_a, int acomp, typename MF::value_type b, MF const &src_b, int bcomp, int dcomp, int ncomp, IntVect const &nghost)
dst = a*src_a + b*src_b
Definition AMReX_FabArrayUtility.H:2254
void ParallelCopy(MF &dst, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &ng_src=IntVect(0), IntVect const &ng_dst=IntVect(0), Periodicity const &period=Periodicity::NonPeriodic())
dst = src w/ MPI communication
Definition AMReX_FabArrayUtility.H:2264
void Saypy_Saxpy(MF &dst1, typename MF::value_type a1, MF &dst2, typename MF::value_type a2, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst1 += a1 * dst2 followed by dst2 += a2 * src
Definition AMReX_FabArrayUtility.H:2245
void Multiply(FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Apply dst(dstcomp+n) *= src(srccomp+n) using a uniform ghost width.
Definition AMReX_FabArrayUtility.H:1466
@ y
Definition AMReX_Orientation.H:14
@ x
Definition AMReX_Orientation.H:14
void Abs(FabArray< FAB > &fa, int icomp, int numcomp, int nghost)
Replace selected components by their absolute values using a uniform ghost width.
Definition AMReX_FabArrayUtility.H:1561
void OverrideSync_finish(FabArray< FAB > &fa)
Finish the current masked OverrideSync_nowait() operation.
Definition AMReX_FabArrayUtility.H:1718
void single_task(L &&f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:1245
void dtoh_memcpy(FabArray< FAB > &dst, FabArray< FAB > const &src, int scomp, int dcomp, int ncomp)
Copy selected components of each local FAB, ghost cells included, device-to-host.
Definition AMReX_FabArrayUtility.H:1733
IntVect nGrowVect(FabArrayBase const &fa)
Convenience wrapper that forwards to fa.nGrowVect().
Definition AMReX_FabArrayBase.cpp:3033
void LocalCopy(DMF &dst, SMF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst = src
Definition AMReX_FabArrayUtility.H:2195
bool TilingIfNotGPU() noexcept
Definition AMReX_MFIter.H:12
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
void setBndry(MF &dst, typename MF::value_type val, int scomp, int ncomp)
dst = val in ghost cells.
Definition AMReX_FabArrayUtility.H:2181
void printCell(FabArray< FAB > const &mf, const IntVect &cell, int comp=-1, const IntVect &ng=IntVect::TheZeroVector())
Print the value(s) stored at a specific cell of a FabArray.
Definition AMReX_FabArrayUtility.H:1271
MF::value_type norminf(MF const &mf, int scomp, int ncomp, IntVect const &nghost, bool local=false)
Return the infinity norm, with an MPI maximum unless local is true.
Definition AMReX_FabArrayUtility.H:2275
bool ReduceLogicalOr(FabArray< FAB > const &fa, int nghost, F &&f)
Return the logical OR of predicate results over locally owned data.
Definition AMReX_FabArrayUtility.H:1101
void LoopConcurrentOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition AMReX_Loop.H:388
void Xpay(MF &dst, typename MF::value_type a, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst = src + a * dst
Definition AMReX_FabArrayUtility.H:2219
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:239
const int[]
Definition AMReX_BLProfiler.cpp:1665
void OverrideSync(FabArray< FAB > &fa, FabArray< IFAB > const &msk, const Periodicity &period)
Synchronize shared nodal values using an owner mask.
Definition AMReX_FabArrayUtility.H:1656
void Divide(FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Apply dst(dstcomp+n) /= src(srccomp+n) using a uniform ghost width.
Definition AMReX_FabArrayUtility.H:1514
bool ReduceLogicalAnd(FabArray< FAB > const &fa, int nghost, F &&f)
Return the logical AND of predicate results over locally owned data.
Definition AMReX_FabArrayUtility.H:932
FAB::value_type ReduceMax(FabArray< FAB > const &fa, int nghost, F &&f)
Compute the rank-local maximum of a functor, including nghost cells.
Definition AMReX_FabArrayUtility.H:674
void Subtract(FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Apply dst(dstcomp+n) -= src(srccomp+n) using a uniform ghost width.
Definition AMReX_FabArrayUtility.H:1418
void Saxpy(MF &dst, typename MF::value_type a, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst += a * src
Definition AMReX_FabArrayUtility.H:2211
void LocalAdd(MF &dst, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst += src
Definition AMReX_FabArrayUtility.H:2203
FAB::value_type ReduceSum(FabArray< FAB > const &fa, int nghost, F &&f)
Sum a user-defined quantity over locally owned data, including nghost cells.
Definition AMReX_FabArrayUtility.H:33
void setVal(MF &dst, typename MF::value_type val)
dst = val
Definition AMReX_FabArrayUtility.H:2174
Definition AMReX_TagParallelFor.H:58
Array4< T > dfab
Definition AMReX_TagParallelFor.H:59
FabArray memory allocation information.
Definition AMReX_FabArray.H:73
Definition AMReX_MFIter.H:20
Struct for holding types.
Definition AMReX_TypeList.H:13