Skip to content

Commit 20f48f2

Browse files
dlei6gsys_zuul
authored andcommitted
Returns spill memory per function from VISA through program output
Change-Id: I6e13cad826594d4ccb3d7130daae8d3345106d9b
1 parent cbb6a35 commit 20f48f2

File tree

5 files changed

+27
-12
lines changed

5 files changed

+27
-12
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4765,17 +4765,28 @@ namespace IGC
47654765
vISA::GenFuncAttribEntry entry;
47664766
Function* F = it.first;
47674767

4768-
// Ignore internal functions
4769-
if (!isEntryFunc(m_program->GetContext()->getMetaDataUtils(), F) &&
4770-
!F->hasFnAttribute("IndirectlyCalled"))
4771-
continue;
4772-
47734768
assert(F->getName().size() <= vISA::MAX_SYMBOL_NAME_LENGTH);
47744769
strcpy_s(entry.f_name, vISA::MAX_SYMBOL_NAME_LENGTH, F->getName().str().c_str());
47754770
entry.f_isKernel = it.second.isKernel ? 1 : 0;
47764771
entry.f_hasBarrier = it.second.hasBarrier ? 1 : 0;
47774772
entry.f_privateMemPerThread = (uint32_t) (it.second.argumentStackSize + it.second.allocaStackSize);
47784773

4774+
// Get spill mem usage from visa
4775+
VISAKernel* visaFunc = nullptr;
4776+
if (it.second.isKernel)
4777+
{
4778+
visaFunc = vMainKernel;
4779+
}
4780+
else
4781+
{
4782+
auto Iter = stackFuncMap.find(F);
4783+
assert(Iter != stackFuncMap.end() && "vISA function not found");
4784+
visaFunc = Iter->second;
4785+
}
4786+
FINALIZER_INFO* jitInfo;
4787+
visaFunc->GetJitInfo(jitInfo);
4788+
entry.f_spillMemPerThread = jitInfo->spillMemUsed;
4789+
47794790
attribTable.push_back(entry);
47804791
}
47814792

IGC/Compiler/CISACodeGen/CISABuilder.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,17 +587,20 @@ namespace IGC
587587

588588
public:
589589
// Used by EmitVISAPass to set function attributes
590-
void SetFunctionIsKernel(llvm::Function* F) {
591-
funcAttributeMap[F].isKernel = true;
590+
void InitFuncAttribute(llvm::Function* F, bool isKernel = false) {
591+
funcAttributeMap[F].isKernel = isKernel;
592592
}
593593
void SetFunctionHasBarrier(llvm::Function* F) {
594-
funcAttributeMap[F].hasBarrier = true;
594+
if (funcAttributeMap.find(F) != funcAttributeMap.end())
595+
funcAttributeMap[F].hasBarrier = true;
595596
}
596597
void SetFunctionMaxArgumentStackSize(llvm::Function* F, unsigned size) {
597-
funcAttributeMap[F].argumentStackSize = MAX(funcAttributeMap[F].argumentStackSize, size);
598+
if (funcAttributeMap.find(F) != funcAttributeMap.end())
599+
funcAttributeMap[F].argumentStackSize = MAX(funcAttributeMap[F].argumentStackSize, size);
598600
}
599601
void SetFunctionAllocaStackSize(llvm::Function* F, unsigned size) {
600-
funcAttributeMap[F].allocaStackSize = size;
602+
if (funcAttributeMap.find(F) != funcAttributeMap.end())
603+
funcAttributeMap[F].allocaStackSize = size;
601604
}
602605
};
603606

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,6 @@ void CShader::InitKernelStack(CVariable*& stackBase, CVariable*& stackAllocSize,
313313
encoder.SetFunctionAllocaStackSize(entry, totalAllocaSize);
314314
}
315315
}
316-
// Indicate this is the kernel function
317-
encoder.SetFunctionIsKernel(entry);
318316

319317
// modify private-memory size to a large setting
320318
m_ModuleMetadata->FuncMD[entry].privateMemoryPerWI = 8192;

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ bool EmitPass::runOnFunction(llvm::Function& F)
504504
m_currShader->PreCompile();
505505
if (hasStackCall)
506506
{
507+
m_encoder->InitFuncAttribute(&F, true);
507508
CVariable* pStackBase = nullptr;
508509
CVariable* pStackSize = nullptr;
509510
m_currShader->InitKernelStack(pStackBase, pStackSize, ptr64bits);
@@ -520,6 +521,7 @@ bool EmitPass::runOnFunction(llvm::Function& F)
520521
m_currShader->BeginFunction(&F);
521522
if (m_FGA && m_FGA->useStackCall(&F))
522523
{
524+
m_encoder->InitFuncAttribute(&F, false);
523525
emitStackFuncEntry(&F, ptr64bits);
524526
}
525527
}

visa/include/RelocationInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ typedef struct {
7575
uint8_t f_isKernel; // Is the function a kernel
7676
uint8_t f_hasBarrier; // Does the function use barriers
7777
uint32_t f_privateMemPerThread; // Total private memory (in bytes) used by this function per thread
78+
uint32_t f_spillMemPerThread; // Spill mem used (in bytes) in scratch space for this function
7879
char f_name[MAX_SYMBOL_NAME_LENGTH]; // The function's name
7980
} GenFuncAttribEntry;
8081

0 commit comments

Comments
 (0)