[gem5-dev] Change in gem5/gem5[master]: cpu: Added new stats to TAGE and LTAGE branch predictors
Pau Cabre has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/14535 ) Change subject: cpu: Added new stats to TAGE and LTAGE branch predictors .. cpu: Added new stats to TAGE and LTAGE branch predictors They are basically used to tell wich component of the predictor is providing the prediction and whether it is correct or wrong Change-Id: I7b3db66535f159091f1b37d70c2d942d50b20fb2 Signed-off-by: Pau Cabre Reviewed-on: https://gem5-review.googlesource.com/c/14535 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power --- M src/cpu/pred/ltage.cc M src/cpu/pred/ltage.hh M src/cpu/pred/tage.cc M src/cpu/pred/tage.hh 4 files changed, 217 insertions(+), 5 deletions(-) Approvals: Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved Objections: Ilias Vougioukas: I would prefer this is not merged as is diff --git a/src/cpu/pred/ltage.cc b/src/cpu/pred/ltage.cc index 3be0193..73f4777 100644 --- a/src/cpu/pred/ltage.cc +++ b/src/cpu/pred/ltage.cc @@ -228,6 +228,7 @@ if ((loopUseCounter >= 0) && bi->loopPredValid) { pred_taken = bi->loopPred; +bi->provider = LOOP; } DPRINTF(LTage, "Predict for %lx: taken?:%d, loopTaken?:%d, " "loopValid?:%d, loopUseCounter:%d, tagePred:%d, altPred:%d\n", @@ -288,6 +289,43 @@ TAGE::squash(tid, bp_history); } + +void +LTAGE::updateStats(bool taken, TageBranchInfo* bi) +{ +TAGE::updateStats(taken, bi); + +LTageBranchInfo * ltage_bi = static_cast(bi); + +if (ltage_bi->provider == LOOP) { +if (taken == ltage_bi->loopPred) { +loopPredictorCorrect++; +} else { +loopPredictorWrong++; +} +} +} + + + +void +LTAGE::regStats() +{ +TAGE::regStats(); + +loopPredictorCorrect +.name(name() + ".loopPredictorCorrect") +.desc("Number of times the loop predictor is the provider and " + "the prediction is correct"); + +loopPredictorWrong +.name(name() + ".loopPredictorWrong") +.desc("Number of times the loop predictor is the provier and " + "the prediction is wrong"); +} + + + LTAGE* LTAGEParams::create() { diff --git a/src/cpu/pred/ltage.hh b/src/cpu/pred/ltage.hh index d614026..e9e34b7 100644 --- a/src/cpu/pred/ltage.hh +++ b/src/cpu/pred/ltage.hh @@ -67,6 +67,8 @@ // Base class methods. void squash(ThreadID tid, void *bp_history) override; +void regStats() override; + private: // Prediction Structures // Loop Predictor Entry @@ -84,6 +86,11 @@ confidence(0), tag(0), age(0), dir(0) { } }; +// more provider types +enum { +LOOP = LAST_TAGE_PROVIDER_TYPE + 1 +}; + // Primary branch history entry struct LTageBranchInfo : public TageBranchInfo { @@ -177,6 +184,14 @@ void squash( ThreadID tid, bool taken, void *bp_history) override; +/** + * Update the stats + * @param taken Actual branch outcome + * @param bi Pointer to information on the prediction + * recorded at prediction time. + */ +void updateStats(bool taken, TageBranchInfo* bi) override; + const unsigned logSizeLoopPred; const unsigned loopTableAgeBits; const unsigned loopTableConfidenceBits; @@ -191,6 +206,10 @@ int8_t loopUseCounter; unsigned withLoopBits; + +// stats +Stats::Scalar loopPredictorCorrect; +Stats::Scalar loopPredictorWrong; }; #endif // __CPU_PRED_LTAGE diff --git a/src/cpu/pred/tage.cc b/src/cpu/pred/tage.cc index c22e6b7..061f808 100644 --- a/src/cpu/pred/tage.cc +++ b/src/cpu/pred/tage.cc @@ -348,16 +348,19 @@ //if the entry is recognized as a newly allocated entry and //useAltPredForNewlyAllocated is positive use the alternate //prediction -if ((useAltPredForNewlyAllocated < 0) - || abs(2 * - gtable[bi->hitBank][tableIndices[bi->hitBank]].ctr + 1) 1) +if ((useAltPredForNewlyAllocated < 0) || ! bi->pseudoNewAlloc) { bi->tagePred = bi->longestMatchPred; -else +bi->provider = TAGE_LONGEST_MATCH; +} else { bi->tagePred = bi->altTaken; +bi->provider = bi->altBank ? TAGE_ALT_MATCH + : BIMODAL_ALT_MATCH; +} } else { bi->altTaken = getBimodePred(pc, bi); bi->tagePred = bi->altTaken; bi->longestMatchPred = bi->altTaken; +bi->provider = BIMODAL_ONLY; } //end TAGE prediction @@ -390,6 +393,7 @@ if (bi->condBranch) { DPRINTF(Tage, "Updating tables for branch:%lx; taken?:%d\n", branch_pc, taken); +updateStats(taken, bi);
[gem5-dev] Change in gem5/gem5[master]: cpu: Added new stats to TAGE and LTAGE branch predictors
Hello Sudhanshu Jha, I'd like you to reexamine a change. Please visit https://gem5-review.googlesource.com/c/public/gem5/+/14535 to look at the new patch set (#2). Change subject: cpu: Added new stats to TAGE and LTAGE branch predictors .. cpu: Added new stats to TAGE and LTAGE branch predictors They are basically used to tell wich component of the predictor is providing the prediction and whether it is correct or wrong Change-Id: I7b3db66535f159091f1b37d70c2d942d50b20fb2 Signed-off-by: Pau Cabre --- M src/cpu/pred/ltage.cc M src/cpu/pred/ltage.hh M src/cpu/pred/tage.cc M src/cpu/pred/tage.hh 4 files changed, 217 insertions(+), 5 deletions(-) -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/14535 To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: master Gerrit-Change-Id: I7b3db66535f159091f1b37d70c2d942d50b20fb2 Gerrit-Change-Number: 14535 Gerrit-PatchSet: 2 Gerrit-Owner: Pau Cabre Gerrit-Reviewer: Pau Cabre Gerrit-Reviewer: Sudhanshu Jha Gerrit-MessageType: newpatchset ___ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev
[gem5-dev] Change in gem5/gem5[master]: cpu: Added new stats to TAGE and LTAGE branch predictors
Pau Cabre has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/14535 Change subject: cpu: Added new stats to TAGE and LTAGE branch predictors .. cpu: Added new stats to TAGE and LTAGE branch predictors They are basically used to tell wich component of the predictor is providing the prediction and whether it is correct or wrong Change-Id: I7b3db66535f159091f1b37d70c2d942d50b20fb2 Signed-off-by: Pau Cabre --- M src/cpu/pred/ltage.cc M src/cpu/pred/ltage.hh M src/cpu/pred/tage.cc M src/cpu/pred/tage.hh 4 files changed, 195 insertions(+), 5 deletions(-) diff --git a/src/cpu/pred/ltage.cc b/src/cpu/pred/ltage.cc index 3be0193..73f4777 100644 --- a/src/cpu/pred/ltage.cc +++ b/src/cpu/pred/ltage.cc @@ -228,6 +228,7 @@ if ((loopUseCounter >= 0) && bi->loopPredValid) { pred_taken = bi->loopPred; +bi->provider = LOOP; } DPRINTF(LTage, "Predict for %lx: taken?:%d, loopTaken?:%d, " "loopValid?:%d, loopUseCounter:%d, tagePred:%d, altPred:%d\n", @@ -288,6 +289,43 @@ TAGE::squash(tid, bp_history); } + +void +LTAGE::updateStats(bool taken, TageBranchInfo* bi) +{ +TAGE::updateStats(taken, bi); + +LTageBranchInfo * ltage_bi = static_cast(bi); + +if (ltage_bi->provider == LOOP) { +if (taken == ltage_bi->loopPred) { +loopPredictorCorrect++; +} else { +loopPredictorWrong++; +} +} +} + + + +void +LTAGE::regStats() +{ +TAGE::regStats(); + +loopPredictorCorrect +.name(name() + ".loopPredictorCorrect") +.desc("Number of times the loop predictor is the provider and " + "the prediction is correct"); + +loopPredictorWrong +.name(name() + ".loopPredictorWrong") +.desc("Number of times the loop predictor is the provier and " + "the prediction is wrong"); +} + + + LTAGE* LTAGEParams::create() { diff --git a/src/cpu/pred/ltage.hh b/src/cpu/pred/ltage.hh index d614026..e9e34b7 100644 --- a/src/cpu/pred/ltage.hh +++ b/src/cpu/pred/ltage.hh @@ -67,6 +67,8 @@ // Base class methods. void squash(ThreadID tid, void *bp_history) override; +void regStats() override; + private: // Prediction Structures // Loop Predictor Entry @@ -84,6 +86,11 @@ confidence(0), tag(0), age(0), dir(0) { } }; +// more provider types +enum { +LOOP = LAST_TAGE_PROVIDER_TYPE + 1 +}; + // Primary branch history entry struct LTageBranchInfo : public TageBranchInfo { @@ -177,6 +184,14 @@ void squash( ThreadID tid, bool taken, void *bp_history) override; +/** + * Update the stats + * @param taken Actual branch outcome + * @param bi Pointer to information on the prediction + * recorded at prediction time. + */ +void updateStats(bool taken, TageBranchInfo* bi) override; + const unsigned logSizeLoopPred; const unsigned loopTableAgeBits; const unsigned loopTableConfidenceBits; @@ -191,6 +206,10 @@ int8_t loopUseCounter; unsigned withLoopBits; + +// stats +Stats::Scalar loopPredictorCorrect; +Stats::Scalar loopPredictorWrong; }; #endif // __CPU_PRED_LTAGE diff --git a/src/cpu/pred/tage.cc b/src/cpu/pred/tage.cc index c22e6b7..6974b07 100644 --- a/src/cpu/pred/tage.cc +++ b/src/cpu/pred/tage.cc @@ -348,16 +348,18 @@ //if the entry is recognized as a newly allocated entry and //useAltPredForNewlyAllocated is positive use the alternate //prediction -if ((useAltPredForNewlyAllocated < 0) - || abs(2 * - gtable[bi->hitBank][tableIndices[bi->hitBank]].ctr + 1) 1) +if ((useAltPredForNewlyAllocated < 0) || ! bi->pseudoNewAlloc) { bi->tagePred = bi->longestMatchPred; -else +bi->provider = TAGE_LONGEST_MATCH; +} else { bi->tagePred = bi->altTaken; +bi->provider = TAGE_ALT_MATCH; +} } else { bi->altTaken = getBimodePred(pc, bi); bi->tagePred = bi->altTaken; bi->longestMatchPred = bi->altTaken; +bi->provider = BIMODAL_ONLY; } //end TAGE prediction @@ -390,6 +392,7 @@ if (bi->condBranch) { DPRINTF(Tage, "Updating tables for branch:%lx; taken?:%d\n", branch_pc, taken); +updateStats(taken, bi); condBranchUpdate(branch_pc, taken, bi, nrand); } if (!squashed) { @@ -602,6 +605,101 @@ [tid].globalHistory[threadHistory[tid].ptGhist]); } +void +TAGE::updateStats(bool taken, TageBranchInfo* bi) +{ +if (taken == bi->tagePred) { +// correct prediction +switch (bi->provider) { + case BIMODAL_ONLY: