pub trait ComputeStorage: Send {
type Resource: Send;
// Required methods
fn alignment(&self) -> usize;
fn get(&mut self, handle: &StorageHandle) -> Self::Resource;
fn alloc(&mut self, size: u64) -> Result<StorageHandle, IoError>;
fn dealloc(&mut self, id: StorageId);
fn flush(&mut self);
// Provided methods
fn get_pinned(
&mut self,
handle: &StorageHandle,
_binding: ManagedMemoryBinding,
) -> Self::Resource { ... }
fn supports_relocation(&self) -> bool { ... }
fn available_memory(&self) -> Option<u64> { ... }
fn relocation_barrier(&mut self) -> Result<(), IoError> { ... }
fn relocation_copy(
&mut self,
_source: &StorageHandle,
_target: &StorageHandle,
) -> Result<(), IoError> { ... }
fn relocation_copy_batch<'a>(
&mut self,
copies: impl IntoIterator<Item = (&'a StorageHandle, &'a StorageHandle)>,
) -> Result<(), IoError>
where Self: Sized { ... }
fn relocation_complete(&mut self) -> Result<(), IoError> { ... }
}Expand description
Storage types are responsible for allocating and deallocating memory.
Required Associated Types§
Required Methods§
Sourcefn get(&mut self, handle: &StorageHandle) -> Self::Resource
fn get(&mut self, handle: &StorageHandle) -> Self::Resource
Returns the underlying resource for a specified storage handle
Sourcefn alloc(&mut self, size: u64) -> Result<StorageHandle, IoError>
fn alloc(&mut self, size: u64) -> Result<StorageHandle, IoError>
Allocates size units of memory and returns a handle to it
Sourcefn dealloc(&mut self, id: StorageId)
fn dealloc(&mut self, id: StorageId)
Deallocates the memory pointed by the given storage id.
These deallocations might need to be flushed with Self::flush.
Provided Methods§
Sourcefn get_pinned(
&mut self,
handle: &StorageHandle,
_binding: ManagedMemoryBinding,
) -> Self::Resource
fn get_pinned( &mut self, handle: &StorageHandle, _binding: ManagedMemoryBinding, ) -> Self::Resource
Resolve a resource while retaining its address lease in adaptive mode.
Sourcefn supports_relocation(&self) -> bool
fn supports_relocation(&self) -> bool
Whether this storage implements real relocation copies and completion waits.
Sourcefn available_memory(&self) -> Option<u64>
fn available_memory(&self) -> Option<u64>
Driver-reported free device memory in bytes; None when it is unknown.
Sourcefn relocation_barrier(&mut self) -> Result<(), IoError>
fn relocation_barrier(&mut self) -> Result<(), IoError>
Wait for all users of storage addresses, including work on other streams.
Sourcefn relocation_copy(
&mut self,
_source: &StorageHandle,
_target: &StorageHandle,
) -> Result<(), IoError>
fn relocation_copy( &mut self, _source: &StorageHandle, _target: &StorageHandle, ) -> Result<(), IoError>
Enqueue a device-local copy between disjoint, equally sized reservations.
Sourcefn relocation_copy_batch<'a>(
&mut self,
copies: impl IntoIterator<Item = (&'a StorageHandle, &'a StorageHandle)>,
) -> Result<(), IoError>where
Self: Sized,
fn relocation_copy_batch<'a>(
&mut self,
copies: impl IntoIterator<Item = (&'a StorageHandle, &'a StorageHandle)>,
) -> Result<(), IoError>where
Self: Sized,
Enqueue a group of relocation copies, with completion checked separately.
Sourcefn relocation_complete(&mut self) -> Result<(), IoError>
fn relocation_complete(&mut self) -> Result<(), IoError>
Wait for copies even when an earlier enqueue failed. Failure is not completion.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".