# include <deal.II/lac/cuda_atomic.h>
+# include <assert.h>
+
DEAL_II_NAMESPACE_OPEN
namespace LinearAlgebra
*
* @ingroup CUDAWrappers
*/
+ template <typename Number>
struct Binop_Addition
{
- template <typename Number>
__device__ static inline Number
operation(const Number a, const Number b)
{
}
};
+ template <typename Number>
+ struct Binop_Addition<std::complex<Number>>
+ {
+ __device__ static inline std::complex<Number>
+ operation(const std::complex<Number> a, const std::complex<Number> b)
+ {
+ printf("This function is not implemented for std::complex<Number>!");
+ assert(false);
+ return {};
+ }
+ };
+
/**
*
* @ingroup CUDAWrappers
*/
+ template <typename Number>
struct Binop_Subtraction
{
- template <typename Number>
__device__ static inline Number
operation(const Number a, const Number b)
{
*
* @ingroup CUDAWrappers
*/
- template <typename Number, typename Binop>
+ template <typename Number, template <typename> class Binop>
__global__ void
- vector_bin_op(Number *v1, Number *v2, const size_type N);
+ vector_bin_op(Number *v1, const Number *v2, const size_type N);
- template <typename Number, typename Binop>
+ template <typename Number, template <typename> class Binop>
__global__ void
- vector_bin_op(Number *v1, Number *v2, const size_type N)
+ vector_bin_op(Number *v1, const Number *v2, const size_type N)
{
const size_type idx_base =
threadIdx.x + blockIdx.x * (blockDim.x * chunk_size);
{
const size_type idx = idx_base + i * block_size;
if (idx < N)
- v1[idx] = Binop::operation(v1[idx], v2[idx]);
+ v1[idx] = Binop<Number>::operation(v1[idx], v2[idx]);
}
}
vec_scale<float>(float *, const float a, const size_type);
template __global__ void
vector_bin_op<float, Binop_Addition>(float * v1,
- float * v2,
+ const float * v2,
const size_type N);
template __global__ void
vector_bin_op<float, Binop_Subtraction>(float * v1,
- float * v2,
+ const float * v2,
const size_type N);
template struct ElemSum<float>;
template struct L1Norm<float>;
vec_scale<double>(double *, const double a, const size_type);
template __global__ void
vector_bin_op<double, Binop_Addition>(double * v1,
- double * v2,
+ const double * v2,
const size_type N);
template __global__ void
vector_bin_op<double, Binop_Subtraction>(double * v1,
- double * v2,
+ const double * v2,
const size_type N);
template struct ElemSum<double>;
template struct L1Norm<double>;