41 #ifndef __CPU_O3_ROB_IMPL_HH__ 42 #define __CPU_O3_ROB_IMPL_HH__ 48 #include "debug/Fetch.hh" 49 #include "debug/ROB.hh" 50 #include "params/DerivO3CPU.hh" 56 : robPolicy(params->smtROBPolicy),
58 numEntries(params->numROBEntries),
59 squashWidth(params->squashWidth),
61 numThreads(params->numThreads)
64 if (
robPolicy == SMTQueuePolicy::Dynamic) {
70 }
else if (
robPolicy == SMTQueuePolicy::Partitioned) {
71 DPRINTF(Fetch,
"ROB sharing policy set to Partitioned\n");
81 }
else if (
robPolicy == SMTQueuePolicy::Threshold) {
82 DPRINTF(Fetch,
"ROB sharing policy set to Threshold\n");
84 int threshold = params->smtROBThreshold;;
103 for (
ThreadID tid = 0; tid < Impl::MaxThreads; tid++) {
117 template <
class Impl>
121 return cpu->name() +
".rob";
124 template <
class Impl>
128 DPRINTF(
ROB,
"Setting active threads list pointer.\n");
132 template <
class Impl>
141 template <
class Impl>
148 template <
class Impl>
158 while (threads != end) {
161 if (
robPolicy == SMTQueuePolicy::Partitioned) {
163 }
else if (
robPolicy == SMTQueuePolicy::Threshold &&
164 active_threads == 1) {
171 template <
class Impl>
175 if (
robPolicy == SMTQueuePolicy::Partitioned) {
182 template <
class Impl>
194 template <
class Impl>
201 template <
class Impl>
209 DPRINTF(
ROB,
"Adding inst PC %s to the ROB.\n", inst->pcState());
220 assert((*
head) == inst);
233 assert((*
tail) == inst);
238 template <
class Impl>
252 assert(head_inst->readyToCommit());
254 DPRINTF(
ROB,
"[tid:%i] Retiring head instruction, " 255 "instruction PC %s, [sn:%llu]\n", tid, head_inst->pcState(),
261 head_inst->clearInROB();
262 head_inst->setCommitted();
270 cpu->removeFrontInst(head_inst);
273 template <
class Impl>
279 return instList[tid].front()->readyToCommit();
285 template <
class Impl>
293 while (threads != end) {
304 template <
class Impl>
311 template <
class Impl>
318 template <
class Impl>
323 DPRINTF(
ROB,
"[tid:%i] Squashing instructions until [sn:%llu].\n",
329 DPRINTF(
ROB,
"[tid:%i] Done squashing instructions.\n",
338 bool robTailUpdate =
false;
340 for (
int numSquashed = 0;
346 DPRINTF(
ROB,
"[tid:%i] Squashing instruction PC %s, seq num %i.\n",
359 DPRINTF(
ROB,
"Reached head of instruction list while " 372 if ((*
squashIt[tid]) == (*tail_thread))
373 robTailUpdate =
true;
381 DPRINTF(
ROB,
"[tid:%i] Done squashing instructions.\n",
395 template <
class Impl>
400 bool first_valid =
true;
406 while (threads != end) {
414 lowest_num = (*head)->seqNum;
423 assert(head_inst != 0);
425 if (head_inst->seqNum < lowest_num) {
427 lowest_num = head_inst->seqNum;
437 template <
class Impl>
442 bool first_valid =
true;
447 while (threads != end) {
468 if ((*tail_thread)->seqNum > (*tail)->seqNum) {
475 template <
class Impl>
480 DPRINTF(
ROB,
"Does not need to squash due to being empty " 487 DPRINTF(
ROB,
"Starting to squash within the ROB.\n");
505 template <
class Impl>
506 const typename Impl::DynInstPtr&
512 assert((*head_thread)->isInROB());
520 template <
class Impl>
521 typename Impl::DynInstPtr
530 template <
class Impl>
534 using namespace Stats;
537 .
desc(
"The number of ROB reads");
541 .
desc(
"The number of ROB writes");
544 template <
class Impl>
545 typename Impl::DynInstPtr
549 if ((*it)->seqNum == squash_inst) {
556 #endif//__CPU_O3_ROB_IMPL_HH__ void takeOverFrom()
Takes over another CPU's thread.
void drainSanityCheck() const
Perform sanity checks after a drain.
std::list< ThreadID > * activeThreads
Active Threads in CPU.
bool canCommit()
Is there any commitable head instruction across all threads ready.
unsigned threadEntries[Impl::MaxThreads]
Entries Per Thread.
void doSquash(ThreadID tid)
Executes the squash, marking squashed instructions.
void retireHead(ThreadID tid)
Retires the head instruction, removing it from the ROB.
SMTQueuePolicy robPolicy
ROB resource sharing policy for SMT mode.
void resetState()
Reset the ROB state.
int numInstsInROB
Number of instructions in the ROB.
InstIt head
Iterator pointing to the instruction which is the first instruction in in the ROB.
Status robStatus[Impl::MaxThreads]
Per-thread ROB status.
ROB(O3CPU *_cpu, DerivO3CPUParams *params)
ROB constructor.
Overload hash function for BasicBlockRange type.
ThreadID numThreads
Number of active threads.
DynInstPtr findInst(ThreadID tid, InstSeqNum squash_inst)
Returns a pointer to the instruction with the given sequence if it is in the ROB. ...
InstIt tail
Iterator pointing to the instruction which is the last instruction in the ROB.
void updateHead()
Updates the head instruction with the new oldest instruction.
InstSeqNum squashedSeqNum[Impl::MaxThreads]
The sequence number of the squashed instruction.
bool isEmpty() const
Returns if the ROB is empty.
const DynInstPtr & readHeadInst(ThreadID tid)
Returns pointer to the head instruction within the ROB.
DynInstPtr readTailInst(ThreadID tid)
Returns pointer to the tail instruction within the ROB.
Impl::DynInstPtr DynInstPtr
std::list< DynInstPtr >::iterator InstIt
unsigned numFreeEntries()
Returns the number of total free entries in the ROB.
std::list< DynInstPtr > instList[Impl::MaxThreads]
ROB List of Instructions.
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to the list of active threads.
InstIt squashIt[Impl::MaxThreads]
Iterator used for walking through the list of instructions when squashing.
void updateTail()
Updates the tail instruction with the new youngest instruction.
const FlagsType total
Print the total.
void squash(InstSeqNum squash_num, ThreadID tid)
Squashes all instructions younger than the given sequence number for the specific thread...
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
int16_t ThreadID
Thread index/ID type.
void regStats()
Registers statistics.
O3CPU * cpu
Pointer to the CPU.
void resetEntries()
Re-adjust ROB partitioning.
bool isHeadReady(ThreadID tid)
Is the oldest instruction across all threads ready.
bool doneSquashing[Impl::MaxThreads]
Is the ROB done squashing.
int countInsts()
This is more of a debugging function than anything.
unsigned squashWidth
Number of instructions that can be squashed in a single cycle.
DynInstPtr dummyInst
Dummy instruction returned if there are no insts left.
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
unsigned numEntries
Number of instructions in the ROB.
void insertInst(const DynInstPtr &inst)
Function to insert an instruction into the ROB.
int entryAmount(ThreadID num_threads)
Number of entries needed For 'num_threads' amount of threads.
unsigned maxEntries[Impl::MaxThreads]
Max Insts a Thread Can Have in the ROB.