cuda::experimental::graph_memory_resource#
-
struct graph_memory_resource#
A memory resource that allocates and frees device memory as CUDA graph nodes.
Constructed with a device_ref that determines where memory is allocated. Inserts
cuGraphAddMemAllocNodeandcuGraphAddMemFreeNodenodes into a graph via a path_builder. Also supports stream-based deallocation for memory that outlives the graph execution.Public Types
-
using default_queries = ::cuda::mr::properties_list<::cuda::mr::device_accessible>#
Public Functions
-
inline explicit graph_memory_resource(device_ref __dev) noexcept#
Construct a graph memory resource for the specified device.
- Parameters:
__dev – The device on which memory will be allocated.
- inline void *allocate(
- path_builder &__pb,
- ::cuda::std::size_t __size,
- ::cuda::std::size_t __alignment = cuda::mr::default_cuda_malloc_alignment
Insert a memory allocation node into the graph.
- Parameters:
__pb – The path builder to insert the alloc node into.
__size – Number of bytes to allocate.
__alignment – Alignment requirement (unused by the CUDA graph alloc API, reserved).
- Returns:
Device pointer to the allocated memory.
- inline void deallocate(
- path_builder &__pb,
- void *__ptr,
- ::cuda::std::size_t __size = 0,
- ::cuda::std::size_t __alignment = ::cuda::mr::default_cuda_malloc_alignment
Insert a memory free node into the graph.
- Parameters:
__pb – The path builder to insert the free node into.
__ptr – Device pointer previously returned by allocate().
__size – Number of bytes (unused, kept for interface symmetry).
__alignment – Alignment (unused, kept for interface symmetry).
- inline void deallocate(
- ::cuda::stream_ref __stream,
- void *__ptr,
- ::cuda::std::size_t __size = 0,
- ::cuda::std::size_t __alignment = ::cuda::mr::default_cuda_malloc_alignment
Free device memory asynchronously on a stream.
- Parameters:
__stream – The stream on which to free the memory.
__ptr – Device pointer previously returned by allocate().
__size – Number of bytes (unused, kept for interface symmetry).
__alignment – Alignment (unused, kept for interface symmetry).
-
inline device_ref device() const noexcept#
Returns the device this resource allocates on.
Friends
- inline friend constexpr void get_property(
- graph_memory_resource const&,
- ::cuda::mr::device_accessible
Enables the
device_accessibleproperty.
- inline friend bool operator==(
- const graph_memory_resource &__lhs,
- const graph_memory_resource &__rhs
- inline friend bool operator!=(
- const graph_memory_resource &__lhs,
- const graph_memory_resource &__rhs
-
using default_queries = ::cuda::mr::properties_list<::cuda::mr::device_accessible>#