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

vISA LSC_UNTYPED

T1 intel-gpu simd insn
Intel GPU vISA Instruction: LSC_UNTYPED
SourceIntel Graphics Compiler Official Virtual ISA (vISA) Specification (intel_gpu_visa)
Reliability TierT1 — Official Specification
ISA / Silicon ScopeIntel Gen8–Xe2 vISA
Intel Gen9–Gen12 / Xe-LP / Xe-HPG / Xe-HPC / Xe2
License & VersionMIT
master
Upstreamhttps://github.com/intel/intel-graphics-compiler/tree/master/documentation/visa
Privilegeuser

Summary

This set of instructions performs an LSC operation on a set of addresses

Syntax / Encoding

LSC_UNTYPED (opcode: LSC_UNTYPED = 0x89)

Binary Encodings (1)

WidthFormatBit PatternMask / Match
Intel-vISA /

Operands

NameDescription
LscSubOpThe specific LSC operation being called
Exec_sizeExecution size. SIMT messages (non-transpose) should
PredPredication control
LscSFIDThe specific LSC unit this operation applies to.
CachingL1Caching behavior for L1.
CachingL3Caching behavior for L3
AddrTypeThe addressing mode type (model). Valid values are:
AddrScaleAn optional scale factor. The compiler may be able to fuse this into the message if it is the data type size (times the vector), otherwise additional instructions are generated to honor the semantics
AddrImmOffsetAn optional immediate offset added to each address. The compiler may be able to fuse this add into the message, otherwise additional instructions are generated to honor the semantics
AddrSizeThe address size enumeration. Valid values are:
DataSizeThe datum size per channel. Valid values are:
DataOrderIndicates if the data is transposed during the transfer from register to memory
DataElemsPerAddrThe number of elements to load per address (vector size)
ChMaskOnly valid for lsc_load_quad and lsc_store_quad, this holds channel-enable bits for the X, Y, Z, and W channels
BlocksOnly for block2d; this holds the count of 2d blocks to load into GRF (the array size)
BlockWidthOnly for block2d; this immediate value holds the 2D region's width (in elements)
BlockHeightOnly for block2d; this immediate value holds the 2D region's height (in elements)
VNNIOnly present in block2d operations. This performs a VNNI transform during the access
SurfaceAn optional surface or base offset to use for this operation. This can be an immediate or a register. Use the immediate value 0 for flat operations unless the platforms supports an a64 base value in which case it can be a nonzero register o
DstDataThe register to store data loaded into for loads. The null register may be used in case of a prefetch-load where none is needed. This is null for stores or atomics without a return value
Src0AddrsThe the vector register holding address operands
Src0AddrBaseOnly for strided; this holds the base address
Src0AddrPitchOnly for strided; this holds the offset of successive elements relative to base address. A value of 0 would be a broadcast load. A value equal to the data type size would emulate a block (packed) load
SurfaceBaseAddrSurface state 64b surface base address (in bytes) (for block2d only).

Reference Notes

## Opcode

  LSC_UNTYPED = 0x89

## Format


### CONDITION

- LscSubOp=lsc_apndctr_atomic_add, lsc_apndctr_atomic_sub


| | | | | | | |
| --- | --- | --- | --- | --- | --- | --- |
| 0x89(LSC_UNTYPED) | LscSubOp                   | Exec_size | Pred      | LscSFID          | CachingL1 | CachingL3 |
|                   | AddrType\*                 | DataSize  | DataOrder | DataElemsPerAddr\* | ChMask\*  | Surface\* |
|                   | DstData                    | Src0Data\* |           |                  |           |           |


### CONDITION

- LscSubOp=lsc_atomic_and, lsc_atomic_fadd, lsc_atomic_fcas, lsc_atomic_fmax, lsc_atomic_fmin, lsc_atomic_fsub, lsc_atomic_iadd, lsc_atomic_icas, lsc_atomic_idec, lsc_atomic_iinc, lsc_atomic_isub, lsc_atomic_load, lsc_atomic_or, lsc_atomic_smax, lsc_atomic_smin, lsc_atomic_store, lsc_atomic_umax, lsc_atomic_umin, lsc_atomic_xor, lsc_load, lsc_load_quad, lsc_load_status, lsc_store, lsc_store_quad, lsc_store_uncompressed


| | | | | | | |
| --- | --- | --- | --- | --- | --- | --- |
| 0x89(LSC_UNTYPED) | LscSubOp                   | Exec_size | Pred          | LscSFID  | CachingL1 | CachingL3 |
|                   | AddrType\*                 | AddrScale\* | AddrImmOffset\* | AddrSize\* | DataSize  | DataOrder |
|                   | DataElemsPerAddr\*         | ChMask\*  | Surface\*     | DstData  | Src0Addrs\* | Src1Data\* |
|                   | Src2Data\*                 |           |               |          |           |           |


### CONDITION

- LscSubOp=lsc_load_block2d, lsc_store_block2d


| | | | | | | |
| --- | --- | --- | --- | --- | --- | --- |
| 0x89(LSC_UNTYPED) | LscSubOp              | Exec_size       | Pred         | LscSFID       | CachingL1    | CachingL3 |
|                   | DataSize              | DataOrder       | Blocks\*     | BlockWidth\*  | BlockHeight\* | VNNI\*    |
|                   | DstData               | SurfaceBaseAddr\* | SurfaceWidth\* | SurfaceHeight\* | SurfacePitch\* | Src0AddrX\* |
|                   | Src0AddrY\*           | Src1Data\*      |              |               |              |           |


### CONDITION

- LscSubOp=lsc_load_strided, lsc_store_strided


| | | | | | | |
| --- | --- | --- | --- | --- | --- | --- |
| 0x89(LSC_UNTYPED) | LscSubOp              | Exec_size | Pred          | LscSFID  | CachingL1    | CachingL3     |
|                   | AddrType\*            | AddrScale\* | AddrImmOffset\* | AddrSize\* | DataSize     | DataOrder     |
|                   | DataElemsPerAddr\*    | ChMask\*  | Surface\*     | DstData  | Src0AddrBase\* | Src0AddrPitch\* |
|                   | Src1Data\*            |           |               |          |              |               |


## Semantics


```
                    struct grf_data_sized {
                       // 8 elements for :d64, 16 for :d32, 32 for :d16, 64 for :d8 (half of this for DG2)
                       DataSize elems[GRF_SIZE_BYTES/sizeof(DataSize)];
                    } DstData, Src1Data, Src2Data;
                    union grf_addr_size {
                       // 8 elements for :a64, 16 for :a32 (half of this for DG2)
                       AddrSize addrs[GRF_SIZE_BYTES/sizeof(AddrSize)];
                    } src0;

                    Base =
                        AddrType == flat ? 0 :
                        AddrType == bss ? BindlessSurfaceStateHeap[Surface].BaseAddr :
                        AddrType == ss ? SurfaceStateHeap[Surface].BaseAddr :
                        AddrType == bti ? BindingTable[Surface]->BaseAddr :
                        AddrType == arg ? IndirectDataBase :
                undefined
      LOAD:
                    for (n = 0; n < ExecSize; n++) {
                      if (Msg.ChEn[n]) {
                        for (v = 0; v < vect_size; v++) {
                          grf_sized src = Base + AddrScale*Src0Addrs[n] + AddrImmOffset
                          auto datum = src.elems[v];
                          if (DataOrder == LSC_DATA_ORDER_TRANSPOSED) {
                            DstData[n].elems[v] = datum
                          } else {
                            DstData[v].elems[n] = datum
                          }
                        }
                      }
                    }

      LOAD_QUAD:
                    for (n = 0; n < ExecSize; n++) {
                      if (Msg.ChEn[n]) {
                        for (m = v = 0; v < 4; v++) {
                          if (ChMask[v]) {
                            grf_sized src = Base + AddrScale*Src0Addrs[n] + AddrImmOffset
                            DstData[m].elems[n] = src.elems[v]
                            m++;
                          }
                        }
                      }
                    }

      LOAD_STRIDED:
                    for (n = 0; n < ExecSize; n++) {
                      if (Msg.ChEn[n]) {
                        for (v = 0; v < vect_size; v++) {
                          auto addr = AddrScale*(Base + offset + Src0Addrs) + n*Src0AddrPitch + AddrImmOffset
                          if (DataOrder == LSC_DATA_ORDER_TRANSPOSED) {
                            dst[n].elems[v] = addr->elems[v]
                          } else {
                            dst[v].elems[n] = addr->elems[v]
                          }
                        }
                      }
                    }

      LOAD_STATUS:
                    for (n = 0; n < ExecSize; n++) {
                      s = 1;
                      if (Msg.ChEn[n]) {
                        auto addr = Base + AddrScale*Src0Addrs[n] + AddrImmOffset
                        for (v = 0; v < vect_size; v++) {
                          if (s) {
                            s = IsTRTT_VALID_PAGE(addr.elems[v])
                          }
                        }
                      }
                      dest.bit[n] = MsgChEn[n] & s
                    }

      LOAD_BLOCK2D:
          // let T be the element data type (e.g. uint32_t for d32)
          // src0.* is see block2d array source payload register
          const int B = Blocks, H = BlockHeight, W = BlockWidth; // values -1-encoded
          const int X = Src0AddrX, Y = Src0AddrY; // these are not -1-encoded
          const bool transpose =  DataOrder == LSC_DATA_ORDER_TRANSPOSED, transform = VNNI;
          const int elems_per_dword = 4/sizeof(T);
          const int elems_per_reg = GRF_SIZE_BYTES/sizeof(T);

          auto store_elem_to_grf = [&](int dst_off, T value) {
            int r = dst_off / elems_per_reg, sr = dst_off % elems_per_reg;
            dst[r].elems[sr] = value;
          };
          const char *block_start = src0.SurfaceBaseAddr + src0.Y * src0.SurfacePitch;

          // 'b' is the block, 'u' represents the Y-axis, and 'v' the X-axis
          auto load_elem = [&](int dst_off, int b, int y, int x) {
            T *row = (T *)(src0.SurfaceBaseAddr + y * src0.SurfacePitch);
            store_elem_to_grf(dst_off, row[X + b * W + x]);
          };

          // loads a row span or column span of elements into GRF ...
          auto load_row_span = [&](int grf_off, int b, int y, int x, int n) {
            for (int i = 0; i < n; i++) load_elem(grf_off + i, b, y, x + i);
          };
          auto load_col_span = [&](int grf_off, int b, int y, int x, int n) {
            for (int i = 0; i < n; i++) load_elem(grf_off + i, b, y + i, x);
          };
          auto fill_grf_zeros = [&](int dst_off, int n) {
            for (int i = 0; i < n; i++) store_elem_to_grf(dst_off + i, 0);
          };

          const int grf_row_size = transpose ? H : W;
          const int grf_row_pitch = round_up_pow2(grf_row_size);
          const int grf_block_size = grf_row_pitch * (transpose ? W : H);
          const int grf_block_pitch = round_to_multiple_of(elems_per_reg, grf_block_size);

          for (int b = 0; b < B; b++) {
            if (!transpose && !transform) {
            for (int y = 0; y < H; y++) {
              int grf_row_s