44#include "debug/FTQ.hh"
45#include "params/BaseO3CPU.hh"
89 stats(_cpu, params.numFTQEntries)
106 return cpu->name() +
".ftq";
127 return ftq[tid].size();
139 return ftq[tid].empty();
146 if (!
ftq[tid].empty()) {
172 for (
auto it =
ftq[tid].begin(); it !=
ftq[tid].end(); it++) {
180 for (
auto it =
ftq[tid].rbegin(); it !=
ftq[tid].rend(); it++) {
189 ftq[tid].push_back(fetchTarget);
194 DPRINTF(
FTQ,
"Insert %s in FTQ[T:%i]. size FTQ:%i\n",
195 fetchTarget->toString(), tid,
ftq[tid].size());
201 for (
auto ft :
ftq[tid]) {
202 assert(ft->bpuHistory ==
nullptr);
213 for (
auto ft :
ftq[tid]) {
214 assert(ft->bpuHistory ==
nullptr);
230 if (
ftq[tid].empty()) {
234 return ftq[tid].front();
240 assert(!
ftq[tid].empty());
241 if (
ftq[tid].front()->bpuHistory !=
nullptr) {
242 DPRINTF(
FTQ,
"Pop FT:[fn%llu] failed. Still contains BP history.\n",
243 ftq[tid].front()->ftNum());
255 DPRINTF(
FTQ,
"Pop FT:[fn%llu] unblocks FTQ. Require squash.\n",
256 ftq[tid].front()->ftNum());
262 ftq[tid].pop_front();
271 for (
auto ft :
ftq[tid]) {
272 DPRINTF(
FTQ,
"FTQ[tid:%i][%i]: %s.\n", tid,
i, ft->toString());
280 "The number of FTQ insertions"),
282 "The number of FTQ removals. Not including squashes"),
284 "The number of FTQ squashes"),
286 "The number of times the FTQ got locked."),
288 "Distribution of the FTQ occupation.")
ProbePointArg generates a point for the class of Arg.
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
void insert(ThreadID tid, FetchTargetPtr fetchTarget)
Pushes a fetch target into the back/tail of the FTQ.
void forAllForward(ThreadID tid, std::function< void(FetchTargetPtr &)> f)
Iterates forward over all fetch targets in the FTQ from head/front to tail/back and applies a given f...
const unsigned numEntries
Number of fetch targets in the FTQ.
void resetState(ThreadID tid)
Reset the FTQ state.
ProbePointArg< FetchTargetPtr > * ppFTQInsert
Probe points to attach the FDP prefetcher.
void squash(ThreadID tid)
Squashes all fetch targets in the FTQ for a specific thread.
FTQ(CPU *_cpu, const BaseO3CPUParams ¶ms)
FTQ constructor.
unsigned size(ThreadID tid)
Returns the size of the ftq for a specific partition.
ProbePointArg< FetchTargetPtr > * ppFTQRemove
void regProbePoints()
Registers probes.
FetchTargetPtr readHead(ThreadID tid)
Returns a pointer to the head fetch target of a specific thread within the FTQ.
bool isReady(ThreadID tid)
Returns if the FTQ is in a ready state and its safe to consmume fetch targets.
unsigned numFreeEntries(ThreadID tid)
Returns the number of free entries in a specific FTQ paritition.
bool isLocked(ThreadID tid)
Check if the FTQ is locked.
void invalidate(ThreadID tid)
Invalidates all fetch targets in the FTQ.
void squashSanityCheck(ThreadID tid)
Sanity check to verify that the fetch targets in the ftq do not have a valid bpu_history.
std::array< Status, MaxThreads > ftqStatus
Per-thread FTQ status.
bool isEmpty(ThreadID tid) const
Returns whether or not a specific thread's queue is empty.
bool isHeadReady(ThreadID tid)
Is the head entry ready for the fetch stage to be consumed.
bool popHead(ThreadID tid)
Pops the head fetch target once its fully processed.
CPU * cpu
Pointer to the CPU.
bool isFull(ThreadID tid)
Returns whether or not a specific thread's queue is full.
std::array< std::list< FetchTargetPtr >, MaxThreads > ftq
FTQ List of Fetch targets.
gem5::o3::FTQ::FTQStats stats
void printFTQ(ThreadID tid)
Print the all fetch targets in the FTQ for debugging.
void forAllBackward(ThreadID tid, std::function< void(FetchTargetPtr &)> f)
Iterates backward over all fetch targets in the FTQ from tail/back to head/front and applies a given ...
void lock(ThreadID tid)
Locks the fetch target queue for a given thread.
std::unique_ptr< PCStateBase > predPC
Predicted target address of the fetch target.
bool taken
If the exit branch is predicted taken.
const ThreadID tid
The thread this FT belongs to.
std::unique_ptr< PCStateBase > startPC
Start address of the fetch target.
void finalize(const PCStateBase &exit_pc, bool _is_branch, bool pred_taken, const PCStateBase &pred_pc)
Complete a fetch target with the exit instruction.
FetchTarget(const ThreadID _tid, const PCStateBase &_start_pc, FTSeqNum _seqNum)
Fetch Target Methods -----------------------------—.
std::unique_ptr< PCStateBase > endPC
End address of the fetch target.
std::string toString()
Print the fetch target for debugging.
branch_prediction::BPredUnit::PredictorHistory * bpuHistory
Anchor point to attach a branch predictor history.
bool is_branch
Whether the exit instruction is a branch.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
std::shared_ptr< FetchTarget > FetchTargetPtr
static constexpr int MaxThreads
const FlagsType pdf
Print the percent of the total that this entry represents.
Copyright (c) 2024 Arm Limited All rights reserved.
int16_t ThreadID
Thread index/ID type.
statistics::Distribution occupancy
FTQStats(CPU *cpu, unsigned numFTQEntries)
statistics::Scalar inserts
statistics::Scalar removals
statistics::Scalar squashes