pub struct GpuBuddy(/* private fields */);Expand description
GPU buddy allocator instance.
This structure wraps the C gpu_buddy allocator using reference counting.
The allocator is automatically cleaned up when all references are dropped.
Refer to the module-level documentation for usage examples.
Implementations§
Source§impl GpuBuddy
impl GpuBuddy
Sourcepub fn new(params: GpuBuddyParams) -> Result<Self>
pub fn new(params: GpuBuddyParams) -> Result<Self>
Create a new buddy allocator.
The allocator manages a contiguous address space of the given size, with the specified minimum allocation unit (chunk_size must be at least 4KB).
Sourcepub fn base_offset(&self) -> u64
pub fn base_offset(&self) -> u64
Get the base offset for allocations.
Sourcepub fn chunk_size(&self) -> Alignment
pub fn chunk_size(&self) -> Alignment
Get the chunk size (minimum allocation unit).
Sourcepub fn alloc_blocks(
&self,
mode: GpuBuddyAllocMode,
size: u64,
min_block_size: Alignment,
flags: impl Into<GpuBuddyAllocFlags>,
) -> impl PinInit<AllocatedBlocks, Error>
pub fn alloc_blocks( &self, mode: GpuBuddyAllocMode, size: u64, min_block_size: Alignment, flags: impl Into<GpuBuddyAllocFlags>, ) -> impl PinInit<AllocatedBlocks, Error>
Allocate blocks from the buddy allocator.
Returns a pin-initializer for AllocatedBlocks.
Auto Trait Implementations§
impl Freeze for GpuBuddy
impl !RefUnwindSafe for GpuBuddy
impl Send for GpuBuddy
impl Sync for GpuBuddy
impl Unpin for GpuBuddy
impl UnsafeUnpin for GpuBuddy
impl !UnwindSafe for GpuBuddy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
Initializes
slot. Read more