41#if defined(__CUDACC__)
60#include <domain_decomposition/BlockDataID.h>
70namespace ReactionKernelIndexedSelector {
72template <
typename FloatType =
double, std::
size_t N = 1>
struct KernelTrait {
73 using ReactionKernelIndexed =
74 pystencils::ReactionKernelIndexed_1_double_precision;
77template <>
struct KernelTrait<
double, 2> {
78 using ReactionKernelIndexed =
79 pystencils::ReactionKernelIndexed_2_double_precision;
82template <>
struct KernelTrait<
double, 3> {
83 using ReactionKernelIndexed =
84 pystencils::ReactionKernelIndexed_3_double_precision;
87template <>
struct KernelTrait<
double, 4> {
88 using ReactionKernelIndexed =
89 pystencils::ReactionKernelIndexed_4_double_precision;
92template <>
struct KernelTrait<
double, 5> {
93 using ReactionKernelIndexed =
94 pystencils::ReactionKernelIndexed_5_double_precision;
97template <>
struct KernelTrait<
float, 1> {
98 using ReactionKernelIndexed =
99 pystencils::ReactionKernelIndexed_1_single_precision;
102template <>
struct KernelTrait<
float, 2> {
103 using ReactionKernelIndexed =
104 pystencils::ReactionKernelIndexed_2_single_precision;
107template <>
struct KernelTrait<
float, 3> {
108 using ReactionKernelIndexed =
109 pystencils::ReactionKernelIndexed_3_single_precision;
112template <>
struct KernelTrait<
float, 4> {
113 using ReactionKernelIndexed =
114 pystencils::ReactionKernelIndexed_4_single_precision;
117template <>
struct KernelTrait<
float, 5> {
118 using ReactionKernelIndexed =
119 pystencils::ReactionKernelIndexed_5_single_precision;
122template <
typename FloatType,
class Reactant, std::size_t...
ints>
123auto get_kernel_impl(
const std::vector<std::shared_ptr<Reactant>> &
reactants,
125 std::index_sequence<ints...>
int_seq) {
126 auto kernel = std::make_shared<
127 typename KernelTrait<FloatType,
int_seq.size()>::ReactionKernelIndexed>(
129 walberla::BlockDataID(
135 std::function<
void(IBlock *)>
sweep = [kernel](IBlock *b) { kernel->run(b); };
139template <
typename FloatType,
class Reactant,
class...
Args>
140auto get_kernel_impl(
const std::vector<std::shared_ptr<Reactant>> &
reactants,
146 std::make_index_sequence<1>{});
150 std::make_index_sequence<2>{});
154 std::make_index_sequence<3>{});
158 std::make_index_sequence<4>{});
162 std::make_index_sequence<5>{});
165 throw std::runtime_error(
"reactions of this size are not implemented!");
170auto get_kernel(
const std::vector<std::shared_ptr<Reactant>> &
reactants,
173 const auto is_double_precision =
174 reactants[0]->get_species()->is_double_precision();
176 if (is_double_precision) {
183#if defined(__CUDACC__)
185template <
typename FloatType =
double, std::
size_t N = 1>
188 pystencils::ReactionKernelIndexed_1_double_precision_CUDA;
193 pystencils::ReactionKernelIndexed_2_double_precision_CUDA;
198 pystencils::ReactionKernelIndexed_3_double_precision_CUDA;
203 pystencils::ReactionKernelIndexed_4_double_precision_CUDA;
208 pystencils::ReactionKernelIndexed_5_double_precision_CUDA;
213 pystencils::ReactionKernelIndexed_1_single_precision_CUDA;
218 pystencils::ReactionKernelIndexed_2_single_precision_CUDA;
223 pystencils::ReactionKernelIndexed_3_single_precision_CUDA;
228 pystencils::ReactionKernelIndexed_4_single_precision_CUDA;
233 pystencils::ReactionKernelIndexed_5_single_precision_CUDA;
236template <
typename FloatType,
class Reactant, std::size_t...
ints>
238 const std::vector<std::shared_ptr<Reactant>> &
reactants,
240 std::index_sequence<ints...>
int_seq) {
244 walberla::BlockDataID(
250 std::function<
void(IBlock *)>
sweep = [kernel](IBlock *b) { kernel->run(b); };
254template <
typename FloatType,
class Reactant,
class...
Args>
261 std::make_index_sequence<1>{});
265 std::make_index_sequence<2>{});
269 std::make_index_sequence<3>{});
273 std::make_index_sequence<4>{});
277 std::make_index_sequence<5>{});
280 throw std::runtime_error(
"reactions of this size are not implemented!");
288 const auto is_double_precision =
289 reactants[0]->get_species()->is_double_precision();
291 if (is_double_precision) {
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
\file PackInfoPdfDoublePrecision.cpp \author pystencils