Skip to main content

SpatialProgram

Struct SpatialProgram 

Source
pub struct SpatialProgram {
Show 20 fields pub name: String, pub tile: TileShape, pub tensors: Vec<TensorDecl>, pub stages: Vec<Stage>, pub buffers: Vec<Buffer>, pub edges: Vec<Edge>, pub semaphores: Vec<Semaphore>, pub sections: Vec<SectionSpan>, pub trips: Vec<Trip>, pub links: Vec<LinkPoint>, pub work: WorkList, pub numerics: NumericsPolicy, pub claim: NumericsClaim, pub acc_tiles_used: usize, pub mem_banks: usize, pub requires: Requirements, pub placement: Option<Placement>, pub memory: Option<MemoryMap>, pub schedule: Option<Schedule>, pub certificate: Option<ChoreographyCertificate>,
}

Fields§

§name: String§tile: TileShape§tensors: Vec<TensorDecl>§stages: Vec<Stage>§buffers: Vec<Buffer>§edges: Vec<Edge>§semaphores: Vec<Semaphore>§sections: Vec<SectionSpan>

The sections, in execution order. EMPTY for a single-workload program — which is every program the one-op front end builds, so the field is absent from their serialization and every existing artifact and fixture parses and round-trips unchanged.

§trips: Vec<Trip>

The loop counts the program reads from its data (Trip); a loop names one by its index. EMPTY for every program whose counts are all fixed, so the field is absent from their serialization.

§links: Vec<LinkPoint>

Where this chip’s program halts for tensors to cross to or from another chip (LinkPoint), in order. EMPTY for every program that is a whole machine’s, so the field is absent from their serialization.

§work: WorkList§numerics: NumericsPolicy§claim: NumericsClaim§acc_tiles_used: usize

Accumulator tiles a compute stage may hold at once (recorded from the target by the passes).

§mem_banks: usize

The banks a site’s local memory interleaves its elements over (recorded from the target by the passes): the consecutive elements a lowering moves in one cycle. One — and absent from the serialization, so every program built before banks existed parses and round-trips unchanged — where a memory serves an element a cycle.

§requires: Requirements§placement: Option<Placement>§memory: Option<MemoryMap>§schedule: Option<Schedule>§certificate: Option<ChoreographyCertificate>

Implementations§

Source§

impl SpatialProgram

Source

pub fn tensor(&self, id: TensorId) -> &TensorDecl

Source

pub fn stage(&self, id: StageId) -> &Stage

Source

pub fn buffer(&self, id: BufferId) -> &Buffer

Source

pub fn page_extents(&self) -> Vec<usize>

★ THE TILES ONE PAGE OF EACH BUFFER HOLDS, by buffer index: the most tiles any op fills or drains one page of it with, and never fewer than its declared page_tiles.

A page is what the op that fills it writes. The evaluator keeps each page as that op’s list of tiles, and reads a page’s plane at that list’s width. The declared page can be smaller. On a target whose accumulator lives in registers, tile declares a matmul’s output as one tile per accumulator lane, because the GEMM kernel stores each lane’s tiles straight to the tensor and never stages the block. The choreography still packs the whole osh · osw block into one page of it. A lowering that stages every page through memory lays its slots out at this extent, or the pack writes past the ring.

Source

pub fn output_tensor(&self) -> Option<&TensorDecl>

Source

pub fn section_result(&self, section: Option<usize>) -> Option<&TensorDecl>

What a section’s work WRITES — the tensor its items’ rectangles and its plan’s grid are blocks of: the section’s Output, or, for a section whose every effect is an in-place update, the state it stores. None names the uncomposed program’s one implicit section.

Source

pub fn carries(&self) -> BTreeMap<BufferId, StageId>

Every CARRIED buffer and the one stage that updates it: a buffer a stage both reads and writes. A carry holds a value across the K blocks of an item — the running state of a fold — and its first page is written by a second stage, its init, before the blocks begin.

Source

pub fn fold_levels(&self) -> Vec<FoldLevel>

Each stage’s level in its item’s K-block fold (FoldLevel), derived from the dataflow. A value MOVES WITH THE BLOCKS when a load that steps LV_KBLOCK (or a K-block receive) brings it, or a body stage computes it. The BODY is every stage that reads such a value, every carry’s update, and every stage that reads a carry and computes what the body reads (a block’s limit from its running start); the EPILOGUE is every other stage that reads a carry — its value after the last block — or what the epilogue computed; the PROLOGUE is what remains: stages that read only values fixed for the item.

Source

pub fn section_of_stage(&self, s: StageId) -> Option<usize>

The section a stage belongs to, by index. None for an uncomposed program (which is ONE implicit section, so every section-scoped query falls back to the whole program).

Source

pub fn section_of_buffer(&self, b: BufferId) -> Option<usize>

The section a buffer belongs to, by index.

Source

pub fn section_of_item(&self, i: WorkItemId) -> Option<usize>

The section a work item belongs to, by index.

Source

pub fn items_at_in(&self, section: Option<usize>, site: Site) -> Vec<WorkItemId>

The work items of site WITHIN a section — the composed program’s item list is the sections’ concatenated, so an unscoped items_at would hand a section every other section’s items.

Source

pub fn site_items(&self) -> SiteItems<'_>

Self::items_at_in for every section and site at once, built in one pass over the placement, for the loops that ask it per stage or per executed op: each question is a lookup, not a copy of the site’s item list.

Source

pub fn plan_of_stage(&self, s: StageId) -> Option<BlockPlan>

The plan a stage was lowered under: its section’s, or the program’s own.

Source

pub fn state_tensors(&self) -> Vec<&TensorDecl>

Every tensor the program carries ACROSS steps — the state a second token chains through.

Source

pub fn dim_classes(&self) -> Vec<Vec<(TensorId, DimAxis)>>

Tile dimensions the computation forces equal: a GEMM’s A.cols ≡ B.rows (K), B.cols ≡ C.cols (N), A.rows ≡ C.rows (M); an elementwise op’s operands and result share both extents; a row op’s rows and its per-column parameters share its width. A lowering prints one runtime symbol per class, so a kernel’s address arithmetic names each extent once — the form the vendor’s kernels have.

Source

pub fn dim_representative( &self, tensor: TensorId, axis: DimAxis, ) -> (TensorId, DimAxis)

The representative of a tile dimension’s class: the output tensor’s extent when the class reaches the output, else the lowest-numbered tensor’s.

Source

pub fn buffer_bytes(&self, b: &Buffer) -> usize

Source

pub fn phase(&self) -> Phase

Source

pub fn neutral_dump(&self) -> String

The deterministic, total, parseable dump of the program (the certificate travels separately).

Source

pub fn parse_neutral(s: &str) -> Result<SpatialProgram, String>

Source

pub fn sites(&self) -> BTreeSet<Site>

Every distinct site any stage is placed on.

Source

pub fn stage_group(&self, s: &Stage) -> Option<GroupId>

The multicast group a Load sends to or a Recv receives from.

Source

pub fn dram_tiles_read(&self) -> u64

DRAM tiles the Load stages read over the whole run.

Source

pub fn engine_signature(&self, p: &EngineProgram) -> String

A site-independent structural signature of an engine program: the kernel a lowering would emit. A buffer is keyed by its template AND its page: a kernel counts pages in literals, so two sites whose pages differ (a boundary site of a grid that does not divide the tile count) cannot share one.

Source

pub fn summary(&self) -> PlanSummary

The emergent plan.

Source

pub fn validate(&self) -> Result<(), IrViolation>

Every structural invariant, target-free. Runs after every pass.

Source

pub fn bound_counts(&self) -> Vec<usize>

Each trip’s greatest count, in trip order — the counts every static question takes.

Source

pub fn trip(&self, id: TripId) -> &Trip

Source

pub fn section_phases(&self) -> Vec<usize>

Each section’s PHASE: the run of sections one barrier closes, counted from the first.

Source

pub fn has_indirect_access(&self) -> bool

Whether any access anywhere in the program — a Load/Store tile address, a Generic map, in the stages or in the schedule’s own ops — is value-dependent. A lowering with no gather semantics refuses the whole program by name on this, before it could print past the term.

Source

pub fn generic_is_plain_pointwise( &self, iters: &[IterSpec], maps: &[ElemAccess], out: &ElemAccess, ins: &[BufferId], ) -> bool

Whether a Generic is the PLAIN pointwise form and nothing more: every axis parallel, every operand map the exact identity over its own page, the output map the identity with no indirect term. The integer fabric’s elementwise datapath can express exactly this and refuses the rest by name; a printer that pattern-matched the body alone would lower a transposed or gathered operand as if it were the identity.

Trait Implementations§

Source§

impl Clone for SpatialProgram

Source§

fn clone(&self) -> SpatialProgram

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SpatialProgram

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SpatialProgram

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for SpatialProgram

Source§

fn eq(&self, other: &SpatialProgram) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for SpatialProgram

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SpatialProgram

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,