Skip to content

Commit 3dc0c88

Browse files
weiyu-chenZuul
authored andcommitted
Make register pressure estimate more accurate by considering alignment for <1GRF variables.
Change-Id: I27b549b8eebe32798af0813b0710d5371fbef523
1 parent da851f3 commit 3dc0c88

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

visa/RPE.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,18 @@ namespace vISA
194194
auto change = before^after;
195195
if (change)
196196
{
197-
double delta = vars[id]->getDeclare()->getByteSize() < 32 ?
198-
vars[id]->getDeclare()->getByteSize() / 32.0 : (double) vars[id]->getDeclare()->getNumRows();
197+
// For <1 GRF variable we have to take alignment into consideration as well when computing register pressure.
198+
// For now we double each <1GRF variable's size if its alignment also exceeds its size.
199+
// Alternative is to simply take the alignment as the size, but it might cause performance regressions
200+
// due to being too conservative (i.e., a GRF-aligned variable may share physical GRF with several other
201+
auto dclSize = vars[id]->getDeclare()->getByteSize();
202+
if (dclSize < getGRFSize() && dclSize < static_cast<uint32_t>(vars[id]->getDeclare()->getSubRegAlign()) * 2)
203+
{
204+
dclSize *= 2;
205+
}
206+
207+
double delta = dclSize < getGRFSize() ?
208+
dclSize / (double) getGRFSize() : (double) vars[id]->getDeclare()->getNumRows();
199209
if (before & change)
200210
{
201211
if (regPressure < delta)

0 commit comments

Comments
 (0)