pub struct MemoryManagement<Storage> { /* private fields */ }
Expand description
Reserves and keeps track of chunks of memory in the storage, and slices upon these chunks.
Implementations§
Source§impl<Storage: ComputeStorage> MemoryManagement<Storage>
impl<Storage: ComputeStorage> MemoryManagement<Storage>
Sourcepub fn from_configuration(
storage: Storage,
properties: &MemoryDeviceProperties,
config: MemoryConfiguration,
) -> Self
pub fn from_configuration( storage: Storage, properties: &MemoryDeviceProperties, config: MemoryConfiguration, ) -> Self
Creates the options from device limits.
Sourcepub fn cleanup(&mut self, explicit: bool)
pub fn cleanup(&mut self, explicit: bool)
Cleanup allocations in pools that are deemed unnecessary.
Sourcepub fn get(&mut self, binding: SliceBinding) -> Option<StorageHandle>
pub fn get(&mut self, binding: SliceBinding) -> Option<StorageHandle>
Returns the storage from the specified binding
Sourcepub fn get_resource(
&mut self,
binding: SliceBinding,
offset_start: Option<u64>,
offset_end: Option<u64>,
) -> Option<Storage::Resource>
pub fn get_resource( &mut self, binding: SliceBinding, offset_start: Option<u64>, offset_end: Option<u64>, ) -> Option<Storage::Resource>
Returns the resource from the storage at the specified handle
Sourcepub fn reserve(
&mut self,
size: u64,
exclude: Option<&StorageExclude>,
) -> SliceHandle
pub fn reserve( &mut self, size: u64, exclude: Option<&StorageExclude>, ) -> SliceHandle
Finds a spot in memory for a resource with the given size in bytes, and returns a handle to it
Sourcepub fn storage(&mut self) -> &mut Storage
pub fn storage(&mut self) -> &mut Storage
Fetch the storage used by the memory manager.
§Notes
The storage should probably not be used for allocations since the handles won’t be compatible with the ones provided by the current trait. Prefer using the alloc and dealloc functions.
This is useful if you need to time the deallocations based on async computation, or to change the mode of storage for different reasons.
Sourcepub fn memory_usage(&self) -> MemoryUsage
pub fn memory_usage(&self) -> MemoryUsage
Get the current memory usage.
Sourcepub fn print_memory_usage(&self)
pub fn print_memory_usage(&self)
Print out a report of the current memory usage.