19 #ifndef OPM_CUSPARSE_SAFE_CALL_HPP 20 #define OPM_CUSPARSE_SAFE_CALL_HPP 24 #include <opm/common/ErrorMacros.hpp> 25 #include <opm/common/OpmLog/OpmLog.hpp> 30 #define CHECK_CUSPARSE_ERROR_TYPE(code, x) \ 42 CHECK_CUSPARSE_ERROR_TYPE(code, CUSPARSE_STATUS_SUCCESS);
43 CHECK_CUSPARSE_ERROR_TYPE(code, CUSPARSE_STATUS_NOT_INITIALIZED);
44 CHECK_CUSPARSE_ERROR_TYPE(code, CUSPARSE_STATUS_ALLOC_FAILED);
45 CHECK_CUSPARSE_ERROR_TYPE(code, CUSPARSE_STATUS_INVALID_VALUE);
46 CHECK_CUSPARSE_ERROR_TYPE(code, CUSPARSE_STATUS_ARCH_MISMATCH);
47 CHECK_CUSPARSE_ERROR_TYPE(code, CUSPARSE_STATUS_MAPPING_ERROR);
48 CHECK_CUSPARSE_ERROR_TYPE(code, CUSPARSE_STATUS_EXECUTION_FAILED);
49 CHECK_CUSPARSE_ERROR_TYPE(code, CUSPARSE_STATUS_INTERNAL_ERROR);
50 CHECK_CUSPARSE_ERROR_TYPE(code, CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED);
51 CHECK_CUSPARSE_ERROR_TYPE(code, CUSPARSE_STATUS_ZERO_PIVOT);
52 CHECK_CUSPARSE_ERROR_TYPE(code, CUSPARSE_STATUS_NOT_SUPPORTED);
53 CHECK_CUSPARSE_ERROR_TYPE(code, CUSPARSE_STATUS_INSUFFICIENT_RESOURCES);
54 return fmt::format(fmt::runtime(
"UNKNOWN CUSPARSE ERROR {}."), code);
57 #undef CHECK_CUSPARSE_ERROR_TYPE 75 const std::string_view& expression,
76 const std::string_view& filename,
77 const std::string_view& functionName,
80 return fmt::format(fmt::runtime(
"cuSparse expression did not execute correctly. Expression was: \n\n" 81 " {}\n\nin function {}, in {}, at line {}\n" 82 "CuSparse error code was: {}\n"),
112 const std::string_view& expression,
113 const std::string_view& filename,
114 const std::string_view& functionName,
117 if (error != CUSPARSE_STATUS_SUCCESS) {
151 inline cusparseStatus_t
153 const std::string_view& expression,
154 const std::string_view& filename,
155 const std::string_view& functionName,
158 if (error != CUSPARSE_STATUS_SUCCESS) {
185 #define OPM_CUSPARSE_SAFE_CALL(expression) \ 186 ::Opm::gpuistl::detail::cusparseSafeCall(expression, #expression, __FILE__, __func__, __LINE__) 206 #define OPM_CUSPARSE_WARN_IF_ERROR(expression) \ 207 ::Opm::gpuistl::detail::cusparseWarnIfError(expression, #expression, __FILE__, __func__, __LINE__) 208 #endif // OPM_CUSPARSE_SAFE_CALL_HPP cusparseStatus_t cusparseWarnIfError(cusparseStatus_t error, const std::string_view &expression, const std::string_view &filename, const std::string_view &functionName, size_t lineNumber)
cusparseWarnIfError checks the return type of the CUSPARSE expression (function call) and issues a wa...
Definition: cusparse_safe_call.hpp:152
void cusparseSafeCall(cusparseStatus_t error, const std::string_view &expression, const std::string_view &filename, const std::string_view &functionName, size_t lineNumber)
cusparseSafeCall checks the return type of the CUSPARSE expression (function call) and throws an exce...
Definition: cusparse_safe_call.hpp:111
std::string getCusparseErrorCodeToString(int code)
getCusparseErrorCodeToString Converts an error code returned from a cusparse function a human readabl...
Definition: cusparse_safe_call.hpp:40
std::string getCusparseErrorMessage(cusparseStatus_t error, const std::string_view &expression, const std::string_view &filename, const std::string_view &functionName, size_t lineNumber)
getCusparseErrorMessage generates the error message to display for a given error. ...
Definition: cusparse_safe_call.hpp:74
Contains wrappers to make the CuBLAS library behave as a modern C++ library with function overlading...
Definition: autotuner.hpp:29