cuda::experimental::stf::cuda_exception#

class cuda_exception : public std::exception#

Exception type across CUDA, CUBLAS, and CUSOLVER.

UNITTEST("cuda_exception")
{
auto e = cuda_exception(CUDA_SUCCESS);
  EXPECT(e.what()[0] == 0);
#  if __has_include(<cusolverDn.h>)
auto e1 = cuda_exception(CUSOLVER_STATUS_ZERO_PIVOT);
  EXPECT(strlen(e1.what()) > 0u);
#  endif
};

Public Functions

cuda_exception() = delete#
template<typename T>
inline cuda_exception(
const T status,
const ::cuda::std::source_location loc = ::cuda::std::source_location::current()
)#

Constructs an exception object from a status value.

If status is 0, the exception is still created with an empty error message. Otherwise, the constructor initializes the error message (later accessible with what()): the location and device, then status_traits<T>::name(status).

Template Parameters:

T – status type, can be cudaError_t, CUresult, cudaOccError, cublasStatus_t, or cusolverStatus_t

Parameters:
  • status – status value, usually the result of a CUDA API call

  • loc – location of the call, defaulted

inline const char *what() const noexcept override#

Returns a message describing the error.

Returns:

the error message

template<typename S>
inline S status() const noexcept#

Returns the status the exception was built from, so a handler can recover it.

S must be the type of that status; asking for another of the accepted status types is a programming error, checked with _CCCL_VERIFY.

Template Parameters:

S – the status type the exception was built from

Returns:

the status