pub struct Arena {
pub buffer: Buffer,
pub size: usize,
/* private fields */
}Fields§
§buffer: Buffer§size: usizeTotal arena size in bytes.
Implementations§
Source§impl Arena
impl Arena
pub fn from_plan(plan: &MemoryPlan) -> Self
pub fn has(&self, id: NodeId) -> bool
Sourcepub fn byte_offset(&self, id: NodeId) -> usize
pub fn byte_offset(&self, id: NodeId) -> usize
Byte offset of a node’s slot.
Sourcepub fn elem_offset(&self, id: NodeId) -> u32
pub fn elem_offset(&self, id: NodeId) -> u32
f32-element offset of a node’s slot (for push constants).
Sourcepub fn slot_elems(&self, id: NodeId) -> usize
pub fn slot_elems(&self, id: NodeId) -> usize
Slot capacity in f32 elements.
Sourcepub fn write_f32(&self, id: NodeId, data: &[f32])
pub fn write_f32(&self, id: NodeId, data: &[f32])
Upload f32 data into a node’s slot (clamped to the slot capacity).
Sourcepub fn write_bytes(&self, id: NodeId, data: &[u8])
pub fn write_bytes(&self, id: NodeId, data: &[u8])
Upload raw bytes into a node’s slot (for non-f32 packed params).
Sourcepub fn read_f32(&self, id: NodeId, n: usize) -> Vec<f32>
pub fn read_f32(&self, id: NodeId, n: usize) -> Vec<f32>
Read n f32 elements from a node’s slot.
Sourcepub fn copy_into(&self, dst: &Arena)
pub fn copy_into(&self, dst: &Arena)
Byte-for-byte copy this arena’s contents into dst (same plan/size).
Used by clone_for_cache to carry params + constants into a twin.
Sourcepub fn read_bytes(&self, id: NodeId, nbytes: usize) -> Vec<u8> ⓘ
pub fn read_bytes(&self, id: NodeId, nbytes: usize) -> Vec<u8> ⓘ
Read nbytes raw bytes from a node’s slot (packed quant weights).
Sourcepub fn copy_node_f32_prefix(&self, dst: NodeId, src: NodeId, n: usize)
pub fn copy_node_f32_prefix(&self, dst: NodeId, src: NodeId, n: usize)
In-arena copy of n f32 elements from src’s slot into dst’s slot,
clamped to both slot capacities. Used by the GPU-resident K/V feed to
fold a decode step’s new-token K/V output back into the past_k_* input
slot without a host round-trip. The arena is HOST_COHERENT and the GPU
queue is idle by the time this runs (see submit_and_wait in run), so
a plain mapped memcpy is safe and visible to the next dispatch.
Sourcepub fn copy_node_f32_range(
&self,
dst: NodeId,
dst_elem: usize,
src: NodeId,
src_elem: usize,
n: usize,
)
pub fn copy_node_f32_range( &self, dst: NodeId, dst_elem: usize, src: NodeId, src_elem: usize, n: usize, )
In-arena copy of n f32 elements from src slot (starting at element
offset src_elem) into dst slot (starting at dst_elem), clamped to
both slot capacities. Used by the decode K/V feed to drop a single new
token row (output row upper) into the resident past_k_* slot at the
active row — without disturbing the already-resident prefix.
Trait Implementations§
Auto Trait Implementations§
impl !Sync for Arena
impl Freeze for Arena
impl RefUnwindSafe for Arena
impl Unpin for Arena
impl UnsafeUnpin for Arena
impl UnwindSafe for Arena
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more