Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ABenC377 committed Jun 5, 2024
1 parent 3b18968 commit c1a78c7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/include/simeng/branchpredictors/GenericPredictor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class GenericPredictor : public BranchPredictor {

/** The Id of the last instruction that update was called on -- used to
* ensure that update is called in program order. */
uint64_t lastUpdatedInstructionId = 0;
[[maybe_unused]] uint64_t lastUpdatedInstructionId_ = 0;
};

} // namespace simeng
2 changes: 1 addition & 1 deletion src/include/simeng/branchpredictors/PerceptronPredictor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class PerceptronPredictor : public BranchPredictor {

/** The Id of the last instruction that update was called on -- used to
* ensure that update is called in program order. */
uint64_t lastUpdatedInstructionId = 0;
[[maybe_unused]] uint64_t lastUpdatedInstructionId_ = 0;
};

} // namespace simeng
4 changes: 2 additions & 2 deletions src/lib/branchpredictors/GenericPredictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ void GenericPredictor::update(uint64_t address, bool isTaken,
uint64_t instructionId) {
// Make sure that this function is called in program order; and then update
// the lastUpdatedInstructionId variable
assert(instructionId >= lastUpdatedInstructionId &&
(lastUpdatedInstructionId = instructionId) >= 0 &&
assert(instructionId >= lastUpdatedInstructionId_ &&
(lastUpdatedInstructionId_ = instructionId) >= 0 &&
"Update not called on branch instructions in program order");

// Get previous prediction and index calculated from the FTQ
Expand Down
9 changes: 3 additions & 6 deletions src/lib/branchpredictors/PerceptronPredictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ void PerceptronPredictor::update(uint64_t address, bool isTaken,
uint64_t instructionId) {
// Make sure that this function is called in program order; and then update
// the lastUpdatedInstructionId variable
assert(instructionId >= lastUpdatedInstructionId &&
(lastUpdatedInstructionId = instructionId) >= 0 &&
assert(instructionId >= lastUpdatedInstructionId_ &&
(lastUpdatedInstructionId_ = instructionId) >= 0 &&
"Update not called on branch instructions in program order");

// Retrieve the previous global history and branch direction prediction from
Expand All @@ -126,11 +126,8 @@ void PerceptronPredictor::update(uint64_t address, bool isTaken,
// Update the perceptron if the prediction was wrong, or the dot product's
// magnitude was not greater than the training threshold
if ((directionPrediction != isTaken) ||
(abs(prevPout) < trainingThreshold_)) {
(static_cast<uint64_t>(std::abs(prevPout)) < trainingThreshold_)) {
int8_t t = (isTaken) ? 1 : -1;
if ((directionPrediction != taken) ||
(static_cast<uint64_t>(std::abs(Pout)) < trainingThreshold_)) {
int8_t t = (taken) ? 1 : -1;

for (uint64_t i = 0; i < globalHistoryLength_; i++) {
int8_t xi =
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pipeline/FetchUnit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void FetchUnit::tick() {
// Set prediction to recorded value during loop buffer filling
if (macroOp[0]->isBranch()) {
macroOp[0]->setBranchPrediction(loopBuffer_.front().prediction);
BranchPrediction pred = branchPredictor_.predict(
[[maybe_unused]] BranchPrediction pred = branchPredictor_.predict(
macroOp[0]->getInstructionAddress(), macroOp[0]->getBranchType(),
macroOp[0]->getKnownOffset());
assert(pred.isTaken == loopBuffer_.front().prediction.isTaken &&
Expand Down

0 comments on commit c1a78c7

Please sign in to comment.