cuda::experimental::stf::cuda_safe_call#

template<typename T>
void cuda::experimental::stf::cuda_safe_call(
const T status,
const ::cuda::std::source_location loc = ::cuda::std::source_location::current(),
)#

Enforces successful call of CUDA API functions.

If status is 0, the function has no effect. Otherwise, the function prints pertinent error information to stderr and aborts the program.

  cuda_safe_call(CUDA_SUCCESS); // no effect
  int dev;
  cuda_safe_call(cudaGetDevice(&dev)); // continue execution if the call is successful
  if (false)
  {
    cuda_safe_call(CUDA_ERROR_INVALID_VALUE); // would abort application if called
  }

Template Parameters:

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

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

  • loc – location of the call, defaulted