gem5 v24.0.0.0
Loading...
Searching...
No Matches
tournament.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011, 2014 ARM Limited
3 * Copyright (c) 2022-2023 The University of Edinburgh
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
14 *
15 * Copyright (c) 2004-2006 The Regents of The University of Michigan
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41
42#ifndef __CPU_PRED_TOURNAMENT_PRED_HH__
43#define __CPU_PRED_TOURNAMENT_PRED_HH__
44
45#include <vector>
46
47#include "base/sat_counter.hh"
48#include "base/types.hh"
50#include "params/TournamentBP.hh"
51
52namespace gem5
53{
54
55namespace branch_prediction
56{
57
66class TournamentBP : public BPredUnit
67{
68 public:
72 TournamentBP(const TournamentBPParams &params);
73
74 // Base class methods.
75 bool lookup(ThreadID tid, Addr pc, void* &bp_history) override;
76 void updateHistories(ThreadID tid, Addr pc, bool uncond, bool taken,
77 Addr target, void * &bp_history) override;
78 void update(ThreadID tid, Addr pc, bool taken,
79 void * &bp_history, bool squashed,
80 const StaticInstPtr & inst, Addr target) override;
81 void squash(ThreadID tid, void * &bp_history) override;
82
83 private:
89 inline bool getPrediction(uint8_t &count);
90
95 inline unsigned calcLocHistIdx(Addr &branch_addr);
96
100 inline void updateGlobalHist(ThreadID tid, bool taken);
101
108 inline void updateLocalHist(unsigned local_history_idx, bool taken);
109
117 {
118#ifdef GEM5_DEBUG
119 BPHistory()
120 { newCount++; }
121 ~BPHistory()
122 { newCount--; }
123
124 static int newCount;
125#endif
128 unsigned localHistory;
132 };
133
135 static const int invalidPredictorIndex = -1;
138
141
143 unsigned localCtrBits;
144
147
150
153
156
159
162
165
170
174
178
182
186
189
192
195
202};
203
204} // namespace branch_prediction
205} // namespace gem5
206
207#endif // __CPU_PRED_TOURNAMENT_PRED_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition bpred_unit.hh:71
Implements a tournament branch predictor, hopefully identical to the one used in the 21264.
Definition tournament.hh:67
unsigned globalHistoryMask
Mask to apply to globalHistory to access global history table.
std::vector< SatCounter8 > choiceCtrs
Array of counters that make up the choice predictor.
unsigned globalHistoryBits
Number of bits for the global history.
void updateGlobalHist(ThreadID tid, bool taken)
Updates global history with the given direction.
TournamentBP(const TournamentBPParams &params)
Default branch predictor constructor.
Definition tournament.cc:53
bool lookup(ThreadID tid, Addr pc, void *&bp_history) override
Looks up a given conditional branch PC of in the BP to see if it is taken or not taken.
unsigned globalPredictorSize
Number of entries in the global predictor.
std::vector< SatCounter8 > localCtrs
Local counters.
void updateHistories(ThreadID tid, Addr pc, bool uncond, bool taken, Addr target, void *&bp_history) override
Ones done with the prediction this function updates the path and global history.
unsigned localPredictorMask
Mask to truncate values stored in the local history table.
void squash(ThreadID tid, void *&bp_history) override
unsigned historyRegisterMask
Mask to control how much history is stored.
bool getPrediction(uint8_t &count)
Returns if the branch should be taken or not, given a counter value.
void update(ThreadID tid, Addr pc, bool taken, void *&bp_history, bool squashed, const StaticInstPtr &inst, Addr target) override
Updates the BP with taken/not taken information.
static const int invalidPredictorIndex
Flag for invalid predictor index.
unsigned localHistoryBits
Number of bits for each entry of the local history table.
std::vector< unsigned > localHistoryTable
Array of local history table entries.
unsigned localCtrBits
Number of bits of the local predictor's counters.
unsigned localThreshold
Thresholds for the counter value; above the threshold is taken, equal to or below the threshold is no...
unsigned choiceHistoryMask
Mask to apply to globalHistory to access choice history table.
void updateLocalHist(unsigned local_history_idx, bool taken)
Updates local histories.
std::vector< SatCounter8 > globalCtrs
Array of counters that make up the global predictor.
unsigned localPredictorSize
Number of counters in the local predictor.
unsigned calcLocHistIdx(Addr &branch_addr)
Returns the local history index, given a branch address.
std::vector< unsigned > globalHistory
Global history register.
unsigned globalCtrBits
Number of bits of the global predictor's counters.
unsigned choiceCtrBits
Number of bits in the choice predictor's counters.
unsigned localHistoryTableSize
Number of entries in the local history table.
unsigned choicePredictorSize
Number of entries in the choice predictor.
STL vector class.
Definition stl.hh:37
const Params & params() const
Bitfield< 4 > pc
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
int16_t ThreadID
Thread index/ID type.
Definition types.hh:235
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
The branch history information that is created upon predicting a branch.

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0