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 using namespace std::literals;
65 rtCheck<TApi, TThrow>(error, (
"'"s + std::string(cmd) +
"' returned error "s).c_str(), file, line);
71 std::ignore = TApi::getLastError();
77 template<
typename TApi,
bool TThrow>
80 typename TApi::Error_t
const error(TApi::getLastError());
81 rtCheck<TApi, TThrow>(error, desc, file, line);
85 # define ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IMPL(cmd, throw, ...) \
88 ::alpaka::uniform_cuda_hip::detail::rtCheckLastError<TApi, throw>( \
89 "'" #cmd "' A previous API call (not this one) set the error ", \
92 ::alpaka::uniform_cuda_hip::detail::rtCheckIgnore<TApi, throw>( \
101 # define ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IGNORE(cmd, ...) \
102 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IMPL(cmd, true, __VA_ARGS__)
105 # define ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK(cmd) ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IMPL(cmd, true, )
108 # define ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IGNORE_NOEXCEPT(cmd, ...) \
109 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK_IMPL(cmd, false, __VA_ARGS__)
112 # 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