27#include <cuda_runtime.h>
46 template <
bool flag = false>
48 static_assert(flag,
"Using device functionality without gpu support! Configure project with -DCudaSupport=ON.");
66 if (success != cudaSuccess) {
67 NDA_RUNTIME_ERROR <<
"Cuda runtime error: " <<
std::to_string(success) <<
"\n"
68 <<
" message: " << message <<
"\n"
69 <<
" cudaGetErrorName: " << std::string(cudaGetErrorName(success)) <<
"\n"
70 <<
" cudaGetErrorString: " << std::string(cudaGetErrorString(success)) <<
"\n";
86 inline cublasOperation_t get_cublas_op(
char op) {
88 case 'N':
return CUBLAS_OP_N;
89 case 'T':
return CUBLAS_OP_T;
90 case 'C':
return CUBLAS_OP_C;
91 default: std::terminate();
return {};
101 inline auto cucplx(std::complex<double> c) {
return cuDoubleComplex{c.real(), c.imag()}; }
109 inline auto *cucplx(std::complex<double> *c) {
return reinterpret_cast<cuDoubleComplex *
>(c); }
117 inline auto *cucplx(std::complex<double>
const *c) {
return reinterpret_cast<const cuDoubleComplex *
>(c); }
126 inline auto **cucplx(std::complex<double> **c) {
return reinterpret_cast<cuDoubleComplex **
>(c); }
135 inline auto **cucplx(std::complex<double>
const **c) {
return reinterpret_cast<const cuDoubleComplex **
>(c); }
140#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.