1919namespace container {
2020namespace cuSolverConnector {
2121
22+ #if CUDA_VERSION >= 11000
23+ // Generic trtri using cuSOLVER generic API (CUDA 11.0+)
2224template <typename T>
2325static inline
2426void 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
5163static inline
5264void potri (cusolverDnHandle_t& cusolver_handle, const char & uplo, const char & diag, const int & n, float * A, const int & lda)
0 commit comments