Skip to content

Commit b96f7e8

Browse files
author
root
committed
Fix: cuda compiling error with CUDA<11.0
1 parent 484ccfe commit b96f7e8

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

source/source_base/module_container/base/macros/cuda.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ struct GetTypeCuda<double>
6565
{
6666
static constexpr cudaDataType cuda_data_type = cudaDataType::CUDA_R_64F;
6767
};
68+
#if CUDA_VERSION >= 11000
6869
template <>
6970
struct GetTypeCuda<int64_t>
7071
{
7172
static constexpr cudaDataType cuda_data_type = cudaDataType::CUDA_R_64I;
7273
};
74+
#endif
7375
template <>
7476
struct GetTypeCuda<std::complex<float>>
7577
{

source/source_base/module_container/base/third_party/cusolver.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
namespace container {
2020
namespace cuSolverConnector {
2121

22+
#if CUDA_VERSION >= 11000
23+
// Generic trtri using cuSOLVER generic API (CUDA 11.0+)
2224
template <typename T>
2325
static inline
2426
void trtri (cusolverDnHandle_t& cusolver_handle, const char& uplo, const char& diag, const int& n, T* A, const int& lda)
@@ -37,7 +39,7 @@ void trtri (cusolverDnHandle_t& cusolver_handle, const char& uplo, const char& d
3739
int h_info = 0;
3840
int* d_info = nullptr;
3941
cudaErrcheck(cudaMalloc((void**)&d_info, sizeof(int)));
40-
// Perform Cholesky decomposition
42+
// Perform triangular matrix inversion
4143
cusolverErrcheck(cusolverDnXtrtri(cusolver_handle, cublas_fill_mode(uplo), cublas_diag_type(diag), n, GetTypeCuda<T>::cuda_data_type, reinterpret_cast<Type*>(A), n, d_work, d_lwork, h_work, h_lwork, d_info));
4244
cudaErrcheck(cudaMemcpy(&h_info, d_info, sizeof(int), cudaMemcpyDeviceToHost));
4345
if (h_info != 0) {
@@ -47,6 +49,16 @@ void trtri (cusolverDnHandle_t& cusolver_handle, const char& uplo, const char& d
4749
cudaErrcheck(cudaFree(d_work));
4850
cudaErrcheck(cudaFree(d_info));
4951
}
52+
#else
53+
// For CUDA < 11.0, trtri is not available in cuSOLVER
54+
// Provide a stub that throws an error if called
55+
template <typename T>
56+
static inline
57+
void trtri (cusolverDnHandle_t& cusolver_handle, const char& uplo, const char& diag, const int& n, T* A, const int& lda)
58+
{
59+
throw std::runtime_error("trtri: cusolverDnXtrtri is not available in CUDA < 11.0. Please upgrade CUDA or use an alternative method.");
60+
}
61+
#endif
5062

5163
static inline
5264
void potri (cusolverDnHandle_t& cusolver_handle, const char& uplo, const char& diag, const int& n, float * A, const int& lda)

0 commit comments

Comments
 (0)