cuda::experimental::host_launch#

template<class _Callable, class ..._Args>
inline graph_node_ref cuda::experimental::host_launch(
path_builder &__pb,
_Callable __callable,
_Args... __args
)#

Adds a host node to a CUDA graph path that invokes a callable on the host.

The callable and its arguments are copied into a heap allocation whose lifetime is tied to the graph via a CUDA user object. The graph can be launched multiple times. The rules and restrictions match cuda::host_launch:

  • The callable must not call into CUDA Runtime or Driver APIs.

  • It must not depend on another thread that could block on asynchronous CUDA work.

Three dispatch paths (mirroring cuda::host_launch):

  1. A bare no-arg function pointer; no allocation.

  2. A std::reference_wrapper (no args) passes the address of the referenced object.

  3. Everything else is heap-allocated with lifetime managed by a graph user object.

Parameters:
  • __pb – Path builder to insert the node into.

  • __callable – Callable to execute on the host.

  • __args – Arguments to forward to the callable.

Throws:

cuda::std::cuda_error – if node creation fails.

Returns:

A graph_node_ref for the newly added host node.