9#include <rmm/cuda_stream_pool.hpp>
10#include <rmm/device_uvector.hpp>
11#include <rmm/mr/device/pool_memory_resource.hpp>
12#include <thrust/reduce.h>
13#include <thrust/transform_reduce.h>
57 const NT res = NT(1) * std::apply([&](
auto &&...args) {
return KERNEL::kernel(q,
k, args...); },
t);
58 return int_element * res * weight;
66 const std::tuple<T...>
t;
81 const ctype qx_max = M_PI)
96 json.get_double(
"/discretization/integration/qx_min", -M_PI),
97 json.get_double(
"/discretization/integration/qx_max", M_PI))
112 json.get_double(
"/discretization/integration/qx_min", -M_PI),
113 json.get_double(
"/discretization/integration/qx_max", M_PI))
172 template <
typename... T> NT
get(
const ctype k,
const T &...t)
const
174 return KERNEL::constant(k, t...) +
175 thrust::transform_reduce(thrust::cuda::par.on(rmm::cuda_stream_per_thread.value()),
176 thrust::make_counting_iterator<uint>(0),
177 thrust::make_counting_iterator<uint>(
grid_size),
179 NT(0), thrust::plus<NT>());
190 template <
typename... T> std::future<NT>
request(
const ctype k,
const T &...t)
const
192 return std::async(std::launch::deferred, [=,
this]() {
return get(k, t...); });
212 template <
typename NT,
typename KERNEL>
class Integrator1DCartesianGPU;
221 template <
typename NT,
typename KERNEL>
class Integrator1DCartesianGPU :
public Integrator1DCartesianTBB<NT, KERNEL>
228 const ctype qx_max = M_PI)
229 : Integrator1DCartesianTBB<NT, KERNEL>(quadrature_provider,
grid_size[0], x_extent,
qx_min, qx_max)
231 (void)max_block_size;
236 : Integrator1DCartesianTBB<NT, KERNEL>(quadrature_provider,
grid_size, x_extent, x_extent,
qx_min, qx_max)
238 (void)max_block_size;
242 const ctype x_extent,
const JSONValue &json)
243 : Integrator1DCartesianTBB<NT, KERNEL>(quadrature_provider,
grid_size, x_extent, json)
Integration of an arbitrary 1D function from qx_min to qx_max using CUDA.
Definition integrator_1D_cartesian_gpu.hh:28
const ctype * ptr_x_quadrature_p
Definition integrator_1D_cartesian_gpu.hh:201
const uint grid_size
Definition integrator_1D_cartesian_gpu.hh:196
typename get_type::ctype< NT > ctype
Numerical type to be used for integration tasks e.g. the argument or possible jacobians.
Definition integrator_1D_cartesian_gpu.hh:33
Integrator1DCartesianGPU(QuadratureProvider &quadrature_provider, const std::array< uint, 1 > grid_size, const JSONValue &json)
Construct a new Integrator1DCartesianGPU object.
Definition integrator_1D_cartesian_gpu.hh:93
const ctype * ptr_x_quadrature_w
Definition integrator_1D_cartesian_gpu.hh:202
std::future< NT > request(const ctype k, const T &...t) const
Get the result of the integration asynchronously.
Definition integrator_1D_cartesian_gpu.hh:190
Integrator1DCartesianGPU(QuadratureProvider &quadrature_provider, const std::array< uint, 1 > grid_size, const ctype x_extent=0., const uint max_block_size=0, const ctype qx_min=-M_PI, const ctype qx_max=M_PI)
Construct a new Integrator1DCartesianGPU object.
Definition integrator_1D_cartesian_gpu.hh:79
ctype qx_min
Definition integrator_1D_cartesian_gpu.hh:198
void set_qx_min(const ctype qx_min)
Set the minimum value of the qx integration range.
Definition integrator_1D_cartesian_gpu.hh:153
Integrator1DCartesianGPU(QuadratureProvider &quadrature_provider, const uint grid_size, const ctype x_extent=0., const ctype qx_min=-M_PI, const ctype qx_max=M_PI)
Construct a new Integrator1DCartesianGPU object.
Definition integrator_1D_cartesian_gpu.hh:126
ctype qx_extent
Definition integrator_1D_cartesian_gpu.hh:199
Integrator1DCartesianGPU(QuadratureProvider &quadrature_provider, const std::array< uint, 1 > grid_size, const ctype x_extent, const JSONValue &json)
Construct a new Integrator1DCartesianGPU object.
Definition integrator_1D_cartesian_gpu.hh:109
Integrator1DCartesianGPU(const Integrator1DCartesianGPU &other)
Construct a copy of an existing Integrator1DCartesianGPU object.
Definition integrator_1D_cartesian_gpu.hh:142
NT get(const ctype k, const T &...t) const
Get the result of the integration.
Definition integrator_1D_cartesian_gpu.hh:172
void set_qx_max(const ctype qx_max)
Set the maximum value of the qx integration range.
Definition integrator_1D_cartesian_gpu.hh:162
A wrapper around the boost json value class.
Definition json.hh:19
A class that provides quadrature points and weights, in host and device memory. The quadrature points...
Definition quadrature_provider.hh:139
const NT * get_device_weights(const size_t order, const int device=0, const QuadratureType type=QuadratureType::legendre)
Get the device-side quadrature weights for a quadrature of size quadrature_size.
Definition quadrature_provider.hh:211
const NT * get_device_points(const size_t order, const int device=0, const QuadratureType type=QuadratureType::legendre)
Get the device-side quadrature points for a quadrature of size quadrature_size.
Definition quadrature_provider.hh:198
typename internal::_ctype< CT >::value ctype
Definition types.hh:106
Definition complex_math.hh:14
constexpr __forceinline__ __host__ __device__ NumberType powr(const NumberType x)
A compile-time evaluatable power function for whole number exponents.
Definition math.hh:45
unsigned int uint
Definition utils.hh:22
Custom functor for the thrust::transform_reduce function.
Definition integrator_1D_cartesian_gpu.hh:40
const std::tuple< T... > t
Definition integrator_1D_cartesian_gpu.hh:66
const ctype k
Definition integrator_1D_cartesian_gpu.hh:65
const ctype qx_extent
Definition integrator_1D_cartesian_gpu.hh:64
const ctype * x_quadrature_w
Definition integrator_1D_cartesian_gpu.hh:63
const ctype qx_min
Definition integrator_1D_cartesian_gpu.hh:64
const ctype * x_quadrature_p
Definition integrator_1D_cartesian_gpu.hh:62
__device__ NT operator()(const uint idx) const
Definition integrator_1D_cartesian_gpu.hh:49
functor(const ctype *x_quadrature_p, const ctype *x_quadrature_w, const ctype qx_min, const ctype qx_extent, const ctype k, T... t)
Definition integrator_1D_cartesian_gpu.hh:42