vISA LSC_UNTYPED
intel_gpu_visa)Intel Gen9–Gen12 / Xe-LP / Xe-HPG / Xe-HPC / Xe2
master
userSummary
This set of instructions performs an LSC operation on a set of addresses
Syntax / Encoding
LSC_UNTYPED (opcode: LSC_UNTYPED = 0x89)
Binary Encodings (1)
| Width | Format | Bit Pattern | Mask / Match |
|---|---|---|---|
| Intel-vISA | | / |
Operands
| Name | Description |
|---|---|
LscSubOp | The specific LSC operation being called |
Exec_size | Execution size. SIMT messages (non-transpose) should |
Pred | Predication control |
LscSFID | The specific LSC unit this operation applies to. |
CachingL1 | Caching behavior for L1. |
CachingL3 | Caching behavior for L3 |
AddrType | The addressing mode type (model). Valid values are: |
AddrScale | An 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 |
AddrImmOffset | An 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 |
AddrSize | The address size enumeration. Valid values are: |
DataSize | The datum size per channel. Valid values are: |
DataOrder | Indicates if the data is transposed during the transfer from register to memory |
DataElemsPerAddr | The number of elements to load per address (vector size) |
ChMask | Only valid for lsc_load_quad and lsc_store_quad, this holds channel-enable bits for the X, Y, Z, and W channels |
Blocks | Only for block2d; this holds the count of 2d blocks to load into GRF (the array size) |
BlockWidth | Only for block2d; this immediate value holds the 2D region's width (in elements) |
BlockHeight | Only for block2d; this immediate value holds the 2D region's height (in elements) |
VNNI | Only present in block2d operations. This performs a VNNI transform during the access |
Surface | An 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 |
DstData | The 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 |
Src0Addrs | The the vector register holding address operands |
Src0AddrBase | Only for strided; this holds the base address |
Src0AddrPitch | Only 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 |
SurfaceBaseAddr | Surface 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