From 9aecfb3e3bfe1b85db9468bad287f22a2eb9bd4e Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 20 Dec 2006 22:20:11 -0800 Subject: [PATCH] don't use (*activeThreads).begin(), use activeThreads->blah(). Also don't call (*activeThreads).end() over and over. Just call activeThreads->end() once and save the result. Make sure we always check that there are elements in the list before we grab the first one. --HG-- extra : convert_revision : d769d8ed52da99532d57a9bbc93e92ddf22b7e58 --- src/cpu/o3/commit_impl.hh | 50 ++++++----- src/cpu/o3/decode_impl.hh | 22 ++--- src/cpu/o3/fetch_impl.hh | 33 +++++--- src/cpu/o3/iew_impl.hh | 40 +++++---- src/cpu/o3/inst_queue_impl.hh | 14 ++-- src/cpu/o3/lsq_impl.hh | 138 +++++++++++++++++++------------ src/cpu/o3/rename_impl.hh | 25 +++--- src/cpu/o3/rename_map.cc | 5 ++ src/cpu/o3/rob_impl.hh | 37 +++++---- src/cpu/ozone/inst_queue_impl.hh | 16 ++-- 10 files changed, 226 insertions(+), 154 deletions(-) diff --git a/src/cpu/o3/commit_impl.hh b/src/cpu/o3/commit_impl.hh index f400d757b..d8236f077 100644 --- a/src/cpu/o3/commit_impl.hh +++ b/src/cpu/o3/commit_impl.hh @@ -387,9 +387,12 @@ void DefaultCommit::updateStatus() { // reset ROB changed variable - std::list::iterator threads = (*activeThreads).begin(); - while (threads != (*activeThreads).end()) { + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { unsigned tid = *threads++; + changedROBNumEntries[tid] = false; // Also check if any of the threads has a trap pending @@ -416,9 +419,10 @@ DefaultCommit::setNextStatus() { int squashes = 0; - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; if (commitStatus[tid] == ROBSquashing) { @@ -439,9 +443,10 @@ template bool DefaultCommit::changedROBEntries() { - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; if (changedROBNumEntries[tid]) { @@ -563,14 +568,15 @@ DefaultCommit::tick() return; } - if ((*activeThreads).size() <= 0) + if (activeThreads->empty()) return; - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); // Check if any of the threads are done squashing. Change the // status if they are done. - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; if (commitStatus[tid] == ROBSquashing) { @@ -591,9 +597,9 @@ DefaultCommit::tick() markCompletedInsts(); - threads = (*activeThreads).begin(); + threads = activeThreads->begin(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; if (!rob->isEmpty(tid) && rob->readHeadInst(tid)->readyToCommit()) { @@ -691,9 +697,10 @@ DefaultCommit::commit() //////////////////////////////////// // Check for any possible squashes, handle them first //////////////////////////////////// - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; // Not sure which one takes priority. I think if we have @@ -812,9 +819,9 @@ DefaultCommit::commit() } //Check for any activity - threads = (*activeThreads).begin(); + threads = activeThreads->begin(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; if (changedROBNumEntries[tid]) { @@ -1264,9 +1271,10 @@ template bool DefaultCommit::robDoneSquashing() { - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; if (!rob->isDoneSquashing(tid)) @@ -1345,7 +1353,8 @@ DefaultCommit::getCommittingThread() return -1; } } else { - int tid = (*activeThreads).front(); + assert(!activeThreads->empty()); + int tid = activeThreads->front(); if (commitStatus[tid] == Running || commitStatus[tid] == Idle || @@ -1392,9 +1401,10 @@ DefaultCommit::oldestReady() unsigned oldest = 0; bool first = true; - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; if (!rob->isEmpty(tid) && diff --git a/src/cpu/o3/decode_impl.hh b/src/cpu/o3/decode_impl.hh index 80b6cc4c9..26ed40c67 100644 --- a/src/cpu/o3/decode_impl.hh +++ b/src/cpu/o3/decode_impl.hh @@ -424,10 +424,12 @@ template bool DefaultDecode::skidsEmpty() { - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { - if (!skidBuffer[*threads++].empty()) + while (threads != end) { + unsigned tid = *threads++; + if (!skidBuffer[tid].empty()) return false; } @@ -440,11 +442,10 @@ DefaultDecode::updateStatus() { bool any_unblocking = false; - std::list::iterator threads = (*activeThreads).begin(); - - threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; if (decodeStatus[tid] == Unblocking) { @@ -597,13 +598,14 @@ DefaultDecode::tick() toRenameIndex = 0; - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); sortInsts(); //Check stall and squash signals. - while (threads != (*activeThreads).end()) { - unsigned tid = *threads++; + while (threads != end) { + unsigned tid = *threads++; DPRINTF(Decode,"Processing [tid:%i]\n",tid); status_change = checkSignalsAndUpdate(tid) || status_change; diff --git a/src/cpu/o3/fetch_impl.hh b/src/cpu/o3/fetch_impl.hh index 622259495..fe320fa79 100644 --- a/src/cpu/o3/fetch_impl.hh +++ b/src/cpu/o3/fetch_impl.hh @@ -756,10 +756,10 @@ typename DefaultFetch::FetchStatus DefaultFetch::updateFetchStatus() { //Check Running - std::list::iterator threads = (*activeThreads).begin(); - - while (threads != (*activeThreads).end()) { + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + while (threads != end) { unsigned tid = *threads++; if (fetchStatus[tid] == Running || @@ -819,12 +819,13 @@ template void DefaultFetch::tick() { - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); bool status_change = false; wroteToTimeBuffer = false; - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; // Check the signals for each thread to determine the proper status @@ -1363,7 +1364,9 @@ DefaultFetch::getFetchingThread(FetchPriority &fetch_priority) return -1; } } else { - int tid = *((*activeThreads).begin()); + std::list::iterator thread = activeThreads->begin(); + assert(thread != activeThreads->end()); + int tid = *thread; if (fetchStatus[tid] == Running || fetchStatus[tid] == IcacheAccessComplete || @@ -1413,9 +1416,10 @@ DefaultFetch::iqCount() { std::priority_queue PQ; - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; PQ.push(fromIEW->iewInfo[tid].iqCount); @@ -1443,10 +1447,10 @@ DefaultFetch::lsqCount() { std::priority_queue PQ; + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - std::list::iterator threads = (*activeThreads).begin(); - - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; PQ.push(fromIEW->iewInfo[tid].ldstqCount); @@ -1472,7 +1476,10 @@ template int DefaultFetch::branchCount() { - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator thread = activeThreads->begin(); + assert(thread != activeThreads->end()); + unsigned tid = *thread; + panic("Branch Count Fetch policy unimplemented\n"); - return *threads; + return 0 * tid; } diff --git a/src/cpu/o3/iew_impl.hh b/src/cpu/o3/iew_impl.hh index 76047b295..d239bd951 100644 --- a/src/cpu/o3/iew_impl.hh +++ b/src/cpu/o3/iew_impl.hh @@ -671,10 +671,12 @@ DefaultIEW::skidCount() { int max=0; - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { - unsigned thread_count = skidBuffer[*threads++].size(); + while (threads != end) { + unsigned tid = *threads++; + unsigned thread_count = skidBuffer[tid].size(); if (max < thread_count) max = thread_count; } @@ -686,10 +688,13 @@ template bool DefaultIEW::skidsEmpty() { - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (threads != (*activeThreads).end()) { - if (!skidBuffer[*threads++].empty()) + if (!skidBuffer[tid].empty()) return false; } @@ -702,11 +707,10 @@ DefaultIEW::updateStatus() { bool any_unblocking = false; - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - threads = (*activeThreads).begin(); - - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; if (dispatchStatus[tid] == Unblocking) { @@ -1226,9 +1230,10 @@ DefaultIEW::executeInsts() wbNumInst = 0; wbCycle = 0; - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; fetchRedirect[tid] = false; } @@ -1469,11 +1474,12 @@ DefaultIEW::tick() // Free function units marked as being freed this cycle. fuPool->processFreeUnits(); - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); // Check stall and squash signals, dispatch any instructions. - while (threads != (*activeThreads).end()) { - unsigned tid = *threads++; + while (threads != end) { + unsigned tid = *threads++; DPRINTF(IEW,"Issue: Processing [tid:%i]\n",tid); @@ -1513,8 +1519,8 @@ DefaultIEW::tick() // nonspeculative instruction. // This is pretty inefficient... - threads = (*activeThreads).begin(); - while (threads != (*activeThreads).end()) { + threads = activeThreads->begin(); + while (threads != end) { unsigned tid = (*threads++); DPRINTF(IEW,"Processing [tid:%i]\n",tid); diff --git a/src/cpu/o3/inst_queue_impl.hh b/src/cpu/o3/inst_queue_impl.hh index 6edb528a9..98b8fa900 100644 --- a/src/cpu/o3/inst_queue_impl.hh +++ b/src/cpu/o3/inst_queue_impl.hh @@ -426,16 +426,18 @@ void InstructionQueue::resetEntries() { if (iqPolicy != Dynamic || numThreads > 1) { - int active_threads = (*activeThreads).size(); + int active_threads = activeThreads->size(); - std::list::iterator threads = (*activeThreads).begin(); - std::list::iterator list_end = (*activeThreads).end(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (threads != list_end) { if (iqPolicy == Partitioned) { - maxEntries[*threads++] = numEntries / active_threads; + maxEntries[tid] = numEntries / active_threads; } else if(iqPolicy == Threshold && active_threads == 1) { - maxEntries[*threads++] = numEntries; + maxEntries[tid] = numEntries; } } } diff --git a/src/cpu/o3/lsq_impl.hh b/src/cpu/o3/lsq_impl.hh index 6758e51c8..cb40d552e 100644 --- a/src/cpu/o3/lsq_impl.hh +++ b/src/cpu/o3/lsq_impl.hh @@ -244,10 +244,7 @@ void LSQ::resetEntries() { if (lsqPolicy != Dynamic || numThreads > 1) { - int active_threads = (*activeThreads).size(); - - std::list::iterator threads = (*activeThreads).begin(); - std::list::iterator list_end = (*activeThreads).end(); + int active_threads = activeThreads->size(); int maxEntries; @@ -259,8 +256,13 @@ LSQ::resetEntries() maxEntries = LQEntries; } - while (threads != list_end) { - resizeEntries(maxEntries,*threads++); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; + + resizeEntries(maxEntries, tid); } } } @@ -285,10 +287,11 @@ template void LSQ::tick() { - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; + while (threads != end) { + unsigned tid = *threads++; thread[tid].tick(); } @@ -334,10 +337,11 @@ template void LSQ::writebackStores() { - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; + while (threads != end) { + unsigned tid = *threads++; if (numStoresToWB(tid) > 0) { DPRINTF(Writeback,"[tid:%i] Writing back stores. %i stores " @@ -353,10 +357,12 @@ bool LSQ::violation() { /* Answers: Does Anybody Have a Violation?*/ - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; if (thread[tid].violation()) return true; } @@ -370,10 +376,12 @@ LSQ::getCount() { unsigned total = 0; - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; total += getCount(tid); } @@ -386,10 +394,12 @@ LSQ::numLoads() { unsigned total = 0; - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; total += numLoads(tid); } @@ -402,10 +412,12 @@ LSQ::numStores() { unsigned total = 0; - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; total += thread[tid].numStores(); } @@ -418,10 +430,12 @@ LSQ::numLoadsReady() { unsigned total = 0; - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; total += thread[tid].numLoadsReady(); } @@ -434,10 +448,12 @@ LSQ::numFreeEntries() { unsigned total = 0; - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; total += thread[tid].numFreeEntries(); } @@ -458,11 +474,13 @@ template bool LSQ::isFull() { - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; - if (! (thread[tid].lqFull() || thread[tid].sqFull()) ) + while (threads != end) { + unsigned tid = *threads++; + + if (!(thread[tid].lqFull() || thread[tid].sqFull())) return false; } @@ -475,7 +493,7 @@ LSQ::isFull(unsigned tid) { //@todo: Change to Calculate All Entries for //Dynamic Policy - if( lsqPolicy == Dynamic ) + if (lsqPolicy == Dynamic) return isFull(); else return thread[tid].lqFull() || thread[tid].sqFull(); @@ -485,10 +503,12 @@ template bool LSQ::lqFull() { - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; if (!thread[tid].lqFull()) return false; } @@ -512,10 +532,12 @@ template bool LSQ::sqFull() { - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; if (!sqFull(tid)) return false; } @@ -539,10 +561,12 @@ template bool LSQ::isStalled() { - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; if (!thread[tid].isStalled()) return false; } @@ -564,13 +588,15 @@ template bool LSQ::hasStoresToWB() { - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - if ((*activeThreads).empty()) + if (threads == end) return false; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; + while (threads != end) { + unsigned tid = *threads++; + if (!hasStoresToWB(tid)) return false; } @@ -582,10 +608,12 @@ template bool LSQ::willWB() { - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; if (!willWB(tid)) return false; } @@ -597,10 +625,12 @@ template void LSQ::dumpInsts() { - std::list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; thread[tid].dumpInsts(); } } diff --git a/src/cpu/o3/rename_impl.hh b/src/cpu/o3/rename_impl.hh index 248d7deb6..3a8e503a0 100644 --- a/src/cpu/o3/rename_impl.hh +++ b/src/cpu/o3/rename_impl.hh @@ -412,10 +412,11 @@ DefaultRename::tick() sortInsts(); - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); // Check stall and squash signals. - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; DPRINTF(Rename, "Processing [tid:%i]\n", tid); @@ -434,9 +435,9 @@ DefaultRename::tick() cpu->activityThisCycle(); } - threads = (*activeThreads).begin(); + threads = activeThreads->begin(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; // If we committed this cycle then doneSeqNum will be > 0 @@ -764,10 +765,13 @@ template bool DefaultRename::skidsEmpty() { - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { - if (!skidBuffer[*threads++].empty()) + while (threads != end) { + unsigned tid = *threads++; + + if (!skidBuffer[tid].empty()) return false; } @@ -780,11 +784,10 @@ DefaultRename::updateStatus() { bool any_unblocking = false; - std::list::iterator threads = (*activeThreads).begin(); - - threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; if (renameStatus[tid] == Unblocking) { diff --git a/src/cpu/o3/rename_map.cc b/src/cpu/o3/rename_map.cc index befbc3e8a..620daf691 100644 --- a/src/cpu/o3/rename_map.cc +++ b/src/cpu/o3/rename_map.cc @@ -180,6 +180,8 @@ SimpleRenameMap::rename(RegIndex arch_reg) // Subtract off the base offset for miscellaneous registers. arch_reg = arch_reg - numLogicalRegs; + DPRINTF(Rename, "Renamed misc reg %d\n", arch_reg); + // No renaming happens to the misc. registers. They are // simply the registers that come after all the physical // registers; thus take the base architected register and add @@ -194,6 +196,9 @@ SimpleRenameMap::rename(RegIndex arch_reg) assert(renamed_reg < numPhysicalRegs + numMiscRegs); } + DPRINTF(Rename, "Renamed reg %d to physical reg %d old mapping was %d\n", + arch_reg, renamed_reg, prev_reg); + return RenameInfo(renamed_reg, prev_reg); } diff --git a/src/cpu/o3/rob_impl.hh b/src/cpu/o3/rob_impl.hh index fab114a74..fde636754 100644 --- a/src/cpu/o3/rob_impl.hh +++ b/src/cpu/o3/rob_impl.hh @@ -155,16 +155,18 @@ void ROB::resetEntries() { if (robPolicy != Dynamic || numThreads > 1) { - int active_threads = (*activeThreads).size(); + int active_threads = activeThreads->size(); - std::list::iterator threads = (*activeThreads).begin(); - std::list::iterator list_end = (*activeThreads).end(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (threads != list_end) { if (robPolicy == Partitioned) { - maxEntries[*threads++] = numEntries / active_threads; + maxEntries[tid] = numEntries / active_threads; } else if (robPolicy == Threshold && active_threads == 1) { - maxEntries[*threads++] = numEntries; + maxEntries[tid] = numEntries; } } } @@ -318,9 +320,10 @@ bool ROB::canCommit() { //@todo: set ActiveThreads through ROB or CPU - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; if (isHeadReady(tid)) { @@ -432,22 +435,23 @@ ROB::updateHead() bool first_valid = true; // @todo: set ActiveThreads through ROB or CPU - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { - unsigned thread_num = *threads++; + while (threads != end) { + unsigned tid = *threads++; - if (instList[thread_num].empty()) + if (instList[tid].empty()) continue; if (first_valid) { - head = instList[thread_num].begin(); + head = instList[tid].begin(); lowest_num = (*head)->seqNum; first_valid = false; continue; } - InstIt head_thread = instList[thread_num].begin(); + InstIt head_thread = instList[tid].begin(); DynInstPtr head_inst = (*head_thread); @@ -472,9 +476,10 @@ ROB::updateTail() tail = instList[0].end(); bool first_valid = true; - std::list::iterator threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); - while (threads != (*activeThreads).end()) { + while (threads != end) { unsigned tid = *threads++; if (instList[tid].empty()) { diff --git a/src/cpu/ozone/inst_queue_impl.hh b/src/cpu/ozone/inst_queue_impl.hh index 32a940241..84f2b2a19 100644 --- a/src/cpu/ozone/inst_queue_impl.hh +++ b/src/cpu/ozone/inst_queue_impl.hh @@ -342,16 +342,18 @@ void InstQueue::resetEntries() { if (iqPolicy != Dynamic || numThreads > 1) { - int active_threads = (*activeThreads).size(); + int active_threads = activeThreads->size(); - list::iterator threads = (*activeThreads).begin(); - list::iterator list_end = (*activeThreads).end(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + while (threads != end) { + unsigned tid = *threads++; - while (threads != list_end) { if (iqPolicy == Partitioned) { - maxEntries[*threads++] = numEntries / active_threads; - } else if(iqPolicy == Threshold && active_threads == 1) { - maxEntries[*threads++] = numEntries; + maxEntries[tid] = numEntries / active_threads; + } else if (iqPolicy == Threshold && active_threads == 1) { + maxEntries[tid] = numEntries; } } } -- 2.30.2