@@ -1980,10 +1980,15 @@ void SWSB::tokenAllocation()
1980
1980
dumpTokenLiveInfo ();
1981
1981
#endif
1982
1982
1983
- for (size_t i = 0 ; i < BBVector.size (); i++)
1984
- {
1985
- BBVector[i]->tokenEdgePrune (int (SBSendNodes.size ()), allTokenNodesMap, &SBNodes);
1986
- }
1983
+ unsigned prunedEdgeNum = 0 ;
1984
+ unsigned prunedGlobalEdgeNum = 0 ;
1985
+ unsigned prunedDiffBBEdgeNum = 0 ;
1986
+ unsigned prunedDiffBBSameTokenEdgeNum = 0 ;
1987
+ tokenEdgePrune (prunedEdgeNum, prunedGlobalEdgeNum, prunedDiffBBEdgeNum, prunedDiffBBSameTokenEdgeNum);
1988
+ kernel.setPrunedEdgeNum (prunedEdgeNum);
1989
+ kernel.setPrunedGlobalEdgeNum (prunedGlobalEdgeNum);
1990
+ kernel.setPrunedDiffBBEdgeNum (prunedDiffBBEdgeNum);
1991
+ kernel.setPrunedDiffBBSameTokenEdgeNum (prunedDiffBBSameTokenEdgeNum);
1987
1992
}
1988
1993
1989
1994
for (auto node_it = SBSendNodes.begin ();
@@ -2735,82 +2740,120 @@ bool SWSB::globalDependenceUseReachAnalysis(G4_BB* bb)
2735
2740
}
2736
2741
2737
2742
2738
- void G4_BB_SB::tokenEdgePrune (int allSendNum,
2739
- BitSet** allTokenNodesMap,
2740
- SBNODE_VECT* SBNodes)
2743
+ void SWSB::tokenEdgePrune (unsigned & prunedEdgeNum,
2744
+ unsigned & prunedGlobalEdgeNum,
2745
+ unsigned & prunedDiffBBEdgeNum,
2746
+ unsigned & prunedDiffBBSameTokenEdgeNum)
2741
2747
{
2742
- if (first_node == - 1 )
2748
+ for ( size_t i = 0 ; i < BBVector. size (); i++ )
2743
2749
{
2744
- return ;
2745
- }
2750
+ if (BBVector[i]->first_node == -1 )
2751
+ {
2752
+ continue ;
2753
+ }
2746
2754
2747
- BitSet activateLiveIn (allSendNum , false );
2748
- activateLiveIn |= *liveInTokenNodes;
2755
+ BitSet activateLiveIn (SBSendNodes. size () , false );
2756
+ activateLiveIn |= *BBVector[i]-> liveInTokenNodes ;
2749
2757
2750
- // Scan the instruction nodes of current BB
2751
- for (int i = first_node; i <= last_node; i++)
2752
- {
2753
- SBNode* node = (*SBNodes)[i];
2754
-
2755
- // scan the incoming dependence edges of current node
2756
- for (auto node_it = node->preds .begin ();
2757
- node_it != node->preds .end ();
2758
- node_it++)
2758
+ // Scan the instruction nodes of current BB
2759
+ for (int j = BBVector[i]->first_node ; j <= BBVector[i]->last_node ; j++)
2759
2760
{
2760
- SBDEP_ITEM& curPred = (*node_it);
2761
- DepType type = curPred.type ;
2762
- SBNode* predNode = curPred.node ;
2761
+ SBNode* node = SBNodes[j];
2762
+ BitSet killedToken (totalTokenNum, false ); // Track the token killed by current instruction.
2763
2763
2764
- // If the predecessor node is a token instruction node.
2765
- if (tokenHonourInstruction (predNode->GetInstruction ()))
2764
+ // scan the incoming dependence edges of current node
2765
+ for (auto node_it = node->preds .begin ();
2766
+ node_it != node->preds .end ();
2767
+ node_it++)
2766
2768
{
2767
- if (!activateLiveIn.isSet (predNode->sendID ))
2769
+ SBDEP_ITEM& curPred = (*node_it);
2770
+ DepType type = curPred.type ;
2771
+ SBNode* predNode = curPred.node ;
2772
+
2773
+ // If the predecessor node is a token instruction node.
2774
+ if (tokenHonourInstruction (predNode->GetInstruction ()))
2768
2775
{
2769
- // If not in the live set of current instruction,
2770
- // (The live in set will be changed during instruction scan)
2771
- // remove the dependence from success list of previous node
2772
- // The dependence SBID assignment only depends on the succ nodes.
2773
- for (auto succ_it = predNode->succs .begin ();
2774
- succ_it != predNode->succs .end ();
2775
- succ_it++)
2776
+ if (!activateLiveIn.isSet (predNode->sendID ))
2776
2777
{
2777
- SBDEP_ITEM& currSucc = (*succ_it);
2778
- if (currSucc.node == node)
2778
+ // If not in the live set of current instruction,
2779
+ // (The live in set will be changed during instruction scan)
2780
+ // remove the dependence from success list of previous node
2781
+ // The dependence SBID assignment only depends on the succ nodes.
2782
+ for (auto succ_it = predNode->succs .begin ();
2783
+ succ_it != predNode->succs .end ();
2784
+ succ_it++)
2779
2785
{
2780
- // Don't do remove previous edge here.
2781
- // 1. conflict with outer loop
2782
- // 2. There is no preds info required any more in following handling
2783
- predNode->succs .erase (succ_it);
2784
- break ;
2786
+ SBDEP_ITEM& currSucc = (*succ_it);
2787
+ if (currSucc.node == node)
2788
+ {
2789
+ // Don't do remove previous edge here.
2790
+ // 1. conflict with outer loop
2791
+ // 2. There is no preds info required any more in following handling
2792
+ predNode->succs .erase (succ_it);
2793
+ prunedEdgeNum++;
2794
+ if (predNode->globalID != -1 )
2795
+ {
2796
+ if (predNode->getBBID () != node->getBBID () &&
2797
+ !killedToken.isSet (predNode->getLastInstruction ()->getToken ()))
2798
+ {
2799
+ prunedDiffBBEdgeNum++;
2800
+ #ifdef DEBUG_VERBOSE_ON
2801
+ std::cerr << " Diff BB Token: " << predNode->getLastInstruction ()->getToken () << " <Pred: " << predNode->getNodeID () << " , Succ: " << node->getNodeID () << " >" << std::endl;;
2802
+ #endif
2803
+ }
2804
+ else if (predNode->getBBID () != node->getBBID ())
2805
+ {
2806
+ prunedDiffBBSameTokenEdgeNum++;
2807
+ #ifdef DEBUG_VERBOSE_ON
2808
+ std::cerr << " Diff BB Same Token: " << predNode->getLastInstruction ()->getToken () << " <Pred: " << predNode->getNodeID () << " , Succ: " << node->getNodeID () << " >" << std::endl;;
2809
+ #endif
2810
+ }
2811
+ else
2812
+ {
2813
+ prunedGlobalEdgeNum++;
2814
+ #ifdef DEBUG_VERBOSE_ON
2815
+ std::cerr << " Global Token: " << predNode->getLastInstruction ()->getToken () << " <Pred: " << predNode->getNodeID () << " , Succ: " << node->getNodeID () << " >" << std::endl;;
2816
+ #endif
2817
+ }
2818
+ }
2819
+ #ifdef DEBUG_VERBOSE_ON
2820
+ else
2821
+ {
2822
+ std::cerr << " Local Token: " << predNode->getLastInstruction ()->getToken () << " <Pred: " << predNode->getNodeID () << " , Succ: " << node->getNodeID () << " >" << std::endl;;
2823
+ }
2824
+ #endif
2825
+ break ;
2826
+ }
2785
2827
}
2786
2828
}
2787
- }
2788
- else // In live in set
2789
- {
2790
- // Kill the dependence if it's a AW dependence
2791
- // What about WAR?
2792
- if (type == RAW || type == WAW)
2829
+ else // In live in set
2793
2830
{
2794
- int token = predNode->getLastInstruction ()->getToken ();
2795
- if (token != (unsigned short )UNKNOWN_TOKEN)
2831
+ // Kill the dependence if it's a AW dependence
2832
+ // What about WAR?
2833
+ if (type == RAW || type == WAW)
2796
2834
{
2797
- activateLiveIn -= *allTokenNodesMap[token];
2835
+ int token = predNode->getLastInstruction ()->getToken ();
2836
+ if (token != (unsigned short )UNKNOWN_TOKEN)
2837
+ {
2838
+ activateLiveIn -= *allTokenNodesMap[token];
2839
+ killedToken.set (token, true );
2840
+ }
2798
2841
}
2799
2842
}
2800
2843
}
2801
2844
}
2802
- }
2803
2845
2804
- // Current instruction is marked as alive
2805
- // How to kill the old one? Especially the WAR?
2806
- // Token reuse will kill all previous nodes with same token? yes
2807
- if (tokenHonourInstruction (node->GetInstruction ()) && !node->GetInstruction ()->isEOT ())
2808
- {
2809
- int token = node->getLastInstruction ()->getToken ();
2810
- if (token != (unsigned short )UNKNOWN_TOKEN)
2846
+ // Current instruction is marked as alive
2847
+ // How to kill the old one? Especially the WAR?
2848
+ // Token reuse will kill all previous nodes with same token? yes
2849
+ if (tokenHonourInstruction (node->GetInstruction ()) && !node->GetInstruction ()->isEOT ())
2811
2850
{
2812
- activateLiveIn -= *allTokenNodesMap[token];
2813
- activateLiveIn.set (node->sendID , true );
2851
+ int token = node->getLastInstruction ()->getToken ();
2852
+ if (token != (unsigned short )UNKNOWN_TOKEN)
2853
+ {
2854
+ activateLiveIn -= *allTokenNodesMap[token];
2855
+ activateLiveIn.set (node->sendID , true );
2856
+ }
2814
2857
}
2815
2858
}
2816
2859
}
0 commit comments