Skip to content

Commit 52dab22

Browse files
trbauerigcbot
authored andcommitted
surface index emulation
Adds a new LSC surface index parameter which walks forward in units of RENDER_SURFACE_STATE entries.
1 parent 207b0c9 commit 52dab22

17 files changed

+265
-167
lines changed

visa/BuildCISAIR.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ class CISA_IR_Builder : public VISABuilder {
617617
VISA_opnd *pred, LSC_OP opcode, LSC_SFID sfid, LSC_CACHE_OPTS caching,
618618
VISA_Exec_Size execSize, VISA_EMask_Ctrl emask, LSC_ADDR addr,
619619
LSC_DATA_SHAPE dataShape,
620-
VISA_opnd *surface, int surfaceIndex,
620+
VISA_opnd *surface, unsigned surfaceIndex,
621621
VISA_opnd *dst,
622622
VISA_opnd *src0,
623623
VISA_opnd *src1,
@@ -626,7 +626,9 @@ class CISA_IR_Builder : public VISABuilder {
626626
bool CISA_create_lsc_untyped_strided_inst(
627627
VISA_opnd *pred, LSC_OP opcode, LSC_SFID sfid, LSC_CACHE_OPTS caching,
628628
VISA_Exec_Size execSize, VISA_EMask_Ctrl emask, LSC_ADDR addr,
629-
LSC_DATA_SHAPE dataShape, VISA_opnd *surface, VISA_opnd *dstData,
629+
LSC_DATA_SHAPE dataShape,
630+
VISA_opnd *surface, unsigned surfaceIndex,
631+
VISA_opnd *dstData,
630632
VISA_opnd *src0AddrBase, VISA_opnd *src0AddrPitch, VISA_opnd *src1Data,
631633
int lineNum);
632634
bool CISA_create_lsc_untyped_block2d_inst(
@@ -641,7 +643,7 @@ class CISA_IR_Builder : public VISABuilder {
641643
VISA_opnd *pred, LSC_OP opcode, LSC_SFID sfid, LSC_CACHE_OPTS caching,
642644
VISA_Exec_Size execSize, VISA_EMask_Ctrl emask, LSC_ADDR_TYPE addrModel,
643645
LSC_ADDR_SIZE addrSize, LSC_DATA_SHAPE dataShape,
644-
VISA_opnd *surface, int surfaceIndex,
646+
VISA_opnd *surface, unsigned surfaceIndex,
645647
VISA_opnd *dst_data,
646648
VISA_opnd *src0_Us, int uOffset,
647649
VISA_opnd *src0_Vs, int vOffset,

visa/BuildCISAIRImpl.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4003,7 +4003,8 @@ bool CISA_IR_Builder::CISA_create_fcvt_instruction(
40034003
bool CISA_IR_Builder::CISA_create_lsc_untyped_inst(
40044004
VISA_opnd *pred, LSC_OP opcode, LSC_SFID sfid, LSC_CACHE_OPTS caching,
40054005
VISA_Exec_Size execSize, VISA_EMask_Ctrl emask, LSC_ADDR addr,
4006-
LSC_DATA_SHAPE dataShape, VISA_opnd *surface, int surfaceIndex,
4006+
LSC_DATA_SHAPE dataShape,
4007+
VISA_opnd *surface, unsigned surfaceIndex,
40074008
VISA_opnd *dstData, VISA_opnd *src0Addr, VISA_opnd *src1Data,
40084009
VISA_opnd *src2Data, int lineNum) {
40094010
VISA_CALL_TO_BOOL(AppendVISALscUntypedInst, opcode, sfid,
@@ -4019,13 +4020,16 @@ bool CISA_IR_Builder::CISA_create_lsc_untyped_inst(
40194020
bool CISA_IR_Builder::CISA_create_lsc_untyped_strided_inst(
40204021
VISA_opnd *pred, LSC_OP opcode, LSC_SFID sfid, LSC_CACHE_OPTS caching,
40214022
VISA_Exec_Size execSize, VISA_EMask_Ctrl emask, LSC_ADDR addr,
4022-
LSC_DATA_SHAPE dataShape, VISA_opnd *surface, VISA_opnd *dst,
4023+
LSC_DATA_SHAPE dataShape,
4024+
VISA_opnd *surface, unsigned surfaceIndex,
4025+
VISA_opnd *dst,
40234026
VISA_opnd *src0Base, VISA_opnd *src0Stride, VISA_opnd *src1Data,
40244027
int lineNum) {
40254028
VISA_CALL_TO_BOOL(
40264029
AppendVISALscUntypedStridedInst, opcode, sfid,
40274030
static_cast<VISA_PredOpnd *>(pred), execSize, emask, caching, addr,
4028-
dataShape, static_cast<VISA_VectorOpnd *>(surface),
4031+
dataShape,
4032+
static_cast<VISA_VectorOpnd *>(surface), surfaceIndex,
40294033
static_cast<VISA_RawOpnd *>(dst), static_cast<VISA_RawOpnd *>(src0Base),
40304034
static_cast<VISA_VectorOpnd *>(src0Stride),
40314035
static_cast<VISA_RawOpnd *>(src1Data));
@@ -4058,7 +4062,7 @@ bool CISA_IR_Builder::CISA_create_lsc_typed_inst(
40584062
VISA_opnd *pred, LSC_OP opcode, LSC_SFID sfid, LSC_CACHE_OPTS caching,
40594063
VISA_Exec_Size execSize, VISA_EMask_Ctrl emask, LSC_ADDR_TYPE addrModel,
40604064
LSC_ADDR_SIZE addrSize, LSC_DATA_SHAPE dataShape,
4061-
VISA_opnd *surface, int surfaceIndex,
4065+
VISA_opnd *surface, unsigned surfaceIndex,
40624066
VISA_opnd *dst_data,
40634067
VISA_opnd *coord0s, int coord0Offset,
40644068
VISA_opnd *coord1s, int coord1Offset,

visa/BuildIR.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,9 +1385,10 @@ class IR_Builder {
13851385

13861386
G4_InstSend *createLscSendInst(G4_Predicate *pred, G4_DstRegRegion *dst,
13871387
G4_SrcRegRegion *src0, G4_SrcRegRegion *src1,
1388-
G4_ExecSize execsize, G4_SendDescRaw *msgDesc,
1388+
G4_ExecSize execsize,
1389+
G4_SendDescRaw *msgDesc,
13891390
G4_InstOpts option, LSC_ADDR_TYPE addrType,
1390-
bool emitA0RegDef);
1391+
unsigned surfOff, bool emitA0RegDef);
13911392

13921393

13931394
G4_SrcRegRegion *getScratchSurfaceStatusIndex();
@@ -2031,6 +2032,7 @@ class IR_Builder {
20312032
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR addrInfo,
20322033
LSC_DATA_SHAPE shape,
20332034
G4_Operand *surface, // surface/bti
2035+
unsigned ssIdx, // optional BSSO index
20342036
G4_DstRegRegion *dstData, G4_SrcRegRegion *src0AddrOrBlockY,
20352037
G4_Operand *src0AddrStrideOrBlockX, // only for strided and block2d
20362038
G4_SrcRegRegion *src1Data, // store data/extra atomic operands
@@ -2047,6 +2049,7 @@ class IR_Builder {
20472049
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR_TYPE addrModel,
20482050
LSC_ADDR_SIZE addrSize, LSC_DATA_SHAPE shape,
20492051
G4_Operand *surface, // surface/bti
2052+
unsigned surfaceIndex,
20502053
G4_DstRegRegion *dstData, // dst on load/atomic
20512054
G4_SrcRegRegion *src0AddrUs, int uOff,
20522055
G4_SrcRegRegion *src0AddrVs, int vOff,

visa/BuildIRImpl.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,7 +2558,8 @@ G4_SendDescRaw *IR_Builder::createLscDesc(SFID sfid, uint32_t desc,
25582558
G4_InstSend *IR_Builder::createLscSendInst(
25592559
G4_Predicate *pred, G4_DstRegRegion *dst, G4_SrcRegRegion *src0,
25602560
G4_SrcRegRegion *src1, G4_ExecSize execSize, G4_SendDescRaw *msgDesc,
2561-
G4_InstOpts option, LSC_ADDR_TYPE addrType, bool emitA0RegDef) {
2561+
G4_InstOpts option, LSC_ADDR_TYPE addrType, unsigned ssIdx,
2562+
bool emitA0RegDef) {
25622563

25632564
uint32_t exDesc = msgDesc->getExtendedDesc();
25642565
G4_Operand *surface = msgDesc->getBti(); // BTI or SS/BSS
@@ -2592,8 +2593,16 @@ G4_InstSend *IR_Builder::createLscSendInst(
25922593
// SS or BSS
25932594
G4_DstRegRegion *addrDstOpnd = createDstRegRegion(builtinA0Dot2, 1);
25942595
if ((addrType == LSC_ADDR_TYPE_BSS) || (addrType == LSC_ADDR_TYPE_SS)) {
2595-
// mov a0.2 surface
2596-
createMov(g4::SIMD1, addrDstOpnd, surface, InstOpt_WriteEnable, true);
2596+
if (ssIdx == 0x0) {
2597+
// (W) mov (1) a0.2 surface
2598+
createMov(g4::SIMD1, addrDstOpnd, surface, InstOpt_WriteEnable, true);
2599+
} else {
2600+
// (W) add (1) a0.2 surface (0x40 * ssIdx):ud
2601+
const unsigned SIZEOF_SURFACE_STATE = 0x40;
2602+
auto *surfOffImm = createImm(SIZEOF_SURFACE_STATE * ssIdx, Type_UD);
2603+
createBinOp(G4_add, g4::SIMD1, addrDstOpnd, surface, surfOffImm,
2604+
InstOpt_WriteEnable, true);
2605+
}
25972606
} else {
25982607
vISA_ASSERT(false, "FLAT have surface == nullptr here");
25992608
}

visa/ByteCodeReaderNG.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,6 +2234,7 @@ static void readInstructionLscUntyped(LSC_OP subOpcode, unsigned &bytePos,
22342234

22352235
VISA_VectorOpnd *surface =
22362236
readVectorOperandNG(bytePos, buf, container, false);
2237+
auto ssIdx = readPrimitiveOperandNG<uint32_t>(bytePos, buf);
22372238
VISA_RawOpnd *dst = readRawOperandNG(bytePos, buf, container);
22382239
VISA_RawOpnd *src0 = readRawOperandNG(bytePos, buf, container);
22392240
VISA_VectorOpnd *src0Pitch = nullptr;
@@ -2249,11 +2250,11 @@ static void readInstructionLscUntyped(LSC_OP subOpcode, unsigned &bytePos,
22492250
if (opInfo.isStrided()) {
22502251
container.kernelBuilder->AppendVISALscUntypedStridedInst(
22512252
subOpcode, lscSfid, pred, execSize, execMask, caching, addrInfo,
2252-
dataInfo, surface, dst, src0, src0Pitch, src1);
2253+
dataInfo, surface, ssIdx, dst, src0, src0Pitch, src1);
22532254
} else {
22542255
container.kernelBuilder->AppendVISALscUntypedInst(
22552256
subOpcode, lscSfid, pred, execSize, execMask, caching, addrInfo,
2256-
dataInfo, surface, dst, src0, src1, src2);
2257+
dataInfo, surface, ssIdx, dst, src0, src1, src2);
22572258
}
22582259
}
22592260

@@ -2323,17 +2324,26 @@ static void readInstructionLscTyped(LSC_OP subOpcode, unsigned &bytePos,
23232324

23242325
VISA_VectorOpnd *surface =
23252326
readVectorOperandNG(bytePos, buf, container, false);
2327+
auto ssIdx = readPrimitiveOperandNG<uint32_t>(bytePos, buf);
23262328
VISA_RawOpnd *dstData = readRawOperandNG(bytePos, buf, container);
23272329
VISA_RawOpnd *src0AddrsU = readRawOperandNG(bytePos, buf, container);
2330+
auto uOff = readPrimitiveOperandNG<int32_t>(bytePos, buf);
23282331
VISA_RawOpnd *src0AddrsV = readRawOperandNG(bytePos, buf, container);
2332+
auto vOff = readPrimitiveOperandNG<int32_t>(bytePos, buf);
23292333
VISA_RawOpnd *src0AddrsR = readRawOperandNG(bytePos, buf, container);
2334+
auto rOff = readPrimitiveOperandNG<int32_t>(bytePos, buf);
23302335
VISA_RawOpnd *src0AddrsLOD = readRawOperandNG(bytePos, buf, container);
23312336
VISA_RawOpnd *src1Data = readRawOperandNG(bytePos, buf, container);
23322337
VISA_RawOpnd *src2Data = readRawOperandNG(bytePos, buf, container);
23332338

23342339
container.kernelBuilder->AppendVISALscTypedInst(
23352340
subOpcode, pred, execSize, execMask, caching, addrModel, addrSize,
2336-
dataInfo, surface, dstData, src0AddrsU, src0AddrsV, src0AddrsR,
2341+
dataInfo,
2342+
surface, ssIdx,
2343+
dstData,
2344+
src0AddrsU, uOff,
2345+
src0AddrsV, vOff,
2346+
src0AddrsR, rOff,
23372347
src0AddrsLOD, src1Data, src2Data);
23382348
}
23392349
static void readInstructionLscFence(unsigned &bytePos, const char *buf,

visa/CISA.y

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,15 +1599,17 @@ LscInstruction:
15991599
//
16001600
// BTI:
16011601
// lsc_load.ugm V53:u32 bti(0x10)[V52]:a32
1602-
// lsc_load.ugml V53:u32 bti(V10.2)[V52]:a32
1602+
// lsc_load.ugm V53:u32 bti(V10(0,1))[V52]:a32
16031603
//
1604-
// SS:
1605-
// lsc_load.ugm V53:u64 ss(0x200)[V52+0x100]:a16
16061604
// BSS:
1607-
// lsc_load.ugm V53:u8x8 bss(V10)[V52+0x100]:a16
1605+
// lsc_load.ugm V53:u8x8 bss(V10)[V52+0x100]:a32
1606+
// lsc_load.ugm V53:u8x8 bss(V10(0,0),0x3)[V52+0x100]:a32
1607+
// SS:
1608+
// lsc_load.ugm V53:u64 ss(V10(0,0))[V52+0x100]:a32
1609+
// lsc_load.ugm V53:u64 ss(0x200)[V52+0x100]:a32
16081610
//
16091611
// ARG:
1610-
// lsc_load.ugm V53:u8x8 arg[V52+0x100]:a16
1612+
// lsc_load.ugm V53:u8x8 arg[V52+0x100]:a32
16111613
//
16121614
LscUntypedLoad:
16131615
// 1 2 3 4 5
@@ -1659,6 +1661,7 @@ LscUntypedStridedLoad:
16591661
$7.addr, // address
16601662
$6.shape, // data
16611663
$7.surface, // surface
1664+
$7.surfaceIndex, // surface index
16621665
$6.reg, // dst
16631666
$7.regs[0], // src0 base
16641667
$7.regs[1], // src0 stride
@@ -1742,6 +1745,7 @@ LscUntypedStridedStore:
17421745
$6.addr, // address
17431746
$7.shape, // data
17441747
$6.surface, // surface
1748+
$6.surfaceIndex, // surface index
17451749
nullptr, // dst
17461750
$6.regs[0], // src0 base
17471751
$6.regs[1], // src0 stride
@@ -2007,7 +2011,7 @@ LscUntypedStridedAddrOperand:
20072011
// 5 6 7 8 9
20082012
LscAddrImmOffsetOpt COMMA LscVectorOpRegOrImm32 RBRACK LSC_ADDR_SIZE_TK
20092013
{
2010-
$$ = {$1.surface, 0, {$4, $7}, {$1.type, (int)$3, (int)$5, $9}};
2014+
$$ = {$1.surface, $1.surfaceIndex, {$4, $7}, {$1.type, (int)$3, (int)$5, $9}};
20112015
}
20122016
| LscUntypedAddrOperand {
20132017
$$ = $1;

0 commit comments

Comments
 (0)