Skip to main content

LoopFabric

Struct LoopFabric 

Source
pub struct LoopFabric {
Show 14 fields pub n_in: usize, pub n_state: usize, pub init: Vec<Src>, pub lo: Src, pub hi: Src, pub invariants: Vec<Src>, pub body: Vec<LoopCell>, pub next: Vec<Src>, pub result_state: usize, pub seq_input: Option<usize>, pub epilogue: Vec<LoopCell>, pub epilogue_result: Src, pub prologue_heap: Vec<LoopCell>, pub seq_heap_ptr: Option<Src>,
}
Expand description

A counted-loop residual lowered to a CGRA: a fixed BODY datapath (SSA over the current loop-carried state + the induction variable + loop invariants, INCLUDING predicated select tiles for data-dependent branches) driven by a sequential controller that clocks the state through the body once per induction value in the inclusive range lo..=hi.

Fields§

§n_in: usize

Circuit input arity (the function’s parameters become circuit inputs in0..).

§n_state: usize

Number of loop-carried state registers (the accumulators).

§init: Vec<Src>

Initial value of each state register, as a Src over the circuit inputs / constants.

§lo: Src

Inclusive induction range: the induction variable takes lo, lo+1, …, hi. Over inputs.

§hi: Src§invariants: Vec<Src>

Loop-invariant values read by the body (fixed across iterations), as Src over inputs.

§body: Vec<LoopCell>

The body as SSA LoopCells. Body-input convention for Src::In(k): 0..n_state = the current state registers, n_state = the induction variable, n_state+1+j = invariant j.

§next: Vec<Src>

For each state register, the Src (over body inputs / body vals) giving its NEXT value after one execution of the body.

§result_state: usize

Which state register holds the loop’s result (returned after the loop).

§seq_input: Option<usize>

Some(k) marks a SEQUENCE loop (Repeat for x in xs) rather than a numeric range loop: input k is the iterated Seq (a memory array), the induction range is 0..=len-1 derived from the sequence’s length at eval time, and the body reads xs[iv] through a LoopCell::MemRead tile. None is a plain counted range loop (lo/hi are the numeric bounds). This is “collections as a spatial resource”: the induction variable IS the address generator streaming the array.

§epilogue: Vec<LoopCell>

The POST-LOOP transform (an epilogue island): straight-line LoopCells over the loop’s FINAL state (Src::In(i) = final value of state register i), computing the returned value when the function does more than return an accumulator (e.g. Return (sum 1..n) * 2). Empty when the loop result IS a carried register — then Self::result_state names it. This is the first CFG COMPOSITION: a loop island feeding a transform island, sequenced into one whole-function fabric.

§epilogue_result: Src

When epilogue is non-empty, the Src (over the final state / epilogue vals) giving the result.

§prologue_heap: Vec<LoopCell>

The PROLOGUE HEAP ISLAND: straight-line LoopCells that build any LOCAL collection the loop iterates (Let ps be [(1,2),(3,4)] → HeapAlloc/HeapWrite). Evaluated ONCE before the loop into a shared heap; the loop body then reads/writes that same heap. Empty for a numeric / parameter-sequence loop.

§seq_heap_ptr: Option<Src>

Some(ptr) marks a FOREACH OVER A LOCAL HEAP LIST (Repeat for (a,b) in ps, ps a local): ptr (a Src over the prologue-heap island) is the iterated list’s pointer, its length is heap[ptr], and element iv is heap[ptr + 1 + iv] — the body destructures it via HeapRead with the heap threaded. Distinct from Self::seq_input (a scalar parameter array). ptr is passed to the body as the FINAL invariant so the element-address generator can read it.

Trait Implementations§

Source§

impl Clone for LoopFabric

Source§

fn clone(&self) -> LoopFabric

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 LoopFabric

Source§

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

Formats the value using the given formatter. Read more

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,

§

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