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

ELWSUB

T1 tenstorrent matrix insn
ELWSUB (Dst = SrcA - SrcB or Dst += SrcA - SrcB)
SourceTenstorrent Official Tensix ISA Documentation (Wormhole & Blackhole) (tenstorrent_tt_isa)
Reliability TierT1 — Official Specification
ISA / Silicon ScopeWormholeB0
Tenstorrent Wormhole B0 & Blackhole A0
License & VersionApache-2.0
main
Upstreamhttps://github.com/tenstorrent/tt-isa-documentation
Privilegeuser
ExtensionsTensix, Matrix Unit, WormholeB0

Summary

An aligned 8x16 block of SrcB is subtracted element-wise from an aligned 8x16 block of SrcA, and the result either assigned to an aligned 8x16 block of Dst or added element-wise to an aligned 8x16 block of Dst. Broadcasting is supported on the SrcB operand; any 1x16 row can be broadcasted up to 8x16 and/or column 0 can be broadcasted to all columns.

Syntax / Encoding

TT_ELWSUB(((/* bool */ FlipSrcB) << 1) +
            /* bool */ FlipSrcA,
            /* bool */ AddDst,
          ((/* bool */ BroadcastSrcBRow) << 1) +
            /* bool */ BroadcastSrcBCol0,
            /* u2 */ AddrMod,
            /* u10 */ DstRow)

Binary Encodings (2)

WidthFormatBit PatternMask / Match
32Tensix-32b00110000xxxxxxxxxxxxxxxxxxxxxxxx0xff000000 / 0x30000000
32Tensix-32b (Blackhole)00110000xxxxxxxxxxxxxxxxxxxxxxxx0xff000000 / 0x30000000

Reference Notes

# `ELWSUB` (`Dst = SrcA - SrcB` or `Dst += SrcA - SrcB`)

**Summary:** An aligned 8x16 block of `SrcB` is subtracted element-wise from an aligned 8x16 block of `SrcA`, and the result either assigned to an aligned 8x16 block of `Dst` or added element-wise to an aligned 8x16 block of `Dst`. Broadcasting is supported on the `SrcB` operand; any 1x16 row can be broadcasted up to 8x16 and/or column 0 can be broadcasted to all columns.

The supported data type combinations are:

|[`Dst` data type](Dst.md#data-types)|= or +=|[`SrcA` data type](SrcASrcB.md#data-types)|-|[`SrcB` data type](SrcASrcB.md#data-types)|
|---|---|---|---|---|
|8x16 matrix of either FP32 or BF16|= or +=|8x16 matrix of either TF32 or BF16|-|8x16 matrix of either TF32 or BF16|
|8x16 matrix of either FP32 or FP16|= or +=|8x16 matrix of FP16|-|8x16 matrix of FP16|
|8x16 matrix of integer "32"|= or +=|8x16 matrix of integer "8"|-|8x16 matrix of integer "8"|

When `Dst += SrcA - SrcB` is performed for integers, the computation is really `Dst = Saturate(Dst + SrcA - SrcB)`, where `Saturate` clamps at ±(2<sup>31</sup>-1).

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

## Syntax

```c
TT_ELWSUB(((/* bool */ FlipSrcB) << 1) +
            /* bool */ FlipSrcA,
            /* bool */ AddDst,
          ((/* bool */ BroadcastSrcBRow) << 1) +
            /* bool */ BroadcastSrcBCol0,
            /* u2 */ AddrMod,
            /* u10 */ DstRow)
```

## Encoding

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

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

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

## Functional model

`ELWSUB`'s functional model is identical to [`ELWADD`'s functional model](ELWADD.md#functional-model), except that:
* `int32_t Result = SrcAValInt + SrcBValInt;` changes to `int32_t Result = SrcAValInt - SrcBValInt;`
* `float Result = SrcAValFP + SrcBValFP;` changes to `float Result = SrcAValFP - SrcBValFP;`