Skip to main content

Module fp_oracle

Module fp_oracle 

Source
Expand description

The hard floating-point oracle: a D5005 persona that measures which binary32 semantics the card’s floating-point DSP block computes (fourteennm_fp_mac, whose simulation model is encrypted), by running the block beside every class of the hypothesis family (super::fp_hypotheses) as soft units on one stream of operands and counting, class by class, the results that differ from the block’s.

The persona is an engine build whose engine is the oracle. Oracle::engine_verilog writes a logos_engine with the engine’s ports, the engine’s own crossing (bridge_verilog) and the oracle’s core as its core instance, so the shell, its commands and the timing constraints an engine build carries hold for it unchanged: the core steps at the compute clock’s rising edges, every path inside it given half a compute cycle.

Each step the core takes one operand triple (A, B, C) from its Source and hands it to three hard blocks: the multiply A·B (sp_mult, ay·az), the add A+B (sp_add, ax+ay) and the multiply-add C+A·B (sp_mult_add, ax+ay·az), every register of each on the compute step. The triple also enters a delay line the soft units read Run::tap + 1 steps late, and each block’s results wait Run::delays steps more, so a block of latency L given tap + 1 - L meets the soft units on its own operands, whatever the three blocks’ latencies. The host measures them first: the multiply’s and the add’s as the taps at which their classes come nearest every vector (Source::Vectors; a block no class names still has its tap), the multiply-add’s as the shift at which its results with C zero are the products. Every step the core adds one to the counter of each class whose result differs from the block’s, and counts the steps no product class or no sum class explains; a recording run (Run::record) stores every step (Record), a counting run the steps nothing explains, up to Oracle::record_cap. Beside them a multiply and an add with only their output registered take the same triples, their results recorded as they leave them: the shift at which they are the aligned blocks’ is their latency, the fewest steps a block of each mode can be.

The host’s commands: ENGINE_TABLE into table 0 at entry 0, the stream’s seed in bits 63:0 of the line; ENGINE_RUN, ARG0 the Run word and ARG1 the triples to take; STORE_READ, the store of STORE_BEATS beats (Store::read): beat 0 the header, then the counters eight to a beat (the product classes’, then the sum classes’), then the records. HOST_PROGRAM runs the whole measurement and prints it as one JSON object.

Structs§

Class
A class of the family: its members’ names (all one function, proven), and the semantics of the first, which the oracle builds.
Depths
How many steps deep a stand-in block is: fully registered, the multiply, the add and the multiply-add; with its output register alone, the multiply and the add.
Header
The store’s header.
Oracle
What the oracle is built from: the classes of the multiply and of the add, and the vectors its ROM holds.
Record
A record: the operands, the three hard results and their flags (bits 3:0 the multiply’s {inexact, invalid, overflow, underflow} and 7:4 the add’s, of each block), which classes agree with the block, and the least-registered blocks’ results.
Run
A run’s word (ENGINE_RUN‘s ARG0): its source in bits 1:0, whether it records every step in bit 2, the soft units’ tap in bits 7:4, and the steps each hard block’s results wait before they meet the soft units: the multiply’s in bits 11:8, the add’s in 15:12, the multiply-add’s in 19:16.
Store
The store read back: the header, each class’s counter, the records.

Enums§

OracleError
Why a discriminator ledger cannot make an oracle.
Source
Where a run’s operands come from.

Constants§

ADD_REGISTERS
DRAIN
Steps a run takes past its last triple, so every result of every triple leaves the delay line.
HOST_PROGRAM
The measurement on the card (sw/logos_fp_oracle.c): the multiply’s and the add’s latencies as the taps at which their classes come nearest every vector (counting runs over the vectors at each tap, no delay: the first tap of the fewest disagreements, so a block no class names still has its depth); the multiply-add’s as the shift at which its results on the vectors whose C is zero are the products (a recording run at the last tap); then, the three aligned (Run::aligned), a recording run over the vectors and counting runs of <steps> triples from the random and the near streams; one JSON object on stdout. The exit status is 0 when every latency was found and every run completed, 1 when a latency was not, 2 when the card cannot be had or a command failed.
LEAST_REGISTERS
The register a least-registered block keeps: its output’s.
MAGIC
The header’s first word: LOGOSFPO.
MAX_PRODUCT_CLASSES
The most product classes a record’s agreement bits hold: the two words it gives the multiply’s agreement, the least-registered multiply’s result beside the flags.
MAX_SUM_CLASSES
The most sum classes a record’s agreement bits hold: three halves of the two words it gives the add, the fourth the least-registered add’s result.
MULTIPLY_ADD_REGISTERS
MULTIPLY_REGISTERS
The registers each mode uses fully registered, every operand the mode reads crossing as many to the adder: the multiply’s and the multiply-add’s their input register and two pipeline registers (AX the chain-in pipeline’s, AY and AZ the multiplier’s), the add’s its input register alone, Quartus allowing an add no multiplier pipeline.
STORE_BEATS
The store’s beats, 512 bits each.
TAPS
The latencies the soft side can be delayed to: a tap of 0 to TAPS - 1, a block latency of 1 to TAPS steps.

Functions§

fma_vectors
The multiply-add’s own vectors: A and B in [1, 2) whose product is inexact, C the product rounded and negated, so a fused multiply-add gives the product’s rounding error and one rounding after another gives zero; then C a power of two beside the product.
fp_mac_blackbox
The floating-point DSP block as the timing model takes it, a box only Quartus elaborates: its interface, one DSP block large (logos_box_area, two halves), its results registers inside it.
hard_model_verilog
fourteennm_fp_mac as a simulator runs the oracle: product and sum the semantics a block’s multiply and add compute (the multiply-add one after the other), depths the steps deep a block is in each mode and registering, each register zero from configuration. The device’s own model is encrypted; this one stands in for it so a simulation of the persona can be held to what the oracle must say of a block whose semantics are known.
host_header
The host program’s table of the oracle’s classes (sw/logos_fp_oracle.h): their counts, the store’s layout, and each class’s members by name.
persona_config
The persona’s accelerator configuration: an engine build on plain 512-bit lines, its compute clock the user clock divided by divide, its build identity (the BUILD register) the first eight bytes of the oracle engine’s SHA-256.
persona_sources
Every file of the persona’s tree for scripts/d5005/build-afu.sh: the engine build’s files (afu_sources of persona_config) with the oracle for its engine (the card’s floating-point DSP blocks left to Quartus), its simulation twin the oracle beside a stand-in block computing model, depths deep (what scripts/d5005/run-cosim.sh runs), and the measurement the card runs, HOST_PROGRAM with its class table (host_header).