Skip to content

Commit

Permalink
(NFC)LSC API simplification
Browse files Browse the repository at this point in the history
Removes nearly all overloads for LSC functions.
SurfaceIndex emulates adding for BSS/SS
(NFC) No functional changes.
  • Loading branch information
trbauer authored and igcbot committed Jul 28, 2023
1 parent ac0ac23 commit 1cd8d20
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 178 deletions.
33 changes: 25 additions & 8 deletions IGC/Compiler/CISACodeGen/CISABuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2628,10 +2628,11 @@ namespace IGC
LSC_ADDR_SIZE_32b,
dataShape,
GetVISALSCSurfaceOpnd(resource.m_surfaceType, resource.m_resource),
0,
dstVar,
dummyZero,
nullptr,
nullptr,
dummyZero, 0,
nullptr, 0,
nullptr, 0,
nullptr,
nullptr,
nullptr));
Expand Down Expand Up @@ -8236,6 +8237,7 @@ namespace IGC
addr,
dataShape,
globalOffsetOpnd,
0,
dstOpnd,
addressOpnd));

Expand All @@ -8250,12 +8252,14 @@ namespace IGC
addr2,
dataShape2,
globalOffsetOpnd2,
0,
dstOpnd2,
addressOpnd2));

return;
}

unsigned surfaceIndex = 0x0;
V(vKernel->AppendVISALscUntypedLoad(
subOp,
lscSfid,
Expand All @@ -8266,6 +8270,7 @@ namespace IGC
addr,
dataShape,
globalOffsetOpnd,
surfaceIndex,
dstOpnd,
addressOpnd));
}
Expand Down Expand Up @@ -8371,6 +8376,7 @@ namespace IGC
addr,
dataShape,
globalOffsetOpnd,
0,
addressOpnd,
src1Opnd));

Expand All @@ -8385,6 +8391,7 @@ namespace IGC
addr2,
dataShape2,
globalOffsetOpnd2,
0,
addressOpnd2,
src1Opnd2));

Expand All @@ -8400,6 +8407,7 @@ namespace IGC
addr,
dataShape,
globalOffsetOpnd,
0,
addressOpnd,
src1Opnd));
}
Expand Down Expand Up @@ -8453,6 +8461,7 @@ namespace IGC
addr,
dataShape,
globalOffsetOpnd,
0,
dstOpnd,
addressOpnd));
}
Expand Down Expand Up @@ -8504,6 +8513,7 @@ namespace IGC
addr,
dataShape,
globalOffsetOpnd,
0,
addressOpnd,
src1Opnd));
}
Expand Down Expand Up @@ -8652,6 +8662,7 @@ namespace IGC
addr,
dataShape,
globalOffsetOpnd,
0,
dstOpnd,
src0AddrOpnd,
src0Opnd,
Expand Down Expand Up @@ -8801,7 +8812,9 @@ namespace IGC
VISA_RawOpnd* pUOffset = GetRawSource(pU, m_encoderState.m_srcOperand[0].subVar * getGRFSize());
VISA_RawOpnd* pVOffset = GetRawSource(pV, m_encoderState.m_srcOperand[1].subVar * getGRFSize());
VISA_RawOpnd* pROffset = GetRawSource(pR, m_encoderState.m_srcOperand[2].subVar * getGRFSize());
VISA_RawOpnd* pLODOffset = GetRawSource(pLOD, m_encoderState.m_srcOperand[3].subVar * getGRFSize());

// LoD or whatever indexing is being used
VISA_RawOpnd* pIndex = GetRawSource(pLOD, m_encoderState.m_srcOperand[3].subVar * getGRFSize());

VISA_PredOpnd* predOpnd = GetFlagOperand(m_encoderState.m_flag);
IGC_ASSERT(m_encoderState.m_dstOperand.subVar == 0);
Expand All @@ -8813,6 +8826,9 @@ namespace IGC
dataShape.order = LSC_DATA_ORDER_NONTRANSPOSE;
dataShape.elems = LSC_GetElementNum(numElems);
dataShape.chmask = chMask;
unsigned surfaceIndex = 0;
int uOff = 0, vOff = 0, rOff = 0;

V(vKernel->AppendVISALscTypedInst(
subOp,
predOpnd,
Expand All @@ -8823,11 +8839,12 @@ namespace IGC
addr_size,
dataShape,
globalOffsetOpnd,
surfaceIndex,
pDst,
pUOffset,
pVOffset,
pROffset,
pLODOffset,
pUOffset, uOff,
pVOffset, vOff,
pROffset, rOff,
pIndex,
pSrc,
nullptr));
}
Expand Down
10 changes: 7 additions & 3 deletions IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4082,9 +4082,10 @@ void GenXKernelBuilder::buildIntrinsic(CallInst *CI, unsigned IntrinID,
LSC_DATA_SHAPE DataDesc = {ElementSize, LSC_DATA_ORDER_NONTRANSPOSE,
LSC_DATA_ELEMS_1};

unsigned SurfIdx = 0;
CISA_CALL(Kernel->AppendVISALscUntypedAtomic(
Opcode, LscSfid, Pred, ExecSize, ExecMask, CacheOpts, AddressDesc,
DataDesc, Base, Dest, Addr, Src1, Src2));
DataDesc, Base, SurfIdx, Dest, Addr, Src1, Src2));
};

auto CreateLscLoad = [&](VISA_PredOpnd *Pred, VISA_Exec_Size ExecSize,
Expand Down Expand Up @@ -4114,9 +4115,11 @@ void GenXKernelBuilder::buildIntrinsic(CallInst *CI, unsigned IntrinID,
DataDesc.chmask = VectorAttr;
}

unsigned SurfIdx = 0;
CISA_CALL(Kernel->AppendVISALscUntypedLoad(Opcode, LscSfid, Pred, ExecSize,
ExecMask, CacheOpts, AddressDesc,
DataDesc, Base, Dest, Addr));
DataDesc, Base, SurfIdx, Dest,
Addr));
};

auto CreateLscStore =
Expand Down Expand Up @@ -4145,9 +4148,10 @@ void GenXKernelBuilder::buildIntrinsic(CallInst *CI, unsigned IntrinID,
DataDesc.chmask = VectorAttr;
}

unsigned SurfIdx = 0;
CISA_CALL(Kernel->AppendVISALscUntypedStore(
Opcode, LscSfid, Pred, ExecSize, ExecMask, CacheOpts, AddressDesc,
DataDesc, Base, Addr, Data));
DataDesc, Base, SurfIdx, Addr, Data));
};

auto CreateLscUntypedBlock2DStateless =
Expand Down
62 changes: 22 additions & 40 deletions visa/VISAKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -823,44 +823,22 @@ class VISAKernelImpl : public VISAFunction {
VISA_SVM_Block_Num numBlocks, VISA_StateOpndHandle *surface,
VISA_RawOpnd *address, VISA_RawOpnd *dst) override;

// overloaded functions for untyped instructions with/without surface index
VISA_BUILDER_API int AppendVISALscUntypedLoad(
LSC_OP op, LSC_SFID sfid, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR addr,
LSC_DATA_SHAPE data, VISA_VectorOpnd *surface, VISA_RawOpnd *dstData,
VISA_RawOpnd *src0Addr) override;
VISA_BUILDER_API int AppendVISALscUntypedLoad(
LSC_OP op, LSC_SFID sfid, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR addr,
LSC_DATA_SHAPE data, VISA_VectorOpnd *surface, unsigned surfaceIndex,
VISA_RawOpnd *dstData, VISA_RawOpnd *src0Addr) override;
VISA_BUILDER_API int AppendVISALscUntypedStore(
LSC_OP op, LSC_SFID sfid, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR addr,
LSC_DATA_SHAPE data, VISA_VectorOpnd *surface, VISA_RawOpnd *src0Addr,
VISA_RawOpnd *src1Data) override;
VISA_BUILDER_API int AppendVISALscUntypedStore(
LSC_OP op, LSC_SFID sfid, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR addr,
LSC_DATA_SHAPE data, VISA_VectorOpnd *surface, unsigned surfaceIndex,
VISA_RawOpnd *src0Addr,VISA_RawOpnd *src1Data) override;
VISA_BUILDER_API int AppendVISALscUntypedAtomic(
LSC_OP op, LSC_SFID sfid, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR addr,
LSC_DATA_SHAPE data, VISA_VectorOpnd *surface, VISA_RawOpnd *dstReadBack,
VISA_RawOpnd *src0Addr, VISA_RawOpnd *src1AtomOpnd1,
VISA_RawOpnd *src2AtomOpnd2) override;
VISA_BUILDER_API int AppendVISALscUntypedAtomic(
LSC_OP op, LSC_SFID sfid, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR addr,
LSC_DATA_SHAPE data, VISA_VectorOpnd *surface, unsigned surfaceIndex,
VISA_RawOpnd *dstReadBack, VISA_RawOpnd *src0Addr, VISA_RawOpnd *src1AtomOpnd1,
VISA_RawOpnd *src2AtomOpnd2) override;
VISA_BUILDER_API int AppendVISALscUntypedInst(
LSC_OP op, LSC_SFID sfid, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR addr,
LSC_DATA_SHAPE data, VISA_VectorOpnd *surface, VISA_RawOpnd *dst,
VISA_RawOpnd *src0, VISA_RawOpnd *src1, VISA_RawOpnd *src2) override;
VISA_BUILDER_API int AppendVISALscUntypedInst(
LSC_OP op, LSC_SFID sfid, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR addr,
Expand All @@ -884,40 +862,44 @@ class VISAKernelImpl : public VISAFunction {
VISA_BUILDER_API int AppendVISALscTypedLoad(
LSC_OP op, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR_TYPE addrModel,
LSC_ADDR_SIZE addrSize, LSC_DATA_SHAPE data, VISA_VectorOpnd *surface,
VISA_RawOpnd *dstData, VISA_RawOpnd *Us, VISA_RawOpnd *Vs,
VISA_RawOpnd *Rs, VISA_RawOpnd *LODs) override;
LSC_ADDR_SIZE addrSize, LSC_DATA_SHAPE data,
VISA_VectorOpnd *surface, unsigned surfaceIndex,
VISA_RawOpnd *dstData,
VISA_RawOpnd *Us, int uOffset,
VISA_RawOpnd *Vs, int vOffset,
VISA_RawOpnd *Rs, int rOffset, VISA_RawOpnd *LODs) override;
VISA_BUILDER_API int AppendVISALscTypedStore(
LSC_OP op, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR_TYPE addrType,
LSC_ADDR_SIZE addrSize, LSC_DATA_SHAPE data, VISA_VectorOpnd *surface,
VISA_RawOpnd *Us, VISA_RawOpnd *Vs, VISA_RawOpnd *Rs, VISA_RawOpnd *LODs,
LSC_ADDR_SIZE addrSize, LSC_DATA_SHAPE data,
VISA_VectorOpnd *surface, unsigned surfaceIndex,
VISA_RawOpnd *Us, int uOffset, VISA_RawOpnd *Vs, int vOffset,
VISA_RawOpnd *Rs, int rOffset, VISA_RawOpnd *LODs,
VISA_RawOpnd *src1Data) override;
VISA_BUILDER_API int AppendVISALscTypedAtomic(
LSC_OP op, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR_TYPE addrType,
LSC_ADDR_SIZE addrSize, LSC_DATA_SHAPE data, VISA_VectorOpnd *surface,
VISA_RawOpnd *dst, VISA_RawOpnd *Us, VISA_RawOpnd *Vs, VISA_RawOpnd *Rs,
VISA_RawOpnd *LODs, VISA_RawOpnd *src1AtomicOpnd1,
VISA_RawOpnd *src2AtomicOpnd2) override;
LSC_ADDR_SIZE addrSize, LSC_DATA_SHAPE data,
VISA_VectorOpnd *surface, unsigned surfaceIndex,
VISA_RawOpnd *dst,
VISA_RawOpnd *Us, int uOffset,
VISA_RawOpnd *Vs, int vOffset,
VISA_RawOpnd *Rs, int rOffset,
VISA_RawOpnd *LODs,
VISA_RawOpnd *src1AtomicOpnd1, VISA_RawOpnd *src2AtomicOpnd2) override;

VISA_BUILDER_API int AppendVISALscTypedInst(
LSC_OP op, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR_TYPE addrType,
LSC_ADDR_SIZE addrSize, LSC_DATA_SHAPE data, VISA_VectorOpnd *surface,
VISA_RawOpnd *dst, VISA_RawOpnd *coord0s, VISA_RawOpnd *coord1s,
VISA_RawOpnd *coord2s, VISA_RawOpnd *features, VISA_RawOpnd *src1, VISA_RawOpnd *src2) override;
VISA_BUILDER_API int AppendVISALscTypedInst(
LSC_OP op, VISA_PredOpnd *pred, VISA_Exec_Size execSize,
VISA_EMask_Ctrl emask, LSC_CACHE_OPTS cacheOpts, LSC_ADDR_TYPE addrType,
LSC_ADDR_SIZE addrSize, LSC_DATA_SHAPE data,
VISA_VectorOpnd *surface, unsigned surfaceIndex,
VISA_RawOpnd *dst,
VISA_RawOpnd *coord0s, int coord0Offset,
VISA_RawOpnd *coord1s, int coord1Offset,
VISA_RawOpnd *coord2s, int coord2Offset,
VISA_RawOpnd *Us, int uOffset,
VISA_RawOpnd *Vs, int vOffset,
VISA_RawOpnd *Rs, int rOffset,
VISA_RawOpnd *features,
VISA_RawOpnd *src1, VISA_RawOpnd *src2) override;

VISA_BUILDER_API int AppendVISALscFence(LSC_SFID lscSfid,
LSC_FENCE_OP fenceOp,
LSC_SCOPE scope) override;
Expand Down
Loading

0 comments on commit 1cd8d20

Please sign in to comment.