Skip to content

Commit a75520c

Browse files
weiyu-chenigcbot
authored andcommitted
Fix a case where vISA spill size is not reported correctly.
Spill code cleanup pass may create OOB spill/fill during coalescing, and we need to adjust spill size accordingly.
1 parent c871f7a commit a75520c

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

visa/GraphColor.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10051,12 +10051,8 @@ int GlobalRA::coloringRegAlloc()
1005110051
return VISA_SPILL;
1005210052
}
1005310053

10054-
// do not double count the spill mem offset
10055-
// Note that this includes both SLM and scratch space spills
10056-
uint32_t spillMemUsed = nextSpillOffset;
10057-
//
10058-
// Report spill memory usage information.
10059-
//
10054+
// this includes vISA's scratch space use only and does not include whatever IGC may use for private memory
10055+
uint32_t spillMemUsed = std::max(this->actualSpillSize, nextSpillOffset);
1006010056
if (spillMemUsed)
1006110057
{
1006210058
builder.criticalMsgStream() << "Spill memory used = " << spillMemUsed << " bytes for kernel " <<

visa/GraphColor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,10 @@ namespace vISA
791791
uint32_t numGRFSpill = 0;
792792
uint32_t numGRFFill = 0;
793793

794+
// kernel's spill size
795+
// We need this because spill code cleanup may result in OOB fill/spill during coalescing.
796+
uint32_t actualSpillSize = 0;
797+
794798
void expandFillNonStackcall(uint32_t numRows, uint32_t offset, short rowOffset, G4_SrcRegRegion* header, G4_DstRegRegion* resultRgn, G4_BB* bb, INST_LIST_ITER& instIt);
795799
void expandSpillNonStackcall(uint32_t numRows, uint32_t offset, short rowOffset, G4_SrcRegRegion* header, G4_SrcRegRegion* payload, G4_BB* bb, INST_LIST_ITER& instIt);
796800
void expandFillStackcall(uint32_t numRows, uint32_t offset, short rowOffset, G4_SrcRegRegion* header, G4_DstRegRegion* resultRgn, G4_BB* bb, INST_LIST_ITER& instIt);

visa/SpillManagerGMRF.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4831,6 +4831,8 @@ void GlobalRA::expandSpillIntrinsic(G4_BB* bb)
48314831
auto header = inst->getSrc(0)->asSrcRegRegion();
48324832
auto payload = inst->getSrc(1)->asSrcRegRegion();
48334833
auto spillIt = instIt;
4834+
auto byteOff = inst->asSpillIntrinsic()->getOffsetInBytes() + numRows * numEltPerGRF<Type_UB>();
4835+
actualSpillSize = std::max(actualSpillSize, byteOff);
48344836

48354837
auto rowOffset = payload->getRegOff();
48364838
{
@@ -5005,6 +5007,8 @@ void GlobalRA::expandFillIntrinsic(G4_BB* bb)
50055007
auto header = inst->getSrc(0)->asSrcRegRegion();
50065008
auto resultRgn = inst->getDst();
50075009
auto fillIt = instIt;
5010+
auto byteOff = inst->asFillIntrinsic()->getOffsetInBytes() + numRows * numEltPerGRF<Type_UB>();
5011+
actualSpillSize = std::max(actualSpillSize, byteOff);
50085012

50095013
auto rowOffset = resultRgn->getRegOff();
50105014
{

0 commit comments

Comments
 (0)