Skip to content

Commit 7aeef7b

Browse files
pratikasharigcbot
authored andcommitted
Report 120kb scratch use when indirect calls are used on
TGLLP. Allow instrumentation to work with HWord messages.
1 parent 8339e4c commit 7aeef7b

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6193,7 +6193,9 @@ namespace IGC
61936193

61946194
uint32_t barrierCount = jitInfo->numBarriers;
61956195
uint32_t privateMemPerThread = (uint32_t)(it.second.argumentStackSize + it.second.allocaStackSize);
6196-
uint32_t spillMemPerThread = getSpillMemSizeWithFG(*F, jitInfo->stats.spillMemUsed, pFga);
6196+
uint32_t spillMemPerThread =
6197+
getSpillMemSizeWithFG(*F, jitInfo->stats.spillMemUsed, pFga,
6198+
jitInfo->numBytesScratchGtpin);
61976199
uint8_t hasRTCalls = (uint8_t)modMD->FuncMD[F].hasSyncRTCalls;
61986200

61996201
attrs.emplace_back(
@@ -6727,7 +6729,8 @@ namespace IGC
67276729
IGC_IS_FLAG_SET(ForceScratchSpaceSize)
67286730
? IGC_GET_FLAG_VALUE(ForceScratchSpaceSize)
67296731
: getSpillMemSizeWithFG(*m_program->entry,
6730-
jitInfo->stats.spillMemUsed, pFGA);
6732+
jitInfo->stats.spillMemUsed, pFGA,
6733+
jitInfo->numBytesScratchGtpin);
67316734

67326735
pMainKernel->GetGTPinBuffer(pOutput->m_gtpinBuffer,
67336736
pOutput->m_gtpinBufferSize,
@@ -6756,23 +6759,35 @@ namespace IGC
67566759
}
67576760

67586761
uint32_t CEncoder::getSpillMemSizeWithFG(const llvm::Function &curFunc,
6759-
uint32_t curSize, GenXFunctionGroupAnalysis *fga)
6760-
{
6762+
uint32_t curSize,
6763+
GenXFunctionGroupAnalysis *fga,
6764+
uint32_t gtpinScratchUse) {
67616765
if (!fga)
67626766
return curSize;
67636767

67646768
// Return the precise stack size for non-group-head function, and the
67656769
// estimated conservative value for group head.
67666770
const FunctionGroup *fg = fga->getGroupForHead(&curFunc);
6767-
if(!fg)
6771+
if (!fg)
67686772
return curSize;
6769-
// Since it is difficult to predict amount of space needed to store stack,
6770-
// we reserve a magic large size. Reserving max PTSS is ideal, but it can
6771-
// lead to OOM on machines with large number of threads.
6773+
// Since it is difficult to predict amount of space needed to store
6774+
// stack, we reserve a magic large size. Reserving max PTSS is
6775+
// ideal, but it can lead to OOM on machines with large number of
6776+
// threads.
67726777
auto visaplt = GetVISAPlatform(&(m_program->GetContext()->platform));
67736778
if (fg->hasIndirectCall() || fg->hasRecursion()) {
6774-
if(visaplt == TARGET_PLATFORM::Xe_PVCXT)
6779+
if (visaplt == TARGET_PLATFORM::Xe_PVCXT)
67756780
return 64 * 1024;
6781+
// gtpin may want to use 8kb for instrumentation. HWord
6782+
// scratch message supports only 128kb addressing. Whereas
6783+
// OWord message for 128kb+ addressing requires free GRF
6784+
// for header. If there are no free GRFs then instrumentation
6785+
// may fail. So for TGLLP, we assume 120kb is used for spills
6786+
// so that gtpin may still be able to use 8kb, when needed.
6787+
// LSC doesn't have restriction of 128kb so this WA is only
6788+
// used for TGLLP and only when gtpin wants to attach.
6789+
if (visaplt == TARGET_PLATFORM::GENX_TGLLP && gtpinScratchUse)
6790+
return 120 * 1024;
67766791
return 128 * 1024;
67776792
}
67786793

IGC/Compiler/CISACodeGen/CISABuilder.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,9 +777,10 @@ namespace IGC
777777
/// For group head functions, when having the stack call, the spillSize
778778
/// returned by vISA is the sum of required stack size of all potential
779779
/// callee and without considering recursive or indirect calls.
780-
uint32_t getSpillMemSizeWithFG(const llvm::Function& curFunc,
780+
uint32_t getSpillMemSizeWithFG(const llvm::Function &curFunc,
781781
uint32_t curSize,
782-
GenXFunctionGroupAnalysis *fga);
782+
GenXFunctionGroupAnalysis *fga,
783+
uint32_t gtpinScratchUse);
783784

784785
protected:
785786
// encoder states

0 commit comments

Comments
 (0)