@@ -2117,7 +2117,8 @@ unsigned G4_Kernel::getSRFInWords() {
2117
2117
2118
2118
// GRF modes supported by HW
2119
2119
// 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) {
2121
2122
switch (platform) {
2122
2123
case Xe_XeHPSDV:
2123
2124
case Xe_DG2:
@@ -2178,7 +2179,7 @@ GRFMode::GRFMode(const TARGET_PLATFORM platform, Options *op) : options(op) {
2178
2179
unsigned GRFMode::setModeByRegPressure (unsigned maxRP, unsigned largestInputReg,
2179
2180
bool forceGRFModeUp) {
2180
2181
unsigned size = configs.size (), i = 0 ;
2181
- bool spillAllowed = options->getuInt32Option (vISA_SpillAllowed) > 256 ;
2182
+ bool spillAllowed = options->getuInt32Option (vISA_SpillAllowed) > 0 ;
2182
2183
// find appropiate GRF based on reg pressure
2183
2184
for (; i < size; i++) {
2184
2185
if (configs[i].VRTEnable && configs[i].numGRF >= lowerBoundGRF &&
@@ -2196,10 +2197,21 @@ unsigned GRFMode::setModeByRegPressure(unsigned maxRP, unsigned largestInputReg,
2196
2197
currentMode = newGRFMode < maxGRFMode ? newGRFMode : maxGRFMode;
2197
2198
}
2198
2199
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 ;
2203
2215
}
2204
2216
}
2205
2217
}
0 commit comments