pub enum RawBuffer {
Cpu {
data: UnsafeCell<AlignedBuffer>,
cpu_accessible: bool,
},
Mmap {
data: Mmap,
size: usize,
},
}Expand description
Opaque handle to device memory.
§Safety
RawBuffer uses UnsafeCell for interior mutability without locking overhead.
Thread safety is guaranteed at a higher level by the scheduler:
- Allocation:
OnceLockinBufferDataensures single initialization - Buffer Access: The scheduler guarantees exclusive access to each buffer during kernel execution - no two kernels access the same buffer concurrently
- Kernel Execution: Raw pointers passed to JIT code; Rust doesn’t access buffer data during execution
This design follows Tinygrad’s approach where buffer synchronization is the scheduler’s responsibility, not the buffer’s.
Variants§
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RawBuffer
impl !RefUnwindSafe for RawBuffer
impl Unpin for RawBuffer
impl UnsafeUnpin for RawBuffer
impl UnwindSafe for RawBuffer
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