Skip to main content

Module spatial_lang

Module spatial_lang 

Source
Expand description

Spatial source emission for a VERIFIED SpatialProgram — the RDU’s own front-door language (Spatial, Koeplinger et al. PLDI 2018; the Plasticine/RDU lineage; the public Spatial → PIR → plastiroute → Tungsten chain built by scripts/plasticine/). The SpatialProgram twin of codegen_sva::spatial_emit, which prints a LoopFabric.

Every construct printed is the image of one IR object:

  • a tensor is a DRAM[T], filled on the host from its recorded fill;
  • a buffer is an SRAM[T] sized by the page its producer fills (Spatial N-buffers a memory written in one controller and read in the next, so the IR’s depth is recorded beside the declaration rather than spelled), or a FIFO[T] when its edge is a Fifo handshake;
  • a stage is one controller: a Load is a load (DRAM → SRAM), a Store a store, a MatmulTiles the row/column Foreach nest around a lane-parallel Reduce dot product — inside a MemReduce over the K blocks when the IR spills partials through an Interm buffer — and a Generic an element-wise Foreach whose reduce axis is a Reduce, its operands read through their access maps with an absent axis reading coordinate 0 (the broadcast), exactly as spatial::eval reads them;
  • the host checks the output’s CHECKSUM against the gold: the spatial oracle’s answer (eval_choreography over the recorded fills) unless the caller hands over the VM’s. The handshake ops (Reserve/Push/Wait/Pop, the accumulator acquire/release, the barriers) have no spelling of their own: Spatial’s compiler derives the buffering and the pipeline from the controller nest, which is why a depth is a comment and not a construct.

What is not spelled is refused BY NAME (SpatialLowerError::Unsupported): multicast groups and Recv stages, Scalar bodies, the fabric’s fused epilogues, external or vendor-random fills, weight-stationary dataflow, cross-site handshakes, non-rectangular tile blocks, aliased buffers, sites carrying several work items. A multi-site program prints as a Parallel of per-site Pipes — spelled, not yet gated through the chain (the gate runs the single-site RDU GEMM).

Structs§

SpatialCheck
A slice of a tensor the app checks, element by element, after the accelerator has run: gold holds the values the caller vouches for (the VM’s) for the row-major elements offset..offset + gold.len(). An integer tensor must match exactly; a float one within rel_tol · max|gold|.

Enums§

SpatialFlavor
Which half of the public chain an app is printed for — the two differ only in how a fold is spelled.

Functions§

emit_spatial_program
Emit the Spatial regression app (@spatial class Logos_<name> extends SpatialTest) for a verified spatial program: every tensor a DRAM[T] filled from its recorded fill, every buffer an SRAM[T]/FIFO[T], every stage one controller, and the host checking the output tensor’s checksum against gold — the VM’s answer when the caller has it (Show checksum of the output), the spatial oracle’s (eval_choreography) otherwise. target is the descriptor the program was compiled for (its name is recorded in the header). The harness’s PASS: true (Logos_<name>) line is what the toolchain ledger parses.
emit_spatial_program_checked
emit_spatial_program with the host checking every slice of checks — the output, and any activation or carried state the caller holds a gold for — rather than one checksum of the output.
emit_spatial_segment
A run of consecutive sections of a composed program, printed as ITS OWN app — the unit PIR can map, since PIR writes an accelerator as one JVM class and a whole composed program is past what the JVM allows one. The app holds the tensors the segment’s stages touch, each filled with its value at the segment’s ENTRY; runs the sections in order; and checks every tensor they store against its value at the segment’s EXIT — exactly for an integer tensor, within rel_tol · max|value| for a float one.