Skip to content

Commit ec21df6

Browse files
jfuentessys_zuul
authored andcommitted
Refactor pre-RA scheduling to use kernel getters instead of options.
Change-Id: I275c9190773fdb4ba0659fdc563373b871c3019d
1 parent 5796d4f commit ec21df6

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

visa/FlowGraph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3356,10 +3356,10 @@ void G4_Kernel::evalAddrExp()
33563356

33573357
void G4_Kernel::setKernelParameters()
33583358
{
3359-
unsigned numThreads = m_options->getuInt32Option(vISA_HWThreadNumberPerEU);
3359+
unsigned overrideGRFNum = m_options->getuInt32Option(vISA_TotalGRFNum);
3360+
33603361

33613362
// Set the number of GRFs
3362-
unsigned overrideGRFNum = m_options->getuInt32Option(vISA_TotalGRFNum);
33633363
if (overrideGRFNum > 0)
33643364
{
33653365
// User-provided number of GRFs

visa/FlowGraph.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,9 +1509,9 @@ class G4_Kernel
15091509
(major == COMMON_ISA_MAJOR_VER && minor <= COMMON_ISA_MINOR_VER),
15101510
"CISA version not supported by this JIT-compiler");
15111511

1512-
setKernelParameters();
15131512

15141513
name = NULL;
1514+
numThreads = 0;
15151515
simdSize = 0;
15161516
hasAddrTaken = false;
15171517
kernelDbgInfo = nullptr;
@@ -1524,6 +1524,8 @@ class G4_Kernel
15241524
{
15251525
gtPinInfo = nullptr;
15261526
}
1527+
1528+
setKernelParameters();
15271529
}
15281530

15291531
~G4_Kernel();
@@ -1540,6 +1542,13 @@ class G4_Kernel
15401542
void setNumThreads(int nThreads) { numThreads = nThreads; }
15411543
uint32_t getNumThreads() const { return numThreads; }
15421544

1545+
void updateKernelByNumThreads(int nThreads)
1546+
{
1547+
numThreads = nThreads;
1548+
m_options->setOption(vISA_TotalGRFNum, (uint32_t)0);
1549+
setKernelParameters();
1550+
}
1551+
15431552
void setNumSWSBTokens(int nSWSBs) { numSWSBTokens = nSWSBs; }
15441553
uint32_t getNumSWSBTokens() const { return numSWSBTokens; }
15451554

visa/LocalScheduler/G4_Sched.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,14 +486,13 @@ class BB_Scheduler {
486486

487487
} // namespace
488488

489-
static unsigned getRPReductionThreshold(G4_Kernel &kernel)
489+
static unsigned getRPReductionThreshold(unsigned NumGrfs, unsigned simdSize)
490490
{
491-
unsigned NumGrfs = kernel.getNumRegTotal();
492491
float Ratio = NumGrfs / 128.0f;
493492

494493
// For SIMD32 kernels, use a higher threshold for rp reduction,
495494
// as it may not be beneficial.
496-
if (kernel.getSimdSize() == 32)
495+
if (simdSize == 32)
497496
return unsigned(PRESSURE_REDUCTION_THRESHOLD_SIMD32 * Ratio);
498497

499498
// For all other kernels, use the default threshold.
@@ -531,7 +530,7 @@ bool preRA_Scheduler::run()
531530
return false;
532531
}
533532

534-
unsigned Threshold = getRPReductionThreshold(kernel);
533+
unsigned Threshold = getRPReductionThreshold(kernel.getNumRegTotal(), kernel.getSimdSize());
535534
unsigned SchedCtrl = m_options->getuInt32Option(vISA_preRA_ScheduleCtrl);
536535

537536
LatencyTable LT(kernel.fg.builder);

visa/LocalScheduler/SWSB_G4IR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5119,7 +5119,7 @@ void SWSB::dumpTokenLiveInfo()
51195119
std::cerr << std::endl;
51205120
if (BBVector[i]->killedTokens != nullptr)
51215121
{
5122-
uint32_t totalTokenNum = kernel.getOptions()->getuInt32Option(vISA_SWSBTokenNum);
5122+
uint32_t totalTokenNum = kernel.getNumSWSBTokens();
51235123
for (uint32_t k = 0; k < totalTokenNum; k++)
51245124
{
51255125
if (BBVector[i]->killedTokens->isSet(k))

visa/VISAKernelImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ int VISAKernelImpl::CreateVISAInputVar(CISA_GEN_VAR *decl,
14941494
dcl->getRegVar()->setPhyReg(m_phyRegPool->getGreg(regNum), subRegNum);
14951495
dcl->setRegFile( G4_INPUT );
14961496
unsigned int reservedGRFNum = m_options->getuInt32Option(vISA_ReservedGRFNum);
1497-
if (regNum + dcl->getNumRows() > m_builder->getOptions()->getuInt32Option(vISA_TotalGRFNum) - reservedGRFNum) {
1497+
if (regNum + dcl->getNumRows() > m_kernel->getNumRegTotal() - reservedGRFNum) {
14981498
MUST_BE_TRUE(false, "INPUT payload execeeds the regsiter number");
14991499
}
15001500
}

visa/include/VISAOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ DEF_VISA_OPTION(vISA_SWSBTokenBarrier, ET_INT32, "-SWSBTokenBarrier", UNUSED
164164
DEF_VISA_OPTION(vISA_EnableSwitch, ET_BOOL, "-enableSwitch", UNUSED, false)
165165
DEF_VISA_OPTION(vISA_EnableISBIDBUNDLE, ET_BOOL, "-SBIDBundle", UNUSED, false)
166166
DEF_VISA_OPTION(vISA_EnableGroupScheduleForBC, ET_BOOL, "-groupScheduleForBC", UNUSED, true)
167-
DEF_VISA_OPTION(vISA_SWSBTokenNum, ET_INT32, "-SWSBTokenNum", "USAGE: -SWSBTokenNum <tokenNum>\n", 16)
167+
DEF_VISA_OPTION(vISA_SWSBTokenNum, ET_INT32, "-SWSBTokenNum", "USAGE: -SWSBTokenNum <tokenNum>\n", 0)
168168
DEF_VISA_OPTION(vISA_EnableSendTokenReduction, ET_BOOL, "-SendTokenReduction", UNUSED, false)
169169
DEF_VISA_OPTION(vISA_GlobalTokenAllocation, ET_BOOL, "-globalTokenAllocation", UNUSED, false)
170170
DEF_VISA_OPTION(vISA_DistPropTokenAllocation, ET_BOOL, "-distPropTokenAllocation", UNUSED, false)

0 commit comments

Comments
 (0)