Expand description
Unified Shared Memory (USM) allocation logic for Intel Level Zero.
Level Zero exposes three flavours of Unified Shared Memory:
- Device USM (
zeMemAllocDevice) — resident in device-local memory, not directly CPU-accessible; fastest for kernels. - Host USM (
zeMemAllocHost) — resident in host memory, accessible by both CPU and GPU (the GPU reads it across the bus). - Shared USM (
zeMemAllocShared) — migratable between host and device; the driver moves pages on demand.
The device-gated part is the raw zeMemAlloc* call (which lives in
crate::memory). Everything in this module is host-side bookkeeping:
the suballocation arithmetic, alignment rounding, memory-ordinal selection
from a queried property table, and the memory-advise model. All of it is
CPU-testable without a physical Intel GPU.
A backend allocates a few large zeMemAlloc* blocks and sub-allocates
individual tensors out of them via UsmSuballocator, returning a byte
offset into the block. The caller then pointer-offsets the block base —
that pointer arithmetic is the only step needing a real allocation.
Structs§
- Memory
Advise State - Accumulates memory-advise hints for a single USM range.
- Memory
Ordinal Info - A single entry of
zeDeviceGetMemoryPropertiesoutput. - Memory
Property Table - A queried memory-property table for one device.
- UsmSub
Allocation - A sub-allocation carved out of a USM block.
- UsmSuballocator
- First-fit free-list sub-allocator over a single USM block.
Enums§
- Memory
Advice - Memory-advise hints applied to a shared/device USM range.
- UsmKind
- The kind of Unified Shared Memory backing an allocation.
Constants§
- USM_
DEFAULT_ ALIGNMENT - Minimum alignment Level Zero guarantees for any USM allocation (bytes).
Functions§
- align_
up - Round
valueup to the nearest multiple ofalignment(a power of two).