1#ifndef BASE_MACROS_CUDA_H_
2#define BASE_MACROS_CUDA_H_
5#include <cuda_runtime.h>
7#include <thrust/complex.h>
13#define THREADS_PER_BLOCK 256
24 using type = thrust::complex<float>;
30 using type = thrust::complex<double>;
34static inline cublasOperation_t GetCublasOperation(
const char& trans,
bool is_complex)
38 case 'N':
case 'n':
return CUBLAS_OP_N;
39 case 'T':
case 't':
return CUBLAS_OP_T;
40 case 'C':
case 'c':
return is_complex ? CUBLAS_OP_C : CUBLAS_OP_T;
41 default:
throw std::invalid_argument(std::string(
"Invalid BLAS transpose flag: ") + trans);
45static inline cublasOperation_t GetCublasOperation(
const char& trans)
47 return GetCublasOperation(trans,
true);
71#if CUDA_VERSION >= 11000
75 static constexpr cudaDataType
cuda_data_type = cudaDataType::CUDA_R_64I;
89static inline cublasFillMode_t cublas_fill_mode(
const char& uplo)
91 if (uplo ==
'U' || uplo ==
'u')
92 return CUBLAS_FILL_MODE_UPPER;
93 else if (uplo ==
'L' || uplo ==
'l')
94 return CUBLAS_FILL_MODE_LOWER;
96 throw std::runtime_error(std::string(
"Invalid BLAS triangle: ") + uplo);
99static inline cublasDiagType_t cublas_diag_type(
const char& diag)
101 if (diag ==
'U' || diag ==
'u')
102 return CUBLAS_DIAG_UNIT;
103 else if (diag ==
'N' || diag ==
'n')
104 return CUBLAS_DIAG_NON_UNIT;
106 throw std::runtime_error(
"cublas_diag_type: unknown diag");
109static inline cusolverEigMode_t cublas_eig_mode(
const char& jobz)
111 if (jobz ==
'N' || jobz ==
'n')
112 return CUSOLVER_EIG_MODE_NOVECTOR;
113 else if (jobz ==
'V' || jobz ==
'v')
114 return CUSOLVER_EIG_MODE_VECTOR;
116 throw std::runtime_error(
"cublas_eig_mode: unknown diag");
119static inline cusolverEigType_t cublas_eig_type(
const int& itype)
122 return CUSOLVER_EIG_TYPE_1;
124 return CUSOLVER_EIG_TYPE_2;
126 throw std::runtime_error(
"cublas_eig_mode: unknown diag");
140static inline cusolverEigRange_t cublas_eig_range(
const char& range)
142 if (range ==
'A' || range ==
'a')
143 return CUSOLVER_EIG_RANGE_ALL;
144 else if (range ==
'V' || range ==
'v')
145 return CUSOLVER_EIG_RANGE_V;
146 else if (range ==
'I' || range ==
'i')
147 return CUSOLVER_EIG_RANGE_I;
149 throw std::runtime_error(
"cublas_eig_range: unknown range '" + std::string(1, range) +
"'");
#define complex
Definition elpa_new.h:28
#define T
Definition exp.cpp:237
static constexpr cudaDataType cuda_data_type
Definition cuda.h:69
static constexpr cudaDataType cuda_data_type
Definition cuda.h:64
static constexpr cudaDataType cuda_data_type
Definition cuda.h:59
static constexpr cudaDataType cuda_data_type
Definition cuda.h:86
static constexpr cudaDataType cuda_data_type
Definition cuda.h:81
static constexpr cudaDataType cuda_data_type
Definition cuda.h:53
thrust::complex< double > type
Definition cuda.h:30
thrust::complex< float > type
Definition cuda.h:24
T type
Definition cuda.h:18