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, the allocation is performed on a worker thread
pinned to the GPU’s NUMA node, ensuring optimal memory placement via
first-touch policy, However, NUMA is only used if enabled via the
DYN_KVBM_ENABLE_NUMA=1 environment variable.
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.