pub struct LevelZeroMemoryManager { /* private fields */ }Expand description
Manages a pool of Level Zero device buffers, returning opaque u64 handles.
Uses explicit host-staging buffers and command lists for host↔device data transfers, matching the Level Zero programming model.
All public methods take &self so the manager can be shared behind Arc.
Implementations§
Source§impl LevelZeroMemoryManager
impl LevelZeroMemoryManager
Sourcepub fn new(device: Arc<LevelZeroDevice>) -> Self
pub fn new(device: Arc<LevelZeroDevice>) -> Self
Create a new memory manager backed by device.
Sourcepub fn device_ptr(&self, handle: u64) -> LevelZeroResult<*mut c_void>
pub fn device_ptr(&self, handle: u64) -> LevelZeroResult<*mut c_void>
Get the raw device pointer for a buffer handle.
Returns the *mut c_void device pointer that Level Zero allocated for
the given handle. This is needed to pass as a kernel argument.
Sourcepub fn alloc(&self, bytes: usize) -> LevelZeroResult<u64>
pub fn alloc(&self, bytes: usize) -> LevelZeroResult<u64>
Allocate bytes bytes of device memory.
Returns an opaque handle. The caller must eventually call free.
Sourcepub fn free(&self, handle: u64) -> LevelZeroResult<()>
pub fn free(&self, handle: u64) -> LevelZeroResult<()>
Release the device buffer associated with handle.
Unknown handles are silently ignored (idempotent free).
Sourcepub fn copy_to_device(&self, handle: u64, src: &[u8]) -> LevelZeroResult<()>
pub fn copy_to_device(&self, handle: u64, src: &[u8]) -> LevelZeroResult<()>
Upload host bytes src into the device buffer identified by handle.
Allocates a temporary host-side staging buffer, copies the data into it, then uses a command list to schedule the device copy and waits for completion.
Sourcepub fn copy_from_device(
&self,
dst: &mut [u8],
handle: u64,
) -> LevelZeroResult<()>
pub fn copy_from_device( &self, dst: &mut [u8], handle: u64, ) -> LevelZeroResult<()>
Download device buffer handle into dst.
Uses a host-staging buffer and a command list for the device→host copy.