pub struct Allocator;
Expand description
Heterogeneous memory allocator.
Implementations
sourceimpl Allocator
impl Allocator
sourcepub fn alloc_mem<T: Clone + Default + DeviceCopy>(
mem_type: MemType,
len: usize
) -> Mem<T>
pub fn alloc_mem<T: Clone + Default + DeviceCopy>(
mem_type: MemType,
len: usize
) -> Mem<T>
Allocates memory of the specified type
sourcepub fn alloc_deref_mem<T: Clone + Default + DeviceCopy>(
mem_type: DerefMemType,
len: usize
) -> DerefMem<T>
pub fn alloc_deref_mem<T: Clone + Default + DeviceCopy>(
mem_type: DerefMemType,
len: usize
) -> DerefMem<T>
Allocates host-dereferencable memory of the specified type
sourcepub fn mem_alloc_fn<T: Clone + Default + DeviceCopy>(
mem_type: MemType
) -> MemAllocFn<T>
pub fn mem_alloc_fn<T: Clone + Default + DeviceCopy>(
mem_type: MemType
) -> MemAllocFn<T>
Returns a generic ‘Mem’ memory allocator that allocates memory of the specified ‘Mem’ type.
sourcepub fn deref_mem_alloc_fn<T: Clone + Default + DeviceCopy>(
mem_type: DerefMemType
) -> DerefMemAllocFn<T>
pub fn deref_mem_alloc_fn<T: Clone + Default + DeviceCopy>(
mem_type: DerefMemType
) -> DerefMemAllocFn<T>
Returns a generic ‘DerefMem’ memory allocator that allocates memory of the specified ‘DerefMem’ type.
sourcepub fn mem_spill_alloc_fn<T>(
cache_spill_type: CacheSpillType
) -> (MemSpillAllocFn<T>, Rc<RefCell<Option<usize>>>) where
T: Clone + Default + DeviceCopy,
pub fn mem_spill_alloc_fn<T>(
cache_spill_type: CacheSpillType
) -> (MemSpillAllocFn<T>, Rc<RefCell<Option<usize>>>) where
T: Clone + Default + DeviceCopy,
Captures the cache memory type and returns a function that returns an allocator
Effectively, we’re gathering the arguments by currying
mem_spill_alloc_fn_internal
.
The returned allocator uses GPU memory until cache_max_len
is reached.
Then, the allocator spills the remainder to CPU memory.
The functional programming approach used here solves the leaky abstraction problem. Oftentimes, the knowledge about how much cache space is available, and the total required space for the data relation reside in two different code modules. Thus, we aggregate this knowledge in a closure to retain modularity, instead of leaking internal details of the modules.
Returns a “future” that is set to the cached length when the allocator is invoked, for logging purposes.
Auto Trait Implementations
impl RefUnwindSafe for Allocator
impl Send for Allocator
impl Sync for Allocator
impl Unpin for Allocator
impl UnwindSafe for Allocator
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more