Skip to content

Commit 1c33976

Browse files
pratikasharigcbot
authored andcommitted
Internal change
Internal change
1 parent 732822e commit 1c33976

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

visa/GraphColor.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6400,16 +6400,33 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
64006400
}
64016401
}
64026402

6403-
// For now it is assumed only 8-byte types will appear
6404-
// here. If other sized types will also appear then
6405-
// augmentation mask also needs to be sent in
6406-
// weak edge data structure below.
6403+
// If 2 variables have weak edge, they can either fully overlap
6404+
// or have no overlap at all. However, if 1 variable exceeds
6405+
// 1 value per channel, then partial overlap can be allowed.
6406+
// Assume var1 has weak edge with var2. This means both var1
6407+
// and var2 are either Default64Bit or Default32Bit and they
6408+
// are > 2 GRFs in size. Assume they're 64-bits in size. By definition
6409+
// of AugmentationMask::Default64Bit it means the program defines
6410+
// var1 in blocks of N GRFs, where N is #GRFs needed to define all
6411+
// channels of 1 variable of the type. In case of SIMD16, GRF row
6412+
// size = 32 bytes, N = 4 GRFs. This means 4 GRFs are needed to
6413+
// define all 16 channels of a 64-bit variable.
6414+
//
6415+
// Every block of N GRFs is defined using mask M0, ie for row4, row8, row12,
6416+
// etc. mask offset used is reset. This means if var1 is 16 GRFs and
6417+
// var2 is 4 GRFs, it is safe to overlap var2 every 4 rows of var1.
6418+
6419+
6420+
auto simdSize = kernel.getSimdSize();
6421+
auto numElemsPerGRF = numEltPerGRF<Type_UQ>();
6422+
auto numGRFPerBlock = simdSize / numElemsPerGRF;
6423+
64076424
for (unsigned r = pvar; r < (pvar + numRegs); r++)
64086425
{
64096426
auto use = regUsage.getWeakEdgeUse(r);
6410-
if (use == 0 || use == (r - pvar + 1))
6427+
if (use == 0 || use == ((r - pvar + 1) % numGRFPerBlock))
64116428
{
6412-
regUsage.setWeakEdgeUse(r, r - pvar + 1);
6429+
regUsage.setWeakEdgeUse(r, (r - pvar + 1) % numGRFPerBlock);
64136430
}
64146431
else
64156432
{
@@ -10120,7 +10137,6 @@ int GlobalRA::coloringRegAlloc()
1012010137
Rematerialization remat(kernel, liveAnalysis, coloring, rpe, *this);
1012110138
remat.run();
1012210139
rematDone = true;
10123-
1012410140
// Re-run GRA loop only if remat caused changes to IR
1012510141
rerunGRA |= remat.getChangesMade();
1012610142
}

0 commit comments

Comments
 (0)