Expand description
Stream-ordered memory allocation (CUDA 11.2+ / 12.x+).
Stream-ordered memory allocation allows memory operations (alloc / free)
to participate in the stream execution order, eliminating the need for
explicit synchronisation between allocation and kernel launch.
This module provides:
StreamMemoryPool— a memory pool bound to a specific device.StreamAllocation— a handle to a stream-ordered allocation.StreamOrderedAllocConfig— pool configuration (sizes, thresholds).PoolAttribute/PoolUsageStats— attribute queries and statistics.PoolExportDescriptor/ShareableHandleType— IPC sharing metadata.stream_alloc/stream_free— convenience free functions.
§Platform behaviour
On macOS (where NVIDIA dropped CUDA support), all operations that would
require the GPU driver return Err(CudaError::NotSupported). Config
validation, statistics tracking, and accessor methods work everywhere.
§Example
use oxicuda_driver::stream_ordered_alloc::*;
let config = StreamOrderedAllocConfig::default_for_device(0);
let mut pool = StreamMemoryPool::new(config)?;
let stream_handle = 0u64; // placeholder
let mut alloc = pool.alloc_async(1024, stream_handle)?;
assert_eq!(alloc.size(), 1024);
assert!(!alloc.is_freed());
pool.free_async(&mut alloc)?;
assert!(alloc.is_freed());Structs§
- Pool
Export Descriptor - Descriptor for exporting a pool for IPC sharing.
- Pool
Usage Stats - Snapshot of pool memory usage.
- Stream
Allocation - Handle to a stream-ordered memory allocation.
- Stream
Memory Pool - A memory pool for stream-ordered allocations.
- Stream
Ordered Alloc Config - Configuration for a stream-ordered memory pool.
Enums§
- Pool
Attribute - Attributes that can be queried or set on a
StreamMemoryPool. - Shareable
Handle Type - Handle type used for IPC sharing of memory pools.
Constants§
- CU_
MEMPOOL_ ATTR_ RELEASE_ THRESHOLD - Release threshold in bytes (memory returned to OS when usage drops below).
- CU_
MEMPOOL_ ATTR_ RESERVED_ MEM_ CURRENT - Current reserved memory (bytes) — read-only.
- CU_
MEMPOOL_ ATTR_ RESERVED_ MEM_ HIGH - High-water mark of reserved memory (bytes) — resettable.
- CU_
MEMPOOL_ ATTR_ REUSE_ ALLOW_ INTERNAL_ DEPENDENCIES - Pool reuse policy: allow internal dependency insertion.
- CU_
MEMPOOL_ ATTR_ REUSE_ ALLOW_ OPPORTUNISTIC - Pool reuse policy: allow opportunistic reuse.
- CU_
MEMPOOL_ ATTR_ REUSE_ FOLLOW_ EVENT_ DEPENDENCIES - Pool reuse policy: follow event dependencies.
- CU_
MEMPOOL_ ATTR_ USED_ MEM_ CURRENT - Current used memory (bytes) — read-only.
- CU_
MEMPOOL_ ATTR_ USED_ MEM_ HIGH - High-water mark of used memory (bytes) — resettable.
Functions§
- stream_
alloc - Allocate memory on a stream using the default pool for device 0.
- stream_
free - Free a stream-ordered allocation using a temporary default pool.