From 47877cf2dbd6ee2f1cf9b2c609d37b0589e876ca Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 26 May 2009 09:23:13 -0700 Subject: types: add a type for thread IDs and try to use it everywhere --- src/cpu/o3/inst_queue_impl.hh | 81 +++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 41 deletions(-) (limited to 'src/cpu/o3/inst_queue_impl.hh') diff --git a/src/cpu/o3/inst_queue_impl.hh b/src/cpu/o3/inst_queue_impl.hh index 1d0f4b9f6..b6d1ec8b0 100644 --- a/src/cpu/o3/inst_queue_impl.hh +++ b/src/cpu/o3/inst_queue_impl.hh @@ -35,9 +35,10 @@ #include "cpu/o3/fu_pool.hh" #include "cpu/o3/inst_queue.hh" #include "enums/OpClass.hh" +#include "params/DerivO3CPU.hh" #include "sim/core.hh" -#include "params/DerivO3CPU.hh" +using namespace std; template InstructionQueue::FUCompletion::FUCompletion(DynInstPtr &_inst, @@ -93,9 +94,9 @@ InstructionQueue::InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr, regScoreboard.resize(numPhysRegs); //Initialize Mem Dependence Units - for (int i = 0; i < numThreads; i++) { - memDepUnit[i].init(params,i); - memDepUnit[i].setIQ(this); + for (ThreadID tid = 0; tid < numThreads; tid++) { + memDepUnit[tid].init(params, tid); + memDepUnit[tid].setIQ(this); } resetState(); @@ -111,8 +112,8 @@ InstructionQueue::InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr, iqPolicy = Dynamic; //Set Max Entries to Total ROB Capacity - for (int i = 0; i < numThreads; i++) { - maxEntries[i] = numEntries; + for (ThreadID tid = 0; tid < numThreads; tid++) { + maxEntries[tid] = numEntries; } } else if (policy == "partitioned") { @@ -122,8 +123,8 @@ InstructionQueue::InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr, int part_amt = numEntries / numThreads; //Divide ROB up evenly - for (int i = 0; i < numThreads; i++) { - maxEntries[i] = part_amt; + for (ThreadID tid = 0; tid < numThreads; tid++) { + maxEntries[tid] = part_amt; } DPRINTF(IQ, "IQ sharing policy set to Partitioned:" @@ -136,8 +137,8 @@ InstructionQueue::InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr, int thresholdIQ = (int)((double)threshold * numEntries); //Divide up by threshold amount - for (int i = 0; i < numThreads; i++) { - maxEntries[i] = thresholdIQ; + for (ThreadID tid = 0; tid < numThreads; tid++) { + maxEntries[tid] = thresholdIQ; } DPRINTF(IQ, "IQ sharing policy set to Threshold:" @@ -315,9 +316,9 @@ InstructionQueue::regStats() ; fuBusyRate = fuBusy / iqInstsIssued; - for ( int i=0; i < numThreads; i++) { + for (ThreadID tid = 0; tid < numThreads; tid++) { // Tell mem dependence unit to reg stats as well. - memDepUnit[i].regStats(); + memDepUnit[tid].regStats(); } } @@ -326,9 +327,9 @@ void InstructionQueue::resetState() { //Initialize thread IQ counts - for (int i = 0; i ::resetState() regScoreboard[i] = false; } - for (int i = 0; i < numThreads; ++i) { - squashedSeqNum[i] = 0; + for (ThreadID tid = 0; tid < numThreads; ++tid) { + squashedSeqNum[tid] = 0; } for (int i = 0; i < Num_OpClasses; ++i) { @@ -359,7 +360,7 @@ InstructionQueue::resetState() template void -InstructionQueue::setActiveThreads(std::list *at_ptr) +InstructionQueue::setActiveThreads(list *at_ptr) { activeThreads = at_ptr; } @@ -395,8 +396,8 @@ InstructionQueue::switchOut() dependGraph.reset(); instsToExecute.clear(); switchedOut = true; - for (int i = 0; i < numThreads; ++i) { - memDepUnit[i].switchOut(); + for (ThreadID tid = 0; tid < numThreads; ++tid) { + memDepUnit[tid].switchOut(); } } @@ -409,7 +410,7 @@ InstructionQueue::takeOverFrom() template int -InstructionQueue::entryAmount(int num_threads) +InstructionQueue::entryAmount(ThreadID num_threads) { if (iqPolicy == Partitioned) { return numEntries / num_threads; @@ -426,11 +427,11 @@ InstructionQueue::resetEntries() if (iqPolicy != Dynamic || numThreads > 1) { int active_threads = activeThreads->size(); - std::list::iterator threads = activeThreads->begin(); - std::list::iterator end = activeThreads->end(); + list::iterator threads = activeThreads->begin(); + list::iterator end = activeThreads->end(); while (threads != end) { - unsigned tid = *threads++; + ThreadID tid = *threads++; if (iqPolicy == Partitioned) { maxEntries[tid] = numEntries / active_threads; @@ -450,7 +451,7 @@ InstructionQueue::numFreeEntries() template unsigned -InstructionQueue::numFreeEntries(unsigned tid) +InstructionQueue::numFreeEntries(ThreadID tid) { return maxEntries[tid] - count[tid]; } @@ -470,7 +471,7 @@ InstructionQueue::isFull() template bool -InstructionQueue::isFull(unsigned tid) +InstructionQueue::isFull(ThreadID tid) { if (numFreeEntries(tid) == 0) { return(true); @@ -726,7 +727,7 @@ InstructionQueue::scheduleReadyInsts() int idx = -2; int op_latency = 1; - int tid = issuing_inst->threadNumber; + ThreadID tid = issuing_inst->threadNumber; if (op_class != No_OpClass) { idx = fuPool->getUnit(op_class); @@ -825,7 +826,7 @@ InstructionQueue::scheduleNonSpec(const InstSeqNum &inst) assert(inst_it != nonSpecInsts.end()); - unsigned tid = (*inst_it).second->threadNumber; + ThreadID tid = (*inst_it).second->threadNumber; (*inst_it).second->setAtCommit(); @@ -844,7 +845,7 @@ InstructionQueue::scheduleNonSpec(const InstSeqNum &inst) template void -InstructionQueue::commit(const InstSeqNum &inst, unsigned tid) +InstructionQueue::commit(const InstSeqNum &inst, ThreadID tid) { DPRINTF(IQ, "[tid:%i]: Committing instructions older than [sn:%i]\n", tid,inst); @@ -976,7 +977,7 @@ template void InstructionQueue::completeMemInst(DynInstPtr &completed_inst) { - int tid = completed_inst->threadNumber; + ThreadID tid = completed_inst->threadNumber; DPRINTF(IQ, "Completing mem instruction PC:%#x [sn:%lli]\n", completed_inst->readPC(), completed_inst->seqNum); @@ -999,7 +1000,7 @@ InstructionQueue::violation(DynInstPtr &store, template void -InstructionQueue::squash(unsigned tid) +InstructionQueue::squash(ThreadID tid) { DPRINTF(IQ, "[tid:%i]: Starting to squash instructions in " "the IQ.\n", tid); @@ -1019,7 +1020,7 @@ InstructionQueue::squash(unsigned tid) template void -InstructionQueue::doSquash(unsigned tid) +InstructionQueue::doSquash(ThreadID tid) { // Start at the tail. ListIt squash_it = instList[tid].end(); @@ -1253,10 +1254,10 @@ InstructionQueue::countInsts() // Change the #if if you want to use this method. int total_insts = 0; - for (int i = 0; i < numThreads; ++i) { - ListIt count_it = instList[i].begin(); + for (ThreadID tid = 0; tid < numThreads; ++tid) { + ListIt count_it = instList[tid].begin(); - while (count_it != instList[i].end()) { + while (count_it != instList[tid].end()) { if (!(*count_it)->isSquashed() && !(*count_it)->isSquashedInIQ()) { if (!(*count_it)->isIssued()) { ++total_insts; @@ -1325,15 +1326,13 @@ template void InstructionQueue::dumpInsts() { - for (int i = 0; i < numThreads; ++i) { + for (ThreadID tid = 0; tid < numThreads; ++tid) { int num = 0; int valid_num = 0; - ListIt inst_list_it = instList[i].begin(); + ListIt inst_list_it = instList[tid].begin(); - while (inst_list_it != instList[i].end()) - { - cprintf("Instruction:%i\n", - num); + while (inst_list_it != instList[tid].end()) { + cprintf("Instruction:%i\n", num); if (!(*inst_list_it)->isSquashed()) { if (!(*inst_list_it)->isIssued()) { ++valid_num; -- cgit v1.2.3