12 #include <initializer_list>
16 #include <type_traits>
18 #if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) || defined(ALPAKA_ACC_GPU_HIP_ENABLED)
23 template<
typename TApi,
bool TThrow>
25 typename TApi::Error_t
const& error,
28 int const& line) noexcept(!TThrow)
30 if(error != TApi::success)
32 auto const sError = std::string{
33 std::string(file) +
"(" + std::to_string(line) +
") " + std::string(desc) +
" : '"
34 + TApi::getErrorName(error) +
"': '" + std::string(TApi::getErrorString(error)) +
"'!"};
37 std::cerr << sError << std::endl;
42 std::ignore = TApi::getLastError();
45 throw std::runtime_error(sError);
50 template<
typename TApi,
bool TThrow>
52 typename TApi::Error_t
const& error,
56 std::initializer_list<typename TApi::Error_t> ignoredErrorCodes) noexcept(!TThrow)
58 if(error != TApi::success)
61 if(std::find(std::cbegin(ignoredErrorCodes), std::cend(ignoredErrorCodes), error)
62 == std::cend(ignoredErrorCodes))
64 rtCheck<TApi, TThrow>(error, (
"'" + std::string(cmd) +
"' returned error ").c_str(), file, line);
70 std::ignore = TApi::getLastError();
76 template<
typename TApi,
bool TThrow>
79 typename TApi::Error_t
const error(TApi::getLastError());
80 rtCheck<TApi, TThrow>(error, desc, file, line);
84 # define ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IMPL(cmd, throw, ...) \
87 ::alpaka::uniform_cuda_hip::detail::rtCheckLastError<TApi, throw>( \
88 "'" #cmd "' A previous API call (not this one) set the error ", \
91 ::alpaka::uniform_cuda_hip::detail::rtCheckIgnore<TApi, throw>( \
100 # define ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IGNORE(cmd, ...) \
101 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IMPL(cmd, true, __VA_ARGS__)
104 # define ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK(cmd) ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IMPL(cmd, true, )
107 # define ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IGNORE_NOEXCEPT(cmd, ...) \
108 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IMPL(cmd, false, __VA_ARGS__)
111 # define ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_NOEXCEPT(cmd) ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IMPL(cmd, false, )
#define ALPAKA_DEBUG_MINIMAL
The minimal debug level.
#define ALPAKA_DEBUG
Set the minimum log level if it is not defined.
#define ALPAKA_DEBUG_BREAK