PACR
tenstorrent_tt_isa)Tenstorrent Wormhole B0 & Blackhole A0
main
userTensix, Packers, BlackholeA0, WormholeB0Summary
Issue work to between one and four packers, where each packer will move some number of datums from Dst to a contiguous range of L1, possibly performing some minor data transformations in the process.
Syntax / Encoding
TT_PACR(/* u2 */ AddrMod, /* bool */ ZeroWrite, /* u4 */ PackerMask,
/* bool */ OvrdThreadId, /* bool */ Concat, /* bool */ Flush,
/* bool */ Last)
Binary Encodings (2)
| Width | Format | Bit Pattern | Mask / Match |
|---|---|---|---|
| 32 | Tensix-32b | 010000010xxxxxxxxxxxxxxxxxxxxxxx | 0xff800000 / 0x41000000 |
| 32 | Tensix-32b (Blackhole) | 010000010xxxxxxxxxxxxxxxxxxxxxxx | 0xff800000 / 0x41000000 |
Reference Notes
# `PACR` (Move datums from `Dst` to L1)
**Summary:** Issue work to between one and four packers, where each packer will move some number of datums from `Dst` to a contiguous range of L1, possibly performing some minor data transformations in the process.
**Backend execution unit:** [Packers](Packers/README.md)
A `PackerMask` other than `0b0001`, `0b0011` or `0b1111`, and `OvrdThreadId` set, are `UnsupportedFunctionality`, and their use is strongly discouraged.
## Syntax
```c
TT_PACR(/* u2 */ AddrMod, /* bool */ ZeroWrite, /* u4 */ PackerMask,
/* bool */ OvrdThreadId, /* bool */ Concat, /* bool */ Flush,
/* bool */ Last)
```
## Encoding

## Functional model
The `PackerMask` field determines which of the four packers are being instructed:
|`PackerMask`|Behavior|
|---|---|
|`0b0000`|Issue work to packer 0 (i.e. as a special case, `0b0000` is rewritten to `0b0001`); `UnsupportedFunctionality`|
|`0b0001`|Issue work to packer 0|
|`0b0010`|Issue work to packer 1; `UnsupportedFunctionality`|
|`0b0100`|Issue work to packer 2; `UnsupportedFunctionality`|
|`0b1000`|Issue work to packer 3; `UnsupportedFunctionality`|
|`0b0011`|Issue work to packers 0 and 1|
|`0b1100`|Issue work to packers 2 and 3; `UnsupportedFunctionality`|
|`0b1111`|Issue work to all four packers|
|Any other value|`UnsupportedFunctionality`|
The issued work will start at the packers' [input address generator](Packers/InputAddressGenerator.md), work through the various [packer pipeline stages](Packers/README.md), and eventually reach the [output address generator](Packers/OutputAddressGenerator.md). The fields of the instruction are used at various stages:
* `AddrMod`: used by the input address generator and the output address generator to manipulate ADC Y/Z values in preparation for the _next_ `PACR` instruction.
* `ZeroWrite`: used by the input address generator (to fetch datums from `/dev/null` rather than `Dst`). The instruction packs the same number of datums to the same addresses as it would otherwise, but nothing is read from `Dst`: every datum reaches the late format conversion as all-zero bits, so [edge masking](Packers/EdgeMasking.md) and ReLU have no effect on it, and the packer's tile position generator, which advances only on reads from `Dst`, does not advance.
* `OvrdThreadId`: used by the input address generator and the output address generator to determine which ADC is in use. Setting it is `UnsupportedFunctionality`.
* `Concat`: if [compression](Packers/Compression.md) is enabled, setting this to `true` causes the _next_ `PACR` instruction to continue the current compression row rather than starting a new compression row. If compression is disabled, then there is no inherent concept of compression row, and this field has no effect.
* `Flush`: used by the input address generator (overrides `InputNumDatums` to zero) and the output address generator (flushes the output buffers sitting before L1 and causes the _next_ `PACR` instruction to start at fresh output addresses).
* `Last`: used by the output address generator (flushes the output buffers sitting before L1 and causes the _next_ `PACR` instruction to start at fresh output addresses).
A lot of [backend configuration fields](BackendConfiguration.md) are consumed by the various stages in the packer pipeline. Some of those fields are sampled when the `PACR` instruction starts, with that sampled value consistently used throughout the lifetime of the instruction. Other fields are sampled per-packer when _some_ `PACR` instruction starts: if there are multiple `PACR` instructions in-flight within a given packer, they will observe the value of these configuration fields as they were when _one_ of the in-flight instructions started. Finally, some fields are sampled at an unspecified point during the lifetime of a `PACR` instruction.
A `PACR` starts when the packers accept it from its thread, and the thread issues nothing after the `PACR` until then, so a configuration write that comes after a `PACR` in the same thread (e.g. [`WRCFG`](WRCFG.md), or [`REG2FLOP`](REG2FLOP_Configuration.md)) never changes what that `PACR` samples when it starts, even with many `PACR`s queued for a busy packer. `THCON_SEC0_REG1_L1_Dest_addr`, `DEST_TARGET_REG_CFG_PACK_SEC0_Offset` and `PCK0_ADDR_CTRL_XY_REG_0_Ystride` are sampled when the `PACR` starts. The edge masks (`PCK_EDGE_OFFSET_SEC0_mask` and the rest) and the ReLU configuration (`STACC_RELU_ApplyRelu`, `STACC_RELU_ReluThreshold`) are only read as the data goes through the packer, so a write to them straight after a `PACR` can change that `PACR`'s output, part way through a row (the last one or two `PACR`s with an idle packer, more with a backlog); before writing them, wait for the packers, e.g. with a `STALLWAIT` with block mask B7 and conditions C3 to C6. A RISCV store to `Config` doesn't wait for the thread's earlier instructions (see [RISCV writes to `Config`](BackendConfiguration.md#riscv-writes-to-config)): a store from RISCV B right after it pushed `PACR`s that were still waiting for a busy packer changed what they sampled when they started.
On Wormhole, changing the fields that set how `Dst` is read (`PCK_DEST_RD_CTRL_Read_32b_data`, `ALU_FORMAT_SPEC_REG2_Dstacc`, and the packers' `In_data_format` and `Out_data_format`) while a `PACR` is in flight, and then starting another `PACR` before the first one finishes, can hang the packers. E.g. a `PACR` of 256 FP16 datums, `WRCFG`s switching all of these fields to FP32, and a second `PACR` straight after them hang; the same sequence finishes if the second `PACR` starts after the first has finished, or if there is no second `PACR`. To change these fields, wait for the packers first, e.g. with a `STALLWAIT` with block mask B7 and conditions C3 to C6 before the configuration writes.