dau_driver.storage

Host-side storage allocation over a platform’s declared tiers.

The dumb half of the allocation lifecycle in STORAGE_AND_NOC.md: the host owns an allocator per shared tier and hands out generation-checked handles; tiles consume grants and never allocate. The handle table this allocator maintains is exactly what a future allocator tile would drive — the API does not change when it does.

Freed storage is never readdressed: free bumps the handle’s generation, and a stale handle raises instead of resolving to reused memory. Exhaustion raises before anything is staged. stage/resolve take any object with write_dma (the duck-typed device convention).

Attributes

_ALLOCATOR_TOKENS

Exceptions

StaleHandleError

A handle whose allocation was freed (or never existed) was used.

StorageExhaustedError

The tier cannot hold the requested allocation.

Classes

StorageHandle

One allocation: identity plus placement. generation is the

StorageAllocator

First-fit allocator over one declared tier's [base, base+capacity),

Module Contents

exception dau_driver.storage.StaleHandleError[source]

Bases: RuntimeError

A handle whose allocation was freed (or never existed) was used.

Initialize self. See help(type(self)) for accurate signature.

exception dau_driver.storage.StorageExhaustedError[source]

Bases: RuntimeError

The tier cannot hold the requested allocation.

Initialize self. See help(type(self)) for accurate signature.

dau_driver.storage._ALLOCATOR_TOKENS
class dau_driver.storage.StorageHandle[source]

One allocation: identity plus placement. generation is the freed-storage guard — the allocator refuses any handle whose id has been freed since, so reused space is never readable through an old name — and allocator binds the handle to the allocator that issued it, so a handle from one tier can never free or address another’s memory. Every operation trusts only the allocator’s LIVE record, never the handle’s own copy of base/capacity.

id: int
generation: int
base: int
capacity: int
tier: str
allocator: int
class dau_driver.storage.StorageAllocator(*, tier: str, capacity_bytes: int, base: int = 0, reserved: tuple[tuple[int, int], ...] = (), align: int = 64)[source]

First-fit allocator over one declared tier’s [base, base+capacity), minus reserved regions (lane-output windows, staging areas).

tier
align = 64
_token
_free: list[tuple[int, int]]
_live: dict[int, StorageHandle]
_generations: dict[int, int]
_free_ids: list[int] = []
_next_id = 0
allocate(nbytes: int) → StorageHandle[source]
free(handle: StorageHandle) → None[source]
resolve(handle: StorageHandle) → int[source]

The handle’s device address, generation-checked. Freed storage is never readdressed through an old name.

stage(device, handle: StorageHandle, data: bytes) → None[source]

Write data into the handle’s allocation through the device.

_insert_free(start: int, end: int) → None[source]