Skip to content

Commit 0e6dbcc

Browse files
aratajewigcbot
authored andcommitted
Fix compile output dumping when recompilation happens
This change fixes dumping patch tokens (*.cos file) in the following scenario: -multiple kernels are being compiled -some kernels got compiled WITHOUT spills/fills, so they don't require recompilation -some kernels got compiled WITH spills/fills, so they need to be recompiled Right after the first compilation phase, oclContext.clear() is being called which results in calling destructors on all llvm::Function objects that were created in this phase. Then the second compilation phase is started and all spilled (in phase 1.) kernels get compiled again. Compile output is being dumped after entire compilation. So if recompilation happened, dumping *.cos files will happen after two phases of compilation. General IGC::Debug::GetDumpNameObj function cannot be used to get the kernel name for *.cos dumps, since it takes kernel name directly from llvm::Function object which will be destroyed for kernels that were compiled in phase 1. Instead, this change introduces taking kernel name from M_kernelInfo member of IGC::COpenCLKernel object which is available for the entire compilation process.
1 parent 8378572 commit 0e6dbcc

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

IGC/AdaptorOCL/OCL/sp/spp_g8.cpp

+26-6
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,33 @@ void overrideOCLKernelBinary(
330330
KernBin->Write(Buf.get(), newBinarySize);
331331
}
332332

333-
void dumpOCLCos(const IGC::CShader *Kernel, const std::string &stateDebugMsg) {
334-
auto name = IGC::Debug::GetDumpNameObj(Kernel, "cos");
335-
auto dump = IGC::Debug::Dump(name, IGC::Debug::DumpType::COS_TEXT);
333+
void dumpOCLCos(const IGC::COpenCLKernel *Kernel, const std::string &stateDebugMsg) {
334+
IGC::CodeGenContext* context = Kernel->GetContext();
336335

337-
IGC::Debug::DumpLock();
338-
dump.stream() << stateDebugMsg;
339-
IGC::Debug::DumpUnlock();
336+
auto dumpName =
337+
IGC::Debug::DumpName(IGC::Debug::GetShaderOutputName())
338+
.Type(ShaderType::OPENCL_SHADER)
339+
.Hash(context->hash)
340+
.StagedInfo(context);
341+
342+
std::string kernelName = Kernel->m_kernelInfo.m_kernelName;
343+
const int MAX_KERNEL_NAME = 180;
344+
345+
// Shorten kernel name to avoid issues with too long file name
346+
if (kernelName.size() > MAX_KERNEL_NAME)
347+
{
348+
kernelName.resize(MAX_KERNEL_NAME);
349+
}
350+
dumpName = dumpName.PostFix(kernelName);
351+
352+
dumpName = dumpName.DispatchMode(Kernel->m_ShaderDispatchMode);
353+
dumpName = dumpName.SIMDSize(Kernel->m_dispatchSize).Retry(context->m_retryManager.GetRetryId()).Extension("cos");
354+
355+
auto dump = IGC::Debug::Dump(dumpName, IGC::Debug::DumpType::COS_TEXT);
356+
357+
IGC::Debug::DumpLock();
358+
dump.stream() << stateDebugMsg;
359+
IGC::Debug::DumpUnlock();
340360
}
341361

342362
// Build a name for an ELF temporary file. If uniqueLockFileName contains any % characters then

0 commit comments

Comments
 (0)