Deriving the matrix–vector operators
The BLAS Level-2 operators — gemv, ger, trmv, symv, syr, syr2 — are all
built from a small set of recurring derivation patterns. This page collects those
patterns in one place; the SURE Algorithms catalog then presents
each operator leanly (the algorithm, its SURE, and an animation) and links back here
for the why. Reading this once makes every L2 spec self-explanatory.
Throughout, the design goal is a pure SURE — every dependence a constant offset — because uniformity is what makes an operator tile and schedule cleanly. The art is getting the operands onto faces and the scalars into the recurrence without introducing an affine (domain-spanning) dependence.
Pattern 1 — the reduction skeleton
Section titled “Pattern 1 — the reduction skeleton”A matrix–vector product is a reduction over . It is
matmul with the second matrix collapsed to a single vector:
with the completed sum at the terminal of the -sweep. The rows are
independent — the parallel (wavefront) direction. This is the core of gemv, trmv,
and symv.
Pattern 2 — the feed axis (a matrix needs a face)
Section titled “Pattern 2 — the feed axis (a matrix needs a face)”An operand indexed by a single domain axis (like ) can enter on a boundary face and pipeline. But a matrix is indexed by both axes and read once, so it has no free axis to enter on. The fix is a depth-1 feed axis : enters on the face and is read one step downstream,
(This mirrors how dot adds a feed axis for its once-read
operands.) When the operator’s result is also a full matrix — the rank updates
ger, syr, syr2 — there is no reduction axis for it to exit along either, so the
feed axis is depth-2 (0 ≤ k < 2): the matrix seeds the accumulator on ,
the update is added at , and the result drains out on the face — the same
inject → add → drain shape as scal/axpy.
Pattern 3 — project-and-pipeline the scalars
Section titled “Pattern 3 — project-and-pipeline the scalars”A scalar like or must never appear as a literal in a recurrence body — that would be an affine broadcast (one value read everywhere). Instead it is projected onto a face and pipelined, then consumed as a product of recurrence variables:
so becomes a product of three uniform taps. For the rank
updates the trick is sharper still: injecting only on the halo (interior
value ) makes the update contribute exactly once — it fires at and
vanishes at the drain. This “one-shot injection” is how ger/syr/syr2 add
their outer product a single time.
Pattern 4 — the terminal-face epilogue
Section titled “Pattern 4 — the terminal-face epilogue”gemv/symv finish with . With folded into the
reduction, the completed sum is ; the term joins it on the
output face — a terminal-face epilogue reading the accumulator and the pipelined
incoming :
Output faces may read taps and do arithmetic, so the epilogue needs no extra machinery.
Pattern 5 — triangular domains and the diagonal-output constraint
Section titled “Pattern 5 — triangular domains and the diagonal-output constraint”trmv, syr, syr2 compute over a triangular index set — the first
non-box domains in the catalog. Two consequences:
- Operand entry changes. On a triangular domain a column begins at the diagonal,
so a broadcast would have to enter on a diagonal face — parallel to the output,
which admits no linear schedule. The remedy is to feed such an operand on the
face (per cell) instead of pipelining it along (used by
trmvfor , and bysyr/syr2for the vectors). - The output can land on a diagonal. In
trmvthe reduction for row completes at , so the result leaves on the diagonal face , whose outward normal forces . The box-operator default is rejected (zero flux on the diagonal); is the canonical schedule. This is a concrete way the domain geometry constrains the schedule. (The rank updatessyr/syr2drain on the face instead, so they keep .)
Pattern 6 — the symmetric confluence
Section titled “Pattern 6 — the symmetric confluence”Symmetric operators store one triangle and route it to both sides.
symv(, ): a two-face feed over the full square — the lower cells () read the stored , the upper cells () read the reflected . So cell always sees and the reduction is the ordinarygemvsweep; a stored is read by cell and its mirror — the two contributions, as two confluence faces reading one triangle.syr/syr2( and ): the outer product itself is symmetric, so the output is the triangle. A single vector drives both axes (fed per cell as and );syr2needs two vectors and four feeds and forms from uniform taps.
In every case the symmetry lives in the confluence or the domain, never in the recurrence — which stays a pure SURE.
Summary
Section titled “Summary”| operator | reduction? | feed | scalars | domain | notable |
|---|---|---|---|---|---|
gemv | yes () | depth-1 | α, β | box | reduction + epilogue |
ger | no | depth-2 | α (once) | box | outer product |
trmv | yes () | depth-1 | — | triangular | diagonal output, |
symv | yes () | depth-1 | α, β | box | two-face symmetric feed |
syr | no | depth-2 | α (once) | triangular | one vector, both axes |
syr2 | no | depth-2 | α (once) | triangular | two vectors, fused rank-2 |
Each row is a combination of Patterns 1–6. The catalog pages show the resulting SURE and its schedule in motion.