@@ -454,6 +454,7 @@ DecoupledBPUWithBTB::DBPBTBStats::DBPBTBStats(
454454 ADD_STAT (otherMiss, statistics::units::Count::get(), " the number of other branch misses" ),
455455 ADD_STAT (branchClassCounts, statistics::units::Count::get(), " branch counts by fine-grained class" ),
456456 ADD_STAT (branchClassMisses, statistics::units::Count::get(), " branch mispredictions by fine-grained class" ),
457+ ADD_STAT (branchClassCountsTotal, statistics::units::Count::get(), " total number of classified branches" ),
457458 ADD_STAT (controlSquashByClass, statistics::units::Count::get(), " commit/resolve-path squashes by branch class" ),
458459 ADD_STAT (staticBranchNum, statistics::units::Count::get(), " the number of all (different) static branches" ),
459460 ADD_STAT (staticBranchNumEverTaken, statistics::units::Count::get(), " the number of all (different) static branches that are once taken" ),
@@ -497,7 +498,15 @@ DecoupledBPUWithBTB::DBPBTBStats::DBPBTBStats(
497498 ADD_STAT (btbEntriesWithOnlyOneJump, statistics::units::Count::get(), " number of btb entries with different start PC starting with a jump" ),
498499 ADD_STAT (predFalseHit, statistics::units::Count::get(), " false hit detected at pred" ),
499500 ADD_STAT (commitFalseHit, statistics::units::Count::get(), " false hit detected at commit" ),
500- ADD_STAT (predictionBlockedForUpdate, statistics::units::Count::get(), " prediction blocked for update priority" )
501+ ADD_STAT (predictionBlockedForUpdate, statistics::units::Count::get(), " prediction blocked for update priority" ),
502+ ADD_STAT (s1PredWrongFallthrough, statistics::units::Count::get(), " S1pred wrong full throughs" ),
503+ ADD_STAT (s1PredWrongUbtb, statistics::units::Count::get()," S1pred wrong using ubtb " ),
504+ ADD_STAT (s1PredWrongAbtb, statistics::units::Count::get(), " S1pred wrong using abtb " ),
505+ ADD_STAT (s3PredWrongMbtb, statistics::units::Count::get(), " S3pred wrong blame mbtb " ),
506+ ADD_STAT (s3PredWrongTage, statistics::units::Count::get(), " S3pred wrong blame tage " ),
507+ ADD_STAT (s3PredWrongIttage, statistics::units::Count::get(), " S3pred wrong blame ittage " ),
508+ ADD_STAT (s3PredWrongRas, statistics::units::Count::get(), " S3pred wrong blame ras " )
509+
501510{
502511 predsOfEachStage.init (numStages);
503512 commitPredsFromEachStage.init (numStages+1 );
@@ -700,6 +709,7 @@ DecoupledBPUWithBTB::addBranchClassStat(BranchClass cls, bool mispred)
700709 dbpBtbStats.branchClassCounts [idx]++;
701710 if (mispred) {
702711 dbpBtbStats.branchClassMisses [idx]++;
712+ dbpBtbStats.branchClassCountsTotal ++;
703713 }
704714
705715 DPRINTF (DBPBTBStats, " Branch classified as %s, mispred=%d\n " ,
@@ -859,9 +869,82 @@ DecoupledBPUWithBTB::commitBranch(const DynInstPtr &inst, bool mispred)
859869 for (auto component : components) {
860870 component->commitBranch (entry, inst);
861871 }
872+ // here add final counter
873+
874+ if (mispred) {
875+ commitPredWrongSource (entry);
876+ }
877+
862878}
863879
880+ void
881+ DecoupledBPUWithBTB::commitPredWrongSource (const FetchStream &entry)
882+ {
883+ int ubtbid = ubtb->getComponentIdx ();
884+ int abtbid = abtb->getComponentIdx ();
885+ int mbtbid = mbtb->getComponentIdx ();
886+ int tageid = tage->getComponentIdx ();
887+ int ittageid = ittage->getComponentIdx ();
888+ int rasid = ras->getComponentIdx ();
889+
890+ int s1PredSource = entry.s1Source ;
891+ int s3PredSource = entry.s3Source ;
892+
893+ auto exeBranchInfo = entry.exeBranchInfo ;
894+
895+ bool onlyDirectionWrong = entry.exeTaken != entry.predTaken ;
896+
897+ assert (s1PredSource < mbtbid);
898+ if (s1PredSource == ubtbid) {
899+ dbpBtbStats.s1PredWrongUbtb ++;
900+ } else if (s1PredSource == abtbid) {
901+ dbpBtbStats.s1PredWrongAbtb ++;
902+ }else {
903+ dbpBtbStats.s1PredWrongFallthrough ++;
904+ }
864905
906+ if (s3PredSource == rasid) {
907+ if (exeBranchInfo.isCond ) {
908+ dbpBtbStats.s3PredWrongTage ++;
909+ } else if (exeBranchInfo.isReturn ) {
910+ dbpBtbStats.s3PredWrongRas ++;
911+ } else {
912+ dbpBtbStats.s3PredWrongMbtb ++;
913+ }
914+ } else if (s3PredSource == ittageid) {
915+ if (exeBranchInfo.isIndirect ) {
916+ dbpBtbStats.s3PredWrongIttage ++;
917+ } else if (exeBranchInfo.isCond ) {
918+ dbpBtbStats.s3PredWrongTage ++;
919+ } else {
920+ dbpBtbStats.s3PredWrongMbtb ++;
921+ }
922+ } else if (s3PredSource == tageid) {
923+ if (exeBranchInfo.isCond ) {
924+ if (onlyDirectionWrong) {
925+ dbpBtbStats.s3PredWrongTage ++;
926+ } else {
927+ dbpBtbStats.s3PredWrongMbtb ++;
928+ }
929+ } else {
930+ dbpBtbStats.s3PredWrongMbtb ++;
931+ }
932+ }else if (s3PredSource == mbtbid) {
933+ if (exeBranchInfo.isCond ) {
934+ if (onlyDirectionWrong) {
935+ dbpBtbStats.s3PredWrongTage ++;
936+ } else {
937+ dbpBtbStats.s3PredWrongMbtb ++;
938+ }
939+ } else if (exeBranchInfo.isIndirect ) {
940+ dbpBtbStats.s3PredWrongIttage ++;
941+ } else {
942+ dbpBtbStats.s3PredWrongMbtb ++;
943+ }
944+ }else if (s3PredSource == -1 ) {
945+ dbpBtbStats.s3PredWrongMbtb ++;
946+ }
947+ }
865948/* *
866949 * @brief Handle instruction commits and phase-based statistics
867950 *
0 commit comments