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¶
Exceptions¶
A handle whose allocation was freed (or never existed) was used. |
|
The tier cannot hold the requested allocation. |
Classes¶
One allocation: identity plus placement. |
|
First-fit allocator over one declared tier's |
Module Contents¶
- exception dau_driver.storage.StaleHandleError[source]¶
Bases:
RuntimeErrorA 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:
RuntimeErrorThe 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.
generationis 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 — andallocatorbinds 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
datainto the handle’s allocation through the device.