Skip to content

Commit 34985c0

Browse files
petechouigcbot
authored andcommitted
Allow user to change back to std::sort() in SWSB::tokenAllocation().
Add a vISA option to control the behavior.
1 parent ee122ae commit 34985c0

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

visa/LocalScheduler/SWSB_G4IR.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,14 +2359,24 @@ void SWSB::tokenAllocation()
23592359
//Assign tokens to nodes in the order of liveness. Here we only need to
23602360
//iterate SB nodes in that order, and don't actually need to sort
23612361
//SBSendNodes as it might be referenced through allTokenNodesMap.
2362-
auto sortInLivenessOrder = [](const SBNODE_VECT& vec) {
2363-
SBNODE_VECT sorted(vec.size());
2364-
std::partial_sort_copy(vec.begin(), vec.end(), sorted.begin(), sorted.end(), compareInterval);
2365-
return sorted;
2362+
auto sortInLivenessOrder = [](const SBNODE_VECT& vec, bool stdSort) {
2363+
if (stdSort)
2364+
{
2365+
SBNODE_VECT sorted(vec);
2366+
std::sort(sorted.begin(), sorted.end(), compareInterval);
2367+
return sorted;
2368+
}
2369+
else
2370+
{
2371+
SBNODE_VECT sorted(vec.size());
2372+
std::partial_sort_copy(vec.begin(), vec.end(), sorted.begin(), sorted.end(), compareInterval);
2373+
return sorted;
2374+
}
23662375
};
23672376
const bool enableSendTokenReduction = fg.builder->getOptions()->getOption(vISA_EnableSendTokenReduction);
23682377
const bool enableDPASTokenReduction = fg.builder->getOptions()->getOption(vISA_EnableDPASTokenReduction);
2369-
for (SBNode* node : sortInLivenessOrder(SBSendNodes))
2378+
const bool assignTokenUsingStdsort = fg.builder->getOptions()->getOption(vISA_AssignTokenUsingStdSort);
2379+
for (SBNode* node : sortInLivenessOrder(SBSendNodes, assignTokenUsingStdsort))
23702380
{
23712381
unsigned startID = node->getLiveStartID();
23722382
G4_INST* inst = node->getLastInstruction();

visa/include/VISAOptionsDefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ DEF_VISA_OPTION(vISA_DistPropTokenAllocation, ET_BOOL, "-distPropTokenAllo
240240
DEF_VISA_OPTION(vISA_SWSBStitch, ET_BOOL, "-SWSBStitch", UNUSED, false)
241241
DEF_VISA_OPTION(vISA_SBIDDepLoc, ET_BOOL, "-SBIDDepLoc", UNUSED, false)
242242
DEF_VISA_OPTION(vISA_DumpSBID, ET_BOOL, "-dumpSBID", UNUSED, false)
243+
DEF_VISA_OPTION(vISA_AssignTokenUsingStdSort, ET_BOOL, "-assignSWSBTokUsingStdSort", UNUSED, false)
243244

244245
DEF_VISA_OPTION(vISA_EnableALUThreePipes, ET_BOOL, "-threeALUPipes", UNUSED, true)
245246
DEF_VISA_OPTION(vISA_EnableDPASTokenReduction, ET_BOOL, "-DPASTokenReduction", UNUSED, false)

0 commit comments

Comments
 (0)