summaryrefslogtreecommitdiff
path: root/cpu/beta_cpu/tournament_pred.cc
diff options
context:
space:
mode:
authorKevin Lim <ktlim@umich.edu>2005-05-19 01:28:25 -0400
committerKevin Lim <ktlim@umich.edu>2005-05-19 01:28:25 -0400
commitc2fcac7c0dd8dff182cb262bdf35d5c67117aa42 (patch)
treefc8804bfbe1aa820c8afa446622b9ec8c658b75e /cpu/beta_cpu/tournament_pred.cc
parente5721ce6777726fa54aee49be414233656bd98d1 (diff)
downloadgem5-c2fcac7c0dd8dff182cb262bdf35d5c67117aa42.tar.xz
Fix up code for initial release. The main bug that remains is properly forwarding data from stores to loads, specifically when they are of differing sizes.
cpu/base_dyn_inst.cc: Remove unused commented out code. cpu/base_dyn_inst.hh: Fix up comments. cpu/beta_cpu/2bit_local_pred.cc: Reorder code to match header file. cpu/beta_cpu/2bit_local_pred.hh: Update comments. cpu/beta_cpu/alpha_dyn_inst.hh: Remove useless comments. cpu/beta_cpu/alpha_dyn_inst_impl.hh: cpu/beta_cpu/alpha_full_cpu_impl.hh: cpu/beta_cpu/comm.hh: cpu/beta_cpu/iew_impl.hh: Remove unused commented code. cpu/beta_cpu/alpha_full_cpu.hh: Remove obsolete comment. cpu/beta_cpu/alpha_impl.hh: cpu/beta_cpu/full_cpu.hh: Alphabetize includes. cpu/beta_cpu/bpred_unit.hh: Remove unused global history code. cpu/beta_cpu/btb.hh: cpu/beta_cpu/free_list.hh: Use full path in #defines. cpu/beta_cpu/commit.hh: cpu/beta_cpu/decode.hh: Reorder functions. cpu/beta_cpu/commit_impl.hh: Remove obsolete commented code. cpu/beta_cpu/fetch.hh: Remove obsolete comments. cpu/beta_cpu/fetch_impl.hh: cpu/beta_cpu/rename_impl.hh: Remove commented code. cpu/beta_cpu/full_cpu.cc: Remove useless defines. cpu/beta_cpu/inst_queue.hh: Use full path for #defines. cpu/beta_cpu/inst_queue_impl.hh: Reorder functions to match header file. cpu/beta_cpu/mem_dep_unit.hh: Use full path name for #defines. cpu/beta_cpu/ras.hh: Use full path names for #defines. Remove mod operation. cpu/beta_cpu/regfile.hh: Remove unused commented code, fix up current comments. cpu/beta_cpu/tournament_pred.cc: cpu/beta_cpu/tournament_pred.hh: Update programming style. --HG-- extra : convert_revision : fb9d18a853f58a1108ff827e3c123d5b52a0608a
Diffstat (limited to 'cpu/beta_cpu/tournament_pred.cc')
-rw-r--r--cpu/beta_cpu/tournament_pred.cc148
1 files changed, 74 insertions, 74 deletions
diff --git a/cpu/beta_cpu/tournament_pred.cc b/cpu/beta_cpu/tournament_pred.cc
index 5a22278eb..41e34adef 100644
--- a/cpu/beta_cpu/tournament_pred.cc
+++ b/cpu/beta_cpu/tournament_pred.cc
@@ -10,52 +10,52 @@ TournamentBP::TournamentBP(unsigned _local_predictor_size,
unsigned _choice_predictor_size,
unsigned _choice_ctr_bits,
unsigned _instShiftAmt)
- : local_predictor_size(_local_predictor_size),
- local_ctr_bits(_local_ctr_bits),
- local_history_table_size(_local_history_table_size),
- local_history_bits(_local_history_bits),
- global_predictor_size(_global_predictor_size),
- global_ctr_bits(_global_ctr_bits),
- global_history_bits(_global_history_bits),
- choice_predictor_size(_global_predictor_size),
- choice_ctr_bits(_choice_ctr_bits),
+ : localPredictorSize(_local_predictor_size),
+ localCtrBits(_local_ctr_bits),
+ localHistoryTableSize(_local_history_table_size),
+ localHistoryBits(_local_history_bits),
+ globalPredictorSize(_global_predictor_size),
+ globalCtrBits(_global_ctr_bits),
+ globalHistoryBits(_global_history_bits),
+ choicePredictorSize(_global_predictor_size),
+ choiceCtrBits(_choice_ctr_bits),
instShiftAmt(_instShiftAmt)
{
//Should do checks here to make sure sizes are correct (powers of 2)
//Setup the array of counters for the local predictor
- local_ctrs = new SatCounter[local_predictor_size];
+ localCtrs = new SatCounter[localPredictorSize];
- for (int i = 0; i < local_predictor_size; ++i)
- local_ctrs[i].setBits(local_ctr_bits);
+ for (int i = 0; i < localPredictorSize; ++i)
+ localCtrs[i].setBits(localCtrBits);
//Setup the history table for the local table
- local_history_table = new unsigned[local_history_table_size];
+ localHistoryTable = new unsigned[localHistoryTableSize];
- for (int i = 0; i < local_history_table_size; ++i)
- local_history_table[i] = 0;
+ for (int i = 0; i < localHistoryTableSize; ++i)
+ localHistoryTable[i] = 0;
// Setup the local history mask
- localHistoryMask = (1 << local_history_bits) - 1;
+ localHistoryMask = (1 << localHistoryBits) - 1;
//Setup the array of counters for the global predictor
- global_ctrs = new SatCounter[global_predictor_size];
+ globalCtrs = new SatCounter[globalPredictorSize];
- for (int i = 0; i < global_predictor_size; ++i)
- global_ctrs[i].setBits(global_ctr_bits);
+ for (int i = 0; i < globalPredictorSize; ++i)
+ globalCtrs[i].setBits(globalCtrBits);
//Clear the global history
- global_history = 0;
+ globalHistory = 0;
// Setup the global history mask
- globalHistoryMask = (1 << global_history_bits) - 1;
+ globalHistoryMask = (1 << globalHistoryBits) - 1;
//Setup the array of counters for the choice predictor
- choice_ctrs = new SatCounter[choice_predictor_size];
+ choiceCtrs = new SatCounter[choicePredictorSize];
- for (int i = 0; i < choice_predictor_size; ++i)
- choice_ctrs[i].setBits(choice_ctr_bits);
+ for (int i = 0; i < choicePredictorSize; ++i)
+ choiceCtrs[i].setBits(choiceCtrBits);
- threshold = (1 << (local_ctr_bits - 1)) - 1;
+ threshold = (1 << (localCtrBits - 1)) - 1;
threshold = threshold / 2;
}
@@ -63,29 +63,29 @@ inline
unsigned
TournamentBP::calcLocHistIdx(Addr &branch_addr)
{
- return (branch_addr >> instShiftAmt) & (local_history_table_size - 1);
+ return (branch_addr >> instShiftAmt) & (localHistoryTableSize - 1);
}
inline
void
TournamentBP::updateHistoriesTaken(unsigned local_history_idx)
{
- global_history = (global_history << 1) | 1;
- global_history = global_history & globalHistoryMask;
+ globalHistory = (globalHistory << 1) | 1;
+ globalHistory = globalHistory & globalHistoryMask;
- local_history_table[local_history_idx] =
- (local_history_table[local_history_idx] << 1) | 1;
+ localHistoryTable[local_history_idx] =
+ (localHistoryTable[local_history_idx] << 1) | 1;
}
inline
void
TournamentBP::updateHistoriesNotTaken(unsigned local_history_idx)
{
- global_history = (global_history << 1);
- global_history = global_history & globalHistoryMask;
+ globalHistory = (globalHistory << 1);
+ globalHistory = globalHistory & globalHistoryMask;
- local_history_table[local_history_idx] =
- (local_history_table[local_history_idx] << 1);
+ localHistoryTable[local_history_idx] =
+ (localHistoryTable[local_history_idx] << 1);
}
bool
@@ -100,15 +100,15 @@ TournamentBP::lookup(Addr &branch_addr)
//Lookup in the local predictor to get its branch prediction
local_history_idx = calcLocHistIdx(branch_addr);
- local_predictor_idx = local_history_table[local_history_idx]
+ local_predictor_idx = localHistoryTable[local_history_idx]
& localHistoryMask;
- local_prediction = local_ctrs[local_predictor_idx].read();
+ local_prediction = localCtrs[local_predictor_idx].read();
//Lookup in the global predictor to get its branch prediction
- global_prediction = global_ctrs[global_history].read();
+ global_prediction = globalCtrs[globalHistory].read();
//Lookup in the choice predictor to see which one to use
- choice_prediction = choice_ctrs[global_history].read();
+ choice_prediction = choiceCtrs[globalHistory].read();
//@todo Put a threshold value in for the three predictors that can
// be set through the constructor (so this isn't hard coded).
@@ -117,21 +117,21 @@ TournamentBP::lookup(Addr &branch_addr)
if (global_prediction > threshold) {
updateHistoriesTaken(local_history_idx);
- assert(global_history < global_predictor_size &&
- local_history_idx < local_predictor_size);
+ assert(globalHistory < globalPredictorSize &&
+ local_history_idx < localPredictorSize);
- global_ctrs[global_history].increment();
- local_ctrs[local_history_idx].increment();
+ globalCtrs[globalHistory].increment();
+ localCtrs[local_history_idx].increment();
return true;
} else {
updateHistoriesNotTaken(local_history_idx);
- assert(global_history < global_predictor_size &&
- local_history_idx < local_predictor_size);
+ assert(globalHistory < globalPredictorSize &&
+ local_history_idx < localPredictorSize);
- global_ctrs[global_history].decrement();
- local_ctrs[local_history_idx].decrement();
+ globalCtrs[globalHistory].decrement();
+ localCtrs[local_history_idx].decrement();
return false;
}
@@ -139,21 +139,21 @@ TournamentBP::lookup(Addr &branch_addr)
if (local_prediction > threshold) {
updateHistoriesTaken(local_history_idx);
- assert(global_history < global_predictor_size &&
- local_history_idx < local_predictor_size);
+ assert(globalHistory < globalPredictorSize &&
+ local_history_idx < localPredictorSize);
- global_ctrs[global_history].increment();
- local_ctrs[local_history_idx].increment();
+ globalCtrs[globalHistory].increment();
+ localCtrs[local_history_idx].increment();
return true;
} else {
updateHistoriesNotTaken(local_history_idx);
- assert(global_history < global_predictor_size &&
- local_history_idx < local_predictor_size);
+ assert(globalHistory < globalPredictorSize &&
+ local_history_idx < localPredictorSize);
- global_ctrs[global_history].decrement();
- local_ctrs[local_history_idx].decrement();
+ globalCtrs[globalHistory].decrement();
+ localCtrs[local_history_idx].decrement();
return false;
}
@@ -174,20 +174,20 @@ TournamentBP::update(Addr &branch_addr, unsigned correct_gh, bool taken)
bool global_pred_taken;
// Load the correct global history into the register.
- global_history = correct_gh;
+ globalHistory = correct_gh;
// Get the local predictor's current prediction, remove the incorrect
// update, and update the local predictor
local_history_idx = calcLocHistIdx(branch_addr);
- local_predictor_idx = local_history_table[local_history_idx];
+ local_predictor_idx = localHistoryTable[local_history_idx];
local_predictor_idx = (local_predictor_idx >> 1) & localHistoryMask;
- local_prediction = local_ctrs[local_predictor_idx].read();
+ local_prediction = localCtrs[local_predictor_idx].read();
local_pred_taken = local_prediction > threshold;
//Get the global predictor's current prediction, and update the
//global predictor
- global_prediction = global_ctrs[global_history].read();
+ global_prediction = globalCtrs[globalHistory].read();
global_pred_taken = global_prediction > threshold;
//Update the choice predictor to tell it which one was correct
@@ -195,34 +195,34 @@ TournamentBP::update(Addr &branch_addr, unsigned correct_gh, bool taken)
//If the local prediction matches the actual outcome, decerement
//the counter. Otherwise increment the counter.
if (local_pred_taken == taken) {
- choice_ctrs[global_history].decrement();
+ choiceCtrs[globalHistory].decrement();
} else {
- choice_ctrs[global_history].increment();
+ choiceCtrs[globalHistory].increment();
}
}
if (taken) {
- assert(global_history < global_predictor_size &&
- local_predictor_idx < local_predictor_size);
+ assert(globalHistory < globalPredictorSize &&
+ local_predictor_idx < localPredictorSize);
- local_ctrs[local_predictor_idx].increment();
- global_ctrs[global_history].increment();
+ localCtrs[local_predictor_idx].increment();
+ globalCtrs[globalHistory].increment();
- global_history = (global_history << 1) | 1;
- global_history = global_history & globalHistoryMask;
+ globalHistory = (globalHistory << 1) | 1;
+ globalHistory = globalHistory & globalHistoryMask;
- local_history_table[local_history_idx] |= 1;
+ localHistoryTable[local_history_idx] |= 1;
}
else {
- assert(global_history < global_predictor_size &&
- local_predictor_idx < local_predictor_size);
+ assert(globalHistory < globalPredictorSize &&
+ local_predictor_idx < localPredictorSize);
- local_ctrs[local_predictor_idx].decrement();
- global_ctrs[global_history].decrement();
+ localCtrs[local_predictor_idx].decrement();
+ globalCtrs[globalHistory].decrement();
- global_history = (global_history << 1);
- global_history = global_history & globalHistoryMask;
+ globalHistory = (globalHistory << 1);
+ globalHistory = globalHistory & globalHistoryMask;
- local_history_table[local_history_idx] &= ~1;
+ localHistoryTable[local_history_idx] &= ~1;
}
}