19#ifndef OPM_CUDA_SAFE_CALL_HPP
20#define OPM_CUDA_SAFE_CALL_HPP
21#include <cuda_runtime.h>
23#include <opm/common/ErrorMacros.hpp>
24#include <opm/common/OpmLog/OpmLog.hpp>
46 const std::string_view& expression,
47 const std::string_view& filename,
48 const std::string_view& functionName,
51 return fmt::format(
"CUDA expression did not execute correctly. Expression was: \n"
54 "in function {}, in {}, at line {}\n",
56 cudaGetErrorString(error),
83 const std::string_view& expression,
84 const std::string_view& filename,
85 const std::string_view& functionName,
88 if (error != cudaSuccess) {
89 OPM_THROW(std::runtime_error,
getCudaErrorMessage(error, expression, filename, functionName, lineNumber));
124 const std::string_view& expression,
125 const std::string_view& filename,
126 const std::string_view& functionName,
129 if (error != cudaSuccess) {
130 OpmLog::warning(
getCudaErrorMessage(error, expression, filename, functionName, lineNumber));
154#define OPM_CUDA_SAFE_CALL(expression) \
155 ::Opm::cuistl::detail::cudaSafeCall(expression, #expression, __FILE__, __func__, __LINE__)
175#define OPM_CUDA_WARN_IF_ERROR(expression) \
176 ::Opm::cuistl::detail::cudaWarnIfError(expression, #expression, __FILE__, __func__, __LINE__)
Contains wrappers to make the CuBLAS library behave as a modern C++ library with function overlading.
Definition cublas_safe_call.hpp:32
void cudaSafeCall(cudaError_t error, const std::string_view &expression, const std::string_view &filename, const std::string_view &functionName, size_t lineNumber)
cudaSafeCall checks the return type of the CUDA expression (function call) and throws an exception if...
Definition cuda_safe_call.hpp:82
std::string getCudaErrorMessage(cudaError_t error, const std::string_view &expression, const std::string_view &filename, const std::string_view &functionName, size_t lineNumber)
getCudaErrorMessage generates the error message to display for a given error.
Definition cuda_safe_call.hpp:45
cudaError_t cudaWarnIfError(cudaError_t error, const std::string_view &expression, const std::string_view &filename, const std::string_view &functionName, size_t lineNumber)
cudaWarnIfError checks the return type of the CUDA expression (function call) and issues a warning if...
Definition cuda_safe_call.hpp:123