1#ifndef AMREX_GPU_LAUNCH_FUNCTS_G_H_
2#define AMREX_GPU_LAUNCH_FUNCTS_G_H_
3#include <AMReX_Config.H>
12 template <
typename F,
typename N>
14 auto call_f_scalar_handler (
F const& f, N i, Gpu::Handler
const&)
15 noexcept ->
decltype(f(0))
20 template <
typename F,
typename N>
22 auto call_f_scalar_handler (
F const& f, N i, Gpu::Handler
const& handler)
23 noexcept ->
decltype(f(0,Gpu::Handler{}))
30 template <
typename F, std::size_t...Ns,
class...Args>
32 auto call_f_intvect_inner (std::index_sequence<Ns...>,
F const& f, IntVectND<1> iv, Args...args)
33 noexcept -> decltype(f(0, 0, 0, args...))
35 return f(iv[0], 0, 0, args...);
38 template <
typename F, std::size_t...Ns,
class...Args>
40 auto call_f_intvect_inner (std::index_sequence<Ns...>,
F const& f,
IntVectND<2> iv, Args...args)
41 noexcept -> decltype(f(0, 0, 0, args...))
43 return f(iv[0], iv[1], 0, args...);
46 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
48 auto call_f_intvect_inner (std::index_sequence<Ns...>,
F const& f,
IntVectND<dim> iv, Args...args)
49 noexcept -> decltype(f(iv, args...))
51 return f(iv, args...);
54 template <
typename F,
int dim, std::size_t...Ns,
class...Args>
56 auto call_f_intvect_inner (std::index_sequence<Ns...>,
F const& f,
IntVectND<dim> iv, Args...args)
57 noexcept -> decltype(f(iv[Ns]..., args...))
59 return f(iv[Ns]..., args...);
64 template <
typename F,
int dim>
67 noexcept ->
decltype(call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv))
69 return call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv);
74 template <
typename F,
int dim>
76 auto call_f_intvect_engine (
F const& f,
IntVectND<dim> iv, RandomEngine engine)
77 noexcept ->
decltype(call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, engine))
79 return call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, engine);
84 template <
typename F,
int dim>
86 auto call_f_intvect_handler (
F const& f,
IntVectND<dim> iv, Gpu::Handler
const&)
87 noexcept ->
decltype(call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv))
89 return call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv);
92 template <
typename F,
int dim>
94 auto call_f_intvect_handler (
F const& f,
IntVectND<dim> iv, Gpu::Handler
const& handler)
95 noexcept ->
decltype(call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, Gpu::Handler{}))
97 return call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, handler);
102 template <
typename F,
typename T,
int dim>
105 noexcept ->
decltype(call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, 0))
107 for (T n = 0; n < ncomp; ++n) {
108 call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, n);
114 template <
typename F,
typename T,
int dim>
116 auto call_f_intvect_ncomp_engine (
F const& f,
IntVectND<dim> iv, T ncomp, RandomEngine engine)
117 noexcept ->
decltype(call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, 0, engine))
119 for (T n = 0; n < ncomp; ++n) {
120 call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, n, engine);
126 template <
typename F,
typename T,
int dim>
128 auto call_f_intvect_ncomp_handler (
F const& f,
IntVectND<dim> iv, T ncomp, Gpu::Handler
const&)
129 noexcept ->
decltype(call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, 0))
131 for (T n = 0; n < ncomp; ++n) {
132 call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, n);
136 template <
typename F,
typename T,
int dim>
138 auto call_f_intvect_ncomp_handler (
F const& f,
IntVectND<dim> iv, T ncomp, Gpu::Handler
const& handler)
139 noexcept ->
decltype(call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, 0, Gpu::Handler{}))
141 for (T n = 0; n < ncomp; ++n) {
142 call_f_intvect_inner(std::make_index_sequence<dim>(), f, iv, n, handler);
154 detail::SyclKernelDevPtr<L> skdp(f, stream);
155 L
const* pf = skdp.template
get<0>();
158 auto& q = *(stream.queue);
160 q.submit([&] (sycl::handler& h) {
161 if constexpr (detail::is_big_kernel<L>()) {
162 h.single_task([=] () { (*pf)(); });
167 }
catch (sycl::exception
const& ex) {
168 amrex::Abort(std::string(
"single_task: ")+ex.what()+
"!!!!!");
173void launch (
int nblocks,
int nthreads_per_block, std::size_t shared_mem_bytes,
176 detail::SyclKernelDevPtr<L> skdp(f, stream);
177 L
const* pf = skdp.template
get<0>();
180 const auto nthreads_total = std::size_t(nthreads_per_block) * nblocks;
181 const std::size_t shared_mem_numull = (shared_mem_bytes+
sizeof(
unsigned long long)-1)
182 /
sizeof(
unsigned long long);
183 auto& q = *(stream.queue);
185 q.submit([&] (sycl::handler& h) {
186 sycl::local_accessor<unsigned long long>
187 shared_data(sycl::range<1>(shared_mem_numull), h);
188 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
189 sycl::range<1>(nthreads_per_block)),
190 [=] (sycl::nd_item<1> item)
193 if constexpr (detail::is_big_kernel<L>()) {
194 (*pf)(
Gpu::Handler{&item,shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get()});
196 f(
Gpu::Handler{&item,shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get()});
200 }
catch (sycl::exception
const& ex) {
201 amrex::Abort(std::string(
"launch: ")+ex.what()+
"!!!!!");
208 detail::SyclKernelDevPtr<L> skdp(f, stream);
209 L
const* pf = skdp.template
get<0>();
212 const auto nthreads_total = std::size_t(nthreads_per_block) * nblocks;
213 auto& q = *(stream.queue);
215 q.submit([&] (sycl::handler& h) {
216 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
217 sycl::range<1>(nthreads_per_block)),
218 [=] (sycl::nd_item<1> item)
221 if constexpr (detail::is_big_kernel<L>()) {
228 }
catch (sycl::exception
const& ex) {
229 amrex::Abort(std::string(
"launch: ")+ex.what()+
"!!!!!");
233template <
int MT,
typename L>
237 detail::SyclKernelDevPtr<L> skdp(f, stream);
238 L
const* pf = skdp.template
get<0>();
241 const auto nthreads_total = MT * std::size_t(nblocks);
242 const std::size_t shared_mem_numull = (shared_mem_bytes+
sizeof(
unsigned long long)-1)
243 /
sizeof(
unsigned long long);
244 auto& q = *(stream.queue);
246 q.submit([&] (sycl::handler& h) {
247 sycl::local_accessor<unsigned long long>
248 shared_data(sycl::range<1>(shared_mem_numull), h);
249 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
251 [=] (sycl::nd_item<1> item)
252 [[sycl::reqd_work_group_size(MT)]]
255 if constexpr (detail::is_big_kernel<L>()) {
256 (*pf)(
Gpu::Handler{&item,shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get()});
258 f(
Gpu::Handler{&item,shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get()});
262 }
catch (sycl::exception
const& ex) {
263 amrex::Abort(std::string(
"launch: ")+ex.what()+
"!!!!!");
267template <
int MT,
typename L>
270 detail::SyclKernelDevPtr<L> skdp(f, stream);
271 L
const* pf = skdp.template
get<0>();
274 const auto nthreads_total = MT * std::size_t(nblocks);
275 auto& q = *(stream.queue);
277 q.submit([&] (sycl::handler& h) {
278 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
280 [=] (sycl::nd_item<1> item)
281 [[sycl::reqd_work_group_size(MT)]]
284 if constexpr (detail::is_big_kernel<L>()) {
291 }
catch (sycl::exception
const& ex) {
292 amrex::Abort(std::string(
"launch: ")+ex.what()+
"!!!!!");
296template<
int MT,
typename T,
typename L>
297void launch (T
const& n, L
const& f)
302 L
const* pf = skdp.template
get<0>();
306 const auto nthreads_per_block = ec.numThreads.x;
307 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
308 auto& q = Gpu::Device::streamQueue();
310 q.submit([&] (sycl::handler& h) {
311 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
312 sycl::range<1>(nthreads_per_block)),
313 [=] (sycl::nd_item<1> item)
314 [[sycl::reqd_work_group_size(MT)]]
317 for (
auto const i :
Gpu::Range(n,item.get_global_id(0),item.get_global_range(0))) {
318 if constexpr (detail::is_big_kernel<L>()) {
326 }
catch (sycl::exception
const& ex) {
327 amrex::Abort(std::string(
"launch: ")+ex.what()+
"!!!!!");
331template <
int MT, std::
integral T,
typename L>
337 L
const* pf = skdp.template
get<0>();
341 const auto nthreads_per_block = ec.numThreads.x;
342 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
343 auto& q = Gpu::Device::streamQueue();
345 if (info.hasReduction()) {
346 q.submit([&] (sycl::handler& h) {
347 sycl::local_accessor<unsigned long long>
350 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
351 sycl::range<1>(nthreads_per_block)),
352 [=] (sycl::nd_item<1> item)
353 [[sycl::reqd_work_group_size(MT)]]
356 for (std::size_t i = item.get_global_id(0), stride = item.get_global_range(0);
357 i < std::size_t(n); i += stride) {
358 int n_active_threads =
amrex::min(std::size_t(n)-i+item.get_local_id(0),
359 item.get_local_range(0));
360 if constexpr (detail::is_big_kernel<L>()) {
361 detail::call_f_scalar_handler(*pf, T(i),
362 Gpu::Handler{&item, shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get(),
365 detail::call_f_scalar_handler(f, T(i),
366 Gpu::Handler{&item, shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get(),
373 q.submit([&] (sycl::handler& h) {
374 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
375 sycl::range<1>(nthreads_per_block)),
376 [=] (sycl::nd_item<1> item)
377 [[sycl::reqd_work_group_size(MT)]]
380 for (std::size_t i = item.get_global_id(0), stride = item.get_global_range(0);
381 i < std::size_t(n); i += stride) {
382 if constexpr (detail::is_big_kernel<L>()) {
383 detail::call_f_scalar_handler(*pf, T(i),
Gpu::Handler{&item});
385 detail::call_f_scalar_handler(f, T(i),
Gpu::Handler{&item});
391 }
catch (sycl::exception
const& ex) {
392 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
396template <
int MT,
typename L,
int dim>
402 L
const* pf = skdp.template
get<0>();
407 const auto nthreads_per_block = ec.numThreads.x;
408 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
409 auto& q = Gpu::Device::streamQueue();
411 if (info.hasReduction()) {
412 q.submit([&] (sycl::handler& h) {
413 sycl::local_accessor<unsigned long long>
416 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
417 sycl::range<1>(nthreads_per_block)),
418 [=] (sycl::nd_item<1> item)
419 [[sycl::reqd_work_group_size(MT)]]
422 for (std::uint64_t icell = item.get_global_id(0), stride = item.get_global_range(0);
423 icell < indexer.numPts(); icell += stride) {
424 auto iv = indexer.intVect(icell);
425 int n_active_threads =
amrex::min(indexer.numPts()-icell+std::uint64_t(item.get_local_id(0)),
426 std::uint64_t(item.get_local_range(0)));
427 if constexpr (detail::is_big_kernel<L>()) {
428 detail::call_f_intvect_handler(*pf,
430 shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get(),
433 detail::call_f_intvect_handler(f,
435 shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get(),
442 q.submit([&] (sycl::handler& h) {
443 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
444 sycl::range<1>(nthreads_per_block)),
445 [=] (sycl::nd_item<1> item)
446 [[sycl::reqd_work_group_size(MT)]]
449 for (std::uint64_t icell = item.get_global_id(0), stride = item.get_global_range(0);
450 icell < indexer.numPts(); icell += stride) {
451 auto iv = indexer.intVect(icell);
452 if constexpr (detail::is_big_kernel<L>()) {
453 detail::call_f_intvect_handler(*pf,iv,
Gpu::Handler{&item});
455 detail::call_f_intvect_handler(f,iv,
Gpu::Handler{&item});
461 }
catch (sycl::exception
const& ex) {
462 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
466template <
int MT, std::
integral T,
typename L,
int dim>
472 L
const* pf = skdp.template
get<0>();
477 const auto nthreads_per_block = ec.numThreads.x;
478 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
479 auto& q = Gpu::Device::streamQueue();
481 if (info.hasReduction()) {
482 q.submit([&] (sycl::handler& h) {
483 sycl::local_accessor<unsigned long long>
486 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
487 sycl::range<1>(nthreads_per_block)),
488 [=] (sycl::nd_item<1> item)
489 [[sycl::reqd_work_group_size(MT)]]
492 for (std::uint64_t icell = item.get_global_id(0), stride = item.get_global_range(0);
493 icell < indexer.numPts(); icell += stride) {
494 auto iv = indexer.intVect(icell);
495 int n_active_threads =
amrex::min(indexer.numPts()-icell+std::uint64_t(item.get_local_id(0)),
496 std::uint64_t(item.get_local_range(0)));
497 if constexpr (detail::is_big_kernel<L>()) {
498 detail::call_f_intvect_ncomp_handler(*pf, iv, ncomp,
499 Gpu::Handler{&item, shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get(),
502 detail::call_f_intvect_ncomp_handler(f, iv, ncomp,
503 Gpu::Handler{&item, shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get(),
510 q.submit([&] (sycl::handler& h) {
511 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
512 sycl::range<1>(nthreads_per_block)),
513 [=] (sycl::nd_item<1> item)
514 [[sycl::reqd_work_group_size(MT)]]
517 for (std::uint64_t icell = item.get_global_id(0), stride = item.get_global_range(0);
518 icell < indexer.numPts(); icell += stride) {
519 auto iv = indexer.intVect(icell);
520 if constexpr (detail::is_big_kernel<L>()) {
521 detail::call_f_intvect_ncomp_handler(*pf,iv,ncomp,
Gpu::Handler{&item});
523 detail::call_f_intvect_ncomp_handler(f,iv,ncomp,
Gpu::Handler{&item});
529 }
catch (sycl::exception
const& ex) {
530 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
534template <std::
integral T,
typename L>
540 L
const* pf = skdp.template
get<0>();
544 const auto nthreads_per_block = ec.numThreads.x;
546 auto& q = Gpu::Device::streamQueue();
547 auto& engdescr = *(getRandEngineDescriptor());
549 q.submit([&] (sycl::handler& h) {
550 auto engine_acc = engdescr.get_access(h);
551 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
552 sycl::range<1>(nthreads_per_block)),
553 [=] (sycl::nd_item<1> item)
554 [[sycl::reqd_work_group_size(AMREX_GPU_MAX_THREADS)]]
557 auto const tid = item.get_global_id(0);
558 auto engine = engine_acc.load(tid);
560 for (std::size_t i = tid, stride = item.get_global_range(0); i < std::size_t(n); i += stride) {
561 if constexpr (detail::is_big_kernel<L>()) {
562 (*pf)(T(i),rand_eng);
567 engine_acc.store(engine, tid);
571 }
catch (sycl::exception
const& ex) {
572 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
576template <
typename L,
int dim>
582 L
const* pf = skdp.template
get<0>();
587 const auto nthreads_per_block = ec.numThreads.x;
589 auto& q = Gpu::Device::streamQueue();
590 auto& engdescr = *(getRandEngineDescriptor());
592 q.submit([&] (sycl::handler& h) {
593 auto engine_acc = engdescr.get_access(h);
594 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
595 sycl::range<1>(nthreads_per_block)),
596 [=] (sycl::nd_item<1> item)
597 [[sycl::reqd_work_group_size(AMREX_GPU_MAX_THREADS)]]
600 auto const tid = item.get_global_id(0);
601 auto engine = engine_acc.load(tid);
603 for (std::uint64_t icell = tid, stride = item.get_global_range(0);
604 icell < indexer.numPts(); icell += stride) {
605 auto iv = indexer.intVect(icell);
606 if constexpr (detail::is_big_kernel<L>()) {
607 detail::call_f_intvect_engine(*pf,iv,rand_eng);
609 detail::call_f_intvect_engine(f,iv,rand_eng);
612 engine_acc.store(engine, tid);
616 }
catch (sycl::exception
const& ex) {
617 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
621template <std::
integral T,
typename L,
int dim>
627 L
const* pf = skdp.template
get<0>();
632 const auto nthreads_per_block = ec.numThreads.x;
634 auto& q = Gpu::Device::streamQueue();
635 auto& engdescr = *(getRandEngineDescriptor());
637 q.submit([&] (sycl::handler& h) {
638 auto engine_acc = engdescr.get_access(h);
639 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
640 sycl::range<1>(nthreads_per_block)),
641 [=] (sycl::nd_item<1> item)
642 [[sycl::reqd_work_group_size(AMREX_GPU_MAX_THREADS)]]
645 auto const tid = item.get_global_id(0);
646 auto engine = engine_acc.load(tid);
648 for (std::uint64_t icell = tid, stride = item.get_global_range(0);
649 icell < indexer.numPts(); icell += stride) {
650 auto iv = indexer.intVect(icell);
651 if constexpr (detail::is_big_kernel<L>()) {
652 detail::call_f_intvect_ncomp_engine(*pf,iv,ncomp,rand_eng);
654 detail::call_f_intvect_ncomp_engine(f,iv,ncomp,rand_eng);
657 engine_acc.store(engine, tid);
661 }
catch (sycl::exception
const& ex) {
662 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
666template <
int MT,
typename L1,
typename L2,
int dim>
672 L1
const* pf1 = skdp.template
get<0>();
673 L2
const* pf2 = skdp.template
get<1>();
679 const auto nthreads_per_block = ec.numThreads.x;
680 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
681 auto& q = Gpu::Device::streamQueue();
683 q.submit([&] (sycl::handler& h) {
684 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
685 sycl::range<1>(nthreads_per_block)),
686 [=] (sycl::nd_item<1> item)
687 [[sycl::reqd_work_group_size(MT)]]
690 auto const ncells = std::max(indexer1.numPts(), indexer2.numPts());
691 for (std::uint64_t icell = item.get_global_id(0), stride = item.get_global_range(0);
692 icell < ncells; icell += stride) {
693 if (icell < indexer1.numPts()) {
694 auto iv = indexer1.intVect(icell);
695 if constexpr (detail::is_big_kernel<L1,L2>()) {
696 detail::call_f_intvect(*pf1,iv);
698 detail::call_f_intvect(f1,iv);
701 if (icell < indexer2.numPts()) {
702 auto iv = indexer2.intVect(icell);
703 if constexpr (detail::is_big_kernel<L1,L2>()) {
704 detail::call_f_intvect(*pf2,iv);
706 detail::call_f_intvect(f2,iv);
712 }
catch (sycl::exception
const& ex) {
713 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
717template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
720 L1
const& f1, L2
const& f2, L3
const& f3)
724 detail::SyclKernelDevPtr<L1,L2,L3> skdp(f1, f2, f3,
Gpu::gpuStream());
725 L1
const* pf1 = skdp.template
get<0>();
726 L2
const* pf2 = skdp.template
get<1>();
727 L3
const* pf3 = skdp.template
get<2>();
734 const auto nthreads_per_block = ec.
numThreads.x;
735 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
736 auto& q = Gpu::Device::streamQueue();
738 q.submit([&] (sycl::handler& h) {
739 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
740 sycl::range<1>(nthreads_per_block)),
741 [=] (sycl::nd_item<1> item)
742 [[sycl::reqd_work_group_size(MT)]]
745 auto const ncells =
amrex::max(indexer1.numPts(), indexer2.numPts(), indexer3.numPts());
746 for (std::uint64_t icell = item.get_global_id(0), stride = item.get_global_range(0);
747 icell < ncells; icell += stride) {
748 if (icell < indexer1.numPts()) {
749 auto iv = indexer1.intVect(icell);
750 if constexpr (detail::is_big_kernel<L1,L2,L3>()) {
751 detail::call_f_intvect(*pf1,iv);
753 detail::call_f_intvect(f1,iv);
756 if (icell < indexer2.numPts()) {
757 auto iv = indexer2.intVect(icell);
758 if constexpr (detail::is_big_kernel<L1,L2,L3>()) {
759 detail::call_f_intvect(*pf2,iv);
761 detail::call_f_intvect(f2,iv);
764 if (icell < indexer3.numPts()) {
765 auto iv = indexer3.intVect(icell);
766 if constexpr (detail::is_big_kernel<L1,L2,L3>()) {
767 detail::call_f_intvect(*pf3,iv);
769 detail::call_f_intvect(f3,iv);
775 }
catch (sycl::exception
const& ex) {
776 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
780template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
782 BoxND<dim> const& box1, T1 ncomp1, L1
const& f1,
783 BoxND<dim> const& box2, T2 ncomp2, L2
const& f2)
788 L1
const* pf1 = skdp.template
get<0>();
789 L2
const* pf2 = skdp.template
get<1>();
795 const auto nthreads_per_block = ec.numThreads.x;
796 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
797 auto& q = Gpu::Device::streamQueue();
799 q.submit([&] (sycl::handler& h) {
800 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
801 sycl::range<1>(nthreads_per_block)),
802 [=] (sycl::nd_item<1> item)
803 [[sycl::reqd_work_group_size(MT)]]
806 auto const ncells = std::max(indexer1.numPts(), indexer2.numPts());
807 for (std::uint64_t icell = item.get_global_id(0), stride = item.get_global_range(0);
808 icell < ncells; icell += stride) {
809 if (icell < indexer1.numPts()) {
810 auto iv = indexer1.intVect(icell);
811 if constexpr (detail::is_big_kernel<L1,L2>()) {
812 detail::call_f_intvect_ncomp(*pf1,iv,ncomp1);
814 detail::call_f_intvect_ncomp(f1,iv,ncomp1);
817 if (icell < indexer2.numPts()) {
818 auto iv = indexer2.intVect(icell);
819 if constexpr (detail::is_big_kernel<L1,L2>()) {
820 detail::call_f_intvect_ncomp(*pf2,iv,ncomp2);
822 detail::call_f_intvect_ncomp(f2,iv,ncomp2);
828 }
catch (sycl::exception
const& ex) {
829 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
833template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
835 BoxND<dim> const& box1, T1 ncomp1, L1
const& f1,
836 BoxND<dim> const& box2, T2 ncomp2, L2
const& f2,
837 BoxND<dim> const& box3, T3 ncomp3, L3
const& f3)
841 detail::SyclKernelDevPtr<L1,L2,L3> skdp(f1, f2, f3,
Gpu::gpuStream());
842 L1
const* pf1 = skdp.template
get<0>();
843 L2
const* pf2 = skdp.template
get<1>();
844 L3
const* pf3 = skdp.template
get<2>();
851 const auto nthreads_per_block = ec.
numThreads.x;
852 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
853 auto& q = Gpu::Device::streamQueue();
855 q.submit([&] (sycl::handler& h) {
856 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
857 sycl::range<1>(nthreads_per_block)),
858 [=] (sycl::nd_item<1> item)
859 [[sycl::reqd_work_group_size(MT)]]
862 auto const ncells =
amrex::max(indexer1.numPts(), indexer2.numPts(), indexer3.numPts());
863 for (std::uint64_t icell = item.get_global_id(0), stride = item.get_global_range(0);
864 icell < ncells; icell += stride) {
865 if (icell < indexer1.numPts()) {
866 auto iv = indexer1.intVect(icell);
867 if constexpr (detail::is_big_kernel<L1,L2,L3>()) {
868 detail::call_f_intvect_ncomp(*pf1,iv,ncomp1);
870 detail::call_f_intvect_ncomp(f1,iv,ncomp1);
873 if (icell < indexer2.numPts()) {
874 auto iv = indexer2.intVect(icell);
875 if constexpr (detail::is_big_kernel<L1,L2,L3>()) {
876 detail::call_f_intvect_ncomp(*pf2,iv,ncomp2);
878 detail::call_f_intvect_ncomp(f2,iv,ncomp2);
881 if (icell < indexer3.numPts()) {
882 auto iv = indexer3.intVect(icell);
883 if constexpr (detail::is_big_kernel<L1,L2,L3>()) {
884 detail::call_f_intvect_ncomp(*pf3,iv,ncomp3);
886 detail::call_f_intvect_ncomp(f3,iv,ncomp3);
892 }
catch (sycl::exception
const& ex) {
893 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
907template <
int MT,
typename L>
915template <
int MT,
typename L>
923void launch (
int nblocks,
int nthreads_per_block, std::size_t shared_mem_bytes,
933 launch(nblocks, nthreads_per_block, 0, stream, std::forward<L>(f));
936template<
int MT, std::
integral T,
typename L>
939 static_assert(
sizeof(T) >= 2);
942 for (
auto const& ec : nec) {
943 const T start_idx = T(ec.start_idx);
944 const T nleft = n - start_idx;
947 auto tid = std::uint64_t(MT)*blockIdx.x+threadIdx.x;
948 if (tid < std::uint64_t(nleft)) {
956template<
int MT,
int dim,
typename L>
962 const auto type = box.
ixType();
963 for (
auto const& ec : nec) {
964 const auto start_idx = std::uint64_t(ec.start_idx);
967 auto icell = std::uint64_t(MT)*blockIdx.x+threadIdx.x + start_idx;
968 if (icell < indexer.
numPts()) {
969 auto iv = indexer.
intVect(icell);
981template <
int MT, std::
integral T,
typename L>
982requires (MaybeDeviceRunnable<L>::value)
986 static_assert(
sizeof(T) >= 2);
989 for (
auto const& ec : nec) {
990 const T start_idx = T(ec.start_idx);
991 const T nleft = n - start_idx;
994 auto tid = std::uint64_t(MT)*blockIdx.x+threadIdx.x;
995 if (tid < std::uint64_t(nleft)) {
996 detail::call_f_scalar_handler(f, T(tid)+start_idx,
998 (std::uint64_t)MT)));
1009template <
int MT,
typename L,
int dim>
1010requires (MaybeDeviceRunnable<L>::value)
1017 for (
auto const& ec : nec) {
1018 const auto start_idx = std::uint64_t(ec.start_idx);
1021 auto icell = std::uint64_t(MT)*blockIdx.x+threadIdx.x + start_idx;
1022 if (icell < indexer.
numPts()) {
1023 auto iv = indexer.
intVect(icell);
1024 detail::call_f_intvect_handler(f, iv,
1026 (std::uint64_t)MT)));
1037template <
int MT, std::
integral T,
typename L,
int dim>
1038requires (MaybeDeviceRunnable<L>::value)
1045 for (
auto const& ec : nec) {
1046 const auto start_idx = std::uint64_t(ec.start_idx);
1049 auto icell = std::uint64_t(MT)*blockIdx.x+threadIdx.x + start_idx;
1050 if (icell < indexer.
numPts()) {
1051 auto iv = indexer.
intVect(icell);
1052 detail::call_f_intvect_ncomp_handler(f, iv, ncomp,
1054 (std::uint64_t)MT)));
1066template <std::
integral T,
typename L>
1067requires (MaybeDeviceRunnable<L>::value)
1078 Long tid =
Long(AMREX_GPU_MAX_THREADS)*blockIdx.x+threadIdx.x;
1080 for (
Long i = tid, stride =
Long(AMREX_GPU_MAX_THREADS)*gridDim.x; i <
Long(n); i += stride) {
1093template <
typename L,
int dim>
1094requires (MaybeDeviceRunnable<L>::value)
1106 auto const tid = std::uint64_t(AMREX_GPU_MAX_THREADS)*blockIdx.x+threadIdx.x;
1108 for (std::uint64_t icell = tid, stride = std::uint64_t(AMREX_GPU_MAX_THREADS)*gridDim.x; icell < indexer.
numPts(); icell += stride) {
1109 auto iv = indexer.
intVect(icell);
1110 detail::call_f_intvect_engine(f, iv, engine);
1122template <std::
integral T,
typename L,
int dim>
1123requires (MaybeDeviceRunnable<L>::value)
1135 auto const tid = std::uint64_t(AMREX_GPU_MAX_THREADS)*blockIdx.x+threadIdx.x;
1137 for (std::uint64_t icell = tid, stride = std::uint64_t(AMREX_GPU_MAX_THREADS)*gridDim.x; icell < indexer.
numPts(); icell += stride) {
1138 auto iv = indexer.
intVect(icell);
1139 detail::call_f_intvect_ncomp_engine(f, iv, ncomp, engine);
1150template <
int MT,
typename L1,
typename L2,
int dim>
1151requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value)
1162 auto const ncells = std::max(indexer1.
numPts(), indexer2.
numPts());
1163 for (std::uint64_t icell = std::uint64_t(MT)*blockIdx.x+threadIdx.x, stride = std::uint64_t(MT)*gridDim.x;
1164 icell < ncells; icell += stride) {
1165 if (icell < indexer1.
numPts()) {
1166 auto iv = indexer1.
intVect(icell);
1167 detail::call_f_intvect(f1, iv);
1169 if (icell < indexer2.
numPts()) {
1170 auto iv = indexer2.
intVect(icell);
1171 detail::call_f_intvect(f2, iv);
1182template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1183requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value &&
1184 MaybeDeviceRunnable<L3>::value)
1188 L1&& f1, L2&& f2, L3&& f3)
1197 auto const ncells = std::max({indexer1.
numPts(), indexer2.
numPts(), indexer3.
numPts()});
1198 for (std::uint64_t icell = std::uint64_t(MT)*blockIdx.x+threadIdx.x, stride = std::uint64_t(MT)*gridDim.x;
1199 icell < ncells; icell += stride) {
1200 if (icell < indexer1.
numPts()) {
1201 auto iv = indexer1.
intVect(icell);
1202 detail::call_f_intvect(f1, iv);
1204 if (icell < indexer2.
numPts()) {
1205 auto iv = indexer2.
intVect(icell);
1206 detail::call_f_intvect(f2, iv);
1208 if (icell < indexer3.
numPts()) {
1209 auto iv = indexer3.
intVect(icell);
1210 detail::call_f_intvect(f3, iv);
1221template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1222requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value)
1234 auto const ncells = std::max(indexer1.
numPts(), indexer2.
numPts());
1235 for (std::uint64_t icell = std::uint64_t(MT)*blockIdx.x+threadIdx.x, stride = std::uint64_t(MT)*gridDim.x;
1236 icell < ncells; icell += stride) {
1237 if (icell < indexer1.
numPts()) {
1238 auto iv = indexer1.
intVect(icell);
1239 detail::call_f_intvect_ncomp(f1, iv, ncomp1);
1241 if (icell < indexer2.
numPts()) {
1242 auto iv = indexer2.
intVect(icell);
1243 detail::call_f_intvect_ncomp(f2, iv, ncomp2);
1254template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1255requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value &&
1256 MaybeDeviceRunnable<L3>::value)
1270 auto const ncells = std::max({indexer1.
numPts(), indexer2.
numPts(), indexer3.
numPts()});
1271 for (std::uint64_t icell = std::uint64_t(MT)*blockIdx.x+threadIdx.x, stride = std::uint64_t(MT)*gridDim.x;
1272 icell < ncells; icell += stride) {
1273 if (icell < indexer1.
numPts()) {
1274 auto iv = indexer1.
intVect(icell);
1275 detail::call_f_intvect_ncomp(f1, iv, ncomp1);
1277 if (icell < indexer2.
numPts()) {
1278 auto iv = indexer2.
intVect(icell);
1279 detail::call_f_intvect_ncomp(f2, iv, ncomp2);
1281 if (icell < indexer3.
numPts()) {
1282 auto iv = indexer3.
intVect(icell);
1283 detail::call_f_intvect_ncomp(f3, iv, ncomp3);
1292template <
typename L>
1298template<
typename T,
typename L>
1308template <std::
integral T,
typename L>
1309requires (MaybeDeviceRunnable<L>::value)
1320template <
typename L,
int dim>
1321requires (MaybeDeviceRunnable<L>::value)
1332template <std::
integral T,
typename L,
int dim>
1333requires (MaybeDeviceRunnable<L>::value)
1344template <
typename L1,
typename L2,
int dim>
1345requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value)
1351 std::forward<L2>(f2));
1358template <
typename L1,
typename L2,
typename L3,
int dim>
1359requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value &&
1360 MaybeDeviceRunnable<L3>::value)
1364 L1&& f1, L2&& f2, L3&& f3)
noexcept
1367 std::forward<L2>(f2), std::forward<L3>(f3));
1374template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1375requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value)
1379 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1382 box2, ncomp2, std::forward<L2>(f2));
1389template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1390requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value &&
1391 MaybeDeviceRunnable<L3>::value)
1396 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1399 box2, ncomp2, std::forward<L2>(f2),
1400 box3, ncomp3, std::forward<L3>(f3));
1403template <std::
integral T,
typename L>
1404void For (Gpu::KernelInfo
const& info, T n, L&& f)
noexcept
1409template <
int MT, std::
integral T,
typename L>
1415template <
typename L,
int dim>
1421template <
int MT,
typename L,
int dim>
1427template <std::
integral T,
typename L,
int dim>
1433template <
int MT, std::
integral T,
typename L,
int dim>
1439template <
typename L1,
typename L2,
int dim>
1446template <
int MT,
typename L1,
typename L2,
int dim>
1450 ParallelFor<MT>(info,box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
1453template <
typename L1,
typename L2,
typename L3,
int dim>
1456 L1&& f1, L2&& f2, L3&& f3)
noexcept
1461template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1464 L1&& f1, L2&& f2, L3&& f3)
noexcept
1466 ParallelFor<MT>(info,box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1469template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1472 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1477template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1480 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1482 ParallelFor<MT>(info,box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
1485template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1489 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1492 box1,ncomp1,std::forward<L1>(f1),
1493 box2,ncomp2,std::forward<L2>(f2),
1494 box3,ncomp3,std::forward<L3>(f3));
1497template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1501 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1504 box1,ncomp1,std::forward<L1>(f1),
1505 box2,ncomp2,std::forward<L2>(f2),
1506 box3,ncomp3,std::forward<L3>(f3));
1513template <std::
integral T,
typename L>
1523template <
int MT, std::
integral T,
typename L>
1533template <
typename L,
int dim>
1543template <
int MT,
typename L,
int dim>
1544void ParallelFor (BoxND<dim>
const& box, L&& f)
noexcept
1553template <std::
integral T,
typename L,
int dim>
1563template <
int MT, std::
integral T,
typename L,
int dim>
1564void ParallelFor (BoxND<dim>
const& box, T ncomp, L&& f)
noexcept
1573template <
typename L1,
typename L2,
int dim>
1583template <
int MT,
typename L1,
typename L2,
int dim>
1593template <
typename L1,
typename L2,
typename L3,
int dim>
1595 L1&& f1, L2&& f2, L3&& f3)
noexcept
1604template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1606 L1&& f1, L2&& f2, L3&& f3)
noexcept
1615template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1617 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1626template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1628 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1637template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1640 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1643 box1,ncomp1,std::forward<L1>(f1),
1644 box2,ncomp2,std::forward<L2>(f2),
1645 box3,ncomp3,std::forward<L3>(f3));
1652template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1655 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1658 box1,ncomp1,std::forward<L1>(f1),
1659 box2,ncomp2,std::forward<L2>(f2),
1660 box3,ncomp3,std::forward<L3>(f3));
1663template <std::
integral T,
typename L>
1669template <
int MT, std::
integral T,
typename L>
1670void For (T n, L&& f)
noexcept
1675template <
typename L,
int dim>
1681template <
int MT,
typename L,
int dim>
1682void For (BoxND<dim>
const& box, L&& f)
noexcept
1687template <std::
integral T,
typename L,
int dim>
1693template <
int MT, std::
integral T,
typename L,
int dim>
1694void For (BoxND<dim>
const& box, T ncomp, L&& f)
noexcept
1699template <
typename L1,
typename L2,
int dim>
1705template <
int MT,
typename L1,
typename L2,
int dim>
1711template <
typename L1,
typename L2,
typename L3,
int dim>
1713 L1&& f1, L2&& f2, L3&& f3)
noexcept
1718template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1720 L1&& f1, L2&& f2, L3&& f3)
noexcept
1725template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1727 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1732template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1734 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1739template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1742 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1745 box1,ncomp1,std::forward<L1>(f1),
1746 box2,ncomp2,std::forward<L2>(f2),
1747 box3,ncomp3,std::forward<L3>(f3));
1750template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1753 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1756 box1,ncomp1,std::forward<L1>(f1),
1757 box2,ncomp2,std::forward<L2>(f2),
1758 box3,ncomp3,std::forward<L3>(f3));
1761template <std::
integral T,
typename L>
1770 for (T i = 0; i < n; ++i) { f(i); }
1774template <
int MT, std::
integral T,
typename L>
1775requires (MaybeHostDeviceRunnable<L>::value)
1783 for (T i = 0; i < n; ++i) { f(i); }
1787template <std::
integral T,
typename L>
1788requires (MaybeHostDeviceRunnable<L>::value)
1795template <
int MT, std::
integral T,
typename L>
1796requires (MaybeHostDeviceRunnable<L>::value)
1803template <
typename L,
int dim>
1804requires (MaybeHostDeviceRunnable<L>::value)
1815template <
int MT,
typename L,
int dim>
1816requires (MaybeHostDeviceRunnable<L>::value)
1827template <std::
integral T,
typename L,
int dim>
1828requires (MaybeHostDeviceRunnable<L>::value)
1839template <
int MT, std::
integral T,
typename L,
int dim>
1840requires (MaybeHostDeviceRunnable<L>::value)
1851template <
typename L1,
typename L2,
int dim>
1852requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value)
1865template <
int MT,
typename L1,
typename L2,
int dim>
1866requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value)
1872 ParallelFor<MT>(info,box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
1879template <
typename L1,
typename L2,
typename L3,
int dim>
1880requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value &&
1881 MaybeHostDeviceRunnable<L3>::value)
1885 L1&& f1, L2&& f2, L3&& f3)
1889 std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1897template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1898requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value &&
1899 MaybeHostDeviceRunnable<L3>::value)
1903 L1&& f1, L2&& f2, L3&& f3)
1907 std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1915template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1916requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value)
1930template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1931requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value)
1938 ParallelFor<MT>(info,box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
1945template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1946requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value &&
1947 MaybeHostDeviceRunnable<L3>::value)
1956 box1,ncomp1,std::forward<L1>(f1),
1957 box2,ncomp2,std::forward<L2>(f2),
1958 box3,ncomp3,std::forward<L3>(f3));
1966template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1967requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value &&
1968 MaybeHostDeviceRunnable<L3>::value)
1977 box1,ncomp1,std::forward<L1>(f1),
1978 box2,ncomp2,std::forward<L2>(f2),
1979 box3,ncomp3,std::forward<L3>(f3));
1987template <std::
integral T,
typename L>
1988void HostDeviceFor (Gpu::KernelInfo
const& info, T n, L&& f)
noexcept
1993template <
int MT, std::
integral T,
typename L>
1999template <
typename L,
int dim>
2005template <
int MT,
typename L,
int dim>
2011template <std::
integral T,
typename L,
int dim>
2017template <
int MT, std::
integral T,
typename L,
int dim>
2023template <
typename L1,
typename L2,
int dim>
2030template <
int MT,
typename L1,
typename L2,
int dim>
2037template <
typename L1,
typename L2,
typename L3,
int dim>
2040 L1&& f1, L2&& f2, L3&& f3)
noexcept
2043 std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
2046template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
2049 L1&& f1, L2&& f2, L3&& f3)
noexcept
2052 std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
2055template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
2058 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
2063template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
2066 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
2071template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
2075 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
2078 box1,ncomp1,std::forward<L1>(f1),
2079 box2,ncomp2,std::forward<L2>(f2),
2080 box3,ncomp3,std::forward<L3>(f3));
2083template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
2087 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
2090 box1,ncomp1,std::forward<L1>(f1),
2091 box2,ncomp2,std::forward<L2>(f2),
2092 box3,ncomp3,std::forward<L3>(f3));
2095template <std::
integral T,
typename L>
2101template <
int MT, std::
integral T,
typename L>
2107template <
typename L,
int dim>
2113template <
int MT,
typename L,
int dim>
2119template <std::
integral T,
typename L,
int dim>
2125template <
int MT, std::
integral T,
typename L,
int dim>
2131template <
typename L1,
typename L2,
int dim>
2137template <
int MT,
typename L1,
typename L2,
int dim>
2143template <
typename L1,
typename L2,
typename L3,
int dim>
2145 L1&& f1, L2&& f2, L3&& f3)
noexcept
2148 std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
2151template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
2153 L1&& f1, L2&& f2, L3&& f3)
noexcept
2156 std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
2159template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
2161 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
2166template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
2168 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
2173template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
2176 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
2179 box1,ncomp1,std::forward<L1>(f1),
2180 box2,ncomp2,std::forward<L2>(f2),
2181 box3,ncomp3,std::forward<L3>(f3));
2184template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
2187 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
2190 box1,ncomp1,std::forward<L1>(f1),
2191 box2,ncomp2,std::forward<L2>(f2),
2192 box3,ncomp3,std::forward<L3>(f3));
#define AMREX_PRAGMA_SIMD
Definition AMReX_Extension.H:85
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:124
#define AMREX_GPU_ERROR_CHECK()
Definition AMReX_GpuError.H:151
#define AMREX_LAUNCH_KERNEL(MT, blocks, threads, sharedMem, stream,...)
Definition AMReX_GpuLaunch.H:37
#define AMREX_LAUNCH_KERNEL_NOBOUND(blocks, threads, sharedMem, stream,...)
Definition AMReX_GpuLaunch.H:39
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
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
static unsigned int maxBlocksPerLaunch() noexcept
Definition AMReX_GpuDevice.H:242
static constexpr int warp_size
Definition AMReX_GpuDevice.H:239
Definition AMReX_GpuKernelInfo.H:8
amrex_long Long
Definition AMReX_INT.H:30
__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:54
__host__ __device__ range_detail::range_impl< T > Range(T const &b) noexcept
Definition AMReX_GpuRange.H:128
void streamSynchronize() noexcept
Definition AMReX_GpuDevice.H:329
bool inLaunchRegion() noexcept
Definition AMReX_GpuControl.H:88
Vector< ExecConfig > makeNExecutionConfigs(Long N) noexcept
Definition AMReX_GpuLaunch.H:181
ExecutionConfig makeExecutionConfig(Long N) noexcept
Definition AMReX_GpuLaunch.H:153
gpuStream_t gpuStream() noexcept
Definition AMReX_GpuDevice.H:310
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 HostDeviceParallelFor(T n, L &&f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:732
@ F
Definition AMReX_Order.H:7
void For(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:400
randState_t * getRandState()
Definition AMReX_RandomEngine.H:65
void launch(T const &n, L const &f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:122
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:202
void HostDeviceFor(T n, L &&f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:835
curandState_t randState_t
Definition AMReX_RandomEngine.H:58
bool isEmpty(T n) noexcept
Definition AMReX_GpuRange.H:15
IntVectND(const Array< int, dim > &) -> IntVectND< dim >
void single_task(L &&f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:1245
AMREX_ATTRIBUTE_FLATTEN_FOR void ParallelForRNG(T n, L const &f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:1157
void LoopConcurrentOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition AMReX_Loop.H:388
cudaStream_t gpuStream_t
Definition AMReX_GpuControl.H:79
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:244
__host__ __device__ constexpr int get(IntVectND< dim > const &iv) noexcept
Get the Idx-th element of IntVectND<dim>.
Definition AMReX_IntVect.H:1360
Utility that maps flattened point indices back to IntVectND coordinates.
Definition AMReX_Box.H:2496
__host__ __device__ IntVectND< dim > intVect(std::uint64_t icell) const
Convert flattened point index icell to its IntVectND coordinate.
Definition AMReX_Box.H:2519
__host__ __device__ std::uint64_t numPts() const
Return the number of points covered by the indexed box.
Definition AMReX_Box.H:2554
Definition AMReX_GpuLaunch.H:121
dim3 numThreads
Definition AMReX_GpuLaunch.H:147
Definition AMReX_GpuTypes.H:86
Definition AMReX_TypeTraits.H:102
Definition AMReX_RandomEngine.H:72