Skip to content

Commit ac5c776

Browse files
kcyganik1pszymich
authored andcommitted
Update max private mem used by each function group while having VLA
Update max private mem used by each function group when function group has VariableLengthAlloca. (cherry picked from commit 25cda17)
1 parent d9e5d92 commit ac5c776

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,13 @@ bool PrivateMemoryResolution::runOnModule(llvm::Module& M)
291291
}
292292
if (FG->hasVariableLengthAlloca())
293293
{
294-
// Add another 1KB if there are VLAs
295-
maxPrivateMem += 1024;
294+
// Add another 4KB if there are VLAs
295+
maxPrivateMem += 4096;
296+
std::string maxPrivateMemValue = std::to_string(maxPrivateMem);
297+
std::string fullWarningMessage = "VLA has been detected, the private memory size is set to " + maxPrivateMemValue + "B. You can change the size by setting flag ForcePerThreadPrivateMemorySize to a value from [1024:20480]. Greater values can affect performance, and lower ones may lead to incorrect results of your program";
298+
299+
// Now, you can pass the concatenated warning message (const char*) to the EmitWarning function
300+
getAnalysis<CodeGenContextWrapper>().getCodeGenContext()->EmitWarning(fullWarningMessage.c_str());
296301
}
297302
maxPrivateMem = std::max(maxPrivateMem, Ctx.getPrivateMemoryMinimalSizePerThread());
298303
maxPrivateMem = std::max(maxPrivateMem, (uint32_t)(IGC_GET_FLAG_VALUE(ForcePerThreadPrivateMemorySize)));

0 commit comments

Comments
 (0)