19#ifndef OPM_GPU_SAFE_CALL_HPP
20#define OPM_GPU_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(
"GPU 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));
122 const std::string_view& expression,
123 const std::string_view& filename,
124 const std::string_view& functionName,
127 if (error != cudaSuccess) {
128 OpmLog::warning(
getCudaErrorMessage(error, expression, filename, functionName, lineNumber));
150#define OPM_GPU_SAFE_CALL(expression) \
151 ::Opm::gpuistl::detail::cudaSafeCall(expression, #expression, __FILE__, __func__, __LINE__)
171#define OPM_GPU_WARN_IF_ERROR(expression) \
172 ::Opm::gpuistl::detail::cudaWarnIfError(expression, #expression, __FILE__, __func__, __LINE__)
Contains wrappers to make the CuBLAS library behave as a modern C++ library with function overlading.
Definition autotuner.hpp:29
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 gpu_safe_call.hpp:45
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 GPU expression (function call) and throws an exception if ...
Definition gpu_safe_call.hpp:82
void 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 GPU expression (function call) and issues a warning if ...
Definition gpu_safe_call.hpp:121