Skip to content

Commit

Permalink
cpu-pred: remove unused boost::to_string
Browse files Browse the repository at this point in the history
  • Loading branch information
tastynoob committed Aug 12, 2024
1 parent fbb3093 commit 65df9ad
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 85 deletions.
4 changes: 0 additions & 4 deletions src/cpu/pred/ftb/decoupled_bpred.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2330,9 +2330,7 @@ DecoupledBPUWithFTB::makeNewPrediction(bool create_new_stream)
// update ghr
int shamt;
std::tie(shamt, taken) = finalPred.getHistInfo();
boost::to_string(s0History, buf1);
histShiftIn(shamt, taken, s0History);
boost::to_string(s0History, buf2);

historyManager.addSpeculativeHist(entry.startPC, shamt, taken, entry.predBranchInfo, fsqId);
tage->checkFoldedHist(s0History, "speculative update");
Expand Down Expand Up @@ -2475,8 +2473,6 @@ DecoupledBPUWithFTB::checkHistory(const boost::dynamic_bitset<> &history)
ideal_hash_hist.resize(comparable_size);
sized_real_hist.resize(comparable_size);
boost::to_string(ideal_hash_hist, buf1);
boost::to_string(sized_real_hist, buf2);
DPRINTF(DecoupleBP,
"Ideal size:\t%u, real history size:\t%u, comparable size:\t%u\n",
ideal_size, historyBits, comparable_size);
Expand Down
23 changes: 8 additions & 15 deletions src/cpu/pred/ftb/ftb_ittage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,15 @@ FTBITTAGE::update(const FetchStream &entry)
unsigned maskMaxNum = std::pow(2, (numPredictors - (pred.main_table + 1)));
unsigned mask = allocLFSR.get() % maskMaxNum;
bitset allocateLFSR(numPredictors - (pred.main_table + 1), mask);
std::string buf;
boost::to_string(allocateLFSR, buf);
DPRINTF(FTBITTAGE || debugFlag, "allocateLFSR %s, size %d\n", buf, allocateLFSR.size());

auto flipped_usefulMask = pred.usefulMask.flip();
boost::to_string(flipped_usefulMask, buf);
DPRINTF(FTBITTAGE || debugFlag, "pred usefulmask %s, size %d\n", buf, pred.usefulMask.size());
bitset masked = allocateLFSR & flipped_usefulMask;
boost::to_string(masked, buf);
DPRINTF(FTBITTAGE || debugFlag, "masked %s, size %d\n", buf, masked.size());
bitset allocate = masked.any() ? masked : flipped_usefulMask;
boost::to_string(allocate, buf);
DPRINTF(FTBITTAGE || debugFlag, "allocate %s, size %d\n", buf, allocate.size());
DPRINTF(FTBITTAGE || debugFlag, "allocateLFSR %s, size %d\n", allocateLFSR, allocateLFSR.size());
DPRINTF(FTBITTAGE || debugFlag, "pred usefulmask %s, size %d\n", flipped_usefulMask,
pred.usefulMask.size());
DPRINTF(FTBITTAGE || debugFlag, "masked %s, size %d\n", masked, masked.size());
DPRINTF(FTBITTAGE || debugFlag, "allocate %s, size %d\n", allocate, allocate.size());

bool allocateValid = flipped_usefulMask.any();
if (needToAllocate && allocateValid) {
Expand Down Expand Up @@ -456,9 +453,7 @@ FTBITTAGE::satDecrement(int min, short &counter)
void
FTBITTAGE::doUpdateHist(const boost::dynamic_bitset<> &history, int shamt, bool taken)
{
std::string buf;
boost::to_string(history, buf);
DPRINTF(FTBITTAGE || debugFlag, "in doUpdateHist, shamt %d, taken %d, history %s\n", shamt, taken, buf);
DPRINTF(FTBITTAGE || debugFlag, "in doUpdateHist, shamt %d, taken %d, history %s\n", shamt, taken, history);
if (shamt == 0) {
DPRINTF(FTBITTAGE || debugFlag, "shamt is 0, returning\n");
return;
Expand Down Expand Up @@ -501,9 +496,7 @@ void
FTBITTAGE::checkFoldedHist(const boost::dynamic_bitset<> &hist, const char * when)
{
DPRINTF(FTBITTAGE || debugFlag, "checking folded history when %s\n", when);
std::string hist_str;
boost::to_string(hist, hist_str);
DPRINTF(FTBITTAGE || debugFlag, "history:\t%s\n", hist_str.c_str());
DPRINTF(FTBITTAGE || debugFlag, "history:\t%s\n", hist);
for (int t = 0; t < numPredictors; t++) {
for (int type = 0; type < 2; type++) {
DPRINTF(FTBITTAGE || debugFlag, "t: %d, type: %d\n", t, type);
Expand Down
16 changes: 1 addition & 15 deletions src/cpu/pred/ftb/ftb_tage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -468,17 +468,9 @@ FTBTAGE::update(const FetchStream &entry)
unsigned mask = allocLFSR.get() % maskMaxNum;
bitset allocateLFSR(numPredictors - (pred.table + 1), mask);
std::string buf;
boost::to_string(allocateLFSR, buf);
// DPRINTF(FTBTAGEUseful, "allocateLFSR %s, size %d\n", buf, allocateLFSR.size());
auto flipped_usefulMask = ~pred.usefulMask;
boost::to_string(flipped_usefulMask, buf);
// DPRINTF(FTBTAGEUseful, "pred usefulmask %s, size %d\n", buf, pred.usefulMask.size());
bitset masked = allocateLFSR & flipped_usefulMask;
boost::to_string(masked, buf);
// DPRINTF(FTBTAGEUseful, "masked %s, size %d\n", buf, masked.size());
bitset allocate = masked.any() ? masked : flipped_usefulMask;
boost::to_string(allocate, buf);
// DPRINTF(FTBTAGEUseful, "allocate %s, size %d\n", buf, allocate.size());
short newCounter = this_cond_actually_taken ? 0 : -1;

bool allocateValid = flipped_usefulMask.any();
Expand Down Expand Up @@ -616,9 +608,7 @@ FTBTAGE::getUseAltIdx(Addr pc) {
void
FTBTAGE::doUpdateHist(const boost::dynamic_bitset<> &history, int shamt, bool taken)
{
std::string buf;
boost::to_string(history, buf);
DPRINTF(FTBTAGE, "in doUpdateHist, shamt %d, taken %d, history %s\n", shamt, taken, buf);
DPRINTF(FTBTAGE, "in doUpdateHist, shamt %d, taken %d, history %s\n", shamt, taken, history);
if (shamt == 0) {
DPRINTF(FTBTAGE, "shamt is 0, returning\n");
return;
Expand Down Expand Up @@ -666,10 +656,6 @@ FTBTAGE::recoverHist(const boost::dynamic_bitset<> &history,
void
FTBTAGE::checkFoldedHist(const boost::dynamic_bitset<> &hist, const char * when)
{
// DPRINTF(FTBTAGE, "checking folded history when %s\n", when);
std::string hist_str;
boost::to_string(hist, hist_str);
// DPRINTF(FTBTAGE, "history:\t%s\n", hist_str.c_str());
for (int t = 0; t < numPredictors; t++) {
for (int type = 0; type < 3; type++) {

Expand Down
25 changes: 10 additions & 15 deletions src/cpu/pred/stream/decoupled_bpred.cc
Original file line number Diff line number Diff line change
Expand Up @@ -636,18 +636,15 @@ DecoupledStreamBPU::trapSquash(unsigned target_id, unsigned stream_id,

historyManager.squash(stream_id, true, last_committed_pc, inst_pc.instAddr());

boost::to_string(s0History, buf1);
boost::to_string(stream.history, buf2);
DPRINTF(DecoupleBP, "Recover history %s\nto %s\n", buf1.c_str(),
buf2.c_str());
DPRINTF(DecoupleBP, "Recover history %s\nto %s\n", s0History,
stream.history);
s0History = stream.history;
streamTAGE->recoverFoldedHist(s0History);
// streamTAGE->checkFoldedHist(s0History);
auto hashed_path =
computePathHash(last_committed_pc, inst_pc.instAddr());
histShiftIn(hashed_path, s0History);
boost::to_string(s0History, buf1);
DPRINTF(DecoupleBP, "Shift in history %s\n", buf1.c_str());
DPRINTF(DecoupleBP, "Shift in history %s\n", s0History);

checkHistory(s0History);

Expand Down Expand Up @@ -1145,12 +1142,13 @@ DecoupledStreamBPU::makeNewPrediction(bool create_new_stream)

auto hashed_path =
computePathHash(s0UbtbPred.controlAddr, s0UbtbPred.nextStream);
boost::to_string(s0History, buf1);
if (debug::DecoupleBP) {
boost::to_string(s0History, buf1);
}
histShiftIn(hashed_path, s0History);
boost::to_string(s0History, buf2);
DPRINTF(DecoupleBP, "Update s0PC to %#lx\n", s0PC);
DPRINTF(DecoupleBP, "Update s0History from %s to %s\n", buf1.c_str(),
buf2.c_str());
DPRINTF(DecoupleBP, "Update s0History from %s to %s\n", buf1,
s0History);
DPRINTF(DecoupleBP, "Hashed path: %#lx\n", hashed_path);

if (create_new_stream) {
Expand Down Expand Up @@ -1206,8 +1204,7 @@ DecoupledStreamBPU::makeNewPrediction(bool create_new_stream)
DPRINTF(DecoupleBP || debugFlagOn,
"After pred, s0StreamStartPC=%#lx, s0PC=%#lx\n", s0StreamStartPC,
s0PC);
boost::to_string(entry.history, buf1);
DPRINTF(DecoupleBP, "New prediction history: %s\n", buf1.c_str());
DPRINTF(DecoupleBP, "New prediction history: %s\n", entry.history);

std::tie(entry.isLoop, entry.loopTarget) = streamLoopPredictor->makeLoopPrediction(s0UbtbPred.controlAddr);
if (s0UbtbPred.useLoopPrediction) {
Expand Down Expand Up @@ -1268,13 +1265,11 @@ DecoupledStreamBPU::checkHistory(const boost::dynamic_bitset<> &history)
ideal_hash_hist.resize(comparable_size);
sized_real_hist.resize(comparable_size);

boost::to_string(ideal_hash_hist, buf1);
boost::to_string(sized_real_hist, buf2);
DPRINTF(DecoupleBP,
"Ideal size:\t%u, real history size:\t%u, comparable size:\t%u\n",
ideal_size, historyBits, comparable_size);
DPRINTF(DecoupleBP, "Ideal history:\t%s\nreal history:\t%s\n",
buf1.c_str(), buf2.c_str());
ideal_hash_hist, sized_real_hist);
assert(ideal_hash_hist == sized_real_hist);
}

Expand Down
45 changes: 11 additions & 34 deletions src/cpu/pred/stream/modify_tage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ StreamTAGE::lookupHelper(bool flag, Addr last_chunk_start, Addr stream_start,
alt_table = -1;
alt_table_index = -1;

std::string buf1;
boost::to_string(history, buf1);
DPRINTF(DecoupleBP || debugFlagOn, "history: %s\n", buf1.c_str());
DPRINTF(DecoupleBP || debugFlagOn, "history: %s\n", history);

for (int i = numPredictors - 1; i >= 0; --i) {
Addr tmp_index = getTageIndex(last_chunk_start, history, i, index_folded_hist);
Expand Down Expand Up @@ -533,9 +531,7 @@ StreamTAGE::getTageTag(Addr pc, const bitset& history, int t, std::vector<bitset
void
StreamTAGE::maintainFoldedHist(const bitset& history, bitset hash)
{
std::string hist_str;
boost::to_string(history, hist_str);
DPRINTF(DecoupleBP, "history:\t%s\n", hist_str.c_str());
DPRINTF(DecoupleBP, "history:\t%s\n", history);
// update the folded history when the global history is updated in the decoupled_bpred.cc
for (int t = 1;t < numPredictors;t++) {
for (int type = 0;type < 2;type++) {
Expand All @@ -544,8 +540,7 @@ StreamTAGE::maintainFoldedHist(const bitset& history, bitset hash)
DPRINTF(DecoupleBP, "t: %d, type: %d\n", t, type);
std::string buf1;
auto &foldedHist = type ? tagFoldedHist[t] : indexFoldedHist[t];
boost::to_string(foldedHist, buf1);
DPRINTF(DecoupleBP, "foldedHist:\t%s\n", buf1.c_str());
DPRINTF(DecoupleBP, "foldedHist:\t%s\n", foldedHist);
unsigned int foldedLen = type ? tableTagBits[t] : tableIndexBits[t];
DPRINTF(DecoupleBP, "foldLen: %d, histLengths: %d\n", foldedLen, histLengths[t]);
unsigned int modResult = histLengths[t] % foldedLen;
Expand All @@ -563,50 +558,39 @@ StreamTAGE::maintainFoldedHist(const bitset& history, bitset hash)
foldedHist[modResult] ^= oriHighRes;
foldedHist.resize(foldedLen);

std::string buf2;
boost::to_string(foldedHist, buf2);
DPRINTF(DecoupleBP, "%d iteration updated foldedHist:\t%s\n", i, buf2.c_str());
DPRINTF(DecoupleBP, "%d iteration updated foldedHist:\t%s\n", i, foldedHist);
}
assert(foldedLen >= 8);
hash.resize(foldedLen);
foldedHist ^= hash;
std::string buf2;
boost::to_string(foldedHist, buf2);
DPRINTF(DecoupleBP, "final foldedHist:\t%s\n", buf2.c_str());
DPRINTF(DecoupleBP, "final foldedHist:\t%s\n", foldedHist);
}
}
}

void
StreamTAGE::checkFoldedHist(const bitset& history)
{
std::string hist_str, hash_str;
boost::to_string(history, hist_str);
DPRINTF(DecoupleBP, "history:\t%s\n", hist_str.c_str());
DPRINTF(DecoupleBP, "history:\t%s\n", history);
// update the folded history when the global history is updated in the decoupled_bpred.cc
for (int t = 1;t < numPredictors;t++) {
for (int type = 0;type < 2;type++) {
DPRINTF(DecoupleBP, "t: %d, type: %d\n", t, type);
std::string buf2, buf3;
auto &foldedHist = type ? tagFoldedHist[t] : indexFoldedHist[t];
unsigned int foldedLen = type ? tableTagBits[t] : tableIndexBits[t];
boost::to_string(foldedHist, buf2);

// check history
bitset idealHist(history);
idealHist.resize(histLengths[t]);
std::string buf4;
boost::to_string(idealHist, buf4);
DPRINTF(DecoupleBP, "idealHist:\t%s\n", buf4.c_str());
DPRINTF(DecoupleBP, "idealHist:\t%s\n", idealHist);

bitset idealFoldedHist;
idealFoldedHist.resize(foldedLen);
for (int i = 0;i < histLengths[t];i++) {
idealFoldedHist[i % foldedLen] ^= idealHist[i];
}
assert(foldedLen >= 8);
boost::to_string(idealFoldedHist, buf3);
DPRINTF(DecoupleBP, "idealFoldedHist:\t%s\tfoldedHist:\t%s\n", buf3.c_str(), buf2.c_str());
DPRINTF(DecoupleBP, "idealFoldedHist:\t%s\tfoldedHist:\t%s\n", idealFoldedHist, foldedHist);
assert(idealFoldedHist == foldedHist);
}
}
Expand All @@ -615,28 +599,21 @@ StreamTAGE::checkFoldedHist(const bitset& history)
void
StreamTAGE::recoverFoldedHist(const bitset& history)
{
std::string buf;
boost::to_string(history, buf);
DPRINTF(DecoupleBP, "recoverFoldedHist: %s\n", buf.c_str());
DPRINTF(DecoupleBP, "recoverFoldedHist: %s\n", history);
// manually compute the folded history
for (int t = 1;t < numPredictors;t++) {
for (int type = 0;type < 2;type++) {
auto &foldedHist = type ? tagFoldedHist[t] : indexFoldedHist[t];
unsigned int foldedLen = type ? tableTagBits[t] : tableIndexBits[t];
std::string buf0, buf1;
boost::to_string(foldedHist, buf0);
DPRINTF(DecoupleBP, "foldedHist:\t%s\tcleared:\t%s\n", foldedHist, foldedLen);
foldedHist.clear();
foldedHist.resize(foldedLen);
boost::to_string(foldedHist, buf1);
DPRINTF(DecoupleBP, "foldedHist:\t%s\tcleared:\t%s\n", buf0.c_str(), buf1.c_str());
bitset tempHist(history);
tempHist.resize(histLengths[t]);
for (int j = 0;j < histLengths[t];j++) {
foldedHist[j % foldedLen] ^= tempHist[j];
}
std::string buf2;
boost::to_string(foldedHist, buf2);
DPRINTF(DecoupleBP, "t:%d, type: %d, history:\t%s\n", t, type, buf2.c_str());
DPRINTF(DecoupleBP, "t:%d, type: %d, history:\t%s\n", t, type, foldedHist);
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/cpu/pred/stream/ubtb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ StreamUBTB::update(/*const PredictionID fsq_id,*/
stream_start_pc);
return;
}
std::string buf;
boost::to_string(history, buf);
// DPRINTF(DecoupleBP,
// "StreamUBTB::update: fsq id: %d, control_pc: %#x, target: %#x, "
// "is_conditional: %d, is_indirect: %d, "
Expand Down

0 comments on commit 65df9ad

Please sign in to comment.