math_sum.bend checks
raw source on the hub · import stelliferous@0.0.3.0/math_sum.bend as Math_sum
The FP32 sum of the library: value i goes to lane i % 8, each lane keeps its rounded sum and the error of every addition (TwoSum), and the lanes merge in a fixed tree, (0,1),(2,3),(4,5),(6,7), then pairs of those.
2 imports
import Base import ./kernel_tile.bend as Tile
Types
type Parts source · line 8 · raw
Data
A rounded sum and the error it left out.
Parts@hi:F32 -> @lo:F32 -> Parts
type Lanes source · line 19 · raw
Data
The eight lanes, lane 0 next. After n steps the lane of value n is in front: slot k holds lane (n + k) % 8, and phase counts the steps.
Lanes@hi:0xd6aaab858a4fbd1461bd0fee27b97184/kernel_tile.Tile8 -> @lo:0xd6aaab858a4fbd1461bd0fee27b97184/kernel_tile.Tile8 -> @phase:U32 -> Lanes
Definitions
def two_sum source · line 12 · raw
@+a:F32 -> @+b:F32 -> Parts
hi = a + b rounded, and lo with hi + lo = a + b exactly when nothing overflows.
def zero source · line 22 · raw
Lanes
def turned source · line 25 · raw
@+h1:F32 -> @+h2:F32 -> @+h3:F32 -> @+h4:F32 -> @+h5:F32 -> @+h6:F32 -> @+h7:F32 -> @l1:F32 -> @l2:F32 -> @l3:F32 -> @l4:F32 -> @l5:F32 -> @l6:F32 -> @l7:F32 -> @l0:F32 -> @+phase:U32 -> @parts:Parts -> Lanes
def stepped source · line 30 · raw
@+value:F32 -> @lanes:Lanes -> Lanes
def step source · line 35 · raw
@lanes:Lanes -> @value:F32 -> Lanes
The front lane takes the value, then the lanes turn by one.
def merged source · line 38 · raw
@+lo:F32 -> @parts:Parts -> Parts
def merge source · line 42 · raw
@left:Parts -> @right:Parts -> Parts
def tree source · line 47 · raw
@p0:Parts -> @p1:Parts -> @p2:Parts -> @p3:Parts -> @p4:Parts -> @p5:Parts -> @p6:Parts -> @p7:Parts -> Parts
def in_order source · line 51 · raw
@turns:Nat -> @+p0:Parts -> @+p1:Parts -> @+p2:Parts -> @+p3:Parts -> @+p4:Parts -> @+p5:Parts -> @+p6:Parts -> @+p7:Parts -> Parts
Lane j sits in slot (j - turns) % 8.
def rounded source · line 62 · raw
@parts:Parts -> F32
def total source · line 67 · raw
@lanes:Lanes -> F32
The sum of the values stepped into the lanes.