Skip to content

Commit fed6aea

Browse files
admitricigcbot
authored andcommitted
Expose method to check autoGRF in CodeGenContext
Create method to check autoGRF to CodeGenContext
1 parent 2130863 commit fed6aea

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4644,34 +4644,20 @@ namespace IGC
46444644
SaveOption(vISA_TotalGRFNum, unsigned(0));
46454645
SaveOption(vISA_AutoGRFSelection, true);
46464646
}
4647+
else if (ClContext->getExpGRFSize() > 0) {
4648+
// Explicit GRF size set per module (by compiler option)
4649+
SaveOption(vISA_TotalGRFNum, ClContext->getExpGRFSize());
4650+
}
46474651
else if (ClContext->getNumThreadsPerEU() > 0)
46484652
{
46494653
// Number of threads per EU is set per module (by compiler option)
46504654
SaveOption(vISA_HWThreadNumberPerEU, unsigned(ClContext->getNumThreadsPerEU()));
46514655
}
4652-
else if (ClContext->getNumThreadsPerEU() == 0)
4653-
{
4656+
else if (ClContext->isAutoGRFSelectionEnabled()) {
46544657
// "Auto" mode per module (by compiler option) - use compiler heuristics to determine number of threads per EU
46554658
SaveOption(vISA_TotalGRFNum, unsigned(0));
46564659
SaveOption(vISA_AutoGRFSelection, true);
46574660
}
4658-
else if (ClContext->getExpGRFSize() > 0) {
4659-
// Explicit GRF size set per module (by compiler option)
4660-
SaveOption(vISA_TotalGRFNum, ClContext->getExpGRFSize());
4661-
}
4662-
else if ((m_program->m_Platform->supportsAutoGRFSelection() &&
4663-
(context->m_DriverInfo.supportsAutoGRFSelection() ||
4664-
ClContext->m_InternalOptions.IntelEnableAutoLargeGRF ||
4665-
ClContext->m_Options.IntelEnableAutoLargeGRF)
4666-
) && !ClContext->m_InternalOptions.Intel128GRFPerThread &&
4667-
!ClContext->m_Options.Intel128GRFPerThread &&
4668-
!ClContext->m_InternalOptions.Intel256GRFPerThread &&
4669-
!ClContext->m_Options.Intel256GRFPerThread
4670-
)
4671-
{
4672-
// When user hasn't specified number of threads, we can rely on compiler heuristics
4673-
SaveOption(vISA_AutoGRFSelection, true);
4674-
}
46754661

46764662
// Emit warnings if mismatch is found in user input
46774663
// Mismatch between number of threads and GRF size (per module)

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,27 @@ namespace IGC
113113
return CodeGenContext::getNumGRFPerThread(returnDefault);
114114
}
115115

116+
bool OpenCLProgramContext::isAutoGRFSelectionEnabled() const
117+
{
118+
if (getNumThreadsPerEU() == 0)
119+
return true;
120+
121+
if ((platform.supportsAutoGRFSelection() &&
122+
(m_DriverInfo.supportsAutoGRFSelection() ||
123+
m_InternalOptions.IntelEnableAutoLargeGRF ||
124+
m_Options.IntelEnableAutoLargeGRF)
125+
) && !m_InternalOptions.Intel128GRFPerThread &&
126+
!m_Options.Intel128GRFPerThread &&
127+
!m_InternalOptions.Intel256GRFPerThread &&
128+
!m_Options.Intel256GRFPerThread
129+
)
130+
{
131+
return true;
132+
}
133+
134+
return false;
135+
}
136+
116137
bool OpenCLProgramContext::forceGlobalMemoryAllocation() const
117138
{
118139
return m_InternalOptions.ForceGlobalMemoryAllocation ||

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ namespace IGC
131131
bool needsDivergentBarrierHandling() const;
132132
unsigned GetSlmSizePerSubslice();
133133
float GetSpillThreshold(SIMDMode dispatchSize);
134+
bool isAutoGRFSelectionEnabled() const override;
134135

135136
void clearBeforeRetry() {
136137
m_programOutput.clearBeforeRetry();

IGC/Compiler/CodeGenPublic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,7 @@ namespace IGC
10951095
virtual uint32_t getExpGRFSize() const;
10961096
virtual uint32_t getNumGRFPerThread(bool returnDefault = true);
10971097
virtual void setNumGRFPerThread(uint32_t value) { m_NumGRFPerThread = value; }
1098+
virtual bool isAutoGRFSelectionEnabled() const { return false; };
10981099
virtual bool forceGlobalMemoryAllocation() const;
10991100
virtual bool allocatePrivateAsGlobalBuffer() const;
11001101
virtual bool noLocalToGenericOptionEnabled() const;

0 commit comments

Comments
 (0)