pub struct PinnedStorage { /* private fields */ }Expand description
CUDA pinned host memory allocated via cudaHostAlloc.
Implementations§
Source§impl PinnedStorage
impl PinnedStorage
Sourcepub fn new(len: usize) -> Result<Self>
pub fn new(len: usize) -> Result<Self>
Allocate new pinned memory of the given size.
This is a convenience method that calls new_for_device(len, None).
§Arguments
len- Size in bytes to allocate
Sourcepub fn new_for_device(len: usize, device_id: Option<u32>) -> Result<Self>
pub fn new_for_device(len: usize, device_id: Option<u32>) -> Result<Self>
Allocate pinned memory, optionally NUMA-aware for a specific GPU.
When device_id is Some, NUMA-aware allocation is attempted by default:
a worker thread pinned to the GPU’s NUMA node performs the allocation,
ensuring optimal memory placement via first-touch policy. If the GPU’s
NUMA node cannot be determined, allocation falls back to the direct path.
Set DYN_MEMORY_DISABLE_NUMA=1 to skip NUMA optimization entirely.
When device_id is None, a direct allocation is performed on device 0.
§Arguments
len- Size in bytes to allocatedevice_id- If Some, use NUMA-aware allocation on the GPU’s NUMA node
§Errors
Returns an error if:
lenis 0- CUDA context creation fails
- Memory allocation fails
Sourcepub unsafe fn as_ptr(&self) -> *const u8
pub unsafe fn as_ptr(&self) -> *const u8
Get a pointer to the underlying memory.
§Safety
The caller must ensure the pointer is not used after this storage is dropped.
Sourcepub unsafe fn as_mut_ptr(&mut self) -> *mut u8
pub unsafe fn as_mut_ptr(&mut self) -> *mut u8
Get a mutable pointer to the underlying memory.
§Safety
The caller must ensure the pointer is not used after this storage is dropped and that there are no other references to this memory.
Sourcepub fn ctx(&self) -> &Arc<CudaContext>
pub fn ctx(&self) -> &Arc<CudaContext>
Get a reference to the CUDA context used for this allocation.