cpu: Fix bi-mode branch predictor thresholds
[gem5.git] / src / cpu / pred / tournament.hh
index 82a1daa64dea630c4036bf49ac3626100c490f08..c4c09268791583c4637fe510f77cbbe12ed8ac5f 100644 (file)
@@ -57,9 +57,8 @@
  * used in the 21264.  It has a local predictor, which uses a local history
  * table to index into a table of counters, and a global predictor, which
  * uses a global history to index into a table of counters.  A choice
- * predictor chooses between the two.  Only the global history register
- * is speculatively updated, the rest are updated upon branches committing
- * or misspeculating.
+ * predictor chooses between the two.  Both the global history register
+ * and the selected local history are speculatively updated.
  */
 class TournamentBP : public BPredUnit
 {
@@ -77,7 +76,7 @@ class TournamentBP : public BPredUnit
      * @param bp_history Pointer that will be set to the BPHistory object.
      * @return Whether or not the branch is taken.
      */
-    bool lookup(Addr branch_addr, void * &bp_history);
+    bool lookup(ThreadID tid, Addr branch_addr, void * &bp_history);
 
     /**
      * Records that there was an unconditional branch, and modifies
@@ -85,7 +84,7 @@ class TournamentBP : public BPredUnit
      * global history stored in it.
      * @param bp_history Pointer that will be set to the BPHistory object.
      */
-    void uncondBranch(Addr pc, void * &bp_history);
+    void uncondBranch(ThreadID tid, Addr pc, void * &bp_history);
     /**
      * Updates the branch predictor to Not Taken if a BTB entry is
      * invalid or not found.
@@ -93,7 +92,7 @@ class TournamentBP : public BPredUnit
      * @param bp_history Pointer to any bp history state.
      * @return Whether or not the branch is taken.
      */
-    void btbUpdate(Addr branch_addr, void * &bp_history);
+    void btbUpdate(ThreadID tid, Addr branch_addr, void * &bp_history);
     /**
      * Updates the branch predictor with the actual result of a branch.
      * @param branch_addr The address of the branch to update.
@@ -103,21 +102,17 @@ class TournamentBP : public BPredUnit
      * @param squashed is set when this function is called during a squash
      * operation.
      */
-    void update(Addr branch_addr, bool taken, void *bp_history, bool squashed);
-
-    void retireSquashed(void *bp_history);
+    void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history,
+                bool squashed);
 
     /**
      * Restores the global branch history on a squash.
      * @param bp_history Pointer to the BPHistory object that has the
      * previous global branch history in it.
      */
-    void squash(void *bp_history);
-
-    unsigned getGHR(void *bp_history) const;
+    void squash(ThreadID tid, void *bp_history);
 
-    /** Returns the global history. */
-    inline unsigned readGlobalHist() { return globalHistory; }
+    unsigned getGHR(ThreadID tid, void *bp_history) const;
 
   private:
     /**
@@ -134,10 +129,10 @@ class TournamentBP : public BPredUnit
     inline unsigned calcLocHistIdx(Addr &branch_addr);
 
     /** Updates global history as taken. */
-    inline void updateGlobalHistTaken();
+    inline void updateGlobalHistTaken(ThreadID tid);
 
     /** Updates global history as not taken. */
-    inline void updateGlobalHistNotTaken();
+    inline void updateGlobalHistNotTaken(ThreadID tid);
 
     /**
      * Updates local histories as taken.
@@ -211,7 +206,7 @@ class TournamentBP : public BPredUnit
     /** Global history register. Contains as much history as specified by
      *  globalHistoryBits. Actual number of bits used is determined by
      *  globalHistoryMask and choiceHistoryMask. */
-    unsigned globalHistory;
+    std::vector<unsigned> globalHistory;
 
     /** Number of bits for the global history. Determines maximum number of
         entries in global and choice predictor tables. */