1#ifndef AMREX_CTO_PARALLEL_FOR_H_
2#define AMREX_CTO_PARALLEL_FOR_H_
30 template<
class F,
int... ctr>
34 template<
class... Args>
36 auto operator() (Args... args)
const noexcept
37 ->
decltype(f(args..., std::integral_constant<int, ctr>{}...)) {
38 return f(args..., std::integral_constant<int, ctr>{}...);
43 std::array<
int,
sizeof...(ctr)> GetOptions ()
noexcept {
48 template <
class L,
typename... As,
class... Fs>
50 AnyCTO_helper2 (
const L& l, TypeList<As...>,
51 std::array<
int,
sizeof...(As)>
const& runtime_options,
const Fs&...cto_functs)
53 if (runtime_options == std::array<
int,
sizeof...(As)>{As::value...}) {
54 if constexpr (
sizeof...(cto_functs) != 0) {
57 l(CTOWrapper<Fs, As::value...>{cto_functs}...);
68 template <
class L,
typename... PPs,
typename RO,
class...Fs>
70 AnyCTO_helper1 (
const L& l, TypeList<PPs...>,
71 RO
const& runtime_options,
const Fs&...cto_functs)
73 bool found_option = (
false || ... ||
74 AnyCTO_helper2(l, PPs{}, runtime_options, cto_functs...));
79 template <
int Begin,
int End,
int... I>
80 constexpr auto MakeCTOImpl(std::integer_sequence<int, I...>)
81 -> CompileTimeOptions<Begin + I...>;
85template <
int Begin,
int End>
86using CTOSeq =
decltype(detail::MakeCTOImpl<Begin, End>(
87 std::make_integer_sequence<int, End - Begin>{}));
190template <
class L,
class... Fs,
typename... CTOs>
192 std::array<
int,
sizeof...(CTOs)>
const& runtime_options,
193 L&& l, Fs&&...cto_functs)
195 detail::AnyCTO_helper1(std::forward<L>(l),
198 std::forward<Fs>(cto_functs)...);
201template <
int MT, std::integral T,
class F,
typename... CTOs>
203 std::array<
int,
sizeof...(CTOs)>
const& runtime_options,
206 AnyCTO(ctos, runtime_options,
208 ParallelFor<MT>(N, cto_func);
214template <
int MT,
class F,
int dim,
typename... CTOs>
216 std::array<
int,
sizeof...(CTOs)>
const& runtime_options,
219 AnyCTO(ctos, runtime_options,
221 ParallelFor<MT>(box, cto_func);
227template <
int MT, std::integral T,
class F,
int dim,
typename... CTOs>
229 std::array<
int,
sizeof...(CTOs)>
const& runtime_options,
232 AnyCTO(ctos, runtime_options,
234 ParallelFor<MT>(box, ncomp, cto_func);
284template <std::integral T,
class F,
typename... CTOs>
286 std::array<
int,
sizeof...(CTOs)>
const& option,
289 ParallelFor<AMREX_GPU_MAX_THREADS>(ctos, option, N, std::forward<F>(f));
337template <
class F,
int dim,
typename... CTOs>
339 std::array<
int,
sizeof...(CTOs)>
const& option,
342 ParallelFor<AMREX_GPU_MAX_THREADS>(ctos, option, box, std::forward<F>(f));
391template <std::integral T,
class F,
int dim,
typename... CTOs>
393 std::array<
int,
sizeof...(CTOs)>
const& option,
396 ParallelFor<AMREX_GPU_MAX_THREADS>(ctos, option, box, ncomp, std::forward<F>(f));
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
A Rectangular Domain on an Integer Lattice.
Definition AMReX_Box.H:49
Definition AMReX_Amr.cpp:50
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:139
void AnyCTO(TypeList< CTOs... > list_of_compile_time_options, std::array< int, sizeof...(CTOs)> const &runtime_options, L &&l, Fs &&...cto_functs)
Compile time optimization of kernels with run time options.
Definition AMReX_CTOParallelForImpl.H:191
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:202
constexpr auto CartesianProduct(Ls...)
Cartesian Product of TypeLists.
Definition AMReX_TypeList.H:155
const int[]
Definition AMReX_BLProfiler.cpp:1664
decltype(detail::MakeCTOImpl< Begin, End >(std::make_integer_sequence< int, End - Begin >{})) CTOSeq
Definition AMReX_CTOParallelForImpl.H:87
Definition AMReX_CTOParallelForImpl.H:22
Struct for holding types.
Definition AMReX_TypeList.H:13