cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
error.hpp File Reference

Facilities for exception-based handling of errors originating to the NVRTC library, including a basic exception class wrapping ::std::runtime_error. More...

#include "types.hpp"
#include <cuda_runtime_api.h>
#include <type_traits>
#include <string>
#include <stdexcept>
Include dependency graph for error.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  cuda::rtc::runtime_error< Kind >
 A (base?) class for exceptions raised by CUDA code; these errors are thrown by essentially all CUDA Runtime API wrappers upon failure. More...
 

Namespaces

 cuda
 Definitions and functionality wrapping CUDA APIs.
 
 cuda::rtc
 Real-time compilation of programs using the NVIDIA libraries.
 

Macros

#define CUDA_API_WRAPPERS_RTC_ERROR_HPP_
 
#define throw_if_rtc_error_lazy(Kind, status__, ...)
 Throws a cuda::rtc::runtime_error exception if the status is not success. More...
 

Typedefs

template<source_kind_t Kind>
using cuda::rtc::status::named_t = typename rtc::detail_::types< Kind >::named_status
 Aliases for NVRTC / PTX compilation library status codes.
 

Functions

template<source_kind_t Kind>
constexpr bool cuda::is_failure (rtc::status_t< Kind > status)
 Determine whether the API call returning the specified status had failed.
 
template<source_kind_t Kind>
void cuda::throw_if_error (rtc::status_t< Kind > status, const ::std::string &message) noexcept(false)
 Do nothing... More...
 
template<source_kind_t Kind>
void cuda::throw_if_error (rtc::status_t< Kind > status) noexcept(false)
 Does nothing - unless the status indicates an error, in which case a cuda::runtime_error exception is thrown. More...
 
template<source_kind_t Kind>
constexpr bool cuda::is_success (rtc::status_t< Kind > status)
 Determine whether the API call returning the specified status had succeeded.
 
inline ::std::string cuda::describe (rtc::status_t< cuda_cpp > status)
 Obtain a brief textual explanation for a specified kind of CUDA Runtime API status or error code.
 

Detailed Description

Facilities for exception-based handling of errors originating to the NVRTC library, including a basic exception class wrapping ::std::runtime_error.

Macro Definition Documentation

◆ throw_if_rtc_error_lazy

#define throw_if_rtc_error_lazy (   Kind,
  status__,
  ... 
)
Value:
do { \
::cuda::rtc::status_t<Kind> tie_status__ = static_cast<::cuda::rtc::status_t<Kind>>(status__); \
if (::cuda::is_failure<Kind>(tie_status__)) { \
throw ::cuda::rtc::runtime_error<Kind>(tie_status__, (__VA_ARGS__)); \
} \
} while(false)
typename detail_::types< Kind >::status_type status_t
Status values returned by the NVIDIA run-time compilation libraries&#39;s API calls: The NVRTC library fo...
Definition: types.hpp:131

Throws a cuda::rtc::runtime_error exception if the status is not success.

Note
The rationale for this macro is that neither the exception, nor its constructor arguments, are evaluated on the "happy path"; and that cannot be achieved with a function - which genertally/typically evaluates its arguments. To guarantee this lazy evaluation with a function, we would need exception-construction-argument-producing lambdas, which we would obviously rather avoid.