Skip to content

Commit c207898

Browse files
gulfemsavrunyenicerisys_zuul
authored andcommitted
Fix encoding for internal functions
1) Remove enforcing SIMD8 mode for kernels with internal functions 2) Allow internal functions to use its kernel functions' group simd size Change-Id: I2144ba3b4cff42cbc40dbe1344ac7be666b84fda
1 parent f975ac6 commit c207898

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -254,34 +254,29 @@ bool EmitPass::canCompileCurrentShader(llvm::Function& F)
254254
// If uses subroutines/stackcall, we can only compile a single SIMD mode
255255
if (m_FGA && (!m_FGA->getGroup(&F)->isSingle() || m_FGA->getGroup(&F)->hasStackCall()))
256256
{
257-
SIMDMode compiledSIMD = SIMDMode::UNKNOWN;
258-
257+
// Check if a specific SIMD size is enforced
259258
if (ctx->type == ShaderType::OPENCL_SHADER)
260259
{
261-
// If SIMD sized is forced by IGC flag, compile the forced mode
262260
if (m_moduleMD->csInfo.forcedSIMDSize != 0)
263261
{
264-
compiledSIMD = lanesToSIMDMode((unsigned)m_moduleMD->csInfo.forcedSIMDSize);
262+
return m_SimdMode == lanesToSIMDMode((unsigned)m_moduleMD->csInfo.forcedSIMDSize);
265263
}
266-
// If max work group size is set, we need to compile the least allowed SIMD
267-
else if (ctx->m_DriverInfo.sendMultipleSIMDModes() && m_moduleMD->csInfo.maxWorkGroupSize != 0)
264+
265+
if (ctx->m_DriverInfo.sendMultipleSIMDModes() && m_moduleMD->csInfo.maxWorkGroupSize != 0)
268266
{
269-
compiledSIMD = getLeastSIMDAllowed(m_moduleMD->csInfo.maxWorkGroupSize, GetHwThreadsPerWG(ctx->platform));
267+
return m_SimdMode == getLeastSIMDAllowed(m_moduleMD->csInfo.maxWorkGroupSize, GetHwThreadsPerWG(ctx->platform));
270268
}
271269
}
272-
if (compiledSIMD != SIMDMode::UNKNOWN)
273-
{
274-
return (m_SimdMode == compiledSIMD);
275-
}
276-
else if (ctx->m_enableFunctionPointer)
270+
271+
if (ctx->m_enableFunctionPointer)
277272
{
278-
// Can compile SIMD8 and SIMD16 for function pointers
273+
// Can compile both SIMD8 and SIMD16 for function pointers
279274
return (m_SimdMode == SIMDMode::SIMD8 || m_SimdMode == SIMDMode::SIMD16);
280275
}
281276
else
282277
{
283-
// Default SIMD8
284-
return m_SimdMode == SIMDMode::SIMD8;
278+
// Can't support SIMD32 due to slicing
279+
return m_SimdMode != SIMDMode::SIMD32;
285280
}
286281
}
287282
else if(m_moduleMD->compOpt.IsLibraryCompilation == true)

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,8 +2112,8 @@ namespace IGC
21122112
CShader* simd8Program = m_parent->GetShader(SIMDMode::SIMD8);
21132113
CShader* simd16Program = m_parent->GetShader(SIMDMode::SIMD16);
21142114
CShader* simd32Program = m_parent->GetShader(SIMDMode::SIMD32);
2115-
CodeGenContext* pCtx = GetContext();
21162115

2116+
CodeGenContext* pCtx = GetContext();
21172117
// Here we see if we have compiled a size for this shader already
21182118
if ((simd8Program && simd8Program->ProgramOutput()->m_programSize > 0) ||
21192119
(simd16Program && simd16Program->ProgramOutput()->m_programSize > 0) ||
@@ -2129,6 +2129,17 @@ namespace IGC
21292129
ModuleMetaData* modMD = pCtx->getModuleMetaData();
21302130
FunctionInfoMetaDataHandle funcInfoMD = pMdUtils->getFunctionsInfoItem(&F);
21312131
int simd_size = funcInfoMD->getSubGroupSize()->getSIMD_size();
2132+
2133+
// Finds the kernel and get the group simd size from the kernel
2134+
if (m_FGA)
2135+
{
2136+
llvm::Function* Kernel = &F;
2137+
auto FG = m_FGA->getGroup(&F);
2138+
Kernel = FG->getHead();
2139+
funcInfoMD = pMdUtils->getFunctionsInfoItem(Kernel);
2140+
simd_size = funcInfoMD->getSubGroupSize()->getSIMD_size();
2141+
}
2142+
21322143
uint32_t groupSize = 0;
21332144
if (modMD->csInfo.maxWorkGroupSize)
21342145
{

0 commit comments

Comments
 (0)