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>();
408 const auto nthreads_per_block = ec.numThreads.x;
409 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
410 auto& q = Gpu::Device::streamQueue();
412 if (info.hasReduction()) {
413 q.submit([&] (sycl::handler& h) {
414 sycl::local_accessor<unsigned long long>
417 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
418 sycl::range<1>(nthreads_per_block)),
419 [=] (sycl::nd_item<1> item)
420 [[sycl::reqd_work_group_size(MT)]]
423 for (UInt icell = UInt(item.get_global_id(0)), stride = UInt(item.get_global_range(0));
424 icell < indexer.numPts(); icell += stride) {
425 auto iv = indexer.intVect(icell);
426 int n_active_threads =
amrex::min(indexer.numPts()-icell+UInt(item.get_local_id(0)),
427 UInt(item.get_local_range(0)));
428 if constexpr (detail::is_big_kernel<L>()) {
429 detail::call_f_intvect_handler(*pf,
431 shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get(),
434 detail::call_f_intvect_handler(f,
436 shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get(),
443 q.submit([&] (sycl::handler& h) {
444 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
445 sycl::range<1>(nthreads_per_block)),
446 [=] (sycl::nd_item<1> item)
447 [[sycl::reqd_work_group_size(MT)]]
450 for (UInt icell = UInt(item.get_global_id(0)), stride = UInt(item.get_global_range(0));
451 icell < indexer.numPts(); icell += stride) {
452 auto iv = indexer.intVect(icell);
453 if constexpr (detail::is_big_kernel<L>()) {
454 detail::call_f_intvect_handler(*pf,iv,
Gpu::Handler{&item});
456 detail::call_f_intvect_handler(f,iv,
Gpu::Handler{&item});
462 }
catch (sycl::exception
const& ex) {
463 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
467template <
int MT, std::
integral T,
typename L,
int dim>
473 L
const* pf = skdp.template
get<0>();
479 const auto nthreads_per_block = ec.numThreads.x;
480 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
481 auto& q = Gpu::Device::streamQueue();
483 if (info.hasReduction()) {
484 q.submit([&] (sycl::handler& h) {
485 sycl::local_accessor<unsigned long long>
488 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
489 sycl::range<1>(nthreads_per_block)),
490 [=] (sycl::nd_item<1> item)
491 [[sycl::reqd_work_group_size(MT)]]
494 for (UInt icell = UInt(item.get_global_id(0)), stride = UInt(item.get_global_range(0));
495 icell < indexer.numPts(); icell += stride) {
496 auto iv = indexer.intVect(icell);
497 int n_active_threads =
amrex::min(indexer.numPts()-icell+UInt(item.get_local_id(0)),
498 UInt(item.get_local_range(0)));
499 if constexpr (detail::is_big_kernel<L>()) {
500 detail::call_f_intvect_ncomp_handler(*pf, iv, ncomp,
501 Gpu::Handler{&item, shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get(),
504 detail::call_f_intvect_ncomp_handler(f, iv, ncomp,
505 Gpu::Handler{&item, shared_data.get_multi_ptr<sycl::access::decorated::yes>().
get(),
512 q.submit([&] (sycl::handler& h) {
513 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
514 sycl::range<1>(nthreads_per_block)),
515 [=] (sycl::nd_item<1> item)
516 [[sycl::reqd_work_group_size(MT)]]
519 for (UInt icell = UInt(item.get_global_id(0)), stride = UInt(item.get_global_range(0));
520 icell < indexer.numPts(); icell += stride) {
521 auto iv = indexer.intVect(icell);
522 if constexpr (detail::is_big_kernel<L>()) {
523 detail::call_f_intvect_ncomp_handler(*pf,iv,ncomp,
Gpu::Handler{&item});
525 detail::call_f_intvect_ncomp_handler(f,iv,ncomp,
Gpu::Handler{&item});
531 }
catch (sycl::exception
const& ex) {
532 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
536template <std::
integral T,
typename L>
542 L
const* pf = skdp.template
get<0>();
546 const auto nthreads_per_block = ec.numThreads.x;
548 auto& q = Gpu::Device::streamQueue();
549 auto& engdescr = *(getRandEngineDescriptor());
551 q.submit([&] (sycl::handler& h) {
552 auto engine_acc = engdescr.get_access(h);
553 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
554 sycl::range<1>(nthreads_per_block)),
555 [=] (sycl::nd_item<1> item)
556 [[sycl::reqd_work_group_size(AMREX_GPU_MAX_THREADS)]]
559 auto const tid = item.get_global_id(0);
560 auto engine = engine_acc.load(tid);
562 for (std::size_t i = tid, stride = item.get_global_range(0); i < std::size_t(n); i += stride) {
563 if constexpr (detail::is_big_kernel<L>()) {
564 (*pf)(T(i),rand_eng);
569 engine_acc.store(engine, tid);
573 }
catch (sycl::exception
const& ex) {
574 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
578template <
typename L,
int dim>
584 L
const* pf = skdp.template
get<0>();
590 const auto nthreads_per_block = ec.numThreads.x;
592 auto& q = Gpu::Device::streamQueue();
593 auto& engdescr = *(getRandEngineDescriptor());
595 q.submit([&] (sycl::handler& h) {
596 auto engine_acc = engdescr.get_access(h);
597 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
598 sycl::range<1>(nthreads_per_block)),
599 [=] (sycl::nd_item<1> item)
600 [[sycl::reqd_work_group_size(AMREX_GPU_MAX_THREADS)]]
603 auto const tid = item.get_global_id(0);
604 auto engine = engine_acc.load(tid);
606 for (UInt icell = UInt(tid), stride = UInt(item.get_global_range(0));
607 icell < indexer.numPts(); icell += stride) {
608 auto iv = indexer.intVect(icell);
609 if constexpr (detail::is_big_kernel<L>()) {
610 detail::call_f_intvect_engine(*pf,iv,rand_eng);
612 detail::call_f_intvect_engine(f,iv,rand_eng);
615 engine_acc.store(engine, tid);
619 }
catch (sycl::exception
const& ex) {
620 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
624template <std::
integral T,
typename L,
int dim>
630 L
const* pf = skdp.template
get<0>();
636 const auto nthreads_per_block = ec.numThreads.x;
638 auto& q = Gpu::Device::streamQueue();
639 auto& engdescr = *(getRandEngineDescriptor());
641 q.submit([&] (sycl::handler& h) {
642 auto engine_acc = engdescr.get_access(h);
643 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
644 sycl::range<1>(nthreads_per_block)),
645 [=] (sycl::nd_item<1> item)
646 [[sycl::reqd_work_group_size(AMREX_GPU_MAX_THREADS)]]
649 auto const tid = item.get_global_id(0);
650 auto engine = engine_acc.load(tid);
652 for (UInt icell = UInt(tid), stride = UInt(item.get_global_range(0));
653 icell < indexer.numPts(); icell += stride) {
654 auto iv = indexer.intVect(icell);
655 if constexpr (detail::is_big_kernel<L>()) {
656 detail::call_f_intvect_ncomp_engine(*pf,iv,ncomp,rand_eng);
658 detail::call_f_intvect_ncomp_engine(f,iv,ncomp,rand_eng);
661 engine_acc.store(engine, tid);
665 }
catch (sycl::exception
const& ex) {
666 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
670template <
int MT,
typename L1,
typename L2,
int dim>
676 L1
const* pf1 = skdp.template
get<0>();
677 L2
const* pf2 = skdp.template
get<1>();
684 const auto nthreads_per_block = ec.numThreads.x;
685 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
686 auto& q = Gpu::Device::streamQueue();
688 q.submit([&] (sycl::handler& h) {
689 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
690 sycl::range<1>(nthreads_per_block)),
691 [=] (sycl::nd_item<1> item)
692 [[sycl::reqd_work_group_size(MT)]]
695 auto const ncells = std::max(indexer1.numPts(), indexer2.numPts());
696 for (UInt icell = UInt(item.get_global_id(0)), stride = UInt(item.get_global_range(0));
697 icell < ncells; icell += stride) {
698 if (icell < indexer1.numPts()) {
699 auto iv = indexer1.intVect(icell);
700 if constexpr (detail::is_big_kernel<L1,L2>()) {
701 detail::call_f_intvect(*pf1,iv);
703 detail::call_f_intvect(f1,iv);
706 if (icell < indexer2.numPts()) {
707 auto iv = indexer2.intVect(icell);
708 if constexpr (detail::is_big_kernel<L1,L2>()) {
709 detail::call_f_intvect(*pf2,iv);
711 detail::call_f_intvect(f2,iv);
717 }
catch (sycl::exception
const& ex) {
718 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
722template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
725 L1
const& f1, L2
const& f2, L3
const& f3)
729 detail::SyclKernelDevPtr<L1,L2,L3> skdp(f1, f2, f3,
Gpu::gpuStream());
730 L1
const* pf1 = skdp.template
get<0>();
731 L2
const* pf2 = skdp.template
get<1>();
732 L3
const* pf3 = skdp.template
get<2>();
740 const auto nthreads_per_block = ec.
numThreads.x;
741 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
742 auto& q = Gpu::Device::streamQueue();
744 q.submit([&] (sycl::handler& h) {
745 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
746 sycl::range<1>(nthreads_per_block)),
747 [=] (sycl::nd_item<1> item)
748 [[sycl::reqd_work_group_size(MT)]]
751 auto const ncells =
amrex::max(indexer1.numPts(), indexer2.numPts(), indexer3.numPts());
752 for (UInt icell = UInt(item.get_global_id(0)), stride = UInt(item.get_global_range(0));
753 icell < ncells; icell += stride) {
754 if (icell < indexer1.numPts()) {
755 auto iv = indexer1.intVect(icell);
756 if constexpr (detail::is_big_kernel<L1,L2,L3>()) {
757 detail::call_f_intvect(*pf1,iv);
759 detail::call_f_intvect(f1,iv);
762 if (icell < indexer2.numPts()) {
763 auto iv = indexer2.intVect(icell);
764 if constexpr (detail::is_big_kernel<L1,L2,L3>()) {
765 detail::call_f_intvect(*pf2,iv);
767 detail::call_f_intvect(f2,iv);
770 if (icell < indexer3.numPts()) {
771 auto iv = indexer3.intVect(icell);
772 if constexpr (detail::is_big_kernel<L1,L2,L3>()) {
773 detail::call_f_intvect(*pf3,iv);
775 detail::call_f_intvect(f3,iv);
781 }
catch (sycl::exception
const& ex) {
782 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
786template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
788 BoxND<dim> const& box1, T1 ncomp1, L1
const& f1,
789 BoxND<dim> const& box2, T2 ncomp2, L2
const& f2)
794 L1
const* pf1 = skdp.template
get<0>();
795 L2
const* pf2 = skdp.template
get<1>();
802 const auto nthreads_per_block = ec.numThreads.x;
803 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
804 auto& q = Gpu::Device::streamQueue();
806 q.submit([&] (sycl::handler& h) {
807 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
808 sycl::range<1>(nthreads_per_block)),
809 [=] (sycl::nd_item<1> item)
810 [[sycl::reqd_work_group_size(MT)]]
813 auto const ncells = std::max(indexer1.numPts(), indexer2.numPts());
814 for (UInt icell = UInt(item.get_global_id(0)), stride = UInt(item.get_global_range(0));
815 icell < ncells; icell += stride) {
816 if (icell < indexer1.numPts()) {
817 auto iv = indexer1.intVect(icell);
818 if constexpr (detail::is_big_kernel<L1,L2>()) {
819 detail::call_f_intvect_ncomp(*pf1,iv,ncomp1);
821 detail::call_f_intvect_ncomp(f1,iv,ncomp1);
824 if (icell < indexer2.numPts()) {
825 auto iv = indexer2.intVect(icell);
826 if constexpr (detail::is_big_kernel<L1,L2>()) {
827 detail::call_f_intvect_ncomp(*pf2,iv,ncomp2);
829 detail::call_f_intvect_ncomp(f2,iv,ncomp2);
835 }
catch (sycl::exception
const& ex) {
836 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
840template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
842 BoxND<dim> const& box1, T1 ncomp1, L1
const& f1,
843 BoxND<dim> const& box2, T2 ncomp2, L2
const& f2,
844 BoxND<dim> const& box3, T3 ncomp3, L3
const& f3)
848 detail::SyclKernelDevPtr<L1,L2,L3> skdp(f1, f2, f3,
Gpu::gpuStream());
849 L1
const* pf1 = skdp.template
get<0>();
850 L2
const* pf2 = skdp.template
get<1>();
851 L3
const* pf3 = skdp.template
get<2>();
859 const auto nthreads_per_block = ec.
numThreads.x;
860 const auto nthreads_total = std::size_t(nthreads_per_block) * ec.numBlocks.x;
861 auto& q = Gpu::Device::streamQueue();
863 q.submit([&] (sycl::handler& h) {
864 h.parallel_for(sycl::nd_range<1>(sycl::range<1>(nthreads_total),
865 sycl::range<1>(nthreads_per_block)),
866 [=] (sycl::nd_item<1> item)
867 [[sycl::reqd_work_group_size(MT)]]
870 auto const ncells =
amrex::max(indexer1.numPts(), indexer2.numPts(), indexer3.numPts());
871 for (UInt icell = UInt(item.get_global_id(0)), stride = UInt(item.get_global_range(0));
872 icell < ncells; icell += stride) {
873 if (icell < indexer1.numPts()) {
874 auto iv = indexer1.intVect(icell);
875 if constexpr (detail::is_big_kernel<L1,L2,L3>()) {
876 detail::call_f_intvect_ncomp(*pf1,iv,ncomp1);
878 detail::call_f_intvect_ncomp(f1,iv,ncomp1);
881 if (icell < indexer2.numPts()) {
882 auto iv = indexer2.intVect(icell);
883 if constexpr (detail::is_big_kernel<L1,L2,L3>()) {
884 detail::call_f_intvect_ncomp(*pf2,iv,ncomp2);
886 detail::call_f_intvect_ncomp(f2,iv,ncomp2);
889 if (icell < indexer3.numPts()) {
890 auto iv = indexer3.intVect(icell);
891 if constexpr (detail::is_big_kernel<L1,L2,L3>()) {
892 detail::call_f_intvect_ncomp(*pf3,iv,ncomp3);
894 detail::call_f_intvect_ncomp(f3,iv,ncomp3);
900 }
catch (sycl::exception
const& ex) {
901 amrex::Abort(std::string(
"ParallelFor: ")+ex.what()+
"!!!!!");
915template <
int MT,
typename L>
923template <
int MT,
typename L>
931void launch (
int nblocks,
int nthreads_per_block, std::size_t shared_mem_bytes,
941 launch(nblocks, nthreads_per_block, 0, stream, std::forward<L>(f));
944template<
int MT, std::
integral T,
typename L>
947 static_assert(
sizeof(T) >= 2);
950 for (
auto const& ec : nec) {
951 const T start_idx = T(ec.start_idx);
952 const T nleft = n - start_idx;
955 auto tid = std::uint64_t(MT)*blockIdx.x+threadIdx.x;
956 if (tid < std::uint64_t(nleft)) {
964template<
int MT,
int dim,
typename L>
971 const auto type = box.
ixType();
972 for (
auto const& ec : nec) {
973 const auto start_idx = UInt(ec.start_idx);
976 auto icell = UInt(MT)*blockIdx.x+threadIdx.x + start_idx;
977 if (icell < indexer.
numPts()) {
978 auto iv = indexer.
intVect(icell);
990template <
int MT, std::
integral T,
typename L>
991requires (MaybeDeviceRunnable<L>::value)
995 static_assert(
sizeof(T) >= 2);
998 for (
auto const& ec : nec) {
999 const T start_idx = T(ec.start_idx);
1000 const T nleft = n - start_idx;
1003 auto tid = std::uint64_t(MT)*blockIdx.x+threadIdx.x;
1004 if (tid < std::uint64_t(nleft)) {
1005 detail::call_f_scalar_handler(f, T(tid)+start_idx,
1007 (std::uint64_t)MT)));
1018template <
int MT,
typename L,
int dim>
1019requires (MaybeDeviceRunnable<L>::value)
1027 for (
auto const& ec : nec) {
1028 const auto start_idx = UInt(ec.start_idx);
1031 auto icell = UInt(MT)*blockIdx.x+threadIdx.x + start_idx;
1032 if (icell < indexer.
numPts()) {
1033 auto iv = indexer.
intVect(icell);
1034 detail::call_f_intvect_handler(f, iv,
1047template <
int MT, std::
integral T,
typename L,
int dim>
1048requires (MaybeDeviceRunnable<L>::value)
1056 for (
auto const& ec : nec) {
1057 const auto start_idx = UInt(ec.start_idx);
1060 auto icell = UInt(MT)*blockIdx.x+threadIdx.x + start_idx;
1061 if (icell < indexer.
numPts()) {
1062 auto iv = indexer.
intVect(icell);
1063 detail::call_f_intvect_ncomp_handler(f, iv, ncomp,
1077template <std::
integral T,
typename L>
1078requires (MaybeDeviceRunnable<L>::value)
1089 Long tid =
Long(AMREX_GPU_MAX_THREADS)*blockIdx.x+threadIdx.x;
1091 for (
Long i = tid, stride =
Long(AMREX_GPU_MAX_THREADS)*gridDim.x; i <
Long(n); i += stride) {
1104template <
typename L,
int dim>
1105requires (MaybeDeviceRunnable<L>::value)
1118 auto const tid = std::uint64_t(AMREX_GPU_MAX_THREADS)*blockIdx.x+threadIdx.x;
1120 for (UInt icell = UInt(tid), stride = UInt(AMREX_GPU_MAX_THREADS)*gridDim.x; icell < indexer.
numPts(); icell += stride) {
1121 auto iv = indexer.
intVect(icell);
1122 detail::call_f_intvect_engine(f, iv, engine);
1134template <std::
integral T,
typename L,
int dim>
1135requires (MaybeDeviceRunnable<L>::value)
1148 auto const tid = std::uint64_t(AMREX_GPU_MAX_THREADS)*blockIdx.x+threadIdx.x;
1150 for (UInt icell = UInt(tid), stride = UInt(AMREX_GPU_MAX_THREADS)*gridDim.x; icell < indexer.
numPts(); icell += stride) {
1151 auto iv = indexer.
intVect(icell);
1152 detail::call_f_intvect_ncomp_engine(f, iv, ncomp, engine);
1163template <
int MT,
typename L1,
typename L2,
int dim>
1164requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value)
1176 auto const ncells = std::max(indexer1.
numPts(), indexer2.
numPts());
1177 for (UInt icell = UInt(MT)*blockIdx.x+threadIdx.x, stride = UInt(MT)*gridDim.x;
1178 icell < ncells; icell += stride) {
1179 if (icell < indexer1.
numPts()) {
1180 auto iv = indexer1.
intVect(icell);
1181 detail::call_f_intvect(f1, iv);
1183 if (icell < indexer2.
numPts()) {
1184 auto iv = indexer2.
intVect(icell);
1185 detail::call_f_intvect(f2, iv);
1196template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1197requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value &&
1198 MaybeDeviceRunnable<L3>::value)
1202 L1&& f1, L2&& f2, L3&& f3)
1212 auto const ncells = std::max({indexer1.
numPts(), indexer2.
numPts(), indexer3.
numPts()});
1213 for (UInt icell = UInt(MT)*blockIdx.x+threadIdx.x, stride = UInt(MT)*gridDim.x;
1214 icell < ncells; icell += stride) {
1215 if (icell < indexer1.
numPts()) {
1216 auto iv = indexer1.
intVect(icell);
1217 detail::call_f_intvect(f1, iv);
1219 if (icell < indexer2.
numPts()) {
1220 auto iv = indexer2.
intVect(icell);
1221 detail::call_f_intvect(f2, iv);
1223 if (icell < indexer3.
numPts()) {
1224 auto iv = indexer3.
intVect(icell);
1225 detail::call_f_intvect(f3, iv);
1236template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1237requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value)
1250 auto const ncells = std::max(indexer1.
numPts(), indexer2.
numPts());
1251 for (UInt icell = UInt(MT)*blockIdx.x+threadIdx.x, stride = UInt(MT)*gridDim.x;
1252 icell < ncells; icell += stride) {
1253 if (icell < indexer1.
numPts()) {
1254 auto iv = indexer1.
intVect(icell);
1255 detail::call_f_intvect_ncomp(f1, iv, ncomp1);
1257 if (icell < indexer2.
numPts()) {
1258 auto iv = indexer2.
intVect(icell);
1259 detail::call_f_intvect_ncomp(f2, iv, ncomp2);
1270template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1271requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value &&
1272 MaybeDeviceRunnable<L3>::value)
1287 auto const ncells = std::max({indexer1.
numPts(), indexer2.
numPts(), indexer3.
numPts()});
1288 for (UInt icell = UInt(MT)*blockIdx.x+threadIdx.x, stride = UInt(MT)*gridDim.x;
1289 icell < ncells; icell += stride) {
1290 if (icell < indexer1.
numPts()) {
1291 auto iv = indexer1.
intVect(icell);
1292 detail::call_f_intvect_ncomp(f1, iv, ncomp1);
1294 if (icell < indexer2.
numPts()) {
1295 auto iv = indexer2.
intVect(icell);
1296 detail::call_f_intvect_ncomp(f2, iv, ncomp2);
1298 if (icell < indexer3.
numPts()) {
1299 auto iv = indexer3.
intVect(icell);
1300 detail::call_f_intvect_ncomp(f3, iv, ncomp3);
1309template <
typename L>
1315template<
typename T,
typename L>
1325template <std::
integral T,
typename L>
1326requires (MaybeDeviceRunnable<L>::value)
1337template <
typename L,
int dim>
1338requires (MaybeDeviceRunnable<L>::value)
1349template <std::
integral T,
typename L,
int dim>
1350requires (MaybeDeviceRunnable<L>::value)
1361template <
typename L1,
typename L2,
int dim>
1362requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value)
1368 std::forward<L2>(f2));
1375template <
typename L1,
typename L2,
typename L3,
int dim>
1376requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value &&
1377 MaybeDeviceRunnable<L3>::value)
1381 L1&& f1, L2&& f2, L3&& f3)
noexcept
1384 std::forward<L2>(f2), std::forward<L3>(f3));
1391template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1392requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value)
1396 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1399 box2, ncomp2, std::forward<L2>(f2));
1406template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1407requires (MaybeDeviceRunnable<L1>::value && MaybeDeviceRunnable<L2>::value &&
1408 MaybeDeviceRunnable<L3>::value)
1413 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1416 box2, ncomp2, std::forward<L2>(f2),
1417 box3, ncomp3, std::forward<L3>(f3));
1420template <std::
integral T,
typename L>
1421void For (Gpu::KernelInfo
const& info, T n, L&& f)
noexcept
1426template <
int MT, std::
integral T,
typename L>
1432template <
typename L,
int dim>
1438template <
int MT,
typename L,
int dim>
1444template <std::
integral T,
typename L,
int dim>
1450template <
int MT, std::
integral T,
typename L,
int dim>
1456template <
typename L1,
typename L2,
int dim>
1463template <
int MT,
typename L1,
typename L2,
int dim>
1467 ParallelFor<MT>(info,box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
1470template <
typename L1,
typename L2,
typename L3,
int dim>
1473 L1&& f1, L2&& f2, L3&& f3)
noexcept
1478template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1481 L1&& f1, L2&& f2, L3&& f3)
noexcept
1483 ParallelFor<MT>(info,box1,box2,box3,std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1486template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1489 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1494template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1497 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1499 ParallelFor<MT>(info,box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
1502template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1506 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1509 box1,ncomp1,std::forward<L1>(f1),
1510 box2,ncomp2,std::forward<L2>(f2),
1511 box3,ncomp3,std::forward<L3>(f3));
1514template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1518 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1521 box1,ncomp1,std::forward<L1>(f1),
1522 box2,ncomp2,std::forward<L2>(f2),
1523 box3,ncomp3,std::forward<L3>(f3));
1530template <std::
integral T,
typename L>
1540template <
int MT, std::
integral T,
typename L>
1550template <
typename L,
int dim>
1560template <
int MT,
typename L,
int dim>
1561void ParallelFor (BoxND<dim>
const& box, L&& f)
noexcept
1570template <std::
integral T,
typename L,
int dim>
1580template <
int MT, std::
integral T,
typename L,
int dim>
1581void ParallelFor (BoxND<dim>
const& box, T ncomp, L&& f)
noexcept
1590template <
typename L1,
typename L2,
int dim>
1600template <
int MT,
typename L1,
typename L2,
int dim>
1610template <
typename L1,
typename L2,
typename L3,
int dim>
1612 L1&& f1, L2&& f2, L3&& f3)
noexcept
1621template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1623 L1&& f1, L2&& f2, L3&& f3)
noexcept
1632template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1634 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1643template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1645 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1654template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1657 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1660 box1,ncomp1,std::forward<L1>(f1),
1661 box2,ncomp2,std::forward<L2>(f2),
1662 box3,ncomp3,std::forward<L3>(f3));
1669template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1672 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1675 box1,ncomp1,std::forward<L1>(f1),
1676 box2,ncomp2,std::forward<L2>(f2),
1677 box3,ncomp3,std::forward<L3>(f3));
1680template <std::
integral T,
typename L>
1686template <
int MT, std::
integral T,
typename L>
1687void For (T n, L&& f)
noexcept
1692template <
typename L,
int dim>
1698template <
int MT,
typename L,
int dim>
1699void For (BoxND<dim>
const& box, L&& f)
noexcept
1704template <std::
integral T,
typename L,
int dim>
1710template <
int MT, std::
integral T,
typename L,
int dim>
1711void For (BoxND<dim>
const& box, T ncomp, L&& f)
noexcept
1716template <
typename L1,
typename L2,
int dim>
1722template <
int MT,
typename L1,
typename L2,
int dim>
1728template <
typename L1,
typename L2,
typename L3,
int dim>
1730 L1&& f1, L2&& f2, L3&& f3)
noexcept
1735template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1737 L1&& f1, L2&& f2, L3&& f3)
noexcept
1742template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1744 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1749template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1751 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
1756template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1759 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1762 box1,ncomp1,std::forward<L1>(f1),
1763 box2,ncomp2,std::forward<L2>(f2),
1764 box3,ncomp3,std::forward<L3>(f3));
1767template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1770 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
1773 box1,ncomp1,std::forward<L1>(f1),
1774 box2,ncomp2,std::forward<L2>(f2),
1775 box3,ncomp3,std::forward<L3>(f3));
1778template <std::
integral T,
typename L>
1787 for (T i = 0; i < n; ++i) { f(i); }
1791template <
int MT, std::
integral T,
typename L>
1792requires (MaybeHostDeviceRunnable<L>::value)
1800 for (T i = 0; i < n; ++i) { f(i); }
1804template <std::
integral T,
typename L>
1805requires (MaybeHostDeviceRunnable<L>::value)
1812template <
int MT, std::
integral T,
typename L>
1813requires (MaybeHostDeviceRunnable<L>::value)
1820template <
typename L,
int dim>
1821requires (MaybeHostDeviceRunnable<L>::value)
1832template <
int MT,
typename L,
int dim>
1833requires (MaybeHostDeviceRunnable<L>::value)
1844template <std::
integral T,
typename L,
int dim>
1845requires (MaybeHostDeviceRunnable<L>::value)
1856template <
int MT, std::
integral T,
typename L,
int dim>
1857requires (MaybeHostDeviceRunnable<L>::value)
1868template <
typename L1,
typename L2,
int dim>
1869requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value)
1882template <
int MT,
typename L1,
typename L2,
int dim>
1883requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value)
1889 ParallelFor<MT>(info,box1,box2,std::forward<L1>(f1),std::forward<L2>(f2));
1896template <
typename L1,
typename L2,
typename L3,
int dim>
1897requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value &&
1898 MaybeHostDeviceRunnable<L3>::value)
1902 L1&& f1, L2&& f2, L3&& f3)
1906 std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1914template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
1915requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value &&
1916 MaybeHostDeviceRunnable<L3>::value)
1920 L1&& f1, L2&& f2, L3&& f3)
1924 std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
1932template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1933requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value)
1947template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
1948requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value)
1955 ParallelFor<MT>(info,box1,ncomp1,std::forward<L1>(f1),box2,ncomp2,std::forward<L2>(f2));
1962template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1963requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value &&
1964 MaybeHostDeviceRunnable<L3>::value)
1973 box1,ncomp1,std::forward<L1>(f1),
1974 box2,ncomp2,std::forward<L2>(f2),
1975 box3,ncomp3,std::forward<L3>(f3));
1983template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
1984requires (MaybeHostDeviceRunnable<L1>::value && MaybeHostDeviceRunnable<L2>::value &&
1985 MaybeHostDeviceRunnable<L3>::value)
1994 box1,ncomp1,std::forward<L1>(f1),
1995 box2,ncomp2,std::forward<L2>(f2),
1996 box3,ncomp3,std::forward<L3>(f3));
2004template <std::
integral T,
typename L>
2005void HostDeviceFor (Gpu::KernelInfo
const& info, T n, L&& f)
noexcept
2010template <
int MT, std::
integral T,
typename L>
2016template <
typename L,
int dim>
2022template <
int MT,
typename L,
int dim>
2028template <std::
integral T,
typename L,
int dim>
2034template <
int MT, std::
integral T,
typename L,
int dim>
2040template <
typename L1,
typename L2,
int dim>
2047template <
int MT,
typename L1,
typename L2,
int dim>
2054template <
typename L1,
typename L2,
typename L3,
int dim>
2057 L1&& f1, L2&& f2, L3&& f3)
noexcept
2060 std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
2063template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
2066 L1&& f1, L2&& f2, L3&& f3)
noexcept
2069 std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
2072template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
2075 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
2080template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
2083 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
2088template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
2092 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
2095 box1,ncomp1,std::forward<L1>(f1),
2096 box2,ncomp2,std::forward<L2>(f2),
2097 box3,ncomp3,std::forward<L3>(f3));
2100template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
2104 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
2107 box1,ncomp1,std::forward<L1>(f1),
2108 box2,ncomp2,std::forward<L2>(f2),
2109 box3,ncomp3,std::forward<L3>(f3));
2112template <std::
integral T,
typename L>
2118template <
int MT, std::
integral T,
typename L>
2124template <
typename L,
int dim>
2130template <
int MT,
typename L,
int dim>
2136template <std::
integral T,
typename L,
int dim>
2142template <
int MT, std::
integral T,
typename L,
int dim>
2148template <
typename L1,
typename L2,
int dim>
2154template <
int MT,
typename L1,
typename L2,
int dim>
2160template <
typename L1,
typename L2,
typename L3,
int dim>
2162 L1&& f1, L2&& f2, L3&& f3)
noexcept
2165 std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
2168template <
int MT,
typename L1,
typename L2,
typename L3,
int dim>
2170 L1&& f1, L2&& f2, L3&& f3)
noexcept
2173 std::forward<L1>(f1),std::forward<L2>(f2),std::forward<L3>(f3));
2176template <std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
2178 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
2183template <
int MT, std::
integral T1, std::
integral T2,
typename L1,
typename L2,
int dim>
2185 BoxND<dim> const& box2, T2 ncomp2, L2&& f2)
noexcept
2190template <std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
2193 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
2196 box1,ncomp1,std::forward<L1>(f1),
2197 box2,ncomp2,std::forward<L2>(f2),
2198 box3,ncomp3,std::forward<L3>(f3));
2201template <
int MT, std::
integral T1, std::
integral T2, std::
integral T3,
typename L1,
typename L2,
typename L3,
int dim>
2204 BoxND<dim> const& box3, T3 ncomp3, L3&& f3)
noexcept
2207 box1,ncomp1,std::forward<L1>(f1),
2208 box2,ncomp2,std::forward<L2>(f2),
2209 box3,ncomp3,std::forward<L3>(f3));
#define AMREX_PRAGMA_SIMD
Definition AMReX_Extension.H:84
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:123
#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:239
__host__ __device__ constexpr int get(IntVectND< dim > const &iv) noexcept
Get the Idx-th element of IntVectND<dim>.
Definition AMReX_IntVect.H:1367
Utility that maps flattened point indices back to IntVectND coordinates.
Definition AMReX_Box.H:2509
UIntT UInt
Definition AMReX_Box.H:2511
__host__ __device__ IntVectND< dim > intVect(std::uint64_t icell) const
Convert flattened point index icell to its IntVectND coordinate.
Definition AMReX_Box.H:2541
__host__ __device__ UInt numPts() const
Return the number of points covered by the indexed box.
Definition AMReX_Box.H:2577
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