Skip to content

Commit e1abe84

Browse files
pratikasharsys_zuul
authored andcommitted
Internal fix
Change-Id: Ifd062ff49c792b55c3f6e56e46e5ed852fe259e8
1 parent 631b2bd commit e1abe84

File tree

6 files changed

+42
-13
lines changed

6 files changed

+42
-13
lines changed

visa/BuildIR.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,8 @@ class IR_Builder {
11131113
return inst;
11141114
}
11151115

1116+
// numRows is in hword units
1117+
// offset is in hword units
11161118
G4_INST* createSpill(
11171119
G4_DstRegRegion* dst, G4_SrcRegRegion* header, G4_SrcRegRegion* payload,
11181120
unsigned int execSize,

visa/GraphColor.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ using namespace vISA;
4949

5050
#define MIN(x,y) (((x)<(y))? (x):(y))
5151
#define MAX(x,y) (((x)<(y))? (y):(x))
52-
#define ROUND(x,y) ((x) + ((y - x % y) % y))
5352

5453
unsigned int BitMask[BITS_DWORD] =
5554
{
@@ -6607,15 +6606,15 @@ G4_Imm* GlobalRA::createMsgDesc(unsigned owordSize, bool writeType, bool isSplit
66076606
unsigned messageLength = 1;
66086607
if (!isSplitSend)
66096608
{
6610-
messageLength += ROUND(owordSize, 2) / 2;
6609+
messageLength += owordToGRFSize(ROUND(owordSize, G4_GRF_REG_NBYTES/OWORD_BYTE_SIZE));
66116610
}
66126611
message |= messageLength << SEND_MSG_LENGTH_BIT_OFFSET;
66136612
}
66146613
else
66156614
{
66166615
unsigned messageType = SEND_OWORD_READ_TYPE;
66176616
message |= messageType << SEND_MSG_TYPE_BIT_OFFSET;
6618-
unsigned responseLength = ROUND(owordSize, 2) / 2;
6617+
unsigned responseLength = owordToGRFSize(ROUND(owordSize, G4_GRF_REG_NBYTES / OWORD_BYTE_SIZE));
66196618
message |= responseLength << SEND_RSP_LENGTH_BIT_OFFSET;
66206619
unsigned messageLength = 1;
66216620
message |= messageLength << SEND_MSG_LENGTH_BIT_OFFSET;
@@ -6668,23 +6667,23 @@ void GraphColor::saveRegs(
66686667
else if (owordSize > 8)
66696668
{
66706669
saveRegs(startReg, 8, scratchRegDcl, framePtr, frameOwordOffset, bb, insertIt);
6671-
saveRegs(startReg + 4, owordSize - 8, scratchRegDcl, framePtr, frameOwordOffset + 8, bb, insertIt);
6670+
saveRegs(startReg + GlobalRA::owordToGRFSize(8), owordSize - 8, scratchRegDcl, framePtr, frameOwordOffset + 8, bb, insertIt);
66726671
}
66736672
//
66746673
// Split into chunks of sizes 4 and remaining owords.
66756674
//
66766675
else if (owordSize > 4)
66776676
{
66786677
saveRegs(startReg, 4, scratchRegDcl, framePtr, frameOwordOffset, bb, insertIt);
6679-
saveRegs(startReg + 2, owordSize - 4, scratchRegDcl, framePtr, frameOwordOffset + 4, bb, insertIt);
6678+
saveRegs(startReg + GlobalRA::owordToGRFSize(4), owordSize - 4, scratchRegDcl, framePtr, frameOwordOffset + 4, bb, insertIt);
66806679
}
66816680
//
66826681
// Split into chunks of sizes 2 and remaining owords.
66836682
//
66846683
else if (owordSize > 2)
66856684
{
66866685
saveRegs(startReg, 2, scratchRegDcl, framePtr, frameOwordOffset, bb, insertIt);
6687-
saveRegs(startReg + 1, owordSize - 2, scratchRegDcl, framePtr, frameOwordOffset + 2, bb, insertIt);
6686+
saveRegs(startReg + GlobalRA::owordToGRFSize(2), owordSize - 2, scratchRegDcl, framePtr, frameOwordOffset + 2, bb, insertIt);
66886687
}
66896688
else
66906689
{
@@ -6711,7 +6710,8 @@ void GraphColor::saveActiveRegs(
67116710
if (startPos < saveRegs.size() && saveRegs[startPos]) {
67126711
unsigned endPos = startPos + 1;
67136712
for (; endPos < saveRegs.size() && saveRegs[endPos] == true; endPos++);
6714-
unsigned owordSize = (endPos - startPos) * 2;
6713+
unsigned owordSize = (endPos - startPos) * GlobalRA::GRFSizeToOwords(1);
6714+
owordSize = std::max(owordSize, GlobalRA::GRFSizeToOwords(1));
67156715
this->saveRegs(startPos + startReg, owordSize, scratchRegDcl, framePtr, frameOwordPos, bb, insertIt);
67166716
frameOwordPos += owordSize;
67176717
startPos = endPos;
@@ -6751,23 +6751,23 @@ void GraphColor::restoreRegs(
67516751
else if (owordSize > 8)
67526752
{
67536753
restoreRegs(startReg, 8, scratchRegDcl, framePtr, frameOwordOffset, bb, insertIt);
6754-
restoreRegs(startReg + 4, owordSize - 8, scratchRegDcl, framePtr, frameOwordOffset + 8, bb, insertIt);
6754+
restoreRegs(startReg + GlobalRA::owordToGRFSize(8), owordSize - 8, scratchRegDcl, framePtr, frameOwordOffset + 8, bb, insertIt);
67556755
}
67566756
//
67576757
// Split into chunks of sizes 4 and remaining owords.
67586758
//
67596759
else if (owordSize > 4)
67606760
{
67616761
restoreRegs(startReg, 4, scratchRegDcl, framePtr, frameOwordOffset, bb, insertIt);
6762-
restoreRegs(startReg + 2, owordSize - 4, scratchRegDcl, framePtr, frameOwordOffset + 4, bb, insertIt);
6762+
restoreRegs(startReg + GlobalRA::owordToGRFSize(4), owordSize - 4, scratchRegDcl, framePtr, frameOwordOffset + 4, bb, insertIt);
67636763
}
67646764
//
67656765
// Split into chunks of sizes 2 and remaining owords.
67666766
//
67676767
else if (owordSize > 2)
67686768
{
67696769
restoreRegs(startReg, 2, scratchRegDcl, framePtr, frameOwordOffset, bb, insertIt);
6770-
restoreRegs(startReg + 1, owordSize - 2, scratchRegDcl, framePtr, frameOwordOffset + 2, bb, insertIt);
6770+
restoreRegs(startReg + GlobalRA::owordToGRFSize(2), owordSize - 2, scratchRegDcl, framePtr, frameOwordOffset + 2, bb, insertIt);
67716771
}
67726772
else
67736773
{
@@ -6794,7 +6794,8 @@ void GraphColor::restoreActiveRegs(
67946794
if (startPos < restoreRegs.size() && restoreRegs[startPos]) {
67956795
unsigned endPos = startPos + 1;
67966796
for (; endPos < restoreRegs.size() && restoreRegs[endPos] == true; endPos++);
6797-
unsigned owordSize = (endPos - startPos) * 2;
6797+
unsigned owordSize = (endPos - startPos) * GlobalRA::GRFSizeToOwords(1);
6798+
owordSize = std::max(owordSize, GlobalRA::GRFSizeToOwords(1));
67986799
this->restoreRegs(startPos + startReg, owordSize, scratchRegDcl, framePtr, frameOwordPos, bb, insertIt);
67996800
frameOwordPos += owordSize;
68006801
startPos = endPos;

visa/GraphColor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3939

4040
#define BITS_DWORD 32
4141
#define SCRATCH_MSG_LIMIT (128 * 1024)
42+
#define ROUND(x,y) ((x) + ((y - x % y) % y))
4243

4344
extern unsigned int BitMask[BITS_DWORD];
4445
namespace vISA
@@ -826,6 +827,10 @@ namespace vISA
826827
return dcl;
827828
}
828829

830+
static unsigned int owordToGRFSize(unsigned int numOwords);
831+
static unsigned int hwordToGRFSize(unsigned int numHwords);
832+
static unsigned int GRFSizeToOwords(unsigned int numGRFs);
833+
829834
// RA specific fields
830835
G4_Declare* getGRFDclForHRA(int GRFNum) const { return GRFDclsForHRA[GRFNum]; }
831836

visa/LocalRA.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,10 @@ void LocalRA::markReferences(unsigned int& numRowsEOT,
12461246
{
12471247
curInst->setLexicalId(id);
12481248
lifetimeOpFound = true;
1249+
if (curInst->opcode() == G4_pseudo_lifetime_end)
1250+
{
1251+
markReferencesInInst(inst_it);
1252+
}
12491253
continue;
12501254
}
12511255

visa/RegAlloc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,6 +3703,7 @@ static void recordRAStats(IR_Builder& builder,
37033703
#endif // COMPILER_STATS_ENABLE
37043704
}
37053705

3706+
37063707
int regAlloc(IR_Builder& builder, PhyRegPool& regPool, G4_Kernel& kernel)
37073708
{
37083709
if (kernel.fg.getHasStackCalls() || kernel.fg.getIsStackCallFunc())

visa/SpillManagerGMRF.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ static const unsigned SCRATCH_MSG_DESC_BLOCK_SIZE = 12;
104104
// Macros
105105

106106
#define LIMIT_SEND_EXEC_SIZE(EXEC_SIZE)(((EXEC_SIZE) > 16)? 16: (EXEC_SIZE))
107-
#define ROUND(x,y) ((x) + ((y - x % y) % y))
108107
#define SPILL_PAYLOAD_HEIGHT_LIMIT 4
109108

110109
extern unsigned int getStackCallRegSize(bool reserveStackCallRegs);
@@ -4393,6 +4392,23 @@ static unsigned int getPayloadSizeOword(unsigned int numOwords)
43934392
return 1u;
43944393
}
43954394

4395+
unsigned int GlobalRA::owordToGRFSize(unsigned int numOwords)
4396+
{
4397+
unsigned int GRFSize = numOwords / (2 * (G4_GRF_REG_NBYTES / HWORD_BYTE_SIZE));
4398+
4399+
return GRFSize;
4400+
}
4401+
4402+
unsigned int GlobalRA::hwordToGRFSize(unsigned int numHwords)
4403+
{
4404+
return owordToGRFSize(numHwords * 2);
4405+
}
4406+
4407+
unsigned int GlobalRA::GRFSizeToOwords(unsigned int numGRFs)
4408+
{
4409+
return numGRFs * (G4_GRF_REG_NBYTES / OWORD_BYTE_SIZE);
4410+
}
4411+
43964412

43974413
void GlobalRA::expandSpillNonStackcall(uint32_t& numRows, uint32_t& offset, short& rowOffset, G4_SrcRegRegion* header, G4_SrcRegRegion* payload, G4_BB* bb, INST_LIST_ITER& instIt)
43984414
{
@@ -4473,7 +4489,7 @@ void GlobalRA::expandSpillStackcall(uint32_t& numRows, uint32_t& offset, short&
44734489
G4_DstRegRegion* dst = builder->createNullDst((execSize > 8) ? Type_UW : Type_UD);
44744490
auto sendSrc0 = builder->createSrcRegRegion(Mod_src_undef, Direct, scratchRegDcl->getRegVar(),
44754491
0, 0, builder->rgnpool.createRegion(8, 8, 1), Type_UD);
4476-
unsigned messageLength = owordSize / 2;
4492+
unsigned messageLength = owordToGRFSize(owordSize);
44774493
G4_Imm* descImm = createMsgDesc(owordSize, true, true);
44784494
G4_INST* sendInst = nullptr;
44794495
{

0 commit comments

Comments
 (0)