Skip to content

Commit bf1393d

Browse files
lwesiersigcbot
authored andcommitted
Add spill size generated by IGC
Add spill size generated by IGC for private variables in *.asm shader dumps.
1 parent 1a304b3 commit bf1393d

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5307,8 +5307,13 @@ namespace IGC
53075307
IGC_ASSERT(nullptr != vKernel);
53085308
uint scratchSpaceSizeTemp = m_program->m_ScratchSpaceSize;
53095309

5310-
if (scratchSpaceSizeTemp == 0 ||
5311-
!m_program->GetContext()->getModuleMetaData()->compOpt.UseScratchSpacePrivateMemory)
5310+
CodeGenContext* context = m_program->GetContext();
5311+
5312+
bool noticedScratchSpaceByIGC = context->m_ScratchSpaceUsage.count(m_program->entry) > 0 &&
5313+
context->m_ScratchSpaceUsage[m_program->entry] > 0;
5314+
5315+
if (!noticedScratchSpaceByIGC && (scratchSpaceSizeTemp == 0 ||
5316+
!m_program->GetContext()->getModuleMetaData()->compOpt.UseScratchSpacePrivateMemory))
53125317
return;
53135318
// slot1 is used for spilling only when SeparatingSpillAndPrivateScratchMemorySpace is on
53145319
// and Slot0 is used for IGC private memory

IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,19 @@ void LowerGEPForPrivMem::MarkNotPromtedAllocas(llvm::AllocaInst& I, IGC::StatusP
522522
I.getContext(),
523523
MDString::get(I.getContext(), reason));
524524

525+
526+
auto allocationSize = I.getAllocationSizeInBits(m_ctx->getModule()->getDataLayout());
527+
528+
if (allocationSize)
529+
{
530+
auto scratchUsage_i = m_ctx->m_ScratchSpaceUsage.find(I.getFunction());
531+
if (scratchUsage_i == m_ctx->m_ScratchSpaceUsage.end())
532+
{
533+
m_ctx->m_ScratchSpaceUsage.insert({ I.getFunction(), 0 });
534+
}
535+
m_ctx->m_ScratchSpaceUsage[I.getFunction()] += allocationSize.getValue() / 8;
536+
}
537+
525538
UserAddrSpaceMD& userASMD = m_ctx->m_UserAddrSpaceMD;
526539
std::function<void(Instruction*, MDNode*)> markAS_PRIV;
527540
markAS_PRIV = [&markAS_PRIV, &userASMD](Instruction* instr, MDNode* node) -> void

IGC/Compiler/CodeGenPublic.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,9 @@ namespace IGC
905905

906906
UserAddrSpaceMD m_UserAddrSpaceMD;
907907

908+
// Used scratch space for private variables
909+
llvm::DenseMap<llvm::Function*, uint64_t> m_ScratchSpaceUsage;
910+
908911
// shader stat for opt customization
909912
uint32_t m_tempCount = 0;
910913
uint32_t m_sampler = 0;

IGC/ocloc_tests/features/metadata_travel_check/user_private_var.cl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ SPDX-License-Identifier: MIT
1717
// RUN: ocloc compile -file %s -options " -g -igc_opts 'PrintToConsole=1 PrintMDBeforeModule=1 PrintAfter=EmitPass'" -device pvc 2>&1 | FileCheck %s --check-prefix=CHECK-LLVM3
1818
// RUN: ocloc compile -file %s -options " -g -igc_opts 'PrintToConsole=1 PrintMDBeforeModule=1 PrintAfter=EmitPass'" -device pvc 2>&1 | FileCheck %s --check-prefix=CHECK-LLVM4
1919

20+
// Looking for the comment which informs about the amount of spill size
21+
// CHECK-ASM: //.private memory size
2022
// Looking for the comment attached to the instructions ex:
2123
// (W) store.ugm .... // address space: private; ; $193
2224
// CHECK-ASM: address space: private;

0 commit comments

Comments
 (0)