ISARef Multi-ISA & Silicon Reference
45,419 ISA items · 105,907 timings · 913 microarchs · 15,555 chips · 105 sources
Arch:
Tier:

GMPOOL

T1 tenstorrent matrix insn
GMPOOL (max reduction along SrcA columns)
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

An aligned 16x16 block of SrcA is reduced to a single 1x16 row by performing max along every column. An element-wise max is then performed between this 1x16 row and a 1x16 row from Dst, with the result written back to Dst. The row of Dst must be the top row of an aligned 4x16 block, and zero will be written to the other rows of the block. To get the effect of avoiding the element-wise max with Dst, ZEROACC can be…

Syntax / Encoding

TT_GMPOOL(((/* bool */ FlipSrcB) << 1) +
            /* bool */ FlipSrcA,
            true,
            /* u2 */ AddrMod,
            /* bool */ ArgMax,
            /* u10 */ DstRow)

Binary Encodings (2)

WidthFormatBit PatternMask / Match
32Tensix-32b00110011xxxxxxxxxxxxxxxxxxxxxxxx0xff000000 / 0x33000000
32Tensix-32b (Blackhole)00110011xxxxxxxxxxxxxxxxxxxxxxxx0xff000000 / 0x33000000

Reference Notes

# `GMPOOL` (`max` reduction along `SrcA` columns)

**Summary:** An aligned 16x16 block of `SrcA` is reduced to a single 1x16 row by performing `max` along every column. An element-wise `max` is then performed between this 1x16 row and a 1x16 row from `Dst`, with the result written back to `Dst`. The row of `Dst` must be the top row of an aligned 4x16 block, and zero will be written to the other rows of the block. To get the effect of avoiding the element-wise `max` with `Dst`, [`ZEROACC`](ZEROACC.md) can be used prior to `GMPOOL`, as `GMPOOL` reads undefined rows as minus infinity (i.e. all bits set). When operating on floating-point data, the `SrcA` matrix is element-wise scaled before the `max` operation, where the matrix of scaling factors is formed by starting with a 1x16 row of `SrcB` (the top row of some aligned 8x16 block), taking just the exponents (i.e. element-wise `exp2 ∘ floor ∘ log2`), transposing that row to form a 16x1 column, and then broadcasting that column to a 16x16 matrix. If software does not want scaling, it should ensure that this 1x16 row of `SrcB` contains the value `1.0` in all datums.

The supported data type combinations are:

|[`Dst` data type](Dst.md#data-types)|[`SrcA` data type](SrcASrcB.md#data-types)|[`SrcB` data type](SrcASrcB.md#data-types) (exponent only, will be transposed)|
|---|---|---|
|1x16 row of either TF32 or BF16|16x16 matrix of either TF32 or BF16|1x16 row of either TF32 or BF16|
|1x16 row of either TF32 or FP16|16x16 matrix of FP16|1x16 row of FP16|
|1x16 row of integer "32" (†)|16x16 matrix of integer "8"|1x16 row of any type (‡)|

(†) For integer data in `Dst`, only the sign bit and the low 19 bits of magnitude are used for `max` input, and the magnitude is truncated to just 13 bits for `max` output.

(‡) Exponent of zero causes scaling by zero. With `ALU_ACC_CTRL_Fp32_enabled` clear, non-zero exponent causes scaling by one (i.e. no scaling). Non-zero datums always have a non-zero exponent.

An integer `max` needs `ALU_ACC_CTRL_Fp32_enabled` clear. With it set, `SrcA` datums are ranked as if they were BF16: their exponent (16 for integer "8") plus the exponent from `SrcB`, then the high seven bits of their magnitude. With integer "8" data in `SrcB`, every non-zero `SrcA` datum then ranks above any `Dst` integer whose magnitude is less than 2<sup>15</sup>, and when a `SrcA` datum is the maximum, the low three bits of its magnitude are cleared in the result.

On Wormhole, there is also _partial_ support for `argmax` (Blackhole ignores `ArgMax`, behaving as if it were false): within each column of `SrcA`, the _index_ of the largest value within the _first eight rows_ is tracked. Depending on the data type in use, this index can be returned as well as the largest value from all 16 rows, or instead of the largest value. A non-linear transform is applied to the index value, which software needs to reverse if it wants the original index value. When several of those rows (or `Dst`) hold the largest value, which one's index is returned depends on their sign and position, as given in the functional model. In any event, the index value is only returned when `Dst` is accessed in 32-bit mode, with the index in the low bits (for FP16 or BF16 data, the largest value is simultaneously returned in the high bits). The supported data type combinations for `argmax` are therefore:

|[`Dst` data type](Dst.md#data-types)|[`SrcA` data type](SrcASrcB.md#data-types)|[`SrcB` data type](SrcASrcB.md#data-types) (exponent only, will be transposed)|
|---|---|---|
|1x16 row of integer "32" (index only)|8x16 matrix of TF32|1x8 half-row of TF32|
|1x16 row of TF32 with the index in its low 12 bits|(16 or 8 †)x16 matrix of BF16|1x16 row of BF16|
|1x16 row of FP16 and integer "16" pairs|(16 or 8 †)x16 matrix of FP16|1x16 row of FP16|
|1x16 row of integer "32" (index only)|8x16 matrix of integer "8"|1x8 half-row of any type (‡)|

(†) 16x16 input matrix used for the BF16 or FP16 `max` part of the output, but only the top half of that (i.e. 8x16) used for the index part of the output.

(‡) As for the `max` part; see the note on integer data above.

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

## Syntax

```c
TT_GMPOOL(((/* bool */ FlipSrcB) << 1) +
            /* bool */ FlipSrcA,
            true,
            /* u2 */ AddrMod,
            /* bool */ ArgMax,
            /* u10 */ DstRow)
```

## Encoding

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

On Blackhole, `AddrMod` is a `u3` rather than a `u2`, giving this encoding:

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

## Functional model

This instruction will, if necessary, spend time waiting at the Wait Gate before being dispatched to the Matrix Unit (FPU):

```c
while (SrcA[MatrixUnit.SrcABank].AllowedClient != MatrixUnit
    || SrcB[MatrixUnit.SrcBBank].AllowedClient != MatrixUnit) {
  wait;
}
```

Once dispatched to the Matrix Unit (FPU):
```c
uint1_t StateID = ThreadConfig[CurrentThread].CFG_STATE_ID_StateID;
auto& ConfigState = Config[StateID];

if (TTArchitecture == Blackhole) {
  ArgMax = false; // Blackhole ignores ArgMax.
}

// Determine the data formats.
// Note: Blackhole implied format behavior for SrcB not fully characterized
uint4_t SrcAStyle, DstStyle;
bool UseDst32b;
uint4_t SrcAFmt = ConfigState.ALU_FORMAT_SPEC_REG_SrcA_override ? ConfigState.ALU_FORMAT_SPEC_REG_SrcA_val : ConfigState.ALU_FORMAT_SPEC_REG0_SrcA;
uint4_t SrcBFmt = ConfigState.ALU_FORMAT_SPEC_REG_SrcB_override ? ConfigState.ALU_FORMAT_SPEC_REG_SrcB_val : ConfigState.ALU_FORMAT_SPEC_REG1_SrcB;
if ((TTArchitecture == Blackhole) && !ThreadConfig[CurrentThread].DISABLE_IMPLIED_SRCA_FMT_Base) {
  SrcAFmt = ImpliedSrcAFmt[MatrixUnit.SrcABank];
}
if ((TTArchitecture == Blackhole) && !ThreadConfig[CurrentThread].DISABLE_IMPLIED_SRCB_FMT_Base) {
  SrcBFmt = ImpliedSrcBFmt[MatrixUnit.SrcBBank];
}
if (ThreadConfig[CurrentThread].FP16A_FORCE_Enable) {
  UnsupportedFunctionality(); // No known usage, confidence in specification belo