cuda::experimental::stf::cuda_safe_call#

Overloads#

cuda_safe_call(status, loc=::cuda::std::source_location::current())#

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

cuda_safe_call(loc=::cuda::std::source_location::current())#

template<auto fun>
auto cuda::experimental::stf::cuda_safe_call(
const ::cuda::std::source_location loc = ::cuda::std::source_location::current()
)

As cuda_try with the same three call shapes and the same limitations, but a failing status reports and aborts instead of throwing (the cuda_safe_call reaction).

The two spellings are deliberately parallel so migrating a call site between the aborting and throwing regimes is a one-token change: cuda_safe_call<f>(a) <-> cuda_try<f>(a).

  int dev = cuda_safe_call<cudaGetDevice>(); // aborting sibling of cuda_try<cudaGetDevice>()
  cuda_safe_call(cudaGetDevice(&dev)); // equivalent to the line above
  EXPECT(cuda_safe_call<test_first_output_param>() == 1);
  EXPECT(cuda_safe_call<test_last_output_param>(2.0) == 2);

cuda_safe_call(p0, rest)#

template<auto fun, typename ...Ps>
auto cuda::experimental::stf::cuda_safe_call(
with_location<reserved::first_param<fun>> p0,
Ps&&... rest
)

cuda_safe_call(p0, rest)#

template<auto fun, typename ...Ps>
auto cuda::experimental::stf::cuda_safe_call(
with_location<reserved::second_param<fun>> p0,
Ps&&... rest
)

cuda_safe_call(...)#

template<auto fun, typename ...Ps>
void cuda::experimental::stf::cuda_safe_call(
Ps&&...
)