Skip to content

Commit

Permalink
minor patches in LDBP and patched report.pl
Browse files Browse the repository at this point in the history
  • Loading branch information
akashsridhar authored and renau committed Apr 19, 2020
1 parent aa1d943 commit bcec701
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 48 deletions.
46 changes: 27 additions & 19 deletions conf/scripts/report.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1613,13 +1613,15 @@ sub branchStats {
################
my $nBranches = 0;
my $nMiss = 0;
my $nNoPredict = 0;
my $avgBranchTime=0;
my $avgFetchTime =0;
for(my $j=0;$j<$smtContexts;$j++) {
my $id = $i*$smtContexts+$j;

$nBranches += $cf->getResultField("P(${id})_BPred","nBranches");
$nMiss += $cf->getResultField("P(${id})_BPred","nMiss");
$nNoPredict += $cf->getResultField("P(${id})_BPred","nNopredict");
$avgBranchTime += $cf->getResultField("P(${id})_FetchEngine_avgBranchTime","v");
$avgFetchTime += $cf->getResultField("P(${id})_FetchEngine_avgFetchTime","v");
}
Expand All @@ -1632,7 +1634,7 @@ sub branchStats {

printf "%-16s :",$type;

printf "%7.2f%% :",100*($nBranches-$nMiss)/($nBranches);
printf "%7.2f%% :",100*($nBranches-$nMiss-$nNoPredict)/($nBranches-$nNoPredict);

################
my $rasHit = 0;
Expand All @@ -1645,34 +1647,34 @@ sub branchStats {

my $rasRatio = ($rasMiss+$rasHit) <= 0 ? 0 : ($rasHit/($rasMiss+$rasHit));

printf " %6.2f%% of %5.2f%% :",100*$rasRatio ,100*($rasHit+$rasMiss)/$nBranches;
printf " %6.2f%% of %5.2f%% :",100*$rasRatio ,100*($rasHit+$rasMiss)/($nBranches-$nNoPredict);

################
my $predHit = $cf->getResultField("P(${i})_BPred_${type}","nHit");
my $predMiss = $cf->getResultField("P(${i})_BPred_${type}","nMiss");

my $predRatio = ($predMiss+$predHit) <= 0 ? 0 : ($predHit/($predMiss+$predHit));

printf " %6.2f%% of %5.2f%% :",100*$predRatio, 100*($predHit+$predMiss)/$nBranches;
printf " %6.2f%% of %5.2f%% :",100*$predRatio, 100*($predHit+$predMiss)/($nBranches-$nNoPredict);

################
my $btbHit = $cf->getResultField("P(${i})_BPred_BTB","nHit");
my $btbMiss = $cf->getResultField("P(${i})_BPred_BTB","nMiss");

my $btbRatio = ($btbMiss+$btbHit) <= 0 ? 0 : ($btbHit/($btbMiss+$btbHit));

printf " %6.2f%% of %5.2f%% :",100*$btbRatio ,100*($btbHit+$btbMiss)/$nBranches;
printf " %6.2f%% of %5.2f%% :",100*$btbRatio ,100*($btbHit+$btbMiss)/($nBranches-$nNoPredict);

my $btbHitLabel = $cf->getResultField("P(${i})_BPred_BTB","nHitLabel");
printf " %6.2f%% :",100*($btbHitLabel)/$nBranches;
printf " %6.2f%% :",100*($btbHitLabel)/($nBranches-$nNoPredict);

my $nBTAC = 0;
for(my $j=0;$j<$smtContexts;$j++) {
my $id = $i*$smtContexts+$j;

$nBTAC += $cf->getResultField("P(${id})_FetchEngine","nBTAC");
}
printf "%7.2f%% :",100*$nBTAC/$nBranches;
printf "%7.2f%% :",100*$nBTAC/($nBranches-$nNoPredict);
################
printf "%7.2f%% ",100*($avgBranchTime)/($avgBranchTime+$avgFetchTime+1);

Expand All @@ -1685,7 +1687,7 @@ sub branchStats {

my $rapRatio = ($rapMiss+$rapHit) <= 0 ? 0 : ($rapHit/($rapMiss+$rapHit));

printf "%6.2f%% of %6.2f%% ",100*$rapRatio ,100*($rapHit+$rapMiss)/$nBranches;
printf "%6.2f%% of %6.2f%% ",100*$rapRatio ,100*($rapHit+$rapMiss)/($nBranches-$nNoPredict);
}

print "\n";
Expand All @@ -1699,31 +1701,36 @@ sub branchStats {
printf "%8.3f : ",$avgBranchTime;
printf "%-16s :",$type2;

my $nBranches2= $cf->getResultField("P(${i})_BPred","nBranches2");
my $nMiss2 = $cf->getResultField("P(${i})_BPred","nMiss2");
my $nBranches2 = $cf->getResultField("P(${i})_BPred","nBranches2");
my $nMiss2 = $cf->getResultField("P(${i})_BPred","nMiss2");
my $nNoPredict2 = $cf->getResultField("P(${i})_BPred","nNopredict2");

printf "%7.2f%% :",100*($nBranches2-$nMiss2)/($nBranches2);
printf "%7.2f%% :",100*(($nBranches2-$nMiss2-$nNoPredict2)/($nBranches2-$nNoPredict2));
if ($nNoPredict2 > 0) {
printf " of %7.2f%% :",100*(1-($nNoPredict2/$nBranches2));
}
printf " %6.2f%% of %5.2f%% :",100*0 ,100*0; # No RAS in L2

my $predHit2 = $cf->getResultField("P(${i})_BPred2_${type2}","nHit");
my $predMiss2 = $cf->getResultField("P(${i})_BPred2_${type2}","nMiss");

my $predRatio2 = ($predMiss2+$predHit2) <= 0 ? 0 : ($predHit2/($predMiss2+$predHit2)); # also the 1st level hits

printf " %6.2f%% of %5.2f%% :",100*$predRatio2, 100*($predHit2+$predMiss2)/$nBranches;
#printf " %6.2f%% of %5.2f%% :",100*$predRatio2, 100*($predHit2+$predMiss2)/$nBranches; #FIXME -> why nBranches??? must be nBranches2
printf " %6.2f%% of %5.2f%% :",100*$predRatio2, 100*($predHit2+$predMiss2)/($nBranches-$nNoPredict);

my $btbHit2 = $cf->getResultField("P(${i})_BPred2_BTB","nHit");
my $btbMiss2 = $cf->getResultField("P(${i})_BPred2_BTB","nMiss");

my $btbRatio2 = ($btbMiss2+$btbHit2) <= 0 ? 0 : ($btbHit2/($btbMiss2+$btbHit2+1));

printf " %6.2f%% of %5.2f%% :",100*$btbRatio2 ,100*($btbHit2+$btbMiss2)/($nBranches2+1);
printf " %6.2f%% of %5.2f%% :",100*$btbRatio2 ,100*($btbHit2+$btbMiss2)/($nBranches2-$nNoPredict2+1);

my $btbHitLabel2 = $cf->getResultField("P(${i})_BPred2_BTB","nHitLabel");
printf " %6.2f%% :",100*($btbHitLabel2)/$nBranches;
printf " %6.2f%% :",100*($btbHitLabel2)/($nBranches-$nNoPredict);

my $nFixes2 = $cf->getResultField("P(${i})_BPred","nFixes2");
printf " (%6.2f%% fixed) :",100*($nFixes2)/$nBranches;
printf " (%6.2f%% fixed) :",100*($nFixes2)/($nBranches-$nNoPredict);

printf "\n";
}
Expand All @@ -1739,30 +1746,31 @@ sub branchStats {

my $nBranches3= $cf->getResultField("P(${i})_BPred","nBranches3");
my $nMiss3 = $cf->getResultField("P(${i})_BPred","nMiss3");
my $nNoPredict3 = $cf->getResultField("P(${i})_BPred","nNopredict3");

printf "%7.2f%% :",100*($nBranches3-$nMiss3)/($nBranches3+1);
printf "%7.2f%% :",100*($nBranches3-$nMiss3-$nNoPredict3)/($nBranches3-$nNoPredict3+1);
printf " %6.2f%% of %5.2f%% :",100*0 ,100*0; # No RAS in L2

my $predHit3 = $cf->getResultField("P(${i})_BPred3_${type3}","nHit");
my $predMiss3 = $cf->getResultField("P(${i})_BPred3_${type3}","nMiss");

my $predRatio3 = ($predMiss3+$predHit3) <= 0 ? 0 : ($predHit3/(1+$predMiss3+$predHit3)); # also the 1st level hits

printf " %6.2f%% of %5.2f%% :",100*$predRatio3, 100*($predHit3+$predMiss3)/$nBranches;
printf " %6.2f%% of %5.2f%% :",100*$predRatio3, 100*($predHit3+$predMiss3)/($nBranches-$nNoPredict);

my $btbHit3 = $cf->getResultField("P(${i})_BPred3_BTB","nHit");
my $btbMiss3 = $cf->getResultField("P(${i})_BPred3_BTB","nMiss");

my $btbRatio3 = ($btbMiss3+$btbHit3) <= 0 ? 0 : ($btbHit3/($btbMiss3+$btbHit3+1));

printf " %6.2f%% of %5.2f%% :",100*$btbRatio3 ,100*($btbHit3+$btbMiss3)/($nBranches3+1);
printf " %6.2f%% of %5.2f%% :",100*$btbRatio3 ,100*($btbHit3+$btbMiss3)/($nBranches3-$nNoPredict3+1);

my $btbHitLabel3 = $cf->getResultField("P(${i})_BPred3_BTB","nHitLabel");
printf " %6.2f%% :",100*($btbHitLabel3)/$nBranches;
printf " %6.2f%% :",100*($btbHitLabel3)/($nBranches-$nNoPredict);

my $nFixes3 = $cf->getResultField("P(${i})_BPred","nFixes3");
my $nUnFixes3 = $cf->getResultField("P(${i})_BPred","nUnFixes3");
printf " (%6.2f%%-%6.2f%% fixed) :",100*($nFixes3)/$nBranches, 100*($nUnFixes3)/$nBranches;
printf " (%6.2f%%-%6.2f%% fixed) :",100*($nFixes3)/($nBranches-$nNoPredict), 100*($nUnFixes3)/($nBranches-$nNoPredict);

printf "\n";
}
Expand Down
2 changes: 1 addition & 1 deletion emul/libqemuint/QEMUInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ extern "C" uint64_t QEMUReader_queue_ctrl_data(uint64_t pc, uint64_t addr, uint6
// I(qsamplerlist[fid]->isActive(fid) || EmuSampler::isTerminated());
#ifdef DEBUG_QEMU_TRACE
uint64_t raw = esesc_mem_read(pc);
MSG("pc=%llx addr=%llx data1=%llx data2=%llx op=%d cpu=%d raw=%llx",pc,addr,data1,data2,op,fid, raw);
MSG("ctrl pc=%llx addr=%llx data1=%llx data2=%llx op=%d cpu=%d raw=%llx",pc,addr,data1,data2,op,fid, raw);

I(pc == (last_addr+2) || pc == (last_addr+4) || last_addr==0);
last_addr = pc;
Expand Down
61 changes: 45 additions & 16 deletions simu/libcore/BPred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,20 +469,24 @@ PredType BPLdbp::predict(DInst *dinst, bool doUpdate, bool doStats) {
}

if(dinst->getLBType() == 1 || dinst->getLBType() == 10) {
MSG("TYPE%d@br",dinst->getLBType());
//MSG("TYPE%d@br",dinst->getLBType());
ptaken = outcome_calculator(br_op, dinst->getBrData1(), dinst->getBrData2());
#if 0
if(ptaken == taken)
MSG("OC@type1 correct prediction");
#endif
}else if(dinst->getLBType() == 2 || dinst->getLBType() == 9) { //FIXME should type9 be in prev if block???
MSG("TYPE%d@br", dinst->getLBType());
//MSG("TYPE%d@br", dinst->getLBType());
ptaken = outcome_calculator(br_op, dinst->getBrData2(), dinst->getBrData1());
#if 0
if(ptaken == taken)
MSG("OC@type2 correct prediction");
#endif
}else if(dinst->getLBType() == 3 || dinst->getLBType() == 4 || dinst->getLBType() == 7 || dinst->getLBType() == 8) {
MSG("TYPE%d@br", dinst->getLBType());
RegType reg2 = dinst->getInst()->getSrc2();
//MSG("TYPE%d@br", dinst->getLBType());
DataType reg2 = dinst->getData2();
if(dinst->getLBType() == 4 || dinst->getLBType() == 7)
reg2 = dinst->getInst()->getSrc1(); //FIXME: src reg2 or data2???
reg2 = dinst->getData(); //FIXME: src reg2 or data2???
#if 1
//doc_table has 128 entries - pick a 14 bit tag+index
AddrType doc_tag = (dinst->getPC() ^ dinst->getDataSign() ^ reg2) & 0x3FFF; //FIXME - tag must be hash(brpc, datasign(BrData1))
Expand All @@ -493,21 +497,24 @@ PredType BPLdbp::predict(DInst *dinst, bool doUpdate, bool doStats) {
ptaken = true;
else
return NoPrediction;
#if 0
if(ptaken == taken)
MSG("DOC@type%d pred=%d correct prediction",dinst->getLBType(), ptaken);
#endif
#endif
}else{
return NoPrediction;
}

#if 0
MSG("TRIGGER@bpred clk=%u brpc=%llx ldpc=%llx br_opcode=%llx br_op=%d d1=%u d2=%u correct_pred=%d ptaken=%d", globalClock, dinst->getPC(),dinst->getLDPC(), (raw_op & 3), br_op, dinst->getBrData1(), dinst->getBrData2(), ptaken==taken, ptaken);
//MSG("TRIGGER@bpred brpc=%llx out=%d pred=%d correct=%d op=%d", dinst->getPC(), taken, ptaken,
// taken==ptaken, br_op);
if(taken == ptaken) {
MSG("TRIGGER@correct_pred clk=%u brpc=%llx ldpc=%llx br_opcode=%llx br_op=%d ldbr=%d br1=%u br2=%u d1=%u d2=%u correct_pred=%d ptaken=%d", globalClock, dinst->getPC(),dinst->getLDPC(), (raw_op & 3), br_op, dinst->getLBType(), dinst->getBrData1(), dinst->getBrData2(), dinst->getData(), dinst->getData2(), ptaken==taken, ptaken);
}
#endif

if(taken != ptaken) {
#if 1
MSG("TRIGGER@mis_pred clk=%u brpc=%llx ldpc=%llx br_opcode=%llx br_op=%d br1=%u br2=%u d1=%u d2=%u correct_pred=%d ptaken=%d", globalClock, dinst->getPC(),dinst->getLDPC(), (raw_op & 3), br_op, dinst->getBrData1(), dinst->getBrData2(), dinst->getData(), dinst->getData2(), ptaken==taken, ptaken);
#if 0
MSG("TRIGGER@mis_pred clk=%u brpc=%llx ldpc=%llx br_opcode=%llx br_op=%d ldbr=%d br1=%u br2=%u d1=%u d2=%u correct_pred=%d ptaken=%d", globalClock, dinst->getPC(),dinst->getLDPC(), (raw_op & 3), br_op, dinst->getLBType(), dinst->getBrData1(), dinst->getBrData2(), dinst->getData(), dinst->getData2(), ptaken==taken, ptaken);
#endif
if(doUpdate)
btb.updateOnly(dinst);
Expand Down Expand Up @@ -1546,12 +1553,15 @@ BPredictor::BPredictor(int32_t i, MemObj *iobj, BPredictor *bpred)
, il1(iobj)
, nBTAC("P(%d)_BPred:nBTAC", id)
, nBranches("P(%d)_BPred:nBranches", id)
, nNoPredict("P(%d)_BPred:nNoPredict", id)
, nTaken("P(%d)_BPred:nTaken", id)
, nMiss("P(%d)_BPred:nMiss", id)
, nBranches2("P(%d)_BPred:nBranches2", id)
, nNoPredict2("P(%d)_BPred:nNoPredict2", id)
, nTaken2("P(%d)_BPred:nTaken2", id)
, nMiss2("P(%d)_BPred:nMiss2", id)
, nBranches3("P(%d)_BPred:nBranches3", id)
, nNoPredict3("P(%d)_BPred:nNoPredict3", id)
, nTaken3("P(%d)_BPred:nTaken3", id)
, nMiss3("P(%d)_BPred:nMiss3", id)
, nFixes1("P(%d)_BPred:nFixes1", id)
Expand Down Expand Up @@ -1712,7 +1722,8 @@ PredType BPredictor::predict1(DInst *dinst) {

PredType p = pred1->doPredict(dinst);

nMiss.inc(p != CorrectPrediction && dinst->getStatsFlag());
nMiss.inc(p == MissPrediction && dinst->getStatsFlag());
nNoPredict.inc(p == NoPrediction && dinst->getStatsFlag());

return p;
}
Expand All @@ -1726,7 +1737,9 @@ PredType BPredictor::predict2(DInst *dinst) {

PredType p = pred2->doPredict(dinst);

nMiss2.inc(p != CorrectPrediction && dinst->getStatsFlag());
//nMiss2.inc(p != CorrectPrediction && dinst->getStatsFlag());
nMiss2.inc(p == MissPrediction && dinst->getStatsFlag());
nNoPredict2.inc(p == NoPrediction && dinst->getStatsFlag());

return p;
}
Expand All @@ -1739,18 +1752,24 @@ PredType BPredictor::predict3(DInst *dinst) {
return NoPrediction;
#endif

#if 0
if(dinst->getDataSign() == DS_NoData)
return NoPrediction;
#endif

nBranches3.inc(dinst->getStatsFlag());
nTaken3.inc(dinst->isTaken() && dinst->getStatsFlag());
// No RAS in L2

PredType p = pred3->doPredict(dinst);
#if 0
if(p == NoPrediction)
return p;
#endif

nMiss3.inc(p != CorrectPrediction && dinst->getStatsFlag());
//nMiss3.inc(p != CorrectPrediction && dinst->getStatsFlag());
nMiss3.inc(p == MissPrediction && dinst->getStatsFlag());
nNoPredict3.inc(p == NoPrediction && dinst->getStatsFlag());

return p;
}
Expand Down Expand Up @@ -1836,16 +1855,26 @@ TimeDelta_t BPredictor::predict(DInst *dinst, bool *fastfix) {

int32_t bpred_total_delay = bpredDelay1 - 1;

if(outcome1 == CorrectPrediction && (outcome2 == CorrectPrediction || outcome2 != CorrectPrediction) && (outcome3 == CorrectPrediction || outcome3 == CorrectPrediction)) {
if(outcome1 == CorrectPrediction && (outcome2 == CorrectPrediction || outcome2 == NoPrediction) && (outcome3 == CorrectPrediction || outcome3 == NoPrediction)) {

I(bpredDelay1<=bpredDelay3);
nFixes1.inc(dinst->getStatsFlag());
bpred_total_delay = bpredDelay1 - 1;
}else if((outcome3 == CorrectPrediction) && (outcome2 == CorrectPrediction || outcome2 != CorrectPrediction)) {

}else if(outcome1 != CorrectPrediction && outcome3 == CorrectPrediction) {

I(bpredDelay3<=bpredDelay2);
nFixes3.inc(dinst->getStatsFlag());
bpred_total_delay = bpredDelay3 - 1;
}else if(outcome2 == CorrectPrediction) {

}else if(outcome1 != CorrectPrediction && outcome2 == CorrectPrediction && outcome3 == NoPrediction) {

nFixes2.inc(dinst->getStatsFlag());
bpred_total_delay = bpredDelay2 - 1;

} else {
I(outcome3 != CorrectPrediction || (outcome2 == MissPrediction && outcome3 == NoPrediction) || (outcome1 != CorrectPrediction && outcome2 == NoPrediction && outcome3 == NoPrediction));

nUnFixes.inc(dinst->getStatsFlag());
*fastfix = false;
bpred_total_delay = 2; // Anything but zero
Expand Down
11 changes: 7 additions & 4 deletions simu/libcore/BPred.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ class BPLdbp : public BPred {
int med = (taken == (2*ntaken + 1)) || (ntaken == (2*taken + 1));
int low = (taken < (2*ntaken + 1)) && (ntaken < (2*taken + 1));
int m = 2 * low + med;
if(m < 2) {
if(m < 1) {
if(taken > ntaken)
return 1;
return 2;
Expand All @@ -568,13 +568,13 @@ class BPLdbp : public BPred {
AddrType t = (_tag >> 7) & 0x7F; //upper 7 bits for tag
int index = _tag & 0x7F; //lower 7 bits for index
if(doc_table[index].tag == t) {
MSG("DOC_TABLE_HIT brpc=%llx index=%d tag=%u T=%d NT=%d", dinst->getPC(), index, t, doc_table[index].taken, doc_table[index].ntaken);
return doc_table[index].update_doc(_tag, false, outcome);
//MSG("DOC_TABLE_HIT brpc=%llx index=%d tag=%u T=%d NT=%d", dinst->getPC(), index, t, doc_table[index].taken, doc_table[index].ntaken);
return doc_table[index].update_doc(t, false, outcome);
}

//DOC miss
doc_table[index].tag = t;
MSG("DOC_TABLE_MISS brpc=%llx index=%d tag=%u T=%d NT=%d", dinst->getPC(), index, t, doc_table[index].taken, doc_table[index].ntaken);
//MSG("DOC_TABLE_MISS brpc=%llx index=%d tag=%u T=%d NT=%d", dinst->getPC(), index, t, doc_table[index].taken, doc_table[index].ntaken);
return doc_table[index].update_doc(t, true, outcome);
}

Expand All @@ -601,14 +601,17 @@ class BPredictor {
GStatsCntr nBTAC;

GStatsCntr nBranches;
GStatsCntr nNoPredict;
GStatsCntr nTaken;
GStatsCntr nMiss; // hits == nBranches - nMiss

GStatsCntr nBranches2;
GStatsCntr nNoPredict2;
GStatsCntr nTaken2;
GStatsCntr nMiss2; // hits == nBranches - nMiss

GStatsCntr nBranches3;
GStatsCntr nNoPredict3;
GStatsCntr nTaken3;
GStatsCntr nMiss3; // hits == nBranches - nMiss

Expand Down
4 changes: 3 additions & 1 deletion simu/libcore/FetchEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,9 @@ void FetchEngine::realfetch(IBucket *bucket, EmulInterface *eint, FlowID fid, in
db_idx = i;
DInst *tmp_dinst = init_ldbp(dinst, db_idx);
dinst = tmp_dinst;
//MSG("HIT@F clk=%u brpc=%llx ldpc=%llx ld_addr=%u fc=%u rc=%u idx=%d hit=%d ldbr=%d", globalClock, dinst->getPC(), dinst->getLDPC(), dinst->getLdAddr(), fetch_br_count, DL1->getRetBrCount(), idx, hit, DL1->load_data_buffer[db_idx].ld_br_type);
#if 0
MSG("HIT@F clk=%u brpc=%llx ldpc=%llx ld_addr=%u ldb_data=%u d1=%u d2=%u fc=%u rc=%u idx=%d hit=%d ldbr=%d", globalClock, dinst->getPC(), dinst->getLDPC(), dinst->getLdAddr(), DL1->load_data_buffer[i].ld_data, dinst->getData(), dinst->getData2(), fetch_br_count, DL1->getRetBrCount(), idx, hit, DL1->load_data_buffer[db_idx].ld_br_type);
#endif
break;
}
}
Expand Down
Loading

0 comments on commit bcec701

Please sign in to comment.