cuda::experimental::graph

Defined in include/cuda/experimental/__graph/graph.cuh

struct graph

An owning wrapper for a cudaGraphExec_t handle.

The graph class provides a safe and convenient interface for managing the lifecycle of a cudaGraphExec_t object, ensuring proper cleanup and resource management. It supports move semantics, resource release, and launch of the CUDA graph.

Note

The graph object is not directly constructible. One is obtained by calling the instantiate() method on a graph_builder object.

Public Functions

inline constexpr graph(graph &&__other) noexcept

Move constructor for graph.

Note

After the move, the source object is left in the empty state.

Parameters

__other – The graph object to move from.

Post

__other.get() == nullptr

inline constexpr ~graph()

Destructor for graph.

Ensures proper cleanup of the CUDA graph execution object.

Throws

None

inline constexpr auto operator=(graph &&__other) noexcept -> graph&

Move assignment operator for graph.

Note

After the move, the source object is left in the empty state.

Parameters

__other – The graph object to move from.

Throws

None

Returns

A reference to the current object.

Post

__other.get() == nullptr

inline constexpr void swap(graph &__other) noexcept

Swaps the contents of this graph with another.

Parameters

__other – The graph object to swap with.

Throws

None

inline constexpr auto get() const noexcept -> cudaGraphExec_t

Retrieves the underlying CUDA graph execution object.

Throws

None

Returns

The cudaGraphExec_t handle.

inline constexpr auto release() noexcept -> cudaGraphExec_t

Releases ownership of the CUDA graph execution object.

Throws

None

Returns

The cudaGraphExec_t handle, leaving this object in a null state.

Post

get() == nullptr

inline constexpr void reset() noexcept

Resets the graph object, destroying the underlying CUDA graph execution object.

Throws

cuda::std::cuda_error – if cudaGraphExecDestroy fails.

Post

get() == nullptr

inline void launch(stream_ref __stream)

Launches the CUDA graph execution object on the specified stream.

Parameters

__stream – The stream on which to launch the graph.

Throws

cuda::std::cuda_error – if cudaGraphLaunch fails.

Public Static Functions

static inline constexpr auto from_native_handle(cudaGraphExec_t __exec) noexcept -> graph

Constructs a graph object from a native CUDA graph execution handle.

Parameters

__exec – The native CUDA graph execution handle to construct the graph object from.

Throws

None

Post

get() == __exec