1#ifndef AMREX_CTO_PARALLEL_FOR_H_
2#define AMREX_CTO_PARALLEL_FOR_H_
28 template<
class F,
int... ctr>
32 template<
class... Args>
34 auto operator() (Args... args)
const noexcept
35 ->
decltype(f(args..., std::integral_constant<int, ctr>{}...)) {
36 return f(args..., std::integral_constant<int, ctr>{}...);
41 std::array<int,
sizeof...(ctr)> GetOptions ()
noexcept {
46 template <
class L,
typename... As,
class... Fs>
48 AnyCTO_helper2 (
const L& l, TypeList<As...>,
49 std::array<
int,
sizeof...(As)>
const& runtime_options,
const Fs&...cto_functs)
51 if (runtime_options == std::array<
int,
sizeof...(As)>{As::value...}) {
52 if constexpr (
sizeof...(cto_functs) != 0) {
55 l(CTOWrapper<Fs, As::value...>{cto_functs}...);
66 template <
class L,
typename... PPs,
typename RO,
class...Fs>
68 AnyCTO_helper1 (
const L& l, TypeList<PPs...>,
69 RO
const& runtime_options,
const Fs&...cto_functs)
71 bool found_option = (
false || ... ||
72 AnyCTO_helper2(l, PPs{}, runtime_options, cto_functs...));
180template <
class L,
class... Fs,
typename... CTOs>
182 std::array<
int,
sizeof...(CTOs)>
const& runtime_options,
183 L&& l, Fs&&...cto_functs)
185 detail::AnyCTO_helper1(std::forward<L>(l),
188 std::forward<Fs>(cto_functs)...);
191template <
int MT,
typename T,
class F,
typename... CTOs>
192std::enable_if_t<std::is_integral_v<T>>
194 std::array<
int,
sizeof...(CTOs)>
const& runtime_options,
197 AnyCTO(ctos, runtime_options,
199 ParallelFor<MT>(N, cto_func);
205template <
int MT,
class F,
int dim,
typename... CTOs>
207 std::array<
int,
sizeof...(CTOs)>
const& runtime_options,
210 AnyCTO(ctos, runtime_options,
212 ParallelFor<MT>(box, cto_func);
218template <
int MT,
typename T,
class F,
int dim,
typename... CTOs>
219std::enable_if_t<std::is_integral_v<T>>
221 std::array<
int,
sizeof...(CTOs)>
const& runtime_options,
224 AnyCTO(ctos, runtime_options,
226 ParallelFor<MT>(box, ncomp, cto_func);
276template <
typename T,
class F,
typename... CTOs>
277std::enable_if_t<std::is_integral_v<T>>
279 std::array<
int,
sizeof...(CTOs)>
const& option,
282 ParallelFor<AMREX_GPU_MAX_THREADS>(ctos, option, N, std::forward<F>(f));
330template <
class F,
int dim,
typename... CTOs>
332 std::array<
int,
sizeof...(CTOs)>
const& option,
335 ParallelFor<AMREX_GPU_MAX_THREADS>(ctos, option, box, std::forward<F>(f));
384template <
typename T,
class F,
int dim,
typename... CTOs>
385std::enable_if_t<std::is_integral_v<T>>
387 std::array<
int,
sizeof...(CTOs)>
const& option,
390 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:49
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:138
std::enable_if_t< std::is_integral_v< T > > ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:193
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:181
constexpr auto CartesianProduct(Ls...)
Cartesian Product of TypeLists.
Definition AMReX_TypeList.H:154
Definition AMReX_CTOParallelForImpl.H:20
Struct for holding types.
Definition AMReX_TypeList.H:12