cuda::experimental::mr::async_memory_pool

Defined in /home/runner/work/cccl/cccl/cudax/include/cuda/experimental/__memory_resource/async_memory_pool.cuh

class async_memory_pool

async_memory_pool is an owning wrapper around a cudaMemPool_t.

It handles creation and destruction of the underlying pool utilizing the provided async_memory_pool_properties.

Public Functions

inline explicit async_memory_pool(const ::cuda::experimental::device_ref __device_id, async_memory_pool_properties __properties = {})

Constructs a async_memory_pool with the optionally specified initial pool size and release threshold. If the pool size grows beyond the release threshold, unused memory held by the pool will be released at the next synchronization event.

Throws

cuda_error – if the CUDA version does not support cudaMallocAsync.

Parameters
  • __device_id – The device id of the device the stream pool is constructed on.

  • __pool_properties – Optional, additional properties of the pool to be created.

async_memory_pool(::cudaMemPool_t) = delete

Disables construction from a plain cudaMemPool_t. We want to ensure clean ownership semantics.

async_memory_pool(async_memory_pool const&) = delete
async_memory_pool(async_memory_pool&&) = delete
async_memory_pool &operator=(async_memory_pool const&) = delete
async_memory_pool &operator=(async_memory_pool&&) = delete
inline ~async_memory_pool() noexcept

Destroys the async_memory_pool by releasing the internal cudaMemPool_t.

inline void trim_to(const size_t __min_bytes_to_keep)

Tries to release memory.

Note

If the pool has less than __minBytesToKeep reserved, the trim_to operation is a no-op. Otherwise the pool will be guaranteed to have at least __minBytesToKeep bytes reserved after the operation.

Parameters

__min_bytes_to_keep – the minimal guaranteed size of the pool.

inline size_t get_attribute(::cudaMemPoolAttr __attr) const

Gets the value of an attribute of the pool.

Parameters

__attribute – the attribute to be set.

Returns

The value of the attribute. For boolean attributes any value not equal to 0 equates to true.

inline void set_attribute(::cudaMemPoolAttr __attr, size_t __value)

Sets an attribute of the pool to a given value.

Note

For boolean attributes any non-zero value equates to true.

Parameters
  • __attribute – the attribute to be set.

  • __value – the new value of that attribute.

inline constexpr bool operator==(async_memory_pool const &__rhs) const noexcept

Equality comparison with another async_memory_pool.

Returns

true if the stored cudaMemPool_t are equal.

inline constexpr bool operator==(async_memory_pool const &__lhs, ::cudaMemPool_t __rhs) noexcept

Equality comparison with a cudaMemPool_t.

Parameters

__rhs – A cudaMemPool_t.

Returns

true if the stored cudaMemPool_t is equal to __rhs.

inline constexpr cudaMemPool_t get() const noexcept

Returns the underlying handle to the CUDA memory pool.

Public Static Functions

static inline async_memory_pool from_native_handle(::cudaMemPool_t __handle) noexcept

Construct an async_memory_pool object from a native cudaMemPool_t handle.

Note

The constructed async_memory_pool object takes ownership of the native handle.

Parameters

__handle – The native handle

Returns

The constructed async_memory_pool object

static async_memory_pool from_native_handle(int) = delete
static async_memory_pool from_native_handle(cuda::std::nullptr_t) = delete