44 #ifndef __CPU_O3_ROB_IMPL_HH__ 45 #define __CPU_O3_ROB_IMPL_HH__ 51 #include "debug/Fetch.hh" 52 #include "debug/ROB.hh" 53 #include "params/DerivO3CPU.hh" 59 : robPolicy(params->smtROBPolicy),
61 numEntries(params->numROBEntries),
62 squashWidth(params->squashWidth),
64 numThreads(params->numThreads)
67 if (
robPolicy == SMTQueuePolicy::Dynamic) {
73 }
else if (
robPolicy == SMTQueuePolicy::Partitioned) {
74 DPRINTF(Fetch,
"ROB sharing policy set to Partitioned\n");
84 }
else if (
robPolicy == SMTQueuePolicy::Threshold) {
85 DPRINTF(Fetch,
"ROB sharing policy set to Threshold\n");
87 int threshold = params->smtROBThreshold;;
102 template <
class Impl>
106 for (
ThreadID tid = 0; tid < Impl::MaxThreads; tid++) {
120 template <
class Impl>
124 return cpu->name() +
".rob";
127 template <
class Impl>
131 DPRINTF(
ROB,
"Setting active threads list pointer.\n");
135 template <
class Impl>
144 template <
class Impl>
151 template <
class Impl>
161 while (threads != end) {
164 if (
robPolicy == SMTQueuePolicy::Partitioned) {
166 }
else if (
robPolicy == SMTQueuePolicy::Threshold &&
167 active_threads == 1) {
174 template <
class Impl>
178 if (
robPolicy == SMTQueuePolicy::Partitioned) {
185 template <
class Impl>
197 template <
class Impl>
204 template <
class Impl>
212 DPRINTF(
ROB,
"Adding inst PC %s to the ROB.\n", inst->pcState());
223 assert((*
head) == inst);
236 assert((*
tail) == inst);
241 template <
class Impl>
255 assert(head_inst->readyToCommit());
257 DPRINTF(
ROB,
"[tid:%i] Retiring head instruction, " 258 "instruction PC %s, [sn:%llu]\n", tid, head_inst->pcState(),
264 head_inst->clearInROB();
265 head_inst->setCommitted();
273 cpu->removeFrontInst(head_inst);
276 template <
class Impl>
282 return instList[tid].front()->readyToCommit();
288 template <
class Impl>
296 while (threads != end) {
307 template <
class Impl>
314 template <
class Impl>
321 template <
class Impl>
326 DPRINTF(
ROB,
"[tid:%i] Squashing instructions until [sn:%llu].\n",
332 DPRINTF(
ROB,
"[tid:%i] Done squashing instructions.\n",
341 bool robTailUpdate =
false;
343 for (
int numSquashed = 0;
349 DPRINTF(
ROB,
"[tid:%i] Squashing instruction PC %s, seq num %i.\n",
362 DPRINTF(
ROB,
"Reached head of instruction list while " 375 if ((*
squashIt[tid]) == (*tail_thread))
376 robTailUpdate =
true;
384 DPRINTF(
ROB,
"[tid:%i] Done squashing instructions.\n",
398 template <
class Impl>
403 bool first_valid =
true;
409 while (threads != end) {
417 lowest_num = (*head)->seqNum;
426 assert(head_inst != 0);
428 if (head_inst->seqNum < lowest_num) {
430 lowest_num = head_inst->seqNum;
440 template <
class Impl>
445 bool first_valid =
true;
450 while (threads != end) {
471 if ((*tail_thread)->seqNum > (*tail)->seqNum) {
478 template <
class Impl>
483 DPRINTF(
ROB,
"Does not need to squash due to being empty " 490 DPRINTF(
ROB,
"Starting to squash within the ROB.\n");
508 template <
class Impl>
509 const typename Impl::DynInstPtr&
515 assert((*head_thread)->isInROB());
523 template <
class Impl>
524 typename Impl::DynInstPtr
533 template <
class Impl>
537 using namespace Stats;
540 .
desc(
"The number of ROB reads");
544 .
desc(
"The number of ROB writes");
547 template <
class Impl>
548 typename Impl::DynInstPtr
552 if ((*it)->seqNum == squash_inst) {
559 #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.