Skip to content

Commit af17e0f

Browse files
jfuentesigcbot
authored andcommitted
Remove unneeded condition
1 parent 384af59 commit af17e0f

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

visa/G4_Kernel.cpp

+18-6
Original file line numberDiff line numberDiff line change
@@ -2117,7 +2117,8 @@ unsigned G4_Kernel::getSRFInWords() {
21172117

21182118
// GRF modes supported by HW
21192119
// There must be at least one Config that is VRTEnable for each platform
2120-
GRFMode::GRFMode(const TARGET_PLATFORM platform, Options *op) : options(op) {
2120+
GRFMode::GRFMode(const TARGET_PLATFORM plat, Options *op)
2121+
: platform(plat), options(op) {
21212122
switch (platform) {
21222123
case Xe_XeHPSDV:
21232124
case Xe_DG2:
@@ -2178,7 +2179,7 @@ GRFMode::GRFMode(const TARGET_PLATFORM platform, Options *op) : options(op) {
21782179
unsigned GRFMode::setModeByRegPressure(unsigned maxRP, unsigned largestInputReg,
21792180
bool forceGRFModeUp) {
21802181
unsigned size = configs.size(), i = 0;
2181-
bool spillAllowed = options->getuInt32Option(vISA_SpillAllowed) > 256;
2182+
bool spillAllowed = options->getuInt32Option(vISA_SpillAllowed) > 0;
21822183
// find appropiate GRF based on reg pressure
21832184
for (; i < size; i++) {
21842185
if (configs[i].VRTEnable && configs[i].numGRF >= lowerBoundGRF &&
@@ -2196,10 +2197,21 @@ unsigned GRFMode::setModeByRegPressure(unsigned maxRP, unsigned largestInputReg,
21962197
currentMode = newGRFMode < maxGRFMode ? newGRFMode : maxGRFMode;
21972198
}
21982199

2199-
if (spillAllowed && currentMode > 0)
2200-
return configs[--currentMode].numGRF;
2201-
else
2202-
return configs[currentMode].numGRF;
2200+
if (platform >= Xe3 && spillAllowed && currentMode > 0) {
2201+
unsigned lowerGRFNum = configs[currentMode - 1].numGRF;
2202+
// Select a lower GRF number in PreRA in case the register
2203+
// pressure computed is a bit higher (e.g. 10%) than the lower GRF
2204+
// config. If spills are detected, RA will still bump up the GRF
2205+
// number to avoid them.
2206+
// For example, if reg pressure is 167, we select 160GRF since
2207+
// we have spill threshold enabled and the diff between 167 and 160
2208+
// is less than 10%.
2209+
if (lowerGRFNum * 1.1 >= maxRP &&
2210+
lowerGRFNum >= (largestInputReg + 8) &&
2211+
lowerGRFNum >= lowerBoundGRF)
2212+
return configs[--currentMode].numGRF;
2213+
}
2214+
return configs[currentMode].numGRF;
22032215
}
22042216
}
22052217
}

visa/G4_Kernel.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ class GRFMode {
266266
unsigned lowerBoundGRF;
267267
unsigned upperBoundGRF;
268268
unsigned GRFModeUpValue;
269+
const TARGET_PLATFORM platform;
269270
Options *options;
270271
};
271272

0 commit comments

Comments
 (0)