cuda::experimental::stf::cuda_try
Defined in include/cuda/experimental/__stf/utility/cuda_safe_call.cuh
-
template<auto fun, typename ...Ps>
auto cuda::experimental::stf::cuda_try(Ps&&... ps) Calls a CUDA function and throws a
cuda_exception
in case of failure.In this overload of
cuda_try
, the function name is passed explicitly as a template argument and also the first argument is omitted, as incuda_try<cudaCreateStream>()
.cuda_try
will create a temporary of the appropriate type internally, call the specified CUDA function with the address of that temporary, and then return the temporary. For example, in the callcuda_try<cudaCreateStream>()
, the created stream object will be returned. That way you can writeauto stream = cuda_try<cudaCreateStream>();
instead ofcudaStream_t stream; cudaCreateStream(&stream);
. This invocation mode relies on the convention used by many CUDA functions with output parameters of specifying them in the first parameter position.Limitations: Does not work with overloaded functions.
- Template Parameters
fun – Name of the CUDA function to invoke, cannot be the name of an overloaded function
Ps – Parameter types to be forwarded
- Parameters
ps – Arguments to be forwarded
- Returns
auto
(see below)