Skip to main content

ComputeStorage

Trait ComputeStorage 

Source
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 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§

Source

type Resource: Send

The resource associated type determines the way data is implemented and how it can be accessed by kernels.

Required Methods§

Source

fn alignment(&self) -> usize

The alignment memory is allocated with in this storage.

Source

fn get(&mut self, handle: &StorageHandle) -> Self::Resource

Returns the underlying resource for a specified storage handle

Source

fn alloc(&mut self, size: u64) -> Result<StorageHandle, IoError>

Allocates size units of memory and returns a handle to it

Source

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.

Source

fn flush(&mut self)

Flush deallocations when required.

Provided Methods§

Source

fn get_pinned( &mut self, handle: &StorageHandle, _binding: ManagedMemoryBinding, ) -> Self::Resource

Resolve a resource while retaining its address lease in adaptive mode.

Source

fn supports_relocation(&self) -> bool

Whether this storage implements real relocation copies and completion waits.

Source

fn relocation_barrier(&mut self) -> Result<(), IoError>

Wait for all users of storage addresses, including work on other streams.

Source

fn relocation_copy( &mut self, _source: &StorageHandle, _target: &StorageHandle, ) -> Result<(), IoError>

Enqueue a device-local copy between disjoint, equally sized reservations.

Source

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.

Source

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".

Implementors§