@@ -824,11 +824,13 @@ void SWSB::handleFuncCall()
824
824
void SWSB::SWSBGlobalTokenGenerator (PointsToAnalysis& p, LiveGRFBuckets& LB, LiveGRFBuckets& globalSendsLB)
825
825
{
826
826
allTokenNodesMap.resize (totalTokenNum);
827
- for (size_t i = 0 ; i < totalTokenNum; i++ )
827
+ for (TokenAllocation& nodeMap : allTokenNodesMap )
828
828
{
829
- allTokenNodesMap[i] .bitset = BitSet (unsigned ( SBSendNodes.size () ), false );
829
+ nodeMap .bitset = BitSet (SBSendNodes.size (), false );
830
830
}
831
831
832
+ const bool enableGlobalTokenAllocation = fg.builder ->getOptions ()->getOption (vISA_GlobalTokenAllocation);
833
+ const bool enableDistPropTokenAllocation = fg.builder ->getOptions ()->getOption (vISA_DistPropTokenAllocation);
832
834
// Get the live out, may kill bit sets
833
835
for (G4_BB_SB *bb : BBVector)
834
836
{
@@ -843,8 +845,7 @@ void SWSB::SWSBGlobalTokenGenerator(PointsToAnalysis& p, LiveGRFBuckets& LB, Liv
843
845
bb->liveOutTokenNodes = BitSet (SBSendNodes.size (), false );
844
846
bb->killedTokens = BitSet (totalTokenNum, false );
845
847
846
- if (fg.builder ->getOptions ()->getOption (vISA_GlobalTokenAllocation) ||
847
- fg.builder ->getOptions ()->getOption (vISA_DistPropTokenAllocation))
848
+ if (enableGlobalTokenAllocation || enableDistPropTokenAllocation)
848
849
{
849
850
bb->tokenLiveInDist = (unsigned *)mem.alloc (sizeof (unsigned ) * globalSendNum);
850
851
bb->tokenLiveOutDist = (unsigned *)mem.alloc (sizeof (unsigned ) * globalSendNum);
@@ -926,8 +927,7 @@ void SWSB::SWSBGlobalTokenGenerator(PointsToAnalysis& p, LiveGRFBuckets& LB, Liv
926
927
SWSBGlobalScalarCFGReachAnalysis ();
927
928
928
929
// 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)
931
931
{
932
932
addGlobalDependenceWithReachingDef (globalSendNum, &globalSendOpndList, &SBNodes, p, true );
933
933
}
@@ -952,11 +952,11 @@ void SWSB::SWSBGlobalTokenGenerator(PointsToAnalysis& p, LiveGRFBuckets& LB, Liv
952
952
addGlobalDependence (globalSendNum, &globalSendOpndList, &SBNodes, p, false );
953
953
954
954
// SWSB token allocation with linear scan algorithm.
955
- if (fg. builder -> getOptions ()-> getOption (vISA_GlobalTokenAllocation) )
955
+ if (enableGlobalTokenAllocation )
956
956
{
957
957
tokenAllocationGlobal ();
958
958
}
959
- else if (fg. builder -> getOptions ()-> getOption (vISA_DistPropTokenAllocation) )
959
+ else if (enableDistPropTokenAllocation )
960
960
{
961
961
tokenAllocationGlobalWithPropogation ();
962
962
}
@@ -2404,10 +2404,7 @@ void SWSB::tokenAllocation()
2404
2404
buildLiveIntervals ();
2405
2405
2406
2406
// Initial free token list
2407
- for (unsigned i = 0 ; i < totalTokenNum; i++)
2408
- {
2409
- freeTokenList.push_back (nullptr );
2410
- }
2407
+ freeTokenList.resize (totalTokenNum);
2411
2408
topIndex = 0 ;
2412
2409
2413
2410
tokenProfile.setTokenInstructionCount ((int )SBSendNodes.size ());
@@ -2424,6 +2421,8 @@ void SWSB::tokenAllocation()
2424
2421
std::partial_sort_copy (vec.begin (), vec.end (), sorted.begin (), sorted.end (), compareInterval);
2425
2422
return sorted;
2426
2423
};
2424
+ const bool enableSendTokenReduction = fg.builder ->getOptions ()->getOption (vISA_EnableSendTokenReduction);
2425
+ const bool enableDPASTokenReduction = fg.builder ->getOptions ()->getOption (vISA_EnableDPASTokenReduction);
2427
2426
for (SBNode* node : sortInLivenessOrder (SBSendNodes))
2428
2427
{
2429
2428
unsigned startID = node->getLiveStartID ();
@@ -2436,12 +2435,12 @@ void SWSB::tokenAllocation()
2436
2435
continue ;
2437
2436
}
2438
2437
2439
- if (fg. builder -> getOptions ()-> getOption (vISA_EnableSendTokenReduction) && node->succs .size () == 0 )
2438
+ if (enableSendTokenReduction && node->succs .size () == 0 )
2440
2439
{
2441
2440
continue ;
2442
2441
}
2443
2442
2444
- if (fg. builder -> getOptions ()-> getOption (vISA_EnableDPASTokenReduction) )
2443
+ if (enableDPASTokenReduction )
2445
2444
{
2446
2445
// If there is no instruction depends on a DPAS instruction, no SBID
2447
2446
if (inst->isDpas () && node->succs .size () == 0 )
@@ -2474,9 +2473,9 @@ void SWSB::tokenAllocation()
2474
2473
2475
2474
if (fg.builder ->getOptions ()->getOption (vISA_SWSBDepReduction))
2476
2475
{
2477
- for (size_t i = 0 ; i < BBVector. size (); i++ )
2476
+ for (G4_BB_SB* sb_bb : BBVector)
2478
2477
{
2479
- BBVector[i] ->getLiveOutToken (unsigned (SBSendNodes.size ()), &SBNodes);
2478
+ sb_bb ->getLiveOutToken (unsigned (SBSendNodes.size ()), &SBNodes);
2480
2479
}
2481
2480
#ifdef DEBUG_VERBOSE_ON
2482
2481
dumpTokenLiveInfo ();
@@ -4289,12 +4288,13 @@ void SWSB::buildLiveIntervals()
4289
4288
for (BB_LIST_ITER ib (fg.begin ()), bend (fg.end ()); ib != bend; ++ib)
4290
4289
{
4291
4290
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 ;
4296
4296
4297
- if (send_live_in-> isEmpty ())
4297
+ if (send_live_in. isEmpty ())
4298
4298
{
4299
4299
continue ;
4300
4300
}
@@ -4311,43 +4311,43 @@ void SWSB::buildLiveIntervals()
4311
4311
4312
4312
if (bucketNode->opndNum == Opnd_dst)
4313
4313
{
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) )
4316
4316
{
4317
- if (!(*ib)->Preds .empty () || !(BBVector[bbID] ->Preds .empty ()))
4317
+ if (!(*ib)->Preds .empty () || !(sb_bb ->Preds .empty ()))
4318
4318
{
4319
- node->setLiveEarliestID (BBVector[bbID] ->first_node , bbID);
4319
+ node->setLiveEarliestID (sb_bb ->first_node , bbID);
4320
4320
}
4321
4321
}
4322
4322
// FIXME: implicit dependence still have issue.
4323
4323
// 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) )
4326
4326
{
4327
- if (!(*ib)->Succs .empty () || !(BBVector[bbID] ->Succs .empty ()))
4327
+ if (!(*ib)->Succs .empty () || !(sb_bb ->Succs .empty ()))
4328
4328
{
4329
- node->setLiveLatestID (BBVector[bbID] ->last_node , bbID);
4329
+ node->setLiveLatestID (sb_bb ->last_node , bbID);
4330
4330
}
4331
4331
}
4332
4332
}
4333
4333
else if (!trueDepOnly)
4334
4334
{
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) )
4337
4337
{
4338
- if (!(*ib)->Preds .empty () || !(BBVector[bbID] ->Preds .empty ()))
4338
+ if (!(*ib)->Preds .empty () || !(sb_bb ->Preds .empty ()))
4339
4339
{
4340
- node->setLiveEarliestID (BBVector[bbID] ->first_node , bbID);
4340
+ node->setLiveEarliestID (sb_bb ->first_node , bbID);
4341
4341
}
4342
4342
}
4343
4343
// FIXME: implicit dependence still have issue.
4344
4344
// 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) )
4347
4347
{
4348
- if (!(*ib)->Succs .empty () || !(BBVector[bbID] ->Succs .empty ()))
4348
+ if (!(*ib)->Succs .empty () || !(sb_bb ->Succs .empty ()))
4349
4349
{
4350
- node->setLiveLatestID (BBVector[bbID] ->last_node , bbID);
4350
+ node->setLiveLatestID (sb_bb ->last_node , bbID);
4351
4351
}
4352
4352
}
4353
4353
}
0 commit comments