@@ -1493,6 +1493,58 @@ void SWSB::handleFuncCall() {
1493
1493
}
1494
1494
}
1495
1495
1496
+ //
1497
+ // Set the global ID bit vector of each bucket touched by corresponding
1498
+ // operands
1499
+ //
1500
+ void SWSB::SWSBInitializeGlobalNodesInBuckets (
1501
+ std::vector<SparseBitVector>
1502
+ &dstGlobalIDs, // node global ID bit vector in buckets touched by dst
1503
+ // operands
1504
+ std::vector<SparseBitVector>
1505
+ &srcGlobalIDs, // node global ID bit vector in buckets touched by src
1506
+ // operands
1507
+ LiveGRFBuckets &globalSendsLB) { // live buckets of global sends
1508
+
1509
+ dstGlobalIDs.resize (kernel.getNumRegTotal () +
1510
+ fg.builder ->getNumScalarRegisters ());
1511
+ srcGlobalIDs.resize (kernel.getNumRegTotal () +
1512
+ fg.builder ->getNumScalarRegisters ());
1513
+
1514
+ // Scan the global send LB to set the node bit in dst or src bit set of each
1515
+ // bucket that node touches.
1516
+ for (unsigned curBucket = 0 ;
1517
+ curBucket <
1518
+ kernel.getNumRegTotal () + fg.builder ->getNumScalarRegisters ();
1519
+ curBucket++) {
1520
+ SparseBitVector dstBitSet;
1521
+ SparseBitVector srcBitSet;
1522
+
1523
+ bool setDstBucket = false ;
1524
+ bool setSrcBucket = false ;
1525
+ for (LiveGRFBuckets::BN_iterator bn_it = globalSendsLB.begin (curBucket);
1526
+ bn_it != globalSendsLB.end (curBucket); ++bn_it) {
1527
+ SBBucketNode *liveBN = (*bn_it);
1528
+ SBNode *curLiveNode = liveBN->node ;
1529
+
1530
+ if (liveBN->opndNum == Opnd_dst) {
1531
+ dstBitSet.set (curLiveNode->globalID );
1532
+ setDstBucket = true ;
1533
+ } else {
1534
+ srcBitSet.set (curLiveNode->globalID );
1535
+ setSrcBucket = true ;
1536
+ }
1537
+ }
1538
+
1539
+ if (setDstBucket) {
1540
+ dstGlobalIDs[curBucket] = dstBitSet;
1541
+ }
1542
+ if (setSrcBucket) {
1543
+ srcGlobalIDs[curBucket] = srcBitSet;
1544
+ }
1545
+ }
1546
+ }
1547
+
1496
1548
void SWSB::SWSBGlobalTokenGenerator (PointsToAnalysis &p, LiveGRFBuckets &LB,
1497
1549
LiveGRFBuckets &globalSendsLB) {
1498
1550
allTokenNodesMap.resize (totalTokenNum);
@@ -1505,6 +1557,18 @@ void SWSB::SWSBGlobalTokenGenerator(PointsToAnalysis &p, LiveGRFBuckets &LB,
1505
1557
const bool enableDistPropTokenAllocation =
1506
1558
fg.builder ->getOptions ()->getOption (vISA_DistPropTokenAllocation);
1507
1559
1560
+ std::vector<SparseBitVector> dstGlobalIDs;
1561
+ std::vector<SparseBitVector> srcGlobalIDs;
1562
+ if (!fg.builder
1563
+ ->hasReadSuppressionOrSharedLocalMemoryWAs () && // No WA needs check
1564
+ // specific
1565
+ // instruction
1566
+ !indexes.DPASIndex ) { // No DPAS instruction which may access part of GRF
1567
+ // Initialilze for setSendGlobalIDMayKilledByCurrentBB only
1568
+ SWSBInitializeGlobalNodesInBuckets (dstGlobalIDs, srcGlobalIDs,
1569
+ globalSendsLB);
1570
+ }
1571
+
1508
1572
// Get the live out, may kill bit sets
1509
1573
for (G4_BB_SB *bb : BBVector) {
1510
1574
bb->liveInTokenNodes = BitSet (SBSendNodes.size (), false );
@@ -1537,7 +1601,15 @@ void SWSB::SWSBGlobalTokenGenerator(PointsToAnalysis &p, LiveGRFBuckets &LB,
1537
1601
}
1538
1602
}
1539
1603
1540
- bb->setSendOpndMayKilled (&globalSendsLB, SBNodes, p);
1604
+ // No WA needs check specific instruction
1605
+ // No DPAS instruction which may access part of GRF
1606
+ if (!fg.builder ->hasReadSuppressionOrSharedLocalMemoryWAs () &&
1607
+ !indexes.DPASIndex ) {
1608
+ bb->setSendGlobalIDMayKilledByCurrentBB (dstGlobalIDs, srcGlobalIDs,
1609
+ SBNodes, p);
1610
+ } else {
1611
+ bb->setSendOpndMayKilled (&globalSendsLB, SBNodes, p);
1612
+ }
1541
1613
1542
1614
#ifdef DEBUG_VERBOSE_ON
1543
1615
bb->dumpLiveInfo (&globalSendOpndList, globalSendNum, nullptr );
@@ -5107,6 +5179,43 @@ void G4_BB_SB::setSendOpndMayKilled(LiveGRFBuckets *globalSendsLB,
5107
5179
}
5108
5180
}
5109
5181
5182
+ //
5183
+ // Set the global ID of the send node which will be killed by current basic
5184
+ // block. This is the prepration work for reaching define data flow analysis.
5185
+ // The function is used to handle the kernel in which only send instruction need
5186
+ // SBID. The smallest GRF granularity of send operand is 1 GRF ,and is GRF
5187
+ // aligned. So the node in the bucket is the node will be killed by current BB.
5188
+ //
5189
+ void G4_BB_SB::setSendGlobalIDMayKilledByCurrentBB (
5190
+ std::vector<SparseBitVector> &dstTokenBit,
5191
+ std::vector<SparseBitVector> &srcTokenBit, SBNODE_VECT &SBNodes,
5192
+ PointsToAnalysis &p) {
5193
+
5194
+ if (first_node == INVALID_ID) {
5195
+ return ;
5196
+ }
5197
+
5198
+ for (auto srcGRF : BBGRF.src ) {
5199
+ // RAW
5200
+ if (!dstTokenBit[srcGRF].empty ()) {
5201
+ send_may_kill.dst |= dstTokenBit[srcGRF];
5202
+ }
5203
+ }
5204
+
5205
+ for (auto dstGRF : BBGRF.dst ) {
5206
+ if (!dstTokenBit[dstGRF].empty ()) {
5207
+ // WAW
5208
+ send_may_kill.dst |= dstTokenBit[dstGRF];
5209
+ send_WAW_may_kill |= dstTokenBit[dstGRF];
5210
+ }
5211
+
5212
+ if (!srcTokenBit[dstGRF].empty ()) {
5213
+ // WAR
5214
+ send_may_kill.src |= srcTokenBit[dstGRF];
5215
+ }
5216
+ }
5217
+ }
5218
+
5110
5219
bool G4_BB_SB::getFootprintForOperand (SBNode *node, G4_INST *inst,
5111
5220
G4_Operand *opnd,
5112
5221
Gen4_Operand_Number opndNum) {
@@ -6725,6 +6834,15 @@ void G4_BB_SB::SBDDD(G4_BB *bb, LiveGRFBuckets *&LB,
6725
6834
bucketNodes[BD.footprint ].push_back (newNode);
6726
6835
LB->add (newNode, BD.bucket );
6727
6836
}
6837
+
6838
+ if (BD.bucket < (int )(builder.kernel .getNumRegTotal () +
6839
+ builder.getNumScalarRegisters ())) {
6840
+ if (BD.opndNum == Opnd_dst) {
6841
+ BBGRF.setDst (BD.bucket , true );
6842
+ } else {
6843
+ BBGRF.setSrc (BD.bucket , true );
6844
+ }
6845
+ }
6728
6846
}
6729
6847
} else {
6730
6848
std::vector<SBBucketNode *> bucketNodes (
@@ -6738,6 +6856,14 @@ void G4_BB_SB::SBDDD(G4_BB *bb, LiveGRFBuckets *&LB,
6738
6856
}
6739
6857
6740
6858
LB->add (bucketNodes[BD.opndNum ], BD.bucket );
6859
+ if (BD.bucket < (int )(builder.kernel .getNumRegTotal () +
6860
+ builder.getNumScalarRegisters ())) {
6861
+ if (BD.opndNum == Opnd_dst) {
6862
+ BBGRF.setDst (BD.bucket , true );
6863
+ } else {
6864
+ BBGRF.setSrc (BD.bucket , true );
6865
+ }
6866
+ }
6741
6867
}
6742
6868
}
6743
6869
0 commit comments