Skip to content

Commit 49ea47e

Browse files
scottp101igcbot
authored andcommitted
[Autobackout][FuncReg]Revert of change: 4c0d9b1
Use getThreadGroupSize() in more places. Have COpenCLKernel use CComputeShaderBase.
1 parent f8df103 commit 49ea47e

File tree

11 files changed

+63
-78
lines changed

11 files changed

+63
-78
lines changed

IGC/AdaptorOCL/ocl_igc_shared/executable_format/patch_list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Abstract: Contains common patch structure definitions
3232

3333
namespace iOpenCL
3434
{
35-
const uint32_t CURRENT_ICBE_VERSION = 1071;
35+
const uint32_t CURRENT_ICBE_VERSION = 1070;
3636
const uint32_t MAGIC_CL = 0x494E5443; // 'I', 'N', 'T', 'C'
3737
const uint32_t INVALID_INDEX = 0xFFFFFFFF;
3838

IGC/Compiler/CISACodeGen/ComputeShaderBase.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,23 @@ namespace IGC
5151
uint threadGroupSize_Z)
5252
{
5353
const CodeGenContext* pCtx = GetContext();
54-
const ModuleMetaData* MMD = pCtx->getModuleMetaData();
5554

56-
if (MMD->csInfo.neededThreadIdLayout == ThreadIDLayout::QuadTile)
55+
if (pCtx->getModuleMetaData()->csInfo.neededThreadIdLayout == ThreadIDLayout::QuadTile)
5756
{
5857
m_ThreadIDLayout = ThreadIDLayout::QuadTile;
5958
return;
6059
}
6160

6261
if ((numberOfTypedAccess >= numberOfUntypedAccess) &&
6362
threadGroupSize_Y % 4 == 0 &&
64-
!MMD->csInfo.disableLocalIdOrderOptimizations &&
63+
!pCtx->getModuleMetaData()->csInfo.disableLocalIdOrderOptimizations &&
6564
IGC_IS_FLAG_ENABLED(UseTiledCSThreadOrder)) {
6665
m_ThreadIDLayout = ThreadIDLayout::TileY;
6766
m_walkOrder = WO_YXZ;
6867
}
6968

7069
bool needsLinearWalk =
71-
MMD->csInfo.neededThreadIdLayout == ThreadIDLayout::X;
70+
pCtx->getModuleMetaData()->csInfo.neededThreadIdLayout == ThreadIDLayout::X;
7271
if (needsLinearWalk)
7372
{
7473
m_ThreadIDLayout = ThreadIDLayout::X;

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13647,9 +13647,14 @@ void EmitPass::emitThreadGroupBarrier(llvm::Instruction* inst)
1364713647
else if (m_currShader->GetShaderType() == ShaderType::OPENCL_SHADER) {
1364813648
Function* F = inst->getParent()->getParent();
1364913649
MetaDataUtils* pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
13650-
uint32_t sz = IGCMetaDataHelper::getThreadGroupSize(*pMdUtils, F);
13651-
if (sz != 0 && sz <= numLanes(m_SimdMode)) {
13652-
skipBarrierInstructionInCS = true;
13650+
FunctionInfoMetaDataHandle funcInfoMD = pMdUtils->getFunctionsInfoItem(F);
13651+
ThreadGroupSizeMetaDataHandle threadGroupSize = funcInfoMD->getThreadGroupSize();
13652+
if (threadGroupSize->hasValue())
13653+
{
13654+
int32_t sz = threadGroupSize->getXDim() * threadGroupSize->getYDim() * threadGroupSize->getZDim();
13655+
if (sz <= (int32_t)numLanes(m_SimdMode)) {
13656+
skipBarrierInstructionInCS = true;
13657+
}
1365313658
}
1365413659
}
1365513660

IGC/Compiler/CISACodeGen/FoldKnownWorkGroupSizes.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,27 @@ void FoldKnownWorkGroupSizes::visitCallInst(llvm::CallInst& I)
9595
}
9696
else if (funcName.equals(WIFuncsAnalysis::GET_ENQUEUED_LOCAL_SIZE))
9797
{
98-
auto Dims = IGCMetaDataHelper::getThreadGroupDims(
99-
*ctx->getMetaDataUtils(),
100-
I.getFunction());
98+
auto itr = ctx->getMetaDataUtils()->findFunctionsInfoItem(I.getFunction());
10199

102-
if (!Dims)
100+
//Check function exists in the metadata
101+
if (itr == ctx->getMetaDataUtils()->end_FunctionsInfo())
102+
return;
103+
104+
FunctionInfoMetaDataHandle funcMDHandle = itr->second;
105+
ThreadGroupSizeMetaDataHandle tgMD = funcMDHandle->getThreadGroupSize();
106+
//Check threadGroup has value
107+
if (!tgMD->hasValue())
103108
return;
104109

105110
IRBuilder<> IRB(&I);
106111

107-
auto* CV = ConstantDataVector::get(I.getContext(), *Dims);
112+
uint32_t Dims[] =
113+
{
114+
(uint32_t)tgMD->getXDim(),
115+
(uint32_t)tgMD->getYDim(),
116+
(uint32_t)tgMD->getZDim(),
117+
};
118+
auto* CV = ConstantDataVector::get(I.getContext(), Dims);
108119

109120
auto* Dim = I.getArgOperand(0);
110121
auto* EE = IRB.CreateExtractElement(CV, Dim, "enqueuedLocalSize");

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace IGC
6060
{
6161

6262
COpenCLKernel::COpenCLKernel(const OpenCLProgramContext* ctx, Function* pFunc, CShaderProgram* pProgram) :
63-
CComputeShaderBase(pFunc, pProgram)
63+
CShader(pFunc, pProgram)
6464
{
6565
m_HasTID = false;
6666
m_HasGlobalSize = false;
@@ -140,21 +140,6 @@ namespace IGC
140140
}
141141
}
142142

143-
bool COpenCLKernel::hasWorkGroupWalkOrder()
144-
{
145-
const CodeGenContext* pCtx = GetContext();
146-
const ModuleMetaData* MMD = pCtx->getModuleMetaData();
147-
if (auto I = MMD->FuncMD.find(entry); I != MMD->FuncMD.end())
148-
{
149-
auto& FMD = I->second;
150-
auto& Order = FMD.workGroupWalkOrder;
151-
if (Order.dim0 != 0 || Order.dim1 != 0 || Order.dim2 != 0)
152-
return true;
153-
}
154-
155-
return false;
156-
}
157-
158143
SOpenCLKernelInfo::SResourceInfo COpenCLKernel::getResourceInfo(int argNo)
159144
{
160145
CodeGenContext* pCtx = GetContext();

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ IN THE SOFTWARE.
2323
============================= end_copyright_notice ===========================*/
2424

2525
#pragma once
26-
#include "Compiler/CISACodeGen/ComputeShaderBase.hpp"
26+
#include "Compiler/CISACodeGen/ShaderCodeGen.hpp"
2727

2828
namespace IGC
2929
{
@@ -33,7 +33,7 @@ namespace IGC
3333
namespace IGC
3434
{
3535

36-
class COpenCLKernel : public CComputeShaderBase
36+
class COpenCLKernel : public CShader
3737
{
3838
public:
3939
friend class CShaderProgram;
@@ -129,8 +129,6 @@ namespace IGC
129129
OpenCLProgramContext* m_Context;
130130

131131
void ClearKernelInfo();
132-
private:
133-
bool hasWorkGroupWalkOrder();
134132
};
135133

136134
}

IGC/Compiler/MetaDataApi/IGCMetaDataHelper.cpp

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -78,42 +78,6 @@ void IGCMetaDataHelper::removeFunction(
7878
}
7979
}
8080

81-
llvm::Optional<std::array<uint32_t, 3>>
82-
IGCMetaDataHelper::getThreadGroupDims(
83-
MetaDataUtils& mdUtils,
84-
llvm::Function* pKernelFunc)
85-
{
86-
auto finfo = mdUtils.findFunctionsInfoItem(pKernelFunc);
87-
if (finfo == mdUtils.end_FunctionsInfo())
88-
return llvm::None;
89-
90-
auto& FI = finfo->second;
91-
92-
if (!FI->getThreadGroupSize()->hasValue())
93-
return llvm::None;
94-
95-
auto Dims = FI->getThreadGroupSize();
96-
97-
std::array<uint32_t, 3> A {
98-
(uint32_t)Dims->getXDim(),
99-
(uint32_t)Dims->getYDim(),
100-
(uint32_t)Dims->getZDim()
101-
};
102-
103-
return A;
104-
}
105-
106-
uint32_t IGCMetaDataHelper::getThreadGroupSize(MetaDataUtils& mdUtils, llvm::Function* pKernelFunc)
107-
{
108-
auto Dims = IGCMD::IGCMetaDataHelper::getThreadGroupDims(mdUtils, pKernelFunc);
109-
if (!Dims)
110-
return 0;
111-
112-
auto& Vals = *Dims;
113-
114-
return Vals[0] * Vals[1] * Vals[2];
115-
}
116-
11781
uint32_t IGCMetaDataHelper::getThreadGroupSizeHint(MetaDataUtils& mdUtils, llvm::Function* pKernelFunc)
11882
{
11983
FunctionInfoMetaDataHandle finfo = mdUtils.getFunctionsInfoItem(pKernelFunc);
@@ -125,4 +89,17 @@ uint32_t IGCMetaDataHelper::getThreadGroupSizeHint(MetaDataUtils& mdUtils, llvm:
12589
finfo->getThreadGroupSizeHint()->getZDim();
12690
}
12791
return size;
92+
}
93+
94+
uint32_t IGCMetaDataHelper::getThreadGroupSize(MetaDataUtils& mdUtils, llvm::Function* pKernelFunc)
95+
{
96+
FunctionInfoMetaDataHandle finfo = mdUtils.getFunctionsInfoItem(pKernelFunc);
97+
uint32_t size = 0;
98+
if (finfo->getThreadGroupSize()->hasValue())
99+
{
100+
size = finfo->getThreadGroupSize()->getXDim() *
101+
finfo->getThreadGroupSize()->getYDim() *
102+
finfo->getThreadGroupSize()->getZDim();
103+
}
104+
return size;
128105
}

IGC/Compiler/MetaDataApi/IGCMetaDataHelper.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ namespace IGC {
4141

4242
// In OCL, thread group size (hint) is given by kernel attributes reqd_work_group_size and work_group_size_hint.
4343
// Return thread group size (hint) if present; return 0 otherwise.
44-
static llvm::Optional<std::array<uint32_t, 3>>
45-
getThreadGroupDims(MetaDataUtils& mdUtils, llvm::Function* pKernelFunc);
4644
static uint32_t getThreadGroupSize(MetaDataUtils& mdUtils, llvm::Function* pKernelFunc);
4745
static uint32_t getThreadGroupSizeHint(MetaDataUtils& mdUtils, llvm::Function* pKernelFunc);
4846
};

IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,23 @@ WIFuncResolution::WIFuncResolution() : FunctionPass(ID), m_implicitArgs()
5656
Constant* WIFuncResolution::getKnownWorkGroupSize(
5757
IGCMD::MetaDataUtils* MDUtils, llvm::Function& F) const
5858
{
59-
auto Dims = IGCMD::IGCMetaDataHelper::getThreadGroupDims(*MDUtils, &F);
60-
if (!Dims)
59+
auto finfo = MDUtils->findFunctionsInfoItem(&F);
60+
if (finfo == MDUtils->end_FunctionsInfo())
6161
return nullptr;
6262

63-
return ConstantDataVector::get(F.getContext(), *Dims);
63+
auto& FI = finfo->second;
64+
if (FI->getThreadGroupSize()->hasValue())
65+
{
66+
uint32_t Dims[] =
67+
{
68+
(uint32_t)FI->getThreadGroupSize()->getXDim(),
69+
(uint32_t)FI->getThreadGroupSize()->getYDim(),
70+
(uint32_t)FI->getThreadGroupSize()->getZDim(),
71+
};
72+
return ConstantDataVector::get(F.getContext(), Dims);
73+
}
74+
75+
return nullptr;
6476
}
6577

6678
bool WIFuncResolution::runOnFunction(Function& F)

IGC/common/MDFrameWork.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ namespace IGC
175175

176176
struct WorkGroupWalkOrderMD
177177
{
178-
int dim0 = 0;
179-
int dim1 = 0;
180-
int dim2 = 0;
178+
int dim0 = 0;
179+
int dim1 = 0;
180+
int dim2 = 0;
181181
};
182182

183183
struct FuncArgMD

visa/BinaryEncodingIGA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ void BinaryEncodingIGA::Encode()
853853
auto secondBB = *(std::next(kernel.fg.begin()));
854854
auto iter = std::find_if(secondBB->begin(), secondBB->end(),
855855
[](G4_INST* inst) { return !inst->isLabel();});
856-
assert(iter != secondBB->end() && "expect at least one non-label inst in second BB");
856+
assert(iter != secondBB->end() && "execpt at least one non-label inst in second BB");
857857
kernel.fg.builder->getJitInfo()->offsetToSkipPerThreadDataLoad =
858858
(uint32_t)(*iter)->getGenOffset();
859859
}

0 commit comments

Comments
 (0)