ISARef Multi-ISA & Silicon Reference
45,419 ISA items · 105,907 timings · 1,823 microarchs · 16,083 chips · 105 sources
Arch:
Tier:

ZEROACC

T1 tenstorrent matrix insn
ZEROACC (Mark some rows of Dst as undefined)
SourceTenstorrent Official Tensix ISA Documentation (Wormhole & Blackhole) (tenstorrent_tt_isa)
Reliability TierT1 — Official Specification
ISA / Silicon ScopeBlackholeA0 / WormholeB0
Tenstorrent Wormhole B0 & Blackhole A0
License & VersionApache-2.0
main
Upstreamhttps://github.com/tenstorrent/tt-isa-documentation
Privilegeuser
ExtensionsTensix, Matrix Unit, BlackholeA0, WormholeB0

Summary

Mark either 1, 16, 256, 512, or 1024 rows of Dst as undefined. Subsequent operations which read from Dst then interpret undefined: * Packers reading from Dst read undefined rows as zero. * Matrix Unit (FPU) instructions read undefined rows as the identity element for the instruction being executed, which is negative infinity for GMPOOL / MPOOL3S1 / MPOOL3S2, and is zero for all other instructions. In any event, the…

Syntax / Encoding

TT_ZEROACC(((/* bool */ UseDst32b) << 2) +
             /* u2 */ Mode,
             /* u2 */ AddrMod,
             /* u10 */ Imm10)

TT_ZEROACC(/* u3 */ Mode,
           /* bool */ UseDst32b,
           /* bool */ Revert,
           /* u3 */ AddrMod,
           /* u10 */ Imm10)

Binary Encodings (2)

WidthFormatBit PatternMask / Match
32Tensix-32b00010000xxxxxxxxxxxxxxxxxxxxxxxx0xff000000 / 0x10000000
32Tensix-32b (Blackhole)00010000xxxxxxxxxxxxxxxxxxxxxxxx0xff000000 / 0x10000000

Reference Notes

# `ZEROACC` (Mark some rows of `Dst` as undefined)

**Summary:** Mark either 1, 16, 256, 512, or 1024 rows of `Dst` as undefined. Subsequent operations which read from `Dst` then interpret undefined:
* Packers reading from `Dst` read undefined rows as zero.
* Matrix Unit (FPU) instructions read undefined rows as the identity element for the instruction being executed, which is negative infinity for `GMPOOL` / `MPOOL3S1` / `MPOOL3S2`, and is zero for all other instructions. In any event, the write performed by these instructions will then cause the row contents to become well defined, with the sole exception of [`MVMUL`](MVMUL.md) with `BroadcastSrcBRow` set, which updates the valid bits of a set of rows that is neither a subset nor a superset of the rows that it writes.
  Setting `ALU_ACC_CTRL_Zero_Flag_disabled_dst` is `UnsupportedFunctionality`. If `ALU_ACC_CTRL_Zero_Flag_disabled_dst` is set, they (`MOVD2A` and `MOVD2B` included) instead read undefined rows as whatever they contain, on Wormhole as on Blackhole. The value of `ALU_ACC_CTRL_Zero_Flag_disabled_dst` an instruction uses is the one the previous instruction down the Matrix Unit's pipeline used (`MOVA2D`, `MOVB2D`, `MOVD2A`, `MOVD2B`, `MOVB2A` and the arithmetic instructions; not `ZEROACC`, `CLEARDVALID`, `SETRWC` or `INCRWC`), so the first such instruction after a change still reads undefined rows the old way. Relying on that delay is `NonContractualBehavior`: after changing `ALU_ACC_CTRL_Zero_Flag_disabled_dst`, software should not read an undefined row with the next such instruction.
* The Vector Unit (SFPU) exhibits `UndefinedBehavior` when reading (i.e. `SFPLOAD` / `SFPLOADMACRO`) an undefined row. An `SFPSTORE` writes only some columns of a row (eight of its sixteen), but marks all four rows of its group as defined, so after an `SFPSTORE` to an undefined row, the columns it didn't write read as their old contents, not as zero; the same goes for rows of the group that it writes no column of (see [`SFPSTORE`](SFPSTORE.md)). Software that wants zeros in those columns should write them.
* Unpackers exhibit `UndefinedBehavior` if an unpack to `Dst` writes to _some_ columns of an undefined row but leaves other columns unwritten.
* If a Vector Unit or unpacker write to `Dst` executes in the same cycle, rows in the same 256-row group as the written rows, and congruent to them modulo 8, are not marked undefined (the write's update of `DstRowValid` takes effect instead). On Blackhole it is the other way around: the `ZEROACC` takes full effect and the write's update of `DstRowValid` is lost (see [`Dst.md` in the Blackhole tree](../../../BlackholeA0/TensixTile/TensixCoprocessor/Dst.md)).

**Backend execution unit:** [Matrix Unit (FPU)](MatrixUnit.md)

## Syntax

```c
TT_ZEROACC(((/* bool */ UseDst32b) << 2) +
             /* u2 */ Mode,
             /* u2 */ AddrMod,
             /* u10 */ Imm10)
```

There is no syntax to specify `/* bool */ Revert`; if a non-zero value is desired for this field, the raw encoding must be used.

On Blackhole, the syntax is instead:

```c
TT_ZEROACC(/* u3 */ Mode,
           /* bool */ UseDst32b,
           /* bool */ Revert,
           /* u3 */ AddrMod,
           /* u10 */ Imm10)
```

## Encoding

![](../../../Diagrams/Out/Bits32_ZEROACC.svg)

On Blackhole, `AddrMod` is a `u3` rather than a `u2`, `UseDst32b` is no longer part of `Mode`, and `Mode` is a `u3`, giving this encoding:

![](../../../Diagrams/Out/Bits32_ZEROACC_BH.svg)

## Functional model

On Blackhole, `Revert` with the 16-row mode and `UseDst32b` set (and `DEST_ACCESS_CFG_zeroacc_absolute_tile_mode` clear) marks the face's rows as defined instead of undefined. Software can use it after an unpack of 32-bit data to `Dst`, to set valid bits that the unpack's own update may have lost to a `ZEROACC` in the same cycle (see [`Dst.md` in the Blackhole tree](../../../BlackholeA0/TensixTile/TensixCoprocessor/Dst.md)). Every other use of `Revert` on Blackhole is `NonContractualBehavior`.

On Blackhole, the 16-row mode's `Imm10` is relative to the half of `Dst` that the instruction addresses, unless `DEST_ACCESS_CFG_zeroacc_absolute_tile_mode` is set. Hardware picks the half using the row that the one-row mode would clear, i.e. `Imm10` plus `DEST_TARGET_REG_CFG_MATH_Offset` plus the `Dst` RWC plus `DEST_REGW_BASE_Base`, with `Imm10` added in as a row number even though this mode treats it as a face number; the upper half is rows 512 and up, or rows 256 and up with `UseDst32b`. Software double-buffering `Dst` normally keeps the base of the current half in `DEST_TARGET_REG_CFG_MATH_Offset`, so `Imm10` should then be the face number within that half. Note that the sum can reach the upper half even when `DEST_TARGET_REG_CFG_MATH_Offset` is in the lower half (e.g. `DEST_TARGET_REG_CFG_MATH_Offset == 496` and `Imm10 == 20`), and that an `Imm10` which already includes the half (e.g. 32 or more for the upper half of a 16-bit `Dst`) is out of bounds once the half is added again. On Wormhole, `Imm10` is always absolute.

```c
if (TTArchitecture == Blackhole && Mode >= 4) {
  UndefinedBehavior();
}
if (Revert) {
  if (TTArchitecture == Blackhole && Mode == ZEROACC_MODE_16_ROWS && UseDst32b && !Config.DEST_ACCESS_CFG_zeroacc_absolute_tile_mode) {
    // In the below, the assignments of DstRowValid set it to true instead of to false, so those rows
    // again read as what they hold (UnpredictableValue if never written since reset). Revert has no
    // other effect.
  } else if (TTArchitecture == Blackhole) {
    NonContractualBehavior {
      // Current silicon behavior (not architecturally guaranteed): as above, the assignments of
      // DstRowValid set it to true instead of to false, and Revert has no other effect.
    }
  } else {
    UndefinedBehavior();
  }
}
uint1_t StateID = ThreadConfig[CurrentThread].CFG_STATE_ID_StateID;
auto& ConfigState = Config[StateID];
uint10_t Row = Imm10;
Row += ThreadConfig[CurrentThread].DEST_TARGET_REG_CFG_MATH_Offset;