From 35a06f86362e6f3ecbc06ad40ff2cc8b17114eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Thu, 30 Jul 2020 10:01:00 +0200 Subject: [PATCH 1/3] Updated nvcc flags for CUDA 11 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27451ef82..fa92f1f85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,7 +220,7 @@ if( ${WITH_CUDA} ) # disable false compiler warnings # reference for the -Xcudafe --diag_suppress and --display_error_number flags: https://stackoverflow.com/a/54142937 # incomplete list of tokens: http://www.ssl.berkeley.edu/~jimm/grizzly_docs/SSL/opt/intel/cc/9.0/lib/locale/en_US/mcpcom.msg - set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; -Wno-deprecated-gpu-targets --expt-relaxed-constexpr --expt-extended-lambda -Xcudafe "\"--diag_suppress=code_is_unreachable --diag_suppress=implicit_return_from_non_void_function --diag_suppress=unsigned_compare_with_zero --diag_suppress=2906 --diag_suppress=2913 --diag_suppress=2886 --diag_suppress=2929 --diag_suppress=2977 --display_error_number\"") + set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; -Wno-deprecated-gpu-targets --expt-relaxed-constexpr --expt-extended-lambda -Xcudafe --diag_suppress=code_is_unreachable -Xcudafe --diag_suppress=loop_not_reachable -Xcudafe --diag_suppress=implicit_return_from_non_void_function -Xcudafe --diag_suppress=unsigned_compare_with_zero -Xcudafe --diag_suppress=2906 -Xcudafe --diag_suppress=2913 -Xcudafe --diag_suppress=2886 -Xcudafe --diag_suppress=2929 -Xcudafe --diag_suppress=2977 -Xcudafe --diag_suppress=3057 -Xcudafe --display_error_number) # temporarily disable host-compler warnings about VLAs, which are caused by nvcc's modifications to the source code set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; -Xcompiler -Wno-vla) # Select GPU architecture -- GitLab From 3eccf1a70cbc788b2f3cbc47edf756b93699a2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Thu, 30 Jul 2020 10:02:14 +0200 Subject: [PATCH 2/3] Workaround for inherited operator= in vectors due to CUDA 11 --- src/TNL/Containers/DistributedVector.h | 2 ++ src/TNL/Containers/DistributedVectorView.h | 2 ++ src/TNL/Containers/StaticVector.h | 2 ++ src/TNL/Containers/Vector.h | 2 ++ src/TNL/Containers/VectorView.h | 2 ++ 5 files changed, 10 insertions(+) diff --git a/src/TNL/Containers/DistributedVector.h b/src/TNL/Containers/DistributedVector.h index b6ebe7e81..5d5f8303f 100644 --- a/src/TNL/Containers/DistributedVector.h +++ b/src/TNL/Containers/DistributedVector.h @@ -49,7 +49,9 @@ public: // inherit all constructors and assignment operators from Array using BaseType::DistributedArray; +#if !defined(__CUDACC_VER_MAJOR__) || __CUDACC_VER_MAJOR__ < 11 using BaseType::operator=; +#endif DistributedVector() = default; diff --git a/src/TNL/Containers/DistributedVectorView.h b/src/TNL/Containers/DistributedVectorView.h index 72bc75881..157a64b94 100644 --- a/src/TNL/Containers/DistributedVectorView.h +++ b/src/TNL/Containers/DistributedVectorView.h @@ -51,7 +51,9 @@ public: // inherit all constructors and assignment operators from ArrayView using BaseType::DistributedArrayView; +#if !defined(__CUDACC_VER_MAJOR__) || __CUDACC_VER_MAJOR__ < 11 using BaseType::operator=; +#endif // In C++14, default constructors cannot be inherited, although Clang // and GCC since version 7.0 inherit them. diff --git a/src/TNL/Containers/StaticVector.h b/src/TNL/Containers/StaticVector.h index 86726a4d3..13cdd0fbc 100644 --- a/src/TNL/Containers/StaticVector.h +++ b/src/TNL/Containers/StaticVector.h @@ -64,7 +64,9 @@ public: //! Constructors and assignment operators are inherited from the class \ref StaticArray. using StaticArray< Size, Real >::StaticArray; +#if !defined(__CUDACC_VER_MAJOR__) || __CUDACC_VER_MAJOR__ < 11 using StaticArray< Size, Real >::operator=; +#endif /** * \brief Constructor from binary vector expression. diff --git a/src/TNL/Containers/Vector.h b/src/TNL/Containers/Vector.h index 685a7f206..9d09ecd50 100644 --- a/src/TNL/Containers/Vector.h +++ b/src/TNL/Containers/Vector.h @@ -194,6 +194,7 @@ public: */ // operator= from the base class should be hidden according to the C++14 standard, // although GCC does not do that - see https://stackoverflow.com/q/57322624 +#if !defined(__CUDACC_VER_MAJOR__) || __CUDACC_VER_MAJOR__ < 11 template< typename T, typename..., typename = std::enable_if_t< std::is_convertible< T, Real >::value || IsArrayType< T >::value > > @@ -202,6 +203,7 @@ public: { return Array< Real, Device, Index, Allocator >::operator=(data); } +#endif /** * \brief Adds elements of this vector and a vector expression and diff --git a/src/TNL/Containers/VectorView.h b/src/TNL/Containers/VectorView.h index 4c5262d30..77c25b3a2 100644 --- a/src/TNL/Containers/VectorView.h +++ b/src/TNL/Containers/VectorView.h @@ -148,6 +148,7 @@ public: */ // operator= from the base class should be hidden according to the C++14 standard, // although GCC does not do that - see https://stackoverflow.com/q/57322624 +#if !defined(__CUDACC_VER_MAJOR__) || __CUDACC_VER_MAJOR__ < 11 template< typename T, typename..., typename = std::enable_if_t< std::is_convertible< T, Real >::value || IsArrayType< T >::value > > @@ -156,6 +157,7 @@ public: { return ArrayView< Real, Device, Index >::operator=(data); } +#endif /** * \brief Adds elements of this vector view and a vector expression and -- GitLab From 32e1ab9b30df0392a3dc8a1399eb8423615c6c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Thu, 30 Jul 2020 10:02:53 +0200 Subject: [PATCH 3/3] Disable use of cusparse functions which were removed in CUDA 11 --- src/Benchmarks/SpMV/cusparseCSRMatrix.h | 24 ++++++++++++++++++------ src/TNL/Matrices/Legacy/CSR_impl.h | 8 ++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/Benchmarks/SpMV/cusparseCSRMatrix.h b/src/Benchmarks/SpMV/cusparseCSRMatrix.h index 1cb52f884..ea5b9ddbf 100644 --- a/src/Benchmarks/SpMV/cusparseCSRMatrix.h +++ b/src/Benchmarks/SpMV/cusparseCSRMatrix.h @@ -62,6 +62,9 @@ class CusparseCSRBase { TNL_ASSERT_TRUE( matrix, "matrix was not initialized" ); #ifdef HAVE_CUDA +#if CUDART_VERSION >= 11000 + throw std::runtime_error("cusparseDcsrmv was removed in CUDA 11."); +#else cusparseDcsrmv( *( this->cusparseHandle ), CUSPARSE_OPERATION_NON_TRANSPOSE, this->matrix->getRows(), @@ -75,6 +78,7 @@ class CusparseCSRBase inVector.getData(), 1.0, outVector.getData() ); +#endif #endif } @@ -104,8 +108,11 @@ class CusparseCSR< double > : public CusparseCSRBase< double > OutVector& outVector ) const { TNL_ASSERT_TRUE( matrix, "matrix was not initialized" ); -#ifdef HAVE_CUDA - double d = 1.0; +#ifdef HAVE_CUDA +#if CUDART_VERSION >= 11000 + throw std::runtime_error("cusparseDcsrmv was removed in CUDA 11."); +#else + double d = 1.0; double* alpha = &d; cusparseDcsrmv( *( this->cusparseHandle ), CUSPARSE_OPERATION_NON_TRANSPOSE, @@ -120,7 +127,8 @@ class CusparseCSR< double > : public CusparseCSRBase< double > inVector.getData(), alpha, outVector.getData() ); -#endif +#endif +#endif } }; @@ -135,8 +143,11 @@ class CusparseCSR< float > : public CusparseCSRBase< float > OutVector& outVector ) const { TNL_ASSERT_TRUE( matrix, "matrix was not initialized" ); -#ifdef HAVE_CUDA - float d = 1.0; +#ifdef HAVE_CUDA +#if CUDART_VERSION >= 11000 + throw std::runtime_error("cusparseScsrmv was removed in CUDA 11."); +#else + float d = 1.0; float* alpha = &d; cusparseScsrmv( *( this->cusparseHandle ), CUSPARSE_OPERATION_NON_TRANSPOSE, @@ -151,7 +162,8 @@ class CusparseCSR< float > : public CusparseCSRBase< float > inVector.getData(), alpha, outVector.getData() ); -#endif +#endif +#endif } }; diff --git a/src/TNL/Matrices/Legacy/CSR_impl.h b/src/TNL/Matrices/Legacy/CSR_impl.h index 3774b3bd8..6990d4072 100644 --- a/src/TNL/Matrices/Legacy/CSR_impl.h +++ b/src/TNL/Matrices/Legacy/CSR_impl.h @@ -1171,6 +1171,9 @@ class tnlCusparseCSRWrapper< float, int > const Real* x, Real* y ) { +#if CUDART_VERSION >= 11000 + throw std::runtime_error("cusparseScsrmv was removed in CUDA 11."); +#else cusparseHandle_t cusparseHandle; cusparseMatDescr_t cusparseMatDescr; cusparseCreate( &cusparseHandle ); @@ -1191,6 +1194,7 @@ class tnlCusparseCSRWrapper< float, int > x, &beta, y ); +#endif }; }; @@ -1211,6 +1215,9 @@ class tnlCusparseCSRWrapper< double, int > const Real* x, Real* y ) { +#if CUDART_VERSION >= 11000 + throw std::runtime_error("cusparseDcsrmv was removed in CUDA 11."); +#else cusparseHandle_t cusparseHandle; cusparseMatDescr_t cusparseMatDescr; cusparseCreate( &cusparseHandle ); @@ -1231,6 +1238,7 @@ class tnlCusparseCSRWrapper< double, int > x, &beta, y ); +#endif }; }; -- GitLab