3#include <AMReX_Config.H>
38template <
typename T, std::
integral N>
39T
Sum (N n, T
const* v, T init_val = 0);
57template <
typename T, std::
integral N,
typename F>
58requires (!std::same_as<T*,std::decay_t<F>>)
59T
Sum (N n,
F const& f, T init_val = 0);
75template <
typename T, std::
integral N>
76T
Min (N n, T
const* v, T init_val = std::numeric_limits<T>::max());
94template <
typename T, std::
integral N,
typename F>
95requires (!std::same_as<T*,std::decay_t<F>>)
96T
Min (N n,
F const& f, T init_val = std::numeric_limits<T>::max());
112template <
typename T, std::
integral N>
113T
Max (N n, T
const* v, T init_val = std::numeric_limits<T>::lowest());
131template <
typename T, std::
integral N,
typename F>
132requires (!std::same_as<T*,std::decay_t<F>>)
133T
Max (N n,
F const& f, T init_val = std::numeric_limits<T>::lowest());
148template <
typename T, std::
integral N>
149std::pair<T,T>
MinMax (N n, T
const* v);
166template <
typename T, std::
integral N,
typename F>
167requires (!std::same_as<T*,std::decay_t<F>>)
168std::pair<T,T>
MinMax (N n,
F const& f);
185template <
typename T, std::
integral N,
typename P>
186bool AnyOf (N n, T
const* v, P
const& pred);
201template <
typename P,
int dim>
207namespace Reduce::detail {
211 template <std::
size_t I,
typename T,
typename P>
213 void for_each_parallel (T& d, T
const& s,
Gpu::Handler const& h)
215 P().parallel_update(amrex::get<I>(d), amrex::get<I>(s), h);
218 template <std::size_t I,
typename T,
typename P,
typename P1,
typename... Ps>
220 void for_each_parallel (T& d, T
const& s, Gpu::Handler
const& h)
222 P().parallel_update(amrex::get<I>(d), amrex::get<I>(s), h);
223 for_each_parallel<I+1,T,P1,Ps...>(d, s, h);
226 template <std::
size_t I,
typename T,
typename P>
228 void for_each_parallel (T& d, T
const& s)
230 P().parallel_update(amrex::get<I>(d), amrex::get<I>(s));
233 template <std::size_t I,
typename T,
typename P,
typename P1,
typename... Ps>
235 void for_each_parallel (T& d, T
const& s)
237 P().parallel_update(amrex::get<I>(d), amrex::get<I>(s));
238 for_each_parallel<I+1,T,P1,Ps...>(d, s);
243 template <std::
size_t I,
typename T,
typename P>
245 void for_each_local (T& d, T
const& s)
247 P().local_update(amrex::get<I>(d), amrex::get<I>(s));
250 template <std::size_t I,
typename T,
typename P,
typename P1,
typename... Ps>
252 void for_each_local (T& d, T
const& s)
254 P().local_update(amrex::get<I>(d), amrex::get<I>(s));
255 for_each_local<I+1,T,P1,Ps...>(d, s);
258 template <std::
size_t I,
typename T,
typename P>
260 constexpr void for_each_init (T& t)
262 P().init(amrex::get<I>(t));
265 template <std::size_t I,
typename T,
typename P,
typename P1,
typename... Ps>
267 constexpr void for_each_init (T& t)
269 P().init(amrex::get<I>(t));
270 for_each_init<I+1,T,P1,Ps...>(t);
281 template <
typename T>
285 if (h.threadIdx() == 0) { d += r; }
288 template <
typename T,
int MT=AMREX_GPU_MAX_THREADS>
291 T r = Gpu::blockReduceSum<MT>(s);
292 if (threadIdx.x == 0) { d += r; }
297 template <
typename T>
301 template <
typename T>
302 constexpr void init (T& t)
const noexcept { t = 0; }
310 template <
typename T>
314 if (h.threadIdx() == 0) { d =
amrex::min(d,r); }
317 template <
typename T,
int MT=AMREX_GPU_MAX_THREADS>
320 T r = Gpu::blockReduceMin<MT>(s);
321 if (threadIdx.x == 0) { d =
amrex::min(d,r); }
326 template <
typename T>
330 template <
typename T>
331 requires (std::numeric_limits<T>::is_specialized)
332 constexpr void init (T& t)
const noexcept { t = std::numeric_limits<T>::max(); }
334 template <
typename T>
335 requires (!std::numeric_limits<T>::is_specialized)
336 constexpr void init (T& t)
const noexcept { t = T::max(); }
344 template <
typename T>
348 if (h.threadIdx() == 0) { d =
amrex::max(d,r); }
351 template <
typename T,
int MT=AMREX_GPU_MAX_THREADS>
354 T r = Gpu::blockReduceMax<MT>(s);
355 if (threadIdx.x == 0) { d =
amrex::max(d,r); }
360 template <
typename T>
364 template <
typename T>
365 requires (std::numeric_limits<T>::is_specialized)
366 constexpr void init (T& t)
const noexcept { t = std::numeric_limits<T>::lowest(); }
368 template <
typename T>
369 requires (!std::numeric_limits<T>::is_specialized)
370 constexpr void init (T& t)
const noexcept { t = T::lowest(); }
378 template <std::
integral T>
382 if (h.threadIdx() == 0) { d = d && r; }
385 template <std::
integral T,
int MT=AMREX_GPU_MAX_THREADS>
388 T r = Gpu::blockReduceLogicalAnd<MT>(s);
389 if (threadIdx.x == 0) { d = d && r; }
394 template <std::
integral T>
398 template <std::
integral T>
399 constexpr void init (T& t)
const noexcept { t =
true; }
407 template <std::
integral T>
411 if (h.threadIdx() == 0) { d = d || r; }
414 template <std::
integral T,
int MT=AMREX_GPU_MAX_THREADS>
417 T r = Gpu::blockReduceLogicalOr<MT>(s);
418 if (threadIdx.x == 0) { d = d || r; }
423 template <std::
integral T>
427 template <std::
integral T>
428 constexpr void init (T& t)
const noexcept { t =
false; }
431template <
typename... Ps>
class ReduceOps;
436template <
typename... Ts>
442 template <
typename... Ps>
444 : m_max_blocks(
Gpu::
Device::maxBlocksPerLaunch()),
447 * m_max_blocks * sizeof(
Type)))),
448 m_fn_value([&reduce_op,this] () ->
Type { return this->
value(reduce_op); })
450 reduce_op.resetResultReadiness();
451 static_assert(std::is_trivially_copyable<Type>(),
452 "ReduceData::Type must be trivially copyable");
453 static_assert(std::is_trivially_destructible<Type>(),
454 "ReduceData::Type must be trivially destructible");
456 new (m_host_tuple) Type();
462 !m_used_external_stream || m_value_called,
463 "ReduceData used on an external GPU stream must call value() before destruction.");
475 Type r = m_fn_value();
476 m_value_called =
true;
480 template <
typename... Ps>
484 m_value_called =
true;
490 return m_device_tuple+streamIndexChecked(s)*m_max_blocks;
502 m_max_stream_index = std::max(m_max_stream_index,streamIndexChecked(s));
513 if (m_stream_index_zero_set) {
515 "ReduceData cannot be reused across different external GPU streams "
516 "or between an external GPU stream and AMReX stream 0.");
518 m_stream_index_zero = s;
519 m_stream_index_zero_set =
true;
526 int m_max_stream_index = 0;
527 Type* m_host_tuple =
nullptr;
528 Type* m_device_tuple =
nullptr;
529 GpuArray<int,AMREX_GPU_MAX_STREAMS> m_nblocks;
531 bool m_stream_index_zero_set =
false;
532 bool m_used_external_stream =
false;
533 bool m_value_called =
false;
534 std::function<Type()> m_fn_value;
538namespace Reduce::detail {
542 template <
typename F,
int dim>
544 auto call_f_intvect_box (F
const& f, IntVectND<dim> iv, IndexTypeND<dim>)
noexcept ->
545 decltype(amrex::detail::call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv))
547 return amrex::detail::call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv);
550 template <
typename F,
int dim>
552 auto call_f_intvect_box (F
const& f, IntVectND<dim> iv, IndexTypeND<dim> t)
noexcept ->
553 decltype(f(BoxND<dim>(iv, iv, t)))
555 return f(BoxND<dim>(iv, iv, t));
559 template <
typename F,
typename T,
int dim>
561 auto call_f_intvect_n (F
const& f, IntVectND<dim> iv, T n)
noexcept ->
562 decltype(amrex::detail::call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, n))
564 return amrex::detail::call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, n);
569 struct iterate_box {};
570 struct iterate_box_comp {};
572 template <
typename I,
typename F,
typename T,
typename... Ps>
573 requires (std::same_as<iterate_box,I>)
575 void mf_call_f (F
const& f,
int ibox,
int i,
int j,
int k,
int, T& r)
noexcept
577 auto const& pr = f(ibox,i,j,k);
578 Reduce::detail::for_each_local<0, T, Ps...>(r, pr);
581 template <
typename I,
typename F,
typename T,
typename... Ps>
582 requires (std::same_as<iterate_box_comp,I>)
584 void mf_call_f (F
const& f,
int ibox,
int i,
int j,
int k,
int ncomp, T& r)
noexcept
586 for (
int n = 0; n < ncomp; ++n) {
587 auto const& pr = f(ibox,i,j,k,n);
588 Reduce::detail::for_each_local<0, T, Ps...>(r, pr);
595template <
typename... Ps>
603 template <
typename I,
typename MF,
typename D,
typename F>
604 void eval_mf (I, MF
const& mf,
IntVect const& nghost,
int ncomp, D& reduce_data,
F const& f)
606 using ReduceTuple =
typename D::Type;
607 const int nboxes = mf.local_size();
609 auto const& parforinfo = mf.getParForInfo(nghost);
610 auto nblocks_per_box = parforinfo.getNBlocksPerBox(AMREX_GPU_MAX_THREADS);
612 const int nblocks = nblocks_per_box * nboxes;
613 const BoxIndexer* dp_boxes = parforinfo.getBoxes();
615 auto const& stream = Gpu::gpuStream();
616 auto pdst = reduce_data.devicePtr(stream);
617 int nblocks_ec = std::min(nblocks, reduce_data.maxBlocks());
619 int& nblocks_ref = reduce_data.nBlocks(stream);
620 auto old_nblocks =
static_cast<unsigned int>(nblocks_ref);
621 nblocks_ref =
amrex::max(nblocks_ref, nblocks_ec);
622 reduce_data.updateMaxStreamIndex(stream);
626 constexpr std::size_t shared_mem_bytes =
sizeof(ReduceTuple)
627 * std::max(Gpu::Device::warp_size, AMREX_GPU_MAX_THREADS/Gpu::Device::warp_size);
628 amrex::launch<AMREX_GPU_MAX_THREADS>(nblocks_ec, shared_mem_bytes, stream,
631 Dim1 blockIdx {gh.blockIdx()};
632 Dim1 threadIdx{gh.threadIdx()};
634 amrex::launch_global<AMREX_GPU_MAX_THREADS>
635 <<<nblocks_ec, AMREX_GPU_MAX_THREADS, 0, stream>>>
640 Reduce::detail::for_each_init<0, ReduceTuple, Ps...>(r);
641 ReduceTuple& dst =
pdst[blockIdx.x];
642 if (threadIdx.x == 0 && blockIdx.x >= old_nblocks) {
645 for (
int iblock = blockIdx.x; iblock < nblocks; iblock += nblocks_ec) {
646 int ibox = iblock / nblocks_per_box;
647 auto icell = std::uint64_t(iblock-ibox*nblocks_per_box)*AMREX_GPU_MAX_THREADS + threadIdx.x;
650 if (icell < indexer.
numPts()) {
651 auto [i, j, k] = indexer(icell);
652 Reduce::detail::mf_call_f<I,
F, ReduceTuple, Ps...>
653 (f, ibox, i, j, k, ncomp, r);
657 Reduce::detail::for_each_parallel<0, ReduceTuple, Ps...>(dst, r, gh);
659 Reduce::detail::for_each_parallel<0, ReduceTuple, Ps...>(dst, r);
666 template <
typename I,
int dim,
typename D,
typename F>
667 void eval_box (I,
BoxND<dim> const& box,
int ncomp, D& reduce_data,
F const& f)
670 using ReduceTuple =
typename D::Type;
671 auto const& stream = Gpu::gpuStream();
672 auto dp = reduce_data.devicePtr(stream);
673 int& nblocks = reduce_data.nBlocks(stream);
676 constexpr int nitems_per_thread = 4;
677 Long nblocks_ec = (box.
numPts() + nitems_per_thread*AMREX_GPU_MAX_THREADS-1)
678 / (nitems_per_thread*AMREX_GPU_MAX_THREADS);
679 nblocks_ec = std::min<Long>(nblocks_ec, reduce_data.maxBlocks());
680 reduce_data.updateMaxStreamIndex(stream);
683 constexpr std::size_t shared_mem_bytes =
sizeof(ReduceTuple)
684 * std::max(Gpu::Device::warp_size, AMREX_GPU_MAX_THREADS/Gpu::Device::warp_size);
685 amrex::launch<AMREX_GPU_MAX_THREADS>(nblocks_ec, shared_mem_bytes, stream,
688 Dim1 blockIdx {gh.blockIdx()};
689 Dim1 threadIdx{gh.threadIdx()};
690 Dim1 gridDim {gh.gridDim()};
692 amrex::launch<AMREX_GPU_MAX_THREADS>(nblocks_ec, 0, stream,
697 Reduce::detail::for_each_init<0, ReduceTuple, Ps...>(r);
698 ReduceTuple& dst = *(dp+blockIdx.x);
699 if (threadIdx.x == 0 &&
static_cast<int>(blockIdx.x) >= nblocks) {
702 for (std::uint64_t icell = std::uint64_t(AMREX_GPU_MAX_THREADS)*blockIdx.x+threadIdx.x,
703 stride = std::uint64_t(AMREX_GPU_MAX_THREADS)*gridDim.x;
707 auto iv = indexer.
intVect(icell);
709 if constexpr (std::is_same_v<Reduce::detail::iterate_box,I>) {
710 auto pr = Reduce::detail::call_f_intvect_box(f, iv, ixtype);
711 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(r, pr);
713 for (
int n = 0; n < ncomp; ++n) {
714 auto pr = Reduce::detail::call_f_intvect_n(f, iv, n);
715 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(r, pr);
720 Reduce::detail::for_each_parallel<0, ReduceTuple, Ps...>(dst, r, gh);
722 Reduce::detail::for_each_parallel<0, ReduceTuple, Ps...>(dst, r);
725 nblocks = std::max(nblocks,
static_cast<int>(nblocks_ec));
730 template <FabArrayType MF,
typename D,
typename F>
731#ifndef AMREX_USE_CUDA
734 void eval (MF
const& mf,
IntVect const& nghost, D& reduce_data, F&& f)
736 using ReduceTuple =
typename D::Type;
737 const int nboxes = mf.local_size();
740 }
else if (!mf.isFusingCandidate()) {
743 const int li = mfi.LocalIndex();
744 this->eval(b, reduce_data,
747 return f(li, i, j, k);
751 eval_mf(Reduce::detail::iterate_box{},
752 mf, nghost, 0, reduce_data, std::forward<F>(f));
756 template <FabArrayType MF,
typename D,
typename F>
757#ifndef AMREX_USE_CUDA
760 void eval (MF
const& mf,
IntVect const& nghost,
int ncomp, D& reduce_data, F&& f)
762 using ReduceTuple =
typename D::Type;
764 const int nboxes = mf.local_size();
768 }
else if (!mf.isFusingCandidate()) {
771 const int li = mfi.LocalIndex();
772 this->eval(b, ncomp, reduce_data,
775 return f(li, i, j, k, n);
779 eval_mf(Reduce::detail::iterate_box_comp{},
780 mf, nghost, ncomp, reduce_data, std::forward<F>(f));
784 template <
typename D,
typename F,
int dim>
787 eval_box(Reduce::detail::iterate_box{}, box, 0, reduce_data, f);
790 template <std::
integral N,
typename D,
typename F,
int dim>
793 eval_box(Reduce::detail::iterate_box_comp{}, box, ncomp, reduce_data, f);
796 template <std::
integral N,
typename D,
typename F>
797 void eval (N n, D & reduce_data, F
const& f)
799 if (n <= 0) {
return; }
800 using ReduceTuple =
typename D::Type;
801 auto const& stream = Gpu::gpuStream();
802 auto dp = reduce_data.devicePtr(stream);
803 int& nblocks = reduce_data.nBlocks(stream);
804 constexpr int nitems_per_thread = 4;
805 int nblocks_ec = (n + nitems_per_thread*AMREX_GPU_MAX_THREADS-1)
806 / (nitems_per_thread*AMREX_GPU_MAX_THREADS);
807 nblocks_ec = std::min(nblocks_ec, reduce_data.maxBlocks());
808 reduce_data.updateMaxStreamIndex(stream);
811 constexpr std::size_t shared_mem_bytes =
sizeof(ReduceTuple)
812 * std::max(Gpu::Device::warp_size, AMREX_GPU_MAX_THREADS/Gpu::Device::warp_size);
813 amrex::launch<AMREX_GPU_MAX_THREADS>(nblocks_ec, shared_mem_bytes, stream,
816 Dim1 blockIdx {gh.blockIdx()};
817 Dim1 threadIdx{gh.threadIdx()};
818 Dim1 gridDim {gh.gridDim()};
820 amrex::launch<AMREX_GPU_MAX_THREADS>(nblocks_ec, 0, stream,
825 Reduce::detail::for_each_init<0, ReduceTuple, Ps...>(r);
826 ReduceTuple& dst = *(dp+blockIdx.x);
827 if (threadIdx.x == 0 &&
static_cast<int>(blockIdx.x) >= nblocks) {
830 for (N i = N(AMREX_GPU_MAX_THREADS)*blockIdx.x+threadIdx.x,
831 stride = N(AMREX_GPU_MAX_THREADS)*gridDim.x;
836 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(r,pr);
839 Reduce::detail::for_each_parallel<0, ReduceTuple, Ps...>(dst, r, gh);
841 Reduce::detail::for_each_parallel<0, ReduceTuple, Ps...>(dst, r);
847 template <
typename D>
848 typename D::Type
value (D & reduce_data)
850 auto hp = reduce_data.hostPtr();
852 if (m_result_is_ready) {
853 reduce_data.markValueCalled();
857 using ReduceTuple =
typename D::Type;
858 auto const& stream = Gpu::gpuStream();
859 auto dp = reduce_data.devicePtr();
860 auto const& nblocks = reduce_data.nBlocks();
861#if defined(AMREX_USE_SYCL)
862 if (reduce_data.maxStreamIndex() == 0 && nblocks[0] <= 4096) {
863 const int N = nblocks[0];
865 Reduce::detail::for_each_init<0, ReduceTuple, Ps...>(*hp);
868 Gpu::dtoh_memcpy_async(tmp.
data(), dp,
sizeof(ReduceTuple)*N);
869 Gpu::streamSynchronize();
870 for (
int i = 1; i < N; ++i) {
871 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(tmp[0], tmp[i]);
878 int maxblocks = reduce_data.maxBlocks();
881 constexpr std::size_t shared_mem_bytes =
sizeof(ReduceTuple)
882 * std::max(Gpu::Device::warp_size, AMREX_GPU_MAX_THREADS/Gpu::Device::warp_size);
883#ifndef AMREX_NO_SYCL_REDUCE_WORKAROUND
886 auto presult = dtmp.
data();
890 amrex::launch<AMREX_GPU_MAX_THREADS>(1, shared_mem_bytes, stream,
894 Reduce::detail::for_each_init<0, ReduceTuple, Ps...>(r);
896 for (
int istream = 0, nstreams = nblocks.size(); istream < nstreams; ++istream) {
897 auto dp_stream = dp+istream*maxblocks;
898 for (
int i = gh.item->get_global_id(0), stride = gh.item->get_global_range(0);
899 i < nblocks[istream]; i += stride) {
900 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(r, dp_stream[i]);
903 Reduce::detail::for_each_parallel<0, ReduceTuple, Ps...>(dst, r, gh);
904 if (gh.threadIdx() == 0) { *presult = dst; }
906#ifndef AMREX_NO_SYCL_REDUCE_WORKAROUND
907 Gpu::dtoh_memcpy_async(hp, dtmp.
data(),
sizeof(ReduceTuple));
910 amrex::launch<AMREX_GPU_MAX_THREADS>(1, 0, stream,
914 Reduce::detail::for_each_init<0, ReduceTuple, Ps...>(r);
916 for (
int istream = 0, nstreams = nblocks.size(); istream < nstreams; ++istream) {
917 auto dp_stream = dp+istream*maxblocks;
918 for (
int i = AMREX_GPU_MAX_THREADS*blockIdx.x+threadIdx.x, stride = AMREX_GPU_MAX_THREADS*gridDim.x;
919 i < nblocks[istream]; i += stride) {
920 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(r, dp_stream[i]);
923 Reduce::detail::for_each_parallel<0, ReduceTuple, Ps...>(dst, r);
924 if (threadIdx.x == 0) { *hp = dst; }
927 Gpu::streamSynchronize();
930 m_result_is_ready =
true;
931 reduce_data.markValueCalled();
937 bool m_result_is_ready =
false;
938 void resetResultReadiness () { m_result_is_ready =
false; }
943template <
typename T, std::
integral N>
944T Sum (N n, T
const* v, T init_val)
948 using ReduceTuple =
typename decltype(reduce_data)::Type;
950 ReduceTuple hv = reduce_data.
value(reduce_op);
951 return amrex::get<0>(hv) + init_val;
954template <
typename T, std::
integral N,
typename F>
955requires (!std::same_as<T*,std::decay_t<F>>)
956T Sum (N n, F
const& f, T init_val)
960 using ReduceTuple =
typename decltype(reduce_data)::Type;
962 ReduceTuple hv = reduce_data.
value(reduce_op);
963 return amrex::get<0>(hv) + init_val;
966template <
typename T, std::
integral N>
967T Min (N n, T
const* v, T init_val)
971 using ReduceTuple =
typename decltype(reduce_data)::Type;
973 ReduceTuple hv = reduce_data.
value(reduce_op);
974 return std::min(amrex::get<0>(hv),init_val);
977template <
typename T, std::
integral N,
typename F>
978requires (!std::same_as<T*,std::decay_t<F>>)
979T Min (N n, F
const& f, T init_val)
983 using ReduceTuple =
typename decltype(reduce_data)::Type;
985 ReduceTuple hv = reduce_data.
value(reduce_op);
986 return std::min(amrex::get<0>(hv),init_val);
989template <
typename T, std::
integral N>
990T Max (N n, T
const* v, T init_val)
994 using ReduceTuple =
typename decltype(reduce_data)::Type;
996 ReduceTuple hv = reduce_data.
value(reduce_op);
997 return std::max(amrex::get<0>(hv),init_val);
1000template <
typename T, std::
integral N,
typename F>
1001requires (!std::same_as<T*,std::decay_t<F>>)
1002T Max (N n, F
const& f, T init_val)
1006 using ReduceTuple =
typename decltype(reduce_data)::Type;
1008 ReduceTuple hv = reduce_data.
value(reduce_op);
1009 return std::max(amrex::get<0>(hv),init_val);
1012template <
typename T, std::
integral N>
1017 using ReduceTuple =
typename decltype(reduce_data)::Type;
1021 auto hv = reduce_data.
value(reduce_op);
1022 return std::make_pair(amrex::get<0>(hv), amrex::get<1>(hv));
1025template <
typename T, std::
integral N,
typename F>
1026requires (!std::same_as<T*,std::decay_t<F>>)
1027std::pair<T,T> MinMax (N n, F
const& f)
1031 using ReduceTuple =
typename decltype(reduce_data)::Type;
1036 auto hv = reduce_data.
value(reduce_op);
1037 return std::make_pair(amrex::get<0>(hv), amrex::get<1>(hv));
1040template <
typename T, std::
integral N,
typename P>
1041bool AnyOf (N n, T
const* v, P
const& pred)
1047 ec.numBlocks.x = std::min(ec.numBlocks.x, Gpu::Device::maxBlocksPerLaunch());
1049#ifdef AMREX_USE_SYCL
1050 const int num_ints = std::max(Gpu::Device::warp_size,
int(ec.numThreads.x)/Gpu::Device::warp_size) + 1;
1051 const std::size_t shared_mem_bytes = num_ints*
sizeof(
int);
1052 amrex::launch<AMREX_GPU_MAX_THREADS>(ec.numBlocks.x, shared_mem_bytes, Gpu::gpuStream(),
1054 int* has_any = &(
static_cast<int*
>(gh.sharedMemory())[num_ints-1]);
1055 if (gh.threadIdx() == 0) { *has_any = *dp; }
1061 for (N i = AMREX_GPU_MAX_THREADS*gh.blockIdx()+gh.threadIdx(), stride = AMREX_GPU_MAX_THREADS*gh.gridDim();
1062 i < n && !r; i += stride)
1064 r = pred(v[i]) ? 1 : 0;
1067 r = Gpu::blockReduce<Gpu::Device::warp_size>
1069 if (gh.threadIdx() == 0 && r) { *dp = 1; }
1073 amrex::launch<AMREX_GPU_MAX_THREADS>(ec.numBlocks.x, 0, Gpu::gpuStream(),
1075 __shared__
int has_any;
1076 if (threadIdx.x == 0) { has_any = *dp; }
1082 for (N i = AMREX_GPU_MAX_THREADS*blockIdx.x+threadIdx.x, stride = AMREX_GPU_MAX_THREADS*gridDim.x;
1083 i < n && !r; i += stride)
1085 r = pred(v[i]) ? 1 : 0;
1087 r = Gpu::blockReduce<Gpu::Device::warp_size>
1089 if (threadIdx.x == 0 && r) *dp = 1;
1096template <
typename P,
int dim>
1104 ec.numBlocks.x = std::min(ec.numBlocks.x, Gpu::Device::maxBlocksPerLaunch());
1106#ifdef AMREX_USE_SYCL
1107 const int num_ints = std::max(Gpu::Device::warp_size,
int(ec.numThreads.x)/Gpu::Device::warp_size) + 1;
1108 const std::size_t shared_mem_bytes = num_ints*
sizeof(
int);
1109 amrex::launch<AMREX_GPU_MAX_THREADS>(ec.numBlocks.x, shared_mem_bytes, Gpu::gpuStream(),
1111 int* has_any = &(
static_cast<int*
>(gh.sharedMemory())[num_ints-1]);
1112 if (gh.threadIdx() == 0) { *has_any = *dp; }
1118 for (std::uint64_t icell = std::uint64_t(AMREX_GPU_MAX_THREADS)*gh.blockIdx()+gh.threadIdx(),
1119 stride = std::uint64_t(AMREX_GPU_MAX_THREADS)*gh.gridDim();
1120 icell < indexer.
numPts() && !r;
1123 auto iv = indexer.
intVect(icell);
1124 r = amrex::detail::call_f_intvect(pred, iv) ? 1 : 0;
1126 r = Gpu::blockReduce<Gpu::Device::warp_size>
1128 if (gh.threadIdx() == 0 && r) { *dp = 1; }
1135 __shared__
int has_any;
1136 if (threadIdx.x == 0) { has_any = *dp; }
1142 for (std::uint64_t icell = std::uint64_t(AMREX_GPU_MAX_THREADS)*blockIdx.x+threadIdx.x,
1143 stride = std::uint64_t(AMREX_GPU_MAX_THREADS)*gridDim.x;
1144 icell < indexer.
numPts() && !r;
1147 auto iv = indexer.
intVect(icell);
1148 r = amrex::detail::call_f_intvect(pred, iv) ? 1 : 0;
1150 r = Gpu::blockReduce<Gpu::Device::warp_size>
1152 if (threadIdx.x == 0 && r) *dp = 1;
1163template <
typename... Ts>
1167 using Type = GpuTuple<Ts...>;
1169 template <
typename... Ps>
1170 explicit ReduceData (ReduceOps<Ps...>& reduce_op)
1171 : m_tuple(OpenMP::in_parallel() ? 1 : OpenMP::get_max_threads()),
1172 m_fn_value([&reduce_op,this] () -> Type { return this->value(reduce_op); })
1174 reduce_op.resetResultReadiness();
1175 for (
auto& t : m_tuple) {
1176 Reduce::detail::for_each_init<0, Type, Ps...>(t);
1180 ~ReduceData () =
default;
1181 ReduceData (ReduceData<Ts...>
const&) =
delete;
1182 ReduceData (ReduceData<Ts...> &&) =
delete;
1183 void operator= (ReduceData<Ts...>
const&) =
delete;
1184 void operator= (ReduceData<Ts...> &&) =
delete;
1186 Type value () {
return m_fn_value(); }
1188 template <
typename... Ps>
1189 Type value (ReduceOps<Ps...>& reduce_op)
1191 return reduce_op.value(*
this);
1194 Vector<Type>& reference () {
return m_tuple; }
1196 Type& reference (
int tid)
1198 if (m_tuple.size() == 1) {
1202 return m_tuple[tid];
1207 Vector<Type> m_tuple;
1208 std::function<Type()> m_fn_value;
1211namespace Reduce::detail {
1215 template <
typename F,
int dim>
1217 auto call_f_intvect (F
const& f, IntVectND<dim> iv)
noexcept ->
1218 decltype(amrex::detail::call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv))
1220 return amrex::detail::call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv);
1225 template <
typename F,
typename T,
int dim>
1227 auto call_f_intvect_n (F
const& f, IntVectND<dim> iv, T n)
noexcept ->
1228 decltype(amrex::detail::call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, n))
1230 return amrex::detail::call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, n);
1234template <
typename... Ps>
1241 template <
typename D,
typename F,
int dim>
1242 requires (std::same_as<std::decay_t<
decltype(
1243 Reduce::detail::call_f_intvect(std::declval<F const&>(), IntVectND<dim>()))>,
1246 static void call_f_box (BoxND<dim>
const& box,
typename D::Type & r, F
const& f)
noexcept
1248 using ReduceTuple =
typename D::Type;
1250 [&] (IntVectND<dim> iv) {
1251 auto pr = Reduce::detail::call_f_intvect(f, iv);
1252 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(r, pr);
1256 template <
typename D,
typename F,
int dim>
1257 requires (std::same_as<std::decay_t<
decltype(
1258 std::declval<F const&>()(std::declval<BoxND<dim>
const&>()))>,
1261 static void call_f_box (BoxND<dim>
const& box,
typename D::Type & r, F
const& f)
noexcept
1263 using ReduceTuple =
typename D::Type;
1264 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(r, f(box));
1269 template <FabArrayType MF,
typename D,
typename F>
1270 requires (IsCallable<F, int, int, int, int>::value)
1271 void eval (MF
const& mf, IntVect
const& nghost, D & reduce_data, F
const& f)
1273 using ReduceTuple =
typename D::Type;
1279 Reduce::detail::for_each_init<0, ReduceTuple, Ps...>(rr);
1280 for (MFIter mfi(mf,
true); mfi.isValid(); ++mfi) {
1281 Box const& b = mfi.growntilebox(nghost);
1282 const int li = mfi.LocalIndex();
1285 for (
int k = lo.z; k <= hi.z; ++k) {
1286 for (
int j = lo.y; j <= hi.y; ++j) {
1287 for (
int i = lo.x; i <= hi.x; ++i) {
1288 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(rr, f(li,i,j,k));
1291 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(
1292 reduce_data.reference(OpenMP::get_thread_num()), rr);
1296 template <FabArrayType MF,
typename D,
typename F>
1297 requires (IsCallable<F, int, int, int, int, int>::value)
1298 void eval (MF
const& mf, IntVect
const& nghost,
int ncomp, D & reduce_data, F
const& f)
1300 using ReduceTuple =
typename D::Type;
1306 Reduce::detail::for_each_init<0, ReduceTuple, Ps...>(rr);
1307 for (MFIter mfi(mf,
true); mfi.isValid(); ++mfi) {
1308 Box const& b = mfi.growntilebox(nghost);
1309 const int li = mfi.LocalIndex();
1312 for (
int n = 0; n < ncomp; ++n) {
1313 for (
int k = lo.z; k <= hi.z; ++k) {
1314 for (
int j = lo.y; j <= hi.y; ++j) {
1315 for (
int i = lo.x; i <= hi.x; ++i) {
1316 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(rr, f(li,i,j,k,n));
1319 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(
1320 reduce_data.reference(OpenMP::get_thread_num()), rr);
1324 template <
typename D,
typename F,
int dim>
1325 void eval (BoxND<dim>
const& box, D & reduce_data, F&& f)
1327 using ReduceTuple =
typename D::Type;
1329 Reduce::detail::for_each_init<0, ReduceTuple, Ps...>(rr);
1330 call_f_box<D>(box, rr, std::forward<F>(f));
1331 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(
1332 reduce_data.reference(OpenMP::get_thread_num()), rr);
1335 template <std::
integral N,
typename D,
typename F,
int dim>
1336 void eval (BoxND<dim>
const& box, N ncomp, D & reduce_data, F
const& f)
1338 using ReduceTuple =
typename D::Type;
1340 Reduce::detail::for_each_init<0, ReduceTuple, Ps...>(rr);
1342 [&] (IntVectND<dim> iv,
int n) {
1343 auto pr = Reduce::detail::call_f_intvect_n(f, iv, n);
1344 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(rr, pr);
1346 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(
1347 reduce_data.reference(OpenMP::get_thread_num()), rr);
1350 template <std::
integral N,
typename D,
typename F>
1351 void eval (N n, D & reduce_data, F
const& f)
1353 using ReduceTuple =
typename D::Type;
1355 Reduce::detail::for_each_init<0, ReduceTuple, Ps...>(rr);
1356 for (N i = 0; i < n; ++i) {
1357 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(rr, f(i));
1359 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(
1360 reduce_data.reference(OpenMP::get_thread_num()), rr);
1363 template <
typename D>
1364 typename D::Type value (D & reduce_data)
1366 auto& rrv = reduce_data.reference();
1367 if (! m_result_is_ready) {
1368 using ReduceTuple =
typename D::Type;
1369 if (rrv.size() > 1) {
1370 for (
int i = 1, N = rrv.size(); i < N; ++i) {
1371 Reduce::detail::for_each_local<0, ReduceTuple, Ps...>(rrv[0], rrv[i]);
1374 m_result_is_ready =
true;
1380 template <
typename... T>
friend class ReduceData;
1381 bool m_result_is_ready =
false;
1382 void resetResultReadiness () { m_result_is_ready =
false; }
1387template <
typename T, std::
integral N,
typename F>
1388requires (!std::same_as<T*,std::decay_t<F>>)
1389T Sum (N n, F
const& f, T init_val)
1393#pragma omp parallel for reduction(+:r)
1395 for (N i = 0; i < n; ++i) {
1401template <
typename T, std::
integral N>
1402T
Sum (N n, T
const* v, T init_val)
1404 return Sum(n, [=] (N i) -> T {
return v[i]; }, init_val);
1407template <
typename T, std::
integral N,
typename F>
1408requires (!std::same_as<T*,std::decay_t<F>>)
1409T Min (N n, F
const& f, T init_val)
1413#pragma omp parallel for reduction(min:r)
1415 for (N i = 0; i < n; ++i) {
1416 r = std::min(r,f(i));
1421template <
typename T, std::
integral N>
1422T
Min (N n, T
const* v, T init_val)
1424 return Reduce::Min(n, [=] (N i) -> T {
return v[i]; }, init_val);
1427template <
typename T, std::
integral N,
typename F>
1428requires (!std::same_as<T*,std::decay_t<F>>)
1429T Max (N n, F
const& f, T init_val)
1433#pragma omp parallel for reduction(max:r)
1435 for (N i = 0; i < n; ++i) {
1436 r = std::max(r,f(i));
1441template <
typename T, std::
integral N>
1442T
Max (N n, T
const* v, T init_val)
1444 return Reduce::Max(n, [=] (N i) -> T {
return v[i]; }, init_val);
1447template <
typename T, std::
integral N,
typename F>
1448requires (!std::same_as<T*,std::decay_t<F>>)
1449std::pair<T,T> MinMax (N n, F
const& f)
1451 T r_min = std::numeric_limits<T>::max();
1452 T r_max = std::numeric_limits<T>::lowest();
1454#pragma omp parallel for reduction(min:r_min) reduction(max:r_max)
1456 for (N i = 0; i < n; ++i) {
1458 r_min = std::min(r_min,tmp);
1459 r_max = std::max(r_max,tmp);
1461 return std::make_pair(r_min,r_max);
1464template <
typename T, std::
integral N>
1465std::pair<T,T>
MinMax (N n, T
const* v)
1467 return Reduce::MinMax<T>(n, [=] (N i) -> T {
return v[i]; });
1470template <
typename T, std::
integral N,
typename P>
1471bool AnyOf (N n, T
const* v, P
const& pred)
1473 return std::any_of(v, v+n, pred);
1476template <
typename P,
int dim>
1477bool AnyOf (BoxND<dim>
const& box, P
const& pred)
1479 for (
auto iv : box.iterator()) {
1480 if (Reduce::detail::call_f_intvect(pred, iv)) {
return true; }
1493template <
typename... Ts,
typename... Ps>
1495constexpr GpuTuple<Ts...>
1499 Reduce::detail::for_each_init<0,
decltype(r), Ps...>(r);
1507template <
typename... Ts,
typename... Ps>
1509constexpr GpuTuple<Ts...>
1513 Reduce::detail::for_each_init<0,
decltype(r), Ps...>(r);
1518template <
typename Ops,
typename Ts>
1521template <
typename... Ops,
typename... Ts>
1522class ReducerImpl<TypeList<Ops...>, TypeList<Ts...>>
1525 static_assert(
sizeof...(Ops) > 0);
1526 static_assert(
sizeof...(Ts) > 0);
1527 static_assert(
sizeof...(Ops) ==
sizeof...(Ts));
1530 : m_reduce_data(m_reduce_op)
1534 using Result_t = GpuTuple<Ts...>;
1535 ReduceOps<Ops...> m_reduce_op;
1536 ReduceData<Ts...> m_reduce_data;
1604template <
typename Ops,
typename Ts>
1606 :
public ReducerImpl<ToTypeList_t<Ops>, ToTypeList_t<Ts>>
1620 void operator= (
Reducer const&) =
delete;
1621 void operator= (
Reducer &&) =
delete;
1637 template <
typename F,
int dim>
1642 this->m_reduce_op.
eval(box, this->m_reduce_data, std::forward<F>(f));
1660 template <
typename F,
int dim>
1665 this->m_reduce_op.eval(box, ncomp, this->m_reduce_data, std::forward<F>(f));
1687 template <FabArrayType MF,
typename F>
1689 void eval (MF
const& mf,
IntVect const& nghost, F && f)
1691 this->m_reduce_op.eval(mf, nghost, this->m_reduce_data, std::forward<F>(f));
1716 template <FabArrayType MF,
typename F>
1718 void eval (MF
const& mf,
IntVect const& nghost,
int ncomp, F && f)
1720 this->m_reduce_op.eval(mf, nghost, ncomp, this->m_reduce_data, std::forward<F>(f));
1735 template <
typename N,
typename F>
1737 void eval (N n, F && f)
1739 this->m_reduce_op.eval(n, this->m_reduce_data, std::forward<F>(f));
1754 return this->m_reduce_data.value(this->m_reduce_op);
Memory arena base class and global arena accessors.
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:49
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:124
#define AMREX_GPU_MAX_STREAMS
Definition AMReX_GpuDevice.H:21
#define AMREX_LAUNCH_KERNEL(MT, blocks, threads, sharedMem, stream,...)
Definition AMReX_GpuLaunch.H:37
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
Convenience header for the core AMReX GPU facilities.
Real * pdst
Definition AMReX_HypreMLABecLap.cpp:1132
virtual void free(void *pt)=0
Free a previously allocated block pointed to by pt.
A Rectangular Domain on an Integer Lattice.
Definition AMReX_Box.H:54
__host__ __device__ bool isEmpty() const noexcept
Checks if it is an empty BoxND.
Definition AMReX_Box.H:223
__host__ __device__ Long numPts() const noexcept
Return the number of points contained in the BoxND.
Definition AMReX_Box.H:385
__host__ __device__ IndexTypeND< dim > ixType() const noexcept
Return the indexing type.
Definition AMReX_Box.H:148
GPU-compatible tuple.
Definition AMReX_Tuple.H:104
static int streamIndex(gpuStream_t s=gpuStream()) noexcept
Definition AMReX_GpuDevice.cpp:715
static bool usingExternalStream() noexcept
Definition AMReX_GpuDevice.cpp:842
Cell-Based or Node-Based Indices.
Definition AMReX_IndexType.H:36
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
Dynamically allocated vector for trivially copyable data.
Definition AMReX_PODVector.H:308
T * data() noexcept
Definition AMReX_PODVector.H:672
Definition AMReX_Reduce.H:438
~ReduceData()
Definition AMReX_Reduce.H:460
int maxStreamIndex() const
Definition AMReX_Reduce.H:500
Type value()
Definition AMReX_Reduce.H:473
void updateMaxStreamIndex(gpuStream_t const &s)
Definition AMReX_Reduce.H:501
int & nBlocks(gpuStream_t const &s)
Definition AMReX_Reduce.H:496
ReduceData(ReduceOps< Ps... > &reduce_op)
Definition AMReX_Reduce.H:443
void markValueCalled() noexcept
Definition AMReX_Reduce.H:505
Type * devicePtr(gpuStream_t const &s)
Definition AMReX_Reduce.H:489
Type value(ReduceOps< Ps... > &reduce_op)
Definition AMReX_Reduce.H:481
Type * devicePtr()
Definition AMReX_Reduce.H:488
GpuArray< int, 8 > & nBlocks()
Definition AMReX_Reduce.H:495
ReduceData(ReduceData< Ts... > const &)=delete
Type * hostPtr()
Definition AMReX_Reduce.H:493
int maxBlocks() const
Definition AMReX_Reduce.H:498
ReduceData(ReduceData< Ts... > &&)=delete
Definition AMReX_Reduce.H:597
void eval(BoxND< dim > const &box, N ncomp, D &reduce_data, F const &f)
Definition AMReX_Reduce.H:791
D::Type value(D &reduce_data)
Definition AMReX_Reduce.H:848
void eval(BoxND< dim > const &box, D &reduce_data, F const &f)
Definition AMReX_Reduce.H:785
void eval(MF const &mf, IntVect const &nghost, D &reduce_data, F &&f)
Definition AMReX_Reduce.H:734
void eval(N n, D &reduce_data, F const &f)
Definition AMReX_Reduce.H:797
Class for local reductions (e.g., sum, min and max).
Definition AMReX_Reduce.H:1607
Result_t getResult()
Get the final reduction result.
Definition AMReX_Reduce.H:1752
typename Base::Result_t Result_t
Reduction result type, GpuTuple<U...>, where U... are the types in Ts.
Definition AMReX_Reduce.H:1611
void eval(BoxND< dim > const &box, F &&f)
Reduction over a Box.
Definition AMReX_Reduce.H:1640
amrex_long Long
Definition AMReX_INT.H:30
T Min(N n, T const *v, T init_val=std::numeric_limits< T >::max())
Compute the minimum of an array of values.
Definition AMReX_Reduce.H:967
bool AnyOf(N n, T const *v, P const &pred)
Test whether any element in an array satisfies a unary predicate.
Definition AMReX_Reduce.H:1041
std::pair< T, T > MinMax(N n, T const *v)
Compute the minimum and maximum of an array of values.
Definition AMReX_Reduce.H:1013
T Max(N n, T const *v, T init_val=std::numeric_limits< T >::lowest())
Compute the maximum of an array of values.
Definition AMReX_Reduce.H:990
T Sum(N n, T const *v, T init_val=0)
Compute the sum of an array of values.
Definition AMReX_Reduce.H:944
__host__ __device__ Dim3 ubound(Array4< T > const &a) noexcept
Return the inclusive upper bounds of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1365
__host__ __device__ Dim3 lbound(Array4< T > const &a) noexcept
Return the inclusive lower bounds of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1351
__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:1326
Arena * The_Pinned_Arena()
Definition AMReX_Arena.cpp:855
Arena * The_Arena()
Definition AMReX_Arena.cpp:815
void Sum(Gpu::DeviceVector< T > &v, MPI_Comm comm)
Definition AMReX_GpuParallelReduce.H:37
__host__ __device__ constexpr const T & min(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:31
__host__ __device__ constexpr const T & max(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:53
__host__ __device__ AMREX_FORCE_INLINE T Max(T *const m, T const value) noexcept
Definition AMReX_GpuAtomic.H:419
__host__ __device__ AMREX_FORCE_INLINE T Min(T *const m, T const value) noexcept
Definition AMReX_GpuAtomic.H:356
__device__ int blockReduceLogicalOr(int source) noexcept
Definition AMReX_GpuReduce.H:559
__device__ T blockReduceMax(T source) noexcept
Definition AMReX_GpuReduce.H:458
__device__ T blockReduceMin(T source) noexcept
Definition AMReX_GpuReduce.H:403
__device__ int blockReduceLogicalAnd(int source) noexcept
Definition AMReX_GpuReduce.H:511
__device__ T blockReduceSum(T source) noexcept
Definition AMReX_GpuReduce.H:353
Definition AMReX_Amr.cpp:50
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:259
void For(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:400
cudaStream_t gpuStream_t
Definition AMReX_GpuControl.H:79
__host__ __device__ constexpr GpuTuple< Ts... > IdentityTuple(GpuTuple< Ts... >, ReduceOps< Ps... >) noexcept
Return a GpuTuple containing the identity element for each operation in ReduceOps....
Definition AMReX_Reduce.H:1496
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
typename ToTypeList< T >::type ToTypeList_t
Definition AMReX_TypeList.H:233
const int[]
Definition AMReX_BLProfiler.cpp:1665
Utility that maps flattened point indices back to IntVectND coordinates.
Definition AMReX_Box.H:2494
__host__ __device__ IntVectND< dim > intVect(std::uint64_t icell) const
Convert flattened point index icell to its IntVectND coordinate.
Definition AMReX_Box.H:2517
__host__ __device__ std::uint64_t numPts() const
Return the number of points covered by the indexed box.
Definition AMReX_Box.H:2552
Fixed-size array that can be used on GPU.
Definition AMReX_Array.H:52
Definition AMReX_Tuple.H:133
Definition AMReX_GpuMemory.H:57
T * dataPtr()
Definition AMReX_GpuMemory.H:91
T dataValue() const
Definition AMReX_GpuMemory.H:93
Definition AMReX_GpuLaunch.H:121
Definition AMReX_GpuTypes.H:88
Definition AMReX_GpuControl.H:127
Definition AMReX_GpuReduce.H:290
Test if a given type T is callable with arguments of type Args...
Definition AMReX_TypeTraits.H:208
Function object that returns the sum of two values.
Definition AMReX_Functional.H:23
Definition AMReX_Reduce.H:375
__host__ __device__ void local_update(T &d, T s) const noexcept
Definition AMReX_Reduce.H:396
constexpr void init(T &t) const noexcept
Definition AMReX_Reduce.H:399
__device__ void parallel_update(T &d, T s) const noexcept
Definition AMReX_Reduce.H:387
Definition AMReX_Reduce.H:404
__device__ void parallel_update(T &d, T s) const noexcept
Definition AMReX_Reduce.H:416
__host__ __device__ void local_update(T &d, T s) const noexcept
Definition AMReX_Reduce.H:425
constexpr void init(T &t) const noexcept
Definition AMReX_Reduce.H:428
Definition AMReX_Reduce.H:341
constexpr void init(T &t) const noexcept
Definition AMReX_Reduce.H:366
__host__ __device__ void local_update(T &d, T const &s) const noexcept
Definition AMReX_Reduce.H:362
__device__ void parallel_update(T &d, T const &s) const noexcept
Definition AMReX_Reduce.H:353
Definition AMReX_Reduce.H:307
constexpr void init(T &t) const noexcept
Definition AMReX_Reduce.H:332
__device__ void parallel_update(T &d, T const &s) const noexcept
Definition AMReX_Reduce.H:319
__host__ __device__ void local_update(T &d, T const &s) const noexcept
Definition AMReX_Reduce.H:328
Definition AMReX_Reduce.H:277
__device__ void parallel_update(T &d, T const &s) const noexcept
Definition AMReX_Reduce.H:290
__host__ __device__ void local_update(T &d, T const &s) const noexcept
Definition AMReX_Reduce.H:299
constexpr void init(T &t) const noexcept
Definition AMReX_Reduce.H:302
Struct for holding types.
Definition AMReX_TypeList.H:13