From: Bruno Turcksin Date: Mon, 23 Apr 2018 22:28:49 +0000 (-0400) Subject: Add cuSOLVER asserts X-Git-Tag: v9.0.0-rc1~100^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45508da1a52b78437ce9a15a9d21d03e31137deb;p=dealii.git Add cuSOLVER asserts --- diff --git a/include/deal.II/base/exceptions.h b/include/deal.II/base/exceptions.h index 9f03b13ab0..3348946340 100644 --- a/include/deal.II/base/exceptions.h +++ b/include/deal.II/base/exceptions.h @@ -23,6 +23,7 @@ #include #ifdef DEAL_II_WITH_CUDA +#include #include #endif @@ -1088,6 +1089,12 @@ namespace deal_II_exceptions * function but there is no equivalent function for cuSPARSE. */ std::string get_cusparse_error_string(const cusparseStatus_t error_code); + + /** + * Return a string given an error code. This is similar to the cudaGetErrorString + * function but there is no equivalent function for cuSOLVER. + */ + std::string get_cusolver_error_string(const cusolverStatus_t error_code); #endif } /*namespace internals*/ @@ -1320,6 +1327,15 @@ AssertThrow(error_code == MPI_SUCCESS, dealii::ExcMPI(error_code)) #define AssertCusparse(error_code) { (void) (error_code); } #endif +#ifdef DEBUG +#define AssertCusolver(error_code) Assert(error_code == CUSOLVER_STATUS_SUCCESS, \ + dealii::ExcCusparseError( \ + dealii::deal_II_exceptions::internals:: \ + get_cusolver_error_string(error_code))) +#else +#define AssertCusolver(error_code) { (void) (error_code); } +#endif + #endif using namespace StandardExceptions; diff --git a/source/base/exceptions.cc b/source/base/exceptions.cc index 73ac867491..6cc57bcba4 100644 --- a/source/base/exceptions.cc +++ b/source/base/exceptions.cc @@ -522,6 +522,48 @@ namespace deal_II_exceptions } } } + + + + std::string get_cusolver_error_string(cusolverStatus_t error_code) + { + std::string message; + switch (error_code) + { + case CUSOLVER_STATUS_NOT_INITIALIZED: + { + return "The cuSolver library was not initialized"; + } + case CUSOLVER_STATUS_ALLOC_FAILED: + { + return "Resource allocation failed inside the cuSolver library"; + } + case CUSOLVER_STATUS_INVALID_VALUE: + { + return "An unsupported value of a parameter was passed to the function"; + } + case CUSOLVER_STATUS_ARCH_MISMATCH: + { + return "The function requires a feature absent from the device architecture"; + } + case CUSOLVER_STATUS_EXECUTION_FAILED: + { + return "The GPU program failed to execute"; + } + case CUSOLVER_STATUS_INTERNAL_ERROR: + { + return "An internal cuSolver operation failed"; + } + case CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED: + { + return "The matrix type is not supported by this function"; + } + default: + { + return "Unknown error"; + } + } + } #endif } /*namespace internals*/