Skip to content

Commit e0c7a46

Browse files
pratikasharigcbot
authored andcommitted
Fix spill/fill message encoding
HWord message has encoding limit of 4k slots of 32 bytes each. When we want to spill/fill beyond this limit, we need to use LSC message. There was a bug in checking whether offset is within limit of HWord encoding. The bug showed up only when spilled/filled operand was > 4 GRFs in size, first part could be encoded using HWord message and the second part required LSC encoding.
1 parent 1c843c0 commit e0c7a46

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

visa/SpillManagerGMRF.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,11 +2408,11 @@ G4_INST *SpillManagerGRF::createLSCSpill(G4_Declare *spillRangeDcl,
24082408
G4_RegVarTmp *rvar = static_cast<G4_RegVarTmp *>(spillRangeDcl->getRegVar());
24092409
int offset = getDisp(rvar->getBaseRegVar());
24102410
getSpillOffset(offset);
2411+
uint32_t totalByteOffset = (offset + spillOff * builder_->getGRFSize());
24112412
// message expects offsets to be in HWord
2412-
uint32_t offsetHwords = (offset + spillOff * builder_->getGRFSize()) >>
2413-
SCRATCH_SPACE_ADDRESS_UNIT;
2413+
uint32_t offsetHwords = totalByteOffset >> SCRATCH_SPACE_ADDRESS_UNIT;
24142414

2415-
G4_SrcRegRegion *header = getLSCSpillFillHeader(fp, offset);
2415+
G4_SrcRegRegion *header = getLSCSpillFillHeader(fp, totalByteOffset);
24162416
auto sendInst =
24172417
builder_->createSpill(postDst, header, srcOpnd, execSize, height,
24182418
offsetHwords, fp, InstOpt_WriteEnable, true);
@@ -2443,10 +2443,10 @@ G4_INST *SpillManagerGRF::createLSCSpill(G4_Declare *spillRangeDcl,
24432443
getSpillOffset(offset);
24442444
// message expects offsets to be in HWord
24452445
auto regOff = spilledRangeRegion->getRegOff();
2446-
uint32_t offsetHwords =
2447-
(offset + regOff * builder_->getGRFSize()) >> SCRATCH_SPACE_ADDRESS_UNIT;
2446+
uint32_t totalByteOffset = (offset + regOff * builder_->getGRFSize());
2447+
uint32_t offsetHwords = totalByteOffset >> SCRATCH_SPACE_ADDRESS_UNIT;
24482448

2449-
G4_SrcRegRegion *header = getLSCSpillFillHeader(fp, offset);
2449+
G4_SrcRegRegion *header = getLSCSpillFillHeader(fp, totalByteOffset);
24502450
auto sendInst = builder_->createSpill(
24512451
postDst, header, srcOpnd, execSize, (uint16_t)extMsgLength, offsetHwords,
24522452
fp, static_cast<G4_InstOption>(option), true, isScatter);
@@ -2473,11 +2473,11 @@ G4_INST *SpillManagerGRF::createLSCFill(G4_Declare *fillRangeDcl,
24732473
G4_RegVarTmp *rvar = static_cast<G4_RegVarTmp *>(r);
24742474
int offset = getDisp(rvar->getBaseRegVar());
24752475
getSpillOffset(offset);
2476+
uint32_t totalByteOffset = (offset + spillOff * builder_->getGRFSize());
24762477
// fill intrinsic expects offsets to be in HWord
2477-
uint32_t offsetHwords = (offset + spillOff * builder_->getGRFSize()) >>
2478-
SCRATCH_SPACE_ADDRESS_UNIT;
2478+
uint32_t offsetHwords = totalByteOffset >> SCRATCH_SPACE_ADDRESS_UNIT;
24792479

2480-
G4_SrcRegRegion *header = getLSCSpillFillHeader(fp, offset);
2480+
G4_SrcRegRegion *header = getLSCSpillFillHeader(fp, totalByteOffset);
24812481
auto fillInst =
24822482
builder_->createFill(header, postDst, g4::SIMD16, height, offsetHwords,
24832483
fp, InstOpt_WriteEnable, true);

0 commit comments

Comments
 (0)