Contents

class

SushiAI::Graph::MemoryPlan

The planner's output: one Placement per value, plus arena sizes.

Declared in
include/SushiAI/graph/memory_plan.hpp

A value type. Copyable, and cheap enough to hand around by value; it holds two vectors and nothing that owns memory on a device.

Public member functions

MemoryPlan()=default

The empty plan: it covers no value and asks for no arena.

Adopting one is how a caller says "pack nothing" - every value then falls through to its own allocation, which is what the library did before this pass existed and what an A/B measurement of the pass needs as its control.

std::size_t value_count() const noexcept

How many values the plan covers.

const Placement & placement(ValueId id) const

Where id lives.

Parameters

id

The value to look up.

Returns

Its placement.

Exceptions

Error

If id is not covered by this plan.

bool is_packed(ValueId id) const noexcept

Whether id was packed into an arena.

ValueId buffer_of(ValueId id) const noexcept

Resolves which value owns the specified value's bytes.

Non-throwing lookup to resolve alias chains even in an empty plan.

Parameters

id

The value to resolve.

Returns

Owning value id, or id itself if unmapped.

SushiRuntime::span< const Arena > arenas() const noexcept

Every arena the plan asks for, in id order.

std::size_t arena_bytes() const noexcept

Total bytes across every arena.

std::size_t unpacked_bytes() const noexcept

What the packed buffers would have cost one allocation each.

bool reuse_enabled() const noexcept

Whether live ranges were actually overlapped.

False means every buffer got its own slot - a correct plan that saves nothing. reuse_note() says why.

std::string_view reuse_note() const noexcept

Why reuse was declined, or empty when it ran.

Static public member functions

static MemoryPlan build(const Graph &graph, const PlanOptions &options={})

Generates an arena memory plan for the given graph.

Parameters

graph

The graph to plan.

options

Packing and alignment options.

Returns

The computed memory plan.

Exceptions

Error

If alignment is zero or graph topological order is broken.