Skip to main content

Module buffer

Module buffer 

Source
Expand description

Buffer protocol types for the Hurray tensor format.

A buffer handle is the unit by which a tensor descriptor references a contiguous region of memory. This module defines the in-memory representation of buffer handles, the device tag that identifies where a buffer resides, and a colocation validator that enforces the spec’s rule that all buffers within a single tensor descriptor must reside on the same device.

The binary encoding of a buffer handle in the descriptor wire format is defined in docs/spec/metadata.md § Buffer Table. The normative rules governing alignment, device tags, ownership, and zero-copy invariants are in docs/spec/buffer-protocol.md.

§Quick reference

ItemDescription
DeviceTagIdentifies the memory space a buffer resides in
SyncModeDescribes how the producer–consumer memory ordering is established
BufferHandleDeclares a buffer’s size, alignment, device, and sync mode
validate_colocationChecks that a set of handles all share the same device
MIN_BUFFER_ALIGNMENT64-byte SIMD minimum for non-empty buffers
PAGE_ALIGNMENT4096-byte recommendation for GPU / IPC buffers

Structs§

BufferHandle
A declaration of a buffer’s size, alignment, device location, and sync mode.
PrivateMemoryClass
An implementation-private memory class byte, guaranteed to be in 0xF0–0xFE.
PrivateTag
An implementation-private device tag byte, guaranteed to be in 0xF0–0xFE.

Enums§

DeviceTag
Identifies the memory space in which a buffer resides.
MemoryClass
The memory access class of a buffer handle.
SyncMode
Describes how the producer–consumer memory ordering guarantee is established for a buffer.

Constants§

MIN_BUFFER_ALIGNMENT
Minimum buffer alignment for SIMD compatibility (64 bytes).
PAGE_ALIGNMENT
Recommended alignment for GPU, IPC, and RDMA buffers (one host page = 4096 bytes).

Functions§

validate_colocation
Checks that all buffer handles in handles share the same DeviceTag and MemoryClass.