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

UNPACR_Regular

T1 tenstorrent load_store insn
UNPACR (Move datums from L1 to SrcA or SrcB or Dst)
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, Unpackers, BlackholeA0, WormholeB0
Note: An UNPACR instruction spends at least two cycles calculating the initial input address: uncompressed data requires exactly two cycles, whereas compressed data requires more. For the duration of these cycles, the issuing thread cannot start its next instruction, nor any can other thread start an UNPACR instruction.…

Summary

Issue work to one unpacker, moving some number of datums from L1 to SrcA or SrcB or Dst.

Syntax / Encoding

TT_OP_UNPACR(/* u1 */ WhichUnpacker,
           ((/* u2 */ Ch1YInc) << 6) +
           ((/* u2 */ Ch1ZInc) << 4) +
           ((/* u2 */ Ch0YInc) << 2) +
             /* u2 */ Ch0ZInc,
             false,
             /* u3 */ ContextNumber,
             /* u2 */ ContextADC,
             /* bool */ MultiContextMode,
             /* bool */ FlipSrc,
             false,
             /* bool */ AllDatumsAreZero,
             /* bool */ UseContextCounter,
             /* bool */ RowSearch,
             false,
             false)

Binary Encodings (1)

WidthFormatBit PatternMask / Match
32Tensix-32b01000010xxxxxxxxxx0xxxxxxxxxxx0x0xff002002 / 0x42000000

Reference Notes

# `UNPACR` (Move datums from L1 to `SrcA` or `SrcB` or `Dst`)

**Summary:** Issue work to one unpacker, moving some number of datums from L1 to [`SrcA` or `SrcB`](SrcASrcB.md) or [`Dst`](Dst.md).

**Backend execution unit:** [Unpackers](Unpackers/README.md)

## Syntax

```c
TT_OP_UNPACR(/* u1 */ WhichUnpacker,
           ((/* u2 */ Ch1YInc) << 6) +
           ((/* u2 */ Ch1ZInc) << 4) +
           ((/* u2 */ Ch0YInc) << 2) +
             /* u2 */ Ch0ZInc,
             false,
             /* u3 */ ContextNumber,
             /* u2 */ ContextADC,
             /* bool */ MultiContextMode,
             /* bool */ FlipSrc,
             false,
             /* bool */ AllDatumsAreZero,
             /* bool */ UseContextCounter,
             /* bool */ RowSearch,
             false,
             false)
```

## Encoding

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

## Functional model

```c
if (RowSearch || UseContextCounter || !MultiContextMode) {
  UnsupportedFunctionality(); // No known usage, confidence in specification below is weak
}
if (ContextADC || ContextNumber) {
  UnsupportedFunctionality(); // Blackhole hardware behaves as below; on Wormhole, confidence in specification below is weak
}

// Start by reading some configuration:
uint1_t StateID = ThreadConfig[CurrentThread].CFG_STATE_ID_StateID;
auto& ConfigState = Config[StateID];
auto& CurrentUnpacker = Unpackers[WhichUnpacker];

uint3_t WhichContext;
uint2_t WhichADC;
if (MultiContextMode) {
  if (UseContextCounter) {
    WhichContext = CurrentUnpacker.ContextCounter[CurrentThread];
  } else {
    WhichContext = ContextNumber;
  }
  WhichContext += ThreadConfig[CurrentThread].UNPACK_MISC_CFG_CfgContextOffset[WhichUnpacker];
  WhichADC = ContextADC;
  if (WhichUnpacker == 1 && WhichContext >= 2) UnsupportedFunctionality();
  if (WhichContext >= 2) UnsupportedFunctionality(); // No known usage of contexts past 1
  if (WhichADC == 3) UndefinedBehavior(); // There is no ADC 3: X, X end and Y come from counters that don't exist
} else {
  WhichContext = 0;
  WhichADC = CurrentThread;
}

// Determine initial input address(es) and input datum count:
auto& ConfigDescriptor = ConfigState.THCON_SEC[WhichUnpacker].REG0_TileDescriptor;

bool IsUncompressed;
if (MultiContextMode) {
  IsUncompressed = ConfigState.THCON_SEC[WhichUnpacker].REG2_Disable_zero_compress_cntx[WhichContext];
} else {
  IsUncompressed = ConfigDescriptor.IsUncompressed;
}
if (!IsUncompressed) {
  UnsupportedFunctionality(); // No known usage, confidence in specification below is weak
}

uint16_t XDim;
if (MultiContextMode && WhichUnpacker == 0) {
  XDim = ConfigState.THCON_SEC[WhichUnpacker].REG5_Tile_x_dim_cntx[WhichContext & 3];
} else {
  XDim = ConfigDescriptor.XDim;
}
uint8_t YDim = ConfigDescriptor.YDim;
uint8_t ZDim = ConfigDescriptor.ZDim ? ConfigDescriptor.ZDim : 1;
uint8_t WDim = ConfigDescriptor.WDim ? ConfigDescriptor.WDim : 1;

uint4_t InDataFormat;
uint4_t OutDataFormat;
if (MultiContextMode && ConfigState.THCON_SEC[WhichUnpacker].REG2_Ovrd_data_format) {
  UnsupportedFunctionality(); // No known usage
  InDataFormat  = ConfigState.THCON_SEC[WhichUnpacker].REG7_Unpack_data_format_cntx[WhichContext];
  OutDataFormat = ConfigState.THCON_SEC[WhichUnpacker].REG7_Unpack_out_data_format_cntx[WhichContext];
} else {
  InDataFormat  = ConfigDescriptor.InDataFormat;
  OutDataFormat = ConfigState.THCON_SEC[WhichUnpacker].REG2_Out_data_format;
}
float DatumSizeBytes;
switch (InDataFormat) {
case BFP2: case BFP2a:            DatumSizeBytes = 0.25; break;
case BFP4: case BFP4a:            DatumSizeBytes = 0.5; break;
case BFP8: case BFP8a:            DatumSizeBytes = 1; break;
case FP8:             case INT8:  DatumSizeBytes = 1; break;
case FP16: case BF16: case INT16: DatumSizeBytes = 2; break;
case FP32: case TF32: case INT32: DatumSizeBytes = 4; break;
}
bool Exponent4b = false; // for FP8 only
if (TTArchitecture == Blackhole) {
  Exponent4b = ConfigState.THCON_SEC[WhichUnpacker].REG1_Unp_LF8_4b_exp;
}

unsigned InAddr;
if (MultiContextMode && WhichContext != 0) {
  InAddr = ConfigState.THCON_SEC[WhichUnpacker].REG3_Base_cntx[WhichContext].address
         +(ConfigState.THCON_SEC[WhichUnpacker].REG7_Offset_cntx[WhichContext & 3].address & 0xffff);
} else {
  InAddr = ConfigState.THCON_SEC[WhichUnpacker].REG3_Base_address
         +(ConfigState.THCON_SEC[WhichUnpacker].REG7_Offset_address & 0xffff);
}
InAddr = (InAddr + 1 + ConfigDescriptor.DigestSize) * 16;

uint16_t* InAddr_RowStart = undefined;
if (!IsUncompressed) {
  InAddr_RowStart = InAddr;
  if (ConfigDescriptor.BlobsPerXYPlane) {
    auto NumBlobs = ConfigDescriptor.BlobsPerXYPlane * ZDim * WDim;
    InAddr += ceil((NumBlobs + 1) * sizeof(uint16_t) / 16.) * 16;
  } else {
    auto NumRows = YDim * ZDim * WDim;
    InAddr += ceil((NumRows + 1) * sizeof(uint16_t) / 16.) * 16;
  }
}

if (ConfigState.THCON_SEC[WhichUnpacker].REG2_Force_shared_exp) {
  UnsupportedFunctionality(); // No known usage
}
double InAddr_Exponents = undefined;
bool BfpExpStream = IsBFPFormat(InDataFormat) && !ConfigState.THCON_SEC[WhichUnpacker].REG2_Force_shared_exp;
if (BfpExpStream) {
  InAddr_Exponents = InAddr;
  if (InDataFormat == BFP8 || InDataFormat == BFP8a || !ConfigDescriptor.NoBFPExpSection) {
    // The hardware counts the rows and the 16-byte units of exponents in 16 bits each, wrapping.
    uint16_t NumRows = YDim * ZDim * WDim;
    uint16_t NumExponentUnits = ceil(XDim * NumRows / 256.);
    InAddr += NumExponentUnits * 16;
  }
}

unsigned FirstDatum;
unsigned InputNumDatums;
unsigned DecompressDrop = 0;
unsigned DecompressNumDatums = UINT32_MAX;
auto& ADC_XY = ADCs[WhichADC     ].Unpacker[WhichUnpacker].Channel[0];
auto& ADC_ZW = ADCs[CurrentThread].Unpacker[WhichUnpacker].Channel[0];
if (IsUncompressed) {
  unsigned XPos;
  unsigned YPos;
  unsigned XEnd;
  if (!RowSearch) {
    XPos = ADC_XY.X;
    YPos = ADC_XY.Y & 0xff;
    XEnd = ADCs[WhichADC].Unpacker[WhichUnpacker].Channel[1].X + 1;
  } else if (ConfigDesc