@@ -824,11 +824,13 @@ void SWSB::handleFuncCall()
824824void SWSB::SWSBGlobalTokenGenerator (PointsToAnalysis& p, LiveGRFBuckets& LB, LiveGRFBuckets& globalSendsLB)
825825{
826826 allTokenNodesMap.resize (totalTokenNum);
827- for (size_t i = 0 ; i < totalTokenNum; i++ )
827+ for (TokenAllocation& nodeMap : allTokenNodesMap )
828828 {
829- allTokenNodesMap[i] .bitset = BitSet (unsigned ( SBSendNodes.size () ), false );
829+ nodeMap .bitset = BitSet (SBSendNodes.size (), false );
830830 }
831831
832+ const bool enableGlobalTokenAllocation = fg.builder ->getOptions ()->getOption (vISA_GlobalTokenAllocation);
833+ const bool enableDistPropTokenAllocation = fg.builder ->getOptions ()->getOption (vISA_DistPropTokenAllocation);
832834 // Get the live out, may kill bit sets
833835 for (G4_BB_SB *bb : BBVector)
834836 {
@@ -843,8 +845,7 @@ void SWSB::SWSBGlobalTokenGenerator(PointsToAnalysis& p, LiveGRFBuckets& LB, Liv
843845 bb->liveOutTokenNodes = BitSet (SBSendNodes.size (), false );
844846 bb->killedTokens = BitSet (totalTokenNum, false );
845847
846- if (fg.builder ->getOptions ()->getOption (vISA_GlobalTokenAllocation) ||
847- fg.builder ->getOptions ()->getOption (vISA_DistPropTokenAllocation))
848+ if (enableGlobalTokenAllocation || enableDistPropTokenAllocation)
848849 {
849850 bb->tokenLiveInDist = (unsigned *)mem.alloc (sizeof (unsigned ) * globalSendNum);
850851 bb->tokenLiveOutDist = (unsigned *)mem.alloc (sizeof (unsigned ) * globalSendNum);
@@ -926,8 +927,7 @@ void SWSB::SWSBGlobalTokenGenerator(PointsToAnalysis& p, LiveGRFBuckets& LB, Liv
926927 SWSBGlobalScalarCFGReachAnalysis ();
927928
928929 // Add dependence according to analysis result
929- if (fg.builder ->getOptions ()->getOption (vISA_GlobalTokenAllocation) ||
930- fg.builder ->getOptions ()->getOption (vISA_DistPropTokenAllocation))
930+ if (enableGlobalTokenAllocation || enableDistPropTokenAllocation)
931931 {
932932 addGlobalDependenceWithReachingDef (globalSendNum, &globalSendOpndList, &SBNodes, p, true );
933933 }
@@ -952,11 +952,11 @@ void SWSB::SWSBGlobalTokenGenerator(PointsToAnalysis& p, LiveGRFBuckets& LB, Liv
952952 addGlobalDependence (globalSendNum, &globalSendOpndList, &SBNodes, p, false );
953953
954954 // SWSB token allocation with linear scan algorithm.
955- if (fg. builder -> getOptions ()-> getOption (vISA_GlobalTokenAllocation) )
955+ if (enableGlobalTokenAllocation )
956956 {
957957 tokenAllocationGlobal ();
958958 }
959- else if (fg. builder -> getOptions ()-> getOption (vISA_DistPropTokenAllocation) )
959+ else if (enableDistPropTokenAllocation )
960960 {
961961 tokenAllocationGlobalWithPropogation ();
962962 }
@@ -2404,10 +2404,7 @@ void SWSB::tokenAllocation()
24042404 buildLiveIntervals ();
24052405
24062406 // Initial free token list
2407- for (unsigned i = 0 ; i < totalTokenNum; i++)
2408- {
2409- freeTokenList.push_back (nullptr );
2410- }
2407+ freeTokenList.resize (totalTokenNum);
24112408 topIndex = 0 ;
24122409
24132410 tokenProfile.setTokenInstructionCount ((int )SBSendNodes.size ());
@@ -2424,6 +2421,8 @@ void SWSB::tokenAllocation()
24242421 std::partial_sort_copy (vec.begin (), vec.end (), sorted.begin (), sorted.end (), compareInterval);
24252422 return sorted;
24262423 };
2424+ const bool enableSendTokenReduction = fg.builder ->getOptions ()->getOption (vISA_EnableSendTokenReduction);
2425+ const bool enableDPASTokenReduction = fg.builder ->getOptions ()->getOption (vISA_EnableDPASTokenReduction);
24272426 for (SBNode* node : sortInLivenessOrder (SBSendNodes))
24282427 {
24292428 unsigned startID = node->getLiveStartID ();
@@ -2436,12 +2435,12 @@ void SWSB::tokenAllocation()
24362435 continue ;
24372436 }
24382437
2439- if (fg. builder -> getOptions ()-> getOption (vISA_EnableSendTokenReduction) && node->succs .size () == 0 )
2438+ if (enableSendTokenReduction && node->succs .size () == 0 )
24402439 {
24412440 continue ;
24422441 }
24432442
2444- if (fg. builder -> getOptions ()-> getOption (vISA_EnableDPASTokenReduction) )
2443+ if (enableDPASTokenReduction )
24452444 {
24462445 // If there is no instruction depends on a DPAS instruction, no SBID
24472446 if (inst->isDpas () && node->succs .size () == 0 )
@@ -2474,9 +2473,9 @@ void SWSB::tokenAllocation()
24742473
24752474 if (fg.builder ->getOptions ()->getOption (vISA_SWSBDepReduction))
24762475 {
2477- for (size_t i = 0 ; i < BBVector. size (); i++ )
2476+ for (G4_BB_SB* sb_bb : BBVector)
24782477 {
2479- BBVector[i] ->getLiveOutToken (unsigned (SBSendNodes.size ()), &SBNodes);
2478+ sb_bb ->getLiveOutToken (unsigned (SBSendNodes.size ()), &SBNodes);
24802479 }
24812480#ifdef DEBUG_VERBOSE_ON
24822481 dumpTokenLiveInfo ();
@@ -4289,12 +4288,13 @@ void SWSB::buildLiveIntervals()
42894288 for (BB_LIST_ITER ib (fg.begin ()), bend (fg.end ()); ib != bend; ++ib)
42904289 {
42914290 unsigned bbID = (*ib)->getId ();
4292- SBBitSets* send_live_in = &BBVector[bbID]->send_live_in ;
4293- SBBitSets* send_live_out = &BBVector[bbID]->send_live_out ;
4294- SBBitSets* send_live_in_scalar = &BBVector[bbID]->send_live_in_scalar ;
4295- SBBitSets* send_live_out_scalar = &BBVector[bbID]->send_live_out_scalar ;
4291+ G4_BB_SB* sb_bb = BBVector[bbID];
4292+ SBBitSets& send_live_in = sb_bb->send_live_in ;
4293+ SBBitSets& send_live_out = sb_bb->send_live_out ;
4294+ SBBitSets& send_live_in_scalar = sb_bb->send_live_in_scalar ;
4295+ SBBitSets& send_live_out_scalar = sb_bb->send_live_out_scalar ;
42964296
4297- if (send_live_in-> isEmpty ())
4297+ if (send_live_in. isEmpty ())
42984298 {
42994299 continue ;
43004300 }
@@ -4311,43 +4311,43 @@ void SWSB::buildLiveIntervals()
43114311
43124312 if (bucketNode->opndNum == Opnd_dst)
43134313 {
4314- if ((send_live_in_scalar-> isDstSet (( unsigned )globalID)) &&
4315- BBVector[bbID]-> first_node != - 1 )
4314+ if (sb_bb-> first_node != - 1 &&
4315+ send_live_in_scalar. isDstSet (( unsigned )globalID) )
43164316 {
4317- if (!(*ib)->Preds .empty () || !(BBVector[bbID] ->Preds .empty ()))
4317+ if (!(*ib)->Preds .empty () || !(sb_bb ->Preds .empty ()))
43184318 {
4319- node->setLiveEarliestID (BBVector[bbID] ->first_node , bbID);
4319+ node->setLiveEarliestID (sb_bb ->first_node , bbID);
43204320 }
43214321 }
43224322 // FIXME: implicit dependence still have issue.
43234323 // the live range of implicit dependence may not counted. But that's ok? This may cause the delay. ...
4324- if ((send_live_out_scalar-> isDstSet (( unsigned )globalID)) &&
4325- BBVector[bbID]-> first_node != - 1 )
4324+ if (sb_bb-> first_node != - 1 &&
4325+ send_live_out_scalar. isDstSet (( unsigned )globalID) )
43264326 {
4327- if (!(*ib)->Succs .empty () || !(BBVector[bbID] ->Succs .empty ()))
4327+ if (!(*ib)->Succs .empty () || !(sb_bb ->Succs .empty ()))
43284328 {
4329- node->setLiveLatestID (BBVector[bbID] ->last_node , bbID);
4329+ node->setLiveLatestID (sb_bb ->last_node , bbID);
43304330 }
43314331 }
43324332 }
43334333 else if (!trueDepOnly)
43344334 {
4335- if ((send_live_in-> isSrcSet (( unsigned )globalID)) &&
4336- BBVector[bbID]-> first_node != - 1 )
4335+ if (sb_bb-> first_node != - 1 &&
4336+ send_live_in. isSrcSet (( unsigned )globalID) )
43374337 {
4338- if (!(*ib)->Preds .empty () || !(BBVector[bbID] ->Preds .empty ()))
4338+ if (!(*ib)->Preds .empty () || !(sb_bb ->Preds .empty ()))
43394339 {
4340- node->setLiveEarliestID (BBVector[bbID] ->first_node , bbID);
4340+ node->setLiveEarliestID (sb_bb ->first_node , bbID);
43414341 }
43424342 }
43434343 // FIXME: implicit dependence still have issue.
43444344 // the live range of implicit dependence may not counted. But that's ok? This may cause the delay. ...
4345- if ((send_live_out-> isSrcSet (( unsigned )globalID)) &&
4346- BBVector[bbID]-> first_node != - 1 )
4345+ if (sb_bb-> first_node != - 1 &&
4346+ send_live_out. isSrcSet (( unsigned )globalID) )
43474347 {
4348- if (!(*ib)->Succs .empty () || !(BBVector[bbID] ->Succs .empty ()))
4348+ if (!(*ib)->Succs .empty () || !(sb_bb ->Succs .empty ()))
43494349 {
4350- node->setLiveLatestID (BBVector[bbID] ->last_node , bbID);
4350+ node->setLiveLatestID (sb_bb ->last_node , bbID);
43514351 }
43524352 }
43534353 }
0 commit comments