16#include <cuda_runtime.h>
35 template <
bool flag = false>
37 static_assert(flag,
"Using device functionality without gpu support! Configure project with -DCudaSupport=ON.");
55 if (success != cudaSuccess) {
56 NDA_RUNTIME_ERROR <<
"Cuda runtime error: " <<
std::to_string(success) <<
"\n"
57 <<
" message: " << message <<
"\n"
58 <<
" cudaGetErrorName: " << std::string(cudaGetErrorName(success)) <<
"\n"
59 <<
" cudaGetErrorString: " << std::string(cudaGetErrorString(success)) <<
"\n";
75 inline cublasOperation_t get_cublas_op(
char op) {
77 case 'N':
return CUBLAS_OP_N;
78 case 'T':
return CUBLAS_OP_T;
79 case 'C':
return CUBLAS_OP_C;
80 default: std::terminate();
return {};
90 inline auto cucplx(std::complex<double> c) {
return cuDoubleComplex{c.real(), c.imag()}; }
98 inline auto *cucplx(std::complex<double> *c) {
return reinterpret_cast<cuDoubleComplex *
>(c); }
106 inline auto *cucplx(std::complex<double>
const *c) {
return reinterpret_cast<const cuDoubleComplex *
>(c); }
115 inline auto **cucplx(std::complex<double> **c) {
return reinterpret_cast<cuDoubleComplex **
>(c); }
124 inline auto **cucplx(std::complex<double>
const **c) {
return reinterpret_cast<const cuDoubleComplex **
>(c); }
129#define device_error_check(ARG1, ARG2) compile_error_no_gpu()
Provides a custom runtime error class and macros to assert conditions and throw exceptions.
static constexpr bool have_cuda
Constexpr variable that is true if the project is configured with CUDA support.
#define device_error_check(ARG1, ARG2)
Trigger a compilation error every time the nda::device_error_check function is called.
static constexpr bool have_device
Constexpr variable that is true if the project is configured with GPU support.
void compile_error_no_gpu()
Trigger a compilation error in case GPU specific functionality is used without configuring the projec...
std::string to_string(std::array< T, R > const &a)
Get a string representation of a std::array.