X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fcpu%2Fo3%2Flsq_impl.hh;h=fb738f7c9f64a8d6d93ba5fdba4ab9f8d9c7a205;hb=ba191d85c274934142430c1522a10ecdbc78d4f6;hp=27aa0dc3c66ae8bd004aae3c229f97eb067c0969;hpb=3c95f5958fd1a90cf83d85e1b24fb700c07bae91;p=gem5.git diff --git a/src/cpu/o3/lsq_impl.hh b/src/cpu/o3/lsq_impl.hh index 27aa0dc3c..fb738f7c9 100644 --- a/src/cpu/o3/lsq_impl.hh +++ b/src/cpu/o3/lsq_impl.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2006 The Regents of The University of Michigan + * Copyright (c) 2005-2006 The Regents of The University of Michigan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,23 +29,84 @@ */ #include +#include #include #include "cpu/o3/lsq.hh" -using namespace std; +template +Tick +LSQ::DcachePort::recvAtomic(PacketPtr pkt) +{ + panic("O3CPU model does not work with atomic mode!"); + return curTick; +} + +template +void +LSQ::DcachePort::recvFunctional(PacketPtr pkt) +{ + DPRINTF(LSQ, "LSQ doesn't update things on a recvFunctional."); +} + +template +void +LSQ::DcachePort::recvStatusChange(Status status) +{ + if (status == RangeChange) { + if (!snoopRangeSent) { + snoopRangeSent = true; + sendStatusChange(Port::RangeChange); + } + return; + } + panic("O3CPU doesn't expect recvStatusChange callback!"); +} + +template +bool +LSQ::DcachePort::recvTiming(PacketPtr pkt) +{ + if (pkt->isResponse()) { + lsq->thread[pkt->req->getThreadNum()].completeDataAccess(pkt); + } + else { + //else it is a coherence request, maybe you need to do something + warn("Recieved a coherence request (Invalidate?), 03CPU doesn't" + "update LSQ for these\n"); + } + return true; +} + +template +void +LSQ::DcachePort::recvRetry() +{ + if (lsq->retryTid == -1) + { + //Squashed, so drop it + return; + } + lsq->thread[lsq->retryTid].recvRetry(); + // Speculatively clear the retry Tid. This will get set again if + // the LSQUnit was unable to complete its access. + lsq->retryTid = -1; +} template LSQ::LSQ(Params *params) - : LQEntries(params->LQEntries), SQEntries(params->SQEntries), - numThreads(params->numberOfThreads) + : dcachePort(this), LQEntries(params->LQEntries), + SQEntries(params->SQEntries), numThreads(params->numberOfThreads), + retryTid(-1) { DPRINTF(LSQ, "Creating LSQ object.\n"); + dcachePort.snoopRangeSent = false; + //**********************************************/ //************ Handle SMT Parameters ***********/ //**********************************************/ - string policy = params->smtLSQPolicy; + std::string policy = params->smtLSQPolicy; //Convert string to lowercase std::transform(policy.begin(), policy.end(), policy.begin(), @@ -94,7 +155,8 @@ LSQ::LSQ(Params *params) //Initialize LSQs for (int tid=0; tid < numThreads; tid++) { - thread[tid].init(params, maxLQEntries, maxSQEntries, tid); + thread[tid].init(params, this, maxLQEntries, maxSQEntries, tid); + thread[tid].setDcachePort(&dcachePort); } } @@ -108,7 +170,17 @@ LSQ::name() const template void -LSQ::setActiveThreads(list *at_ptr) +LSQ::regStats() +{ + //Initialize LSQs + for (int tid=0; tid < numThreads; tid++) { + thread[tid].regStats(); + } +} + +template +void +LSQ::setActiveThreads(std::list *at_ptr) { activeThreads = at_ptr; assert(activeThreads != 0); @@ -116,10 +188,12 @@ LSQ::setActiveThreads(list *at_ptr) template void -LSQ::setCPU(FullCPU *cpu_ptr) +LSQ::setCPU(O3CPU *cpu_ptr) { cpu = cpu_ptr; + dcachePort.setName(name()); + for (int tid=0; tid < numThreads; tid++) { thread[tid].setCPU(cpu_ptr); } @@ -170,10 +244,7 @@ void LSQ::resetEntries() { if (lsqPolicy != Dynamic || numThreads > 1) { - int active_threads = (*activeThreads).size(); - - list::iterator threads = (*activeThreads).begin(); - list::iterator list_end = (*activeThreads).end(); + int active_threads = activeThreads->size(); int maxEntries; @@ -185,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); } } } @@ -211,10 +287,11 @@ template void LSQ::tick() { - 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(); } @@ -260,10 +337,11 @@ template void LSQ::writebackStores() { - 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 " @@ -279,10 +357,12 @@ bool LSQ::violation() { /* Answers: Does Anybody Have a Violation?*/ - 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; } @@ -296,10 +376,12 @@ LSQ::getCount() { unsigned total = 0; - 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); } @@ -312,10 +394,12 @@ LSQ::numLoads() { unsigned total = 0; - 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); } @@ -328,10 +412,12 @@ LSQ::numStores() { unsigned total = 0; - 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(); } @@ -344,10 +430,12 @@ LSQ::numLoadsReady() { unsigned total = 0; - 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(); } @@ -360,10 +448,12 @@ LSQ::numFreeEntries() { unsigned total = 0; - 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(); } @@ -374,7 +464,7 @@ template unsigned LSQ::numFreeEntries(unsigned tid) { - //if( lsqPolicy == Dynamic ) + //if (lsqPolicy == Dynamic) //return numFreeEntries(); //else return thread[tid].numFreeEntries(); @@ -384,11 +474,13 @@ template bool LSQ::isFull() { - 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() || thread[tid].sqFull()) ) + if (!(thread[tid].lqFull() || thread[tid].sqFull())) return false; } @@ -401,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(); @@ -411,10 +503,12 @@ template bool LSQ::lqFull() { - 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; } @@ -428,7 +522,7 @@ LSQ::lqFull(unsigned tid) { //@todo: Change to Calculate All Entries for //Dynamic Policy - if( lsqPolicy == Dynamic ) + if (lsqPolicy == Dynamic) return lqFull(); else return thread[tid].lqFull(); @@ -438,10 +532,12 @@ template bool LSQ::sqFull() { - 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; } @@ -455,7 +551,7 @@ LSQ::sqFull(unsigned tid) { //@todo: Change to Calculate All Entries for //Dynamic Policy - if( lsqPolicy == Dynamic ) + if (lsqPolicy == Dynamic) return sqFull(); else return thread[tid].sqFull(); @@ -465,10 +561,12 @@ template bool LSQ::isStalled() { - 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; } @@ -480,7 +578,7 @@ template bool LSQ::isStalled(unsigned tid) { - if( lsqPolicy == Dynamic ) + if (lsqPolicy == Dynamic) return isStalled(); else return thread[tid].isStalled(); @@ -490,10 +588,15 @@ template bool LSQ::hasStoresToWB() { - list::iterator active_threads = (*activeThreads).begin(); + std::list::iterator threads = activeThreads->begin(); + std::list::iterator end = activeThreads->end(); + + if (threads == end) + return false; + + while (threads != end) { + unsigned tid = *threads++; - while (active_threads != (*activeThreads).end()) { - unsigned tid = *active_threads++; if (!hasStoresToWB(tid)) return false; } @@ -505,10 +608,12 @@ template bool LSQ::willWB() { - 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; } @@ -520,10 +625,12 @@ template void LSQ::dumpInsts() { - 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(); } }