SFPLOADMACRO
tenstorrent_tt_isa)Tenstorrent Wormhole B0 & Blackhole A0
main
userTensix, Vector Unit, BlackholeA0, WormholeB0Summary
This instruction starts by executing as per SFPLOAD to move (up to) 32 datums from Dst to an LReg. It then schedules up to four additional Vector Unit (SFPU) instructions for execution in future cycles, with this consisting of at most one instruction from each of the following four columns:
Syntax / Encoding
TT_SFPLOADMACRO(((/* u2 */ MacroIndex) << 2) +
/* u2 */ VDLo,
/* u4 */ Mod0,
/* u2 */ AddrMod,
((/* u9 */ Imm9) << 1) +
/* u1 */ VDHi)
Binary Encodings (2)
| Width | Format | Bit Pattern | Mask / Match |
|---|---|---|---|
| 32 | Tensix-32b | 10010011xxxxxxxxxxxxxxxxxxxxxxxx | 0xff000000 / 0x93000000 |
| 32 | Tensix-32b (Blackhole) | 10010011xxxxxxxxxxxxxxxxxxxxxxxx | 0xff000000 / 0x93000000 |
Reference Notes
# `SFPLOADMACRO` (Move from `Dst` to `LReg` and then schedule up to four additional vector instructions)
**Summary:** This instruction starts by executing as per [`SFPLOAD`](SFPLOAD.md) to move (up to) 32 datums from [`Dst`](Dst.md) to an `LReg`. It then schedules up to four additional Vector Unit (SFPU) instructions for execution in future cycles, with this consisting of at most one instruction from each of the following four columns:
|Simple (at most one †)|MAD (at most one)|Round (at most one †)|Store (at most one)|
|---|---|---|---|
|`SFPABS`<br/>`SFPAND`<br/>`SFPCAST`<br/>`SFPCOMPC`<br/>`SFPCONFIG`<br/>`SFPDIVP2`<br/>`SFPENCC`<br/>`SFPEXEXP`<br/>`SFPEXMAN`<br/>`SFPIADD`<br/>`SFPLZ`<br/>`SFPMOV`<br/>`SFPNOP`<br/>`SFPNOT`<br/>`SFPOR`<br/>`SFPPOPC`<br/>`SFPPUSHC`<br/>`SFPSETCC`<br/>`SFPSETEXP`<br/>`SFPSETMAN`<br/>`SFPSETSGN`<br/>`SFPSHFT`<br/>`SFPSWAP` (‡)<br/>`SFPTRANSP`<br/>`SFPXOR`|`SFPADD`<br/>`SFPADDI`<br/>`SFPLUT`<br/>`SFPLUTFP32`<br/>`SFPMAD`<br/>`SFPMUL`<br/>`SFPMULI`<br/>`SFPNOP`|`SFPNOP`<br/>`SFPSHFT2`<br/>`SFPSTOCHRND`|`SFPSTORE`|
(†) If a Simple instruction and a Round instruction execute on the same cycle, then one of them needs to have `VD == 16` and the other needs to have `VD != 16`.
(‡) If `SFPSWAP` is scheduled to the Simple sub-unit, then the MAD sub-unit must not execute anything other than `SFPNOP` on the same cycle (it can be idle, or have `SFPNOP` scheduled for then), and both of the Simple and Round sub-units either need to be idle on the next cycle or have `SFPNOP` scheduled for then. On that next cycle, the scheduled `SFPSWAP` reads `VC` and `VD` again and then writes them, so an instruction which writes to `VC` or `VD` on the same cycle as the `SFPSWAP` (for example `SFPLOAD`) changes the values which get moved, but not the outcome of the comparison.
The Vector Unit (SFPU) is capable of executing up to five instructions per cycle: one load-style instruction (`SFPLOAD` or `SFPLOADI` or `SFPLOADMACRO` or `SFPNOP`), and then one instruction from each of the above four columns. However, `SFPLOADMACRO` is the only mechanism for attaining more than one instruction per cycle, and some pre-configuration is required (via [`SFPCONFIG`](SFPCONFIG.md)).
**Backend execution unit:** [Vector Unit (SFPU)](VectorUnit.md), load sub-unit
## Syntax
```c
TT_SFPLOADMACRO(((/* u2 */ MacroIndex) << 2) +
/* u2 */ VDLo,
/* u4 */ Mod0,
/* u2 */ AddrMod,
((/* u9 */ Imm9) << 1) +
/* u1 */ VDHi)
```
## Encoding

## Cross-lane data movement pattern
Assuming all 32 lanes active:

Note that this pattern is the exact inverse of [`SFPSTORE`](SFPSTORE.md).
## Functional model
The `SFPLOAD` part of `SFPLOADMACRO` executes as per the [`SFPLOAD` functional model](SFPLOAD.md#functional-model), using this pair of definitions:
```c
uint10_t Imm10 = (Imm9 << 1) | VDHi;
uint4_t VD = (0 << 3) | ((Addr & 1) << 2) | VDLo;
```
Where `Addr` is the `Dst` address which the `SFPLOAD` functional model computes from `Imm10` (before it uses `VD`). The low bit of `Addr` equals `VDHi` as long as everything added to `Imm10` (`DEST_TARGET_REG_CFG_MATH_Offset`, `DEST_REGW_BASE_Base` and the `Dst` RWC, or for `MOD0_FMT_INT32_ALL` the low two bits of the latter two's sum) sums to an even number; if it sums to an odd number, `VD` ends up being 4 more or 4 less than intended.
The remaining part of `SFPLOADMACRO` assumes the following state, which is written via [`SFPCONFIG`](SFPCONFIG.md):
```c
struct {
struct { // This consists of 12 bits, tightly packed, described starting from the least significant bit.
uint4_t StoreMod0;
uint4_t UsesLoadMod0ForStore; // 1 bit per macro
uint4_t UnitDelayKind; // 1 bit per sub-unit
} Misc;
uint32_t Sequence[4]; // 32 bits per macro, with that 32 consisting of 8 bits per sub-unit
uint32_t InstructionTemplate[4]; // Each of these is an arbitrary Vector Unit (SFPU) instruction
} LoadMacroConfig[32];
```
With this state in mind, the remaining part of `SFPLOADMACRO` is:
```c
for (auto [i, SubUnit] in enumerate({SimpleSubUnit, MADSubUnit, RoundSubUnit, StoreSubUnit}) {
uint8_t SequenceBits = LoadMacroConfig[Lane].Sequence[MacroIndex] >> (i * 8);
uint3_t Delay = (SequenceBits >> 3) & 7;
// Forget any pre-existing scheduled instruction which would execute at the same point
// in time as the instruction we're about to schedule (even if nothing is about to be
// scheduled, except for Delay == 0):
if (Delay != 0 || (SequenceBits & 7) != 0) {
SubUnit.ForgetFutureInstructionWhoseDelayIs(Delay);
}
// Start with an instruction template:
Instruction Insn;
switch (SequenceBits & 7) {
case 0: continue; // Do not schedule anything for this sub-unit.
case 1: UndefinedBehavior(); break;
case 2: Insn.Opcode = SFPNOP; break;
case 3: Insn.Opcode = SFPSTORE; Insn.VD = 0; break;
case 4: Insn = ParseInsn(LoadMacroConfig[Lane].InstructionTemplate[0]); break;
case 5: Insn = ParseInsn(LoadMacroConfig[Lane].InstructionTemplate[1]); break;
case 6: Insn = ParseInsn(LoadMacroConfig[Lane].InstructionTemplate[2]); break;
case 7: Insn = ParseInsn(LoadMacroConfig[Lane].InstructionTemplate[3]); break;
}
if (!SubUnit.CanExecuteOpcode(Insn.Opcode)) { // Consult the table at the top of this page.
Insn.Opcode = SFPNOP;
if (!SubUnit.CanExecuteOpcode(Insn.Opcode)) {
// This branch applies to StoreSubUnit, which should not be fed SFPNOP.
UndefinedBehavior();
}
}
// Override some instruction fields with values from the SFPLOADMACRO instruction:
if (i != 3) {
// This branch applies to SimpleSubUnit, MADSubUnit, and RoundSubUnit. The instruction's
// VD (result LReg index) is overridden, as is either VB or VC (input LReg indices).
if (SequenceBits & 0x80) {
Insn.VB = VD;
if (Insn.VC is None) {
Insn.VC =