lsq_impl.hh revision 3867
1955SN/A/* 2955SN/A * Copyright (c) 2005-2006 The Regents of The University of Michigan 35871Snate@binkert.org * All rights reserved. 41762SN/A * 5955SN/A * Redistribution and use in source and binary forms, with or without 6955SN/A * modification, are permitted provided that the following conditions are 7955SN/A * met: redistributions of source code must retain the above copyright 8955SN/A * notice, this list of conditions and the following disclaimer; 9955SN/A * redistributions in binary form must reproduce the above copyright 10955SN/A * notice, this list of conditions and the following disclaimer in the 11955SN/A * documentation and/or other materials provided with the distribution; 12955SN/A * neither the name of the copyright holders nor the names of its 13955SN/A * contributors may be used to endorse or promote products derived from 14955SN/A * this software without specific prior written permission. 15955SN/A * 16955SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17955SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18955SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19955SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20955SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21955SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22955SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23955SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24955SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25955SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26955SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27955SN/A * 28955SN/A * Authors: Korey Sewell 292665Ssaidi@eecs.umich.edu */ 302665Ssaidi@eecs.umich.edu 315863Snate@binkert.org#include <algorithm> 32955SN/A#include <list> 33955SN/A#include <string> 34955SN/A 35955SN/A#include "cpu/o3/lsq.hh" 36955SN/A 372632Sstever@eecs.umich.edutemplate <class Impl> 382632Sstever@eecs.umich.eduTick 392632Sstever@eecs.umich.eduLSQ<Impl>::DcachePort::recvAtomic(PacketPtr pkt) 402632Sstever@eecs.umich.edu{ 41955SN/A panic("O3CPU model does not work with atomic mode!"); 422632Sstever@eecs.umich.edu return curTick; 432632Sstever@eecs.umich.edu} 442761Sstever@eecs.umich.edu 452632Sstever@eecs.umich.edutemplate <class Impl> 462632Sstever@eecs.umich.eduvoid 472632Sstever@eecs.umich.eduLSQ<Impl>::DcachePort::recvFunctional(PacketPtr pkt) 482761Sstever@eecs.umich.edu{ 492761Sstever@eecs.umich.edu DPRINTF(LSQ, "LSQ doesn't update things on a recvFunctional."); 502761Sstever@eecs.umich.edu} 512632Sstever@eecs.umich.edu 522632Sstever@eecs.umich.edutemplate <class Impl> 532761Sstever@eecs.umich.eduvoid 542761Sstever@eecs.umich.eduLSQ<Impl>::DcachePort::recvStatusChange(Status status) 552761Sstever@eecs.umich.edu{ 562761Sstever@eecs.umich.edu if (status == RangeChange) { 572761Sstever@eecs.umich.edu if (!snoopRangeSent) { 582632Sstever@eecs.umich.edu snoopRangeSent = true; 592632Sstever@eecs.umich.edu sendStatusChange(Port::RangeChange); 602632Sstever@eecs.umich.edu } 612632Sstever@eecs.umich.edu return; 622632Sstever@eecs.umich.edu } 632632Sstever@eecs.umich.edu panic("O3CPU doesn't expect recvStatusChange callback!"); 642632Sstever@eecs.umich.edu} 65955SN/A 66955SN/Atemplate <class Impl> 67955SN/Abool 685863Snate@binkert.orgLSQ<Impl>::DcachePort::recvTiming(PacketPtr pkt) 695863Snate@binkert.org{ 705863Snate@binkert.org if (pkt->isResponse()) { 715863Snate@binkert.org lsq->thread[pkt->req->getThreadNum()].completeDataAccess(pkt); 725863Snate@binkert.org } 735863Snate@binkert.org else { 745863Snate@binkert.org //else it is a coherence request, maybe you need to do something 755863Snate@binkert.org warn("Recieved a coherence request (Invalidate?), 03CPU doesn't" 765863Snate@binkert.org "update LSQ for these\n"); 775863Snate@binkert.org } 785863Snate@binkert.org return true; 795863Snate@binkert.org} 805863Snate@binkert.org 815863Snate@binkert.orgtemplate <class Impl> 825863Snate@binkert.orgvoid 835863Snate@binkert.orgLSQ<Impl>::DcachePort::recvRetry() 845863Snate@binkert.org{ 855863Snate@binkert.org if (lsq->retryTid == -1) 865863Snate@binkert.org { 875863Snate@binkert.org //Squashed, so drop it 885863Snate@binkert.org return; 895863Snate@binkert.org } 905863Snate@binkert.org lsq->thread[lsq->retryTid].recvRetry(); 915863Snate@binkert.org // Speculatively clear the retry Tid. This will get set again if 925863Snate@binkert.org // the LSQUnit was unable to complete its access. 935863Snate@binkert.org lsq->retryTid = -1; 945863Snate@binkert.org} 955863Snate@binkert.org 965863Snate@binkert.orgtemplate <class Impl> 975863Snate@binkert.orgLSQ<Impl>::LSQ(Params *params) 985863Snate@binkert.org : dcachePort(this), LQEntries(params->LQEntries), 996654Snate@binkert.org SQEntries(params->SQEntries), numThreads(params->numberOfThreads), 100955SN/A retryTid(-1) 1015396Ssaidi@eecs.umich.edu{ 1025863Snate@binkert.org DPRINTF(LSQ, "Creating LSQ object.\n"); 1035863Snate@binkert.org 1044202Sbinkertn@umich.edu dcachePort.snoopRangeSent = false; 1055863Snate@binkert.org 1065863Snate@binkert.org //**********************************************/ 1075863Snate@binkert.org //************ Handle SMT Parameters ***********/ 1085863Snate@binkert.org //**********************************************/ 109955SN/A std::string policy = params->smtLSQPolicy; 1106654Snate@binkert.org 1115273Sstever@gmail.com //Convert string to lowercase 1125871Snate@binkert.org std::transform(policy.begin(), policy.end(), policy.begin(), 1135273Sstever@gmail.com (int(*)(int)) tolower); 1146655Snate@binkert.org 1156655Snate@binkert.org //Figure out fetch policy 1166655Snate@binkert.org if (policy == "dynamic") { 1176655Snate@binkert.org lsqPolicy = Dynamic; 1186655Snate@binkert.org 1196655Snate@binkert.org maxLQEntries = LQEntries; 1205871Snate@binkert.org maxSQEntries = SQEntries; 1216654Snate@binkert.org 1225396Ssaidi@eecs.umich.edu DPRINTF(LSQ, "LSQ sharing policy set to Dynamic\n"); 1235871Snate@binkert.org 1245871Snate@binkert.org } else if (policy == "partitioned") { 1256121Snate@binkert.org lsqPolicy = Partitioned; 1265871Snate@binkert.org 1275871Snate@binkert.org //@todo:make work if part_amt doesnt divide evenly. 1286003Snate@binkert.org maxLQEntries = LQEntries / numThreads; 1296655Snate@binkert.org maxSQEntries = SQEntries / numThreads; 130955SN/A 1315871Snate@binkert.org DPRINTF(Fetch, "LSQ sharing policy set to Partitioned: " 1325871Snate@binkert.org "%i entries per LQ | %i entries per SQ", 1335871Snate@binkert.org maxLQEntries,maxSQEntries); 1345871Snate@binkert.org 135955SN/A } else if (policy == "threshold") { 1366121Snate@binkert.org lsqPolicy = Threshold; 1376121Snate@binkert.org 1386121Snate@binkert.org assert(params->smtLSQThreshold > LQEntries); 1391533SN/A assert(params->smtLSQThreshold > SQEntries); 1406655Snate@binkert.org 1416655Snate@binkert.org //Divide up by threshold amount 1426655Snate@binkert.org //@todo: Should threads check the max and the total 1436655Snate@binkert.org //amount of the LSQ 1445871Snate@binkert.org maxLQEntries = params->smtLSQThreshold; 1455871Snate@binkert.org maxSQEntries = params->smtLSQThreshold; 1465863Snate@binkert.org 1475871Snate@binkert.org DPRINTF(LSQ, "LSQ sharing policy set to Threshold: " 1485871Snate@binkert.org "%i entries per LQ | %i entries per SQ", 1495871Snate@binkert.org maxLQEntries,maxSQEntries); 1505871Snate@binkert.org 1515871Snate@binkert.org } else { 1525863Snate@binkert.org assert(0 && "Invalid LSQ Sharing Policy.Options Are:{Dynamic," 1536121Snate@binkert.org "Partitioned, Threshold}"); 1545863Snate@binkert.org } 1555871Snate@binkert.org 1564678Snate@binkert.org //Initialize LSQs 1574678Snate@binkert.org for (int tid=0; tid < numThreads; tid++) { 1584678Snate@binkert.org thread[tid].init(params, this, maxLQEntries, maxSQEntries, tid); 1594678Snate@binkert.org thread[tid].setDcachePort(&dcachePort); 1604678Snate@binkert.org } 1614678Snate@binkert.org} 1624678Snate@binkert.org 1634678Snate@binkert.org 1644678Snate@binkert.orgtemplate<class Impl> 1654678Snate@binkert.orgstd::string 1664678Snate@binkert.orgLSQ<Impl>::name() const 1674678Snate@binkert.org{ 1686121Snate@binkert.org return iewStage->name() + ".lsq"; 1694678Snate@binkert.org} 1705871Snate@binkert.org 1715871Snate@binkert.orgtemplate<class Impl> 1725871Snate@binkert.orgvoid 1735871Snate@binkert.orgLSQ<Impl>::regStats() 1745871Snate@binkert.org{ 1755871Snate@binkert.org //Initialize LSQs 1765871Snate@binkert.org for (int tid=0; tid < numThreads; tid++) { 1775871Snate@binkert.org thread[tid].regStats(); 1785871Snate@binkert.org } 1795871Snate@binkert.org} 1805871Snate@binkert.org 1815871Snate@binkert.orgtemplate<class Impl> 1825871Snate@binkert.orgvoid 1835990Ssaidi@eecs.umich.eduLSQ<Impl>::setActiveThreads(std::list<unsigned> *at_ptr) 1845871Snate@binkert.org{ 1855871Snate@binkert.org activeThreads = at_ptr; 1865871Snate@binkert.org assert(activeThreads != 0); 1874678Snate@binkert.org} 1886654Snate@binkert.org 1895871Snate@binkert.orgtemplate<class Impl> 1905871Snate@binkert.orgvoid 1915871Snate@binkert.orgLSQ<Impl>::setCPU(O3CPU *cpu_ptr) 1925871Snate@binkert.org{ 1935871Snate@binkert.org cpu = cpu_ptr; 1945871Snate@binkert.org 1955871Snate@binkert.org dcachePort.setName(name()); 1965871Snate@binkert.org 1975871Snate@binkert.org for (int tid=0; tid < numThreads; tid++) { 1984678Snate@binkert.org thread[tid].setCPU(cpu_ptr); 1995871Snate@binkert.org } 2004678Snate@binkert.org} 2015871Snate@binkert.org 2025871Snate@binkert.orgtemplate<class Impl> 2035871Snate@binkert.orgvoid 2045871Snate@binkert.orgLSQ<Impl>::setIEW(IEW *iew_ptr) 2055871Snate@binkert.org{ 2065871Snate@binkert.org iewStage = iew_ptr; 2075871Snate@binkert.org 2085871Snate@binkert.org for (int tid=0; tid < numThreads; tid++) { 2095871Snate@binkert.org thread[tid].setIEW(iew_ptr); 2106121Snate@binkert.org } 2116121Snate@binkert.org} 2125863Snate@binkert.org 213955SN/Atemplate <class Impl> 214955SN/Avoid 2152632Sstever@eecs.umich.eduLSQ<Impl>::switchOut() 2162632Sstever@eecs.umich.edu{ 217955SN/A for (int tid = 0; tid < numThreads; tid++) { 218955SN/A thread[tid].switchOut(); 219955SN/A } 220955SN/A} 2215863Snate@binkert.org 222955SN/Atemplate <class Impl> 2232632Sstever@eecs.umich.eduvoid 2242632Sstever@eecs.umich.eduLSQ<Impl>::takeOverFrom() 2252632Sstever@eecs.umich.edu{ 2262632Sstever@eecs.umich.edu for (int tid = 0; tid < numThreads; tid++) { 2272632Sstever@eecs.umich.edu thread[tid].takeOverFrom(); 2282632Sstever@eecs.umich.edu } 2292632Sstever@eecs.umich.edu} 2302632Sstever@eecs.umich.edu 2312632Sstever@eecs.umich.edutemplate <class Impl> 2322632Sstever@eecs.umich.eduint 2332632Sstever@eecs.umich.eduLSQ<Impl>::entryAmount(int num_threads) 2342632Sstever@eecs.umich.edu{ 2352632Sstever@eecs.umich.edu if (lsqPolicy == Partitioned) { 2363718Sstever@eecs.umich.edu return LQEntries / num_threads; 2373718Sstever@eecs.umich.edu } else { 2383718Sstever@eecs.umich.edu return 0; 2393718Sstever@eecs.umich.edu } 2403718Sstever@eecs.umich.edu} 2415863Snate@binkert.org 2425863Snate@binkert.orgtemplate <class Impl> 2433718Sstever@eecs.umich.eduvoid 2443718Sstever@eecs.umich.eduLSQ<Impl>::resetEntries() 2456121Snate@binkert.org{ 2465863Snate@binkert.org if (lsqPolicy != Dynamic || numThreads > 1) { 2473718Sstever@eecs.umich.edu int active_threads = activeThreads->size(); 2483718Sstever@eecs.umich.edu 2492634Sstever@eecs.umich.edu int maxEntries; 2502634Sstever@eecs.umich.edu 2515863Snate@binkert.org if (lsqPolicy == Partitioned) { 2522638Sstever@eecs.umich.edu maxEntries = LQEntries / active_threads; 2532632Sstever@eecs.umich.edu } else if (lsqPolicy == Threshold && active_threads == 1) { 2542632Sstever@eecs.umich.edu maxEntries = LQEntries; 2552632Sstever@eecs.umich.edu } else { 2562632Sstever@eecs.umich.edu maxEntries = LQEntries; 2572632Sstever@eecs.umich.edu } 2582632Sstever@eecs.umich.edu 2591858SN/A std::list<unsigned>::iterator threads = activeThreads->begin(); 2603716Sstever@eecs.umich.edu std::list<unsigned>::iterator end = activeThreads->end(); 2612638Sstever@eecs.umich.edu 2622638Sstever@eecs.umich.edu while (threads != end) { 2632638Sstever@eecs.umich.edu unsigned tid = *threads++; 2642638Sstever@eecs.umich.edu 2652638Sstever@eecs.umich.edu resizeEntries(maxEntries, tid); 2662638Sstever@eecs.umich.edu } 2672638Sstever@eecs.umich.edu } 2685863Snate@binkert.org} 2695863Snate@binkert.org 2705863Snate@binkert.orgtemplate<class Impl> 271955SN/Avoid 2725341Sstever@gmail.comLSQ<Impl>::removeEntries(unsigned tid) 2735341Sstever@gmail.com{ 2745863Snate@binkert.org thread[tid].clearLQ(); 2755341Sstever@gmail.com thread[tid].clearSQ(); 2766121Snate@binkert.org} 2774494Ssaidi@eecs.umich.edu 2786121Snate@binkert.orgtemplate<class Impl> 2791105SN/Avoid 2802667Sstever@eecs.umich.eduLSQ<Impl>::resizeEntries(unsigned size,unsigned tid) 2812667Sstever@eecs.umich.edu{ 2822667Sstever@eecs.umich.edu thread[tid].resizeLQ(size); 2832667Sstever@eecs.umich.edu thread[tid].resizeSQ(size); 2846121Snate@binkert.org} 2852667Sstever@eecs.umich.edu 2865341Sstever@gmail.comtemplate<class Impl> 2875863Snate@binkert.orgvoid 2885341Sstever@gmail.comLSQ<Impl>::tick() 2895341Sstever@gmail.com{ 2905341Sstever@gmail.com std::list<unsigned>::iterator threads = activeThreads->begin(); 2915863Snate@binkert.org std::list<unsigned>::iterator end = activeThreads->end(); 2925341Sstever@gmail.com 2935341Sstever@gmail.com while (threads != end) { 2945341Sstever@gmail.com unsigned tid = *threads++; 2955863Snate@binkert.org 2965341Sstever@gmail.com thread[tid].tick(); 2975341Sstever@gmail.com } 2985341Sstever@gmail.com} 2995341Sstever@gmail.com 3005341Sstever@gmail.comtemplate<class Impl> 3015341Sstever@gmail.comvoid 3025341Sstever@gmail.comLSQ<Impl>::insertLoad(DynInstPtr &load_inst) 3035341Sstever@gmail.com{ 3045341Sstever@gmail.com unsigned tid = load_inst->threadNumber; 3055341Sstever@gmail.com 3065863Snate@binkert.org thread[tid].insertLoad(load_inst); 3075341Sstever@gmail.com} 3085863Snate@binkert.org 3095341Sstever@gmail.comtemplate<class Impl> 3105863Snate@binkert.orgvoid 3116121Snate@binkert.orgLSQ<Impl>::insertStore(DynInstPtr &store_inst) 3126121Snate@binkert.org{ 3135397Ssaidi@eecs.umich.edu unsigned tid = store_inst->threadNumber; 3145397Ssaidi@eecs.umich.edu 3155341Sstever@gmail.com thread[tid].insertStore(store_inst); 3166168Snate@binkert.org} 3176168Snate@binkert.org 3186168Snate@binkert.orgtemplate<class Impl> 3195341Sstever@gmail.comFault 3205341Sstever@gmail.comLSQ<Impl>::executeLoad(DynInstPtr &inst) 3215341Sstever@gmail.com{ 3225341Sstever@gmail.com unsigned tid = inst->threadNumber; 3235341Sstever@gmail.com 3245863Snate@binkert.org return thread[tid].executeLoad(inst); 3255341Sstever@gmail.com} 3265341Sstever@gmail.com 3276121Snate@binkert.orgtemplate<class Impl> 3285341Sstever@gmail.comFault 3296121Snate@binkert.orgLSQ<Impl>::executeStore(DynInstPtr &inst) 3306121Snate@binkert.org{ 3315341Sstever@gmail.com unsigned tid = inst->threadNumber; 3325863Snate@binkert.org 3336121Snate@binkert.org return thread[tid].executeStore(inst); 3345341Sstever@gmail.com} 3355863Snate@binkert.org 3365341Sstever@gmail.comtemplate<class Impl> 3376121Snate@binkert.orgvoid 3386121Snate@binkert.orgLSQ<Impl>::writebackStores() 3396121Snate@binkert.org{ 3405742Snate@binkert.org std::list<unsigned>::iterator threads = activeThreads->begin(); 3415742Snate@binkert.org std::list<unsigned>::iterator end = activeThreads->end(); 3425341Sstever@gmail.com 3435742Snate@binkert.org while (threads != end) { 3445742Snate@binkert.org unsigned tid = *threads++; 3455341Sstever@gmail.com 3466017Snate@binkert.org if (numStoresToWB(tid) > 0) { 3476121Snate@binkert.org DPRINTF(Writeback,"[tid:%i] Writing back stores. %i stores " 3486017Snate@binkert.org "available for Writeback.\n", tid, numStoresToWB(tid)); 3496654Snate@binkert.org } 3506654Snate@binkert.org 3515871Snate@binkert.org thread[tid].writebackStores(); 3526121Snate@binkert.org } 3536121Snate@binkert.org} 3546121Snate@binkert.org 3556121Snate@binkert.orgtemplate<class Impl> 3563940Ssaidi@eecs.umich.edubool 3573918Ssaidi@eecs.umich.eduLSQ<Impl>::violation() 3583918Ssaidi@eecs.umich.edu{ 3591858SN/A /* Answers: Does Anybody Have a Violation?*/ 3606121Snate@binkert.org std::list<unsigned>::iterator threads = activeThreads->begin(); 3616121Snate@binkert.org std::list<unsigned>::iterator end = activeThreads->end(); 3626121Snate@binkert.org 3636143Snate@binkert.org while (threads != end) { 3646121Snate@binkert.org unsigned tid = *threads++; 3656121Snate@binkert.org 3663940Ssaidi@eecs.umich.edu if (thread[tid].violation()) 3676121Snate@binkert.org return true; 3686121Snate@binkert.org } 3696121Snate@binkert.org 3706121Snate@binkert.org return false; 3716121Snate@binkert.org} 3726121Snate@binkert.org 3736121Snate@binkert.orgtemplate<class Impl> 3743918Ssaidi@eecs.umich.eduint 3753918Ssaidi@eecs.umich.eduLSQ<Impl>::getCount() 3763940Ssaidi@eecs.umich.edu{ 3773918Ssaidi@eecs.umich.edu unsigned total = 0; 3783918Ssaidi@eecs.umich.edu 3796157Snate@binkert.org std::list<unsigned>::iterator threads = activeThreads->begin(); 3806157Snate@binkert.org std::list<unsigned>::iterator end = activeThreads->end(); 3816157Snate@binkert.org 3826157Snate@binkert.org while (threads != end) { 3835397Ssaidi@eecs.umich.edu unsigned tid = *threads++; 3845397Ssaidi@eecs.umich.edu 3856121Snate@binkert.org total += getCount(tid); 3866121Snate@binkert.org } 3876121Snate@binkert.org 3886121Snate@binkert.org return total; 3896121Snate@binkert.org} 3906121Snate@binkert.org 3915397Ssaidi@eecs.umich.edutemplate<class Impl> 3921851SN/Aint 3931851SN/ALSQ<Impl>::numLoads() 3946655Snate@binkert.org{ 395955SN/A unsigned total = 0; 3963053Sstever@eecs.umich.edu 3976121Snate@binkert.org std::list<unsigned>::iterator threads = activeThreads->begin(); 3983053Sstever@eecs.umich.edu std::list<unsigned>::iterator end = activeThreads->end(); 3993053Sstever@eecs.umich.edu 4003053Sstever@eecs.umich.edu while (threads != end) { 4013053Sstever@eecs.umich.edu unsigned tid = *threads++; 4023053Sstever@eecs.umich.edu 4036654Snate@binkert.org total += numLoads(tid); 4043053Sstever@eecs.umich.edu } 4054742Sstever@eecs.umich.edu 4064742Sstever@eecs.umich.edu return total; 4073053Sstever@eecs.umich.edu} 4083053Sstever@eecs.umich.edu 4093053Sstever@eecs.umich.edutemplate<class Impl> 4103053Sstever@eecs.umich.eduint 4116654Snate@binkert.orgLSQ<Impl>::numStores() 4123053Sstever@eecs.umich.edu{ 4133053Sstever@eecs.umich.edu unsigned total = 0; 4143053Sstever@eecs.umich.edu 4153053Sstever@eecs.umich.edu std::list<unsigned>::iterator threads = activeThreads->begin(); 4162667Sstever@eecs.umich.edu std::list<unsigned>::iterator end = activeThreads->end(); 4174554Sbinkertn@umich.edu 4186121Snate@binkert.org while (threads != end) { 4192667Sstever@eecs.umich.edu unsigned tid = *threads++; 4204554Sbinkertn@umich.edu 4214554Sbinkertn@umich.edu total += thread[tid].numStores(); 4224554Sbinkertn@umich.edu } 4236121Snate@binkert.org 4244554Sbinkertn@umich.edu return total; 4254554Sbinkertn@umich.edu} 4264554Sbinkertn@umich.edu 4274781Snate@binkert.orgtemplate<class Impl> 4284554Sbinkertn@umich.eduint 4294554Sbinkertn@umich.eduLSQ<Impl>::numLoadsReady() 4302667Sstever@eecs.umich.edu{ 4314554Sbinkertn@umich.edu unsigned total = 0; 4324554Sbinkertn@umich.edu 4334554Sbinkertn@umich.edu std::list<unsigned>::iterator threads = activeThreads->begin(); 4344554Sbinkertn@umich.edu std::list<unsigned>::iterator end = activeThreads->end(); 4352667Sstever@eecs.umich.edu 4364554Sbinkertn@umich.edu while (threads != end) { 4372667Sstever@eecs.umich.edu unsigned tid = *threads++; 4384554Sbinkertn@umich.edu 4396121Snate@binkert.org total += thread[tid].numLoadsReady(); 4402667Sstever@eecs.umich.edu } 4415522Snate@binkert.org 4425522Snate@binkert.org return total; 4435522Snate@binkert.org} 4445522Snate@binkert.org 4455522Snate@binkert.orgtemplate<class Impl> 4465522Snate@binkert.orgunsigned 4475522Snate@binkert.orgLSQ<Impl>::numFreeEntries() 4485522Snate@binkert.org{ 4495522Snate@binkert.org unsigned total = 0; 4505522Snate@binkert.org 4515522Snate@binkert.org std::list<unsigned>::iterator threads = activeThreads->begin(); 4525522Snate@binkert.org std::list<unsigned>::iterator end = activeThreads->end(); 4535522Snate@binkert.org 4545522Snate@binkert.org while (threads != end) { 4555522Snate@binkert.org unsigned tid = *threads++; 4565522Snate@binkert.org 4575522Snate@binkert.org total += thread[tid].numFreeEntries(); 4585522Snate@binkert.org } 4595522Snate@binkert.org 4605522Snate@binkert.org return total; 4615522Snate@binkert.org} 4625522Snate@binkert.org 4635522Snate@binkert.orgtemplate<class Impl> 4645522Snate@binkert.orgunsigned 4655522Snate@binkert.orgLSQ<Impl>::numFreeEntries(unsigned tid) 4665522Snate@binkert.org{ 4672638Sstever@eecs.umich.edu //if( lsqPolicy == Dynamic ) 4682638Sstever@eecs.umich.edu //return numFreeEntries(); 4696121Snate@binkert.org //else 4703716Sstever@eecs.umich.edu return thread[tid].numFreeEntries(); 4715522Snate@binkert.org} 4725522Snate@binkert.org 4735522Snate@binkert.orgtemplate<class Impl> 4745522Snate@binkert.orgbool 4755522Snate@binkert.orgLSQ<Impl>::isFull() 4765522Snate@binkert.org{ 4771858SN/A std::list<unsigned>::iterator threads = activeThreads->begin(); 4785227Ssaidi@eecs.umich.edu std::list<unsigned>::iterator end = activeThreads->end(); 4795227Ssaidi@eecs.umich.edu 4805227Ssaidi@eecs.umich.edu while (threads != end) { 4815227Ssaidi@eecs.umich.edu unsigned tid = *threads++; 4826654Snate@binkert.org 4836654Snate@binkert.org if (!(thread[tid].lqFull() || thread[tid].sqFull())) 4846121Snate@binkert.org return false; 4856121Snate@binkert.org } 4866121Snate@binkert.org 4876121Snate@binkert.org return true; 4885227Ssaidi@eecs.umich.edu} 4895227Ssaidi@eecs.umich.edu 4905227Ssaidi@eecs.umich.edutemplate<class Impl> 4915204Sstever@gmail.combool 4925204Sstever@gmail.comLSQ<Impl>::isFull(unsigned tid) 4935204Sstever@gmail.com{ 4945204Sstever@gmail.com //@todo: Change to Calculate All Entries for 4955204Sstever@gmail.com //Dynamic Policy 4965204Sstever@gmail.com if (lsqPolicy == Dynamic) 4975204Sstever@gmail.com return isFull(); 4985204Sstever@gmail.com else 4995204Sstever@gmail.com return thread[tid].lqFull() || thread[tid].sqFull(); 5005204Sstever@gmail.com} 5015204Sstever@gmail.com 5025204Sstever@gmail.comtemplate<class Impl> 5035204Sstever@gmail.combool 5045204Sstever@gmail.comLSQ<Impl>::lqFull() 5055204Sstever@gmail.com{ 5065204Sstever@gmail.com std::list<unsigned>::iterator threads = activeThreads->begin(); 5075204Sstever@gmail.com std::list<unsigned>::iterator end = activeThreads->end(); 5086121Snate@binkert.org 5095204Sstever@gmail.com while (threads != end) { 5103118Sstever@eecs.umich.edu unsigned tid = *threads++; 5113118Sstever@eecs.umich.edu 5123118Sstever@eecs.umich.edu if (!thread[tid].lqFull()) 5133118Sstever@eecs.umich.edu return false; 5143118Sstever@eecs.umich.edu } 5155863Snate@binkert.org 5163118Sstever@eecs.umich.edu return true; 5175863Snate@binkert.org} 5183118Sstever@eecs.umich.edu 5195863Snate@binkert.orgtemplate<class Impl> 5205863Snate@binkert.orgbool 5215863Snate@binkert.orgLSQ<Impl>::lqFull(unsigned tid) 5225863Snate@binkert.org{ 5235863Snate@binkert.org //@todo: Change to Calculate All Entries for 5245863Snate@binkert.org //Dynamic Policy 5255863Snate@binkert.org if( lsqPolicy == Dynamic ) 5265863Snate@binkert.org return lqFull(); 5276003Snate@binkert.org else 5285863Snate@binkert.org return thread[tid].lqFull(); 5295863Snate@binkert.org} 5305863Snate@binkert.org 5316120Snate@binkert.orgtemplate<class Impl> 5325863Snate@binkert.orgbool 5335863Snate@binkert.orgLSQ<Impl>::sqFull() 5345863Snate@binkert.org{ 5356120Snate@binkert.org std::list<unsigned>::iterator threads = activeThreads->begin(); 5366120Snate@binkert.org std::list<unsigned>::iterator end = activeThreads->end(); 5375863Snate@binkert.org 5385863Snate@binkert.org while (threads != end) { 5396120Snate@binkert.org unsigned tid = *threads++; 5405863Snate@binkert.org 5416121Snate@binkert.org if (!sqFull(tid)) 5426121Snate@binkert.org return false; 5435863Snate@binkert.org } 5445863Snate@binkert.org 5453118Sstever@eecs.umich.edu return true; 5465863Snate@binkert.org} 5473118Sstever@eecs.umich.edu 5483118Sstever@eecs.umich.edutemplate<class Impl> 5495863Snate@binkert.orgbool 5505863Snate@binkert.orgLSQ<Impl>::sqFull(unsigned tid) 5515863Snate@binkert.org{ 5525863Snate@binkert.org //@todo: Change to Calculate All Entries for 5533118Sstever@eecs.umich.edu //Dynamic Policy 5543483Ssaidi@eecs.umich.edu if( lsqPolicy == Dynamic ) 5553494Ssaidi@eecs.umich.edu return sqFull(); 5563494Ssaidi@eecs.umich.edu else 5573483Ssaidi@eecs.umich.edu return thread[tid].sqFull(); 5583483Ssaidi@eecs.umich.edu} 5593483Ssaidi@eecs.umich.edu 5603053Sstever@eecs.umich.edutemplate<class Impl> 5613053Sstever@eecs.umich.edubool 5623918Ssaidi@eecs.umich.eduLSQ<Impl>::isStalled() 5633053Sstever@eecs.umich.edu{ 5643053Sstever@eecs.umich.edu std::list<unsigned>::iterator threads = activeThreads->begin(); 5653053Sstever@eecs.umich.edu std::list<unsigned>::iterator end = activeThreads->end(); 5663053Sstever@eecs.umich.edu 5673053Sstever@eecs.umich.edu while (threads != end) { 5681858SN/A unsigned tid = *threads++; 5691858SN/A 5701858SN/A if (!thread[tid].isStalled()) 5711858SN/A return false; 5721858SN/A } 5731858SN/A 5745863Snate@binkert.org return true; 5755863Snate@binkert.org} 5761859SN/A 5775863Snate@binkert.orgtemplate<class Impl> 5781858SN/Abool 5795863Snate@binkert.orgLSQ<Impl>::isStalled(unsigned tid) 5801858SN/A{ 5811859SN/A if( lsqPolicy == Dynamic ) 5821859SN/A return isStalled(); 5836654Snate@binkert.org else 5843053Sstever@eecs.umich.edu return thread[tid].isStalled(); 5856654Snate@binkert.org} 5863053Sstever@eecs.umich.edu 5873053Sstever@eecs.umich.edutemplate<class Impl> 5881859SN/Abool 5891859SN/ALSQ<Impl>::hasStoresToWB() 5901859SN/A{ 5911859SN/A std::list<unsigned>::iterator threads = activeThreads->begin(); 5921859SN/A std::list<unsigned>::iterator end = activeThreads->end(); 5931859SN/A 5941859SN/A if (threads == end) 5951859SN/A return false; 5961862SN/A 5971859SN/A while (threads != end) { 5981859SN/A unsigned tid = *threads++; 5991859SN/A 6005863Snate@binkert.org if (!hasStoresToWB(tid)) 6015863Snate@binkert.org return false; 6025863Snate@binkert.org } 6035863Snate@binkert.org 6046121Snate@binkert.org return true; 6051858SN/A} 6065863Snate@binkert.org 6075863Snate@binkert.orgtemplate<class Impl> 6085863Snate@binkert.orgbool 6095863Snate@binkert.orgLSQ<Impl>::willWB() 6105863Snate@binkert.org{ 6112139SN/A std::list<unsigned>::iterator threads = activeThreads->begin(); 6124202Sbinkertn@umich.edu std::list<unsigned>::iterator end = activeThreads->end(); 6134202Sbinkertn@umich.edu 6142139SN/A while (threads != end) { 6152155SN/A unsigned tid = *threads++; 6164202Sbinkertn@umich.edu 6174202Sbinkertn@umich.edu if (!willWB(tid)) 6184202Sbinkertn@umich.edu return false; 6192155SN/A } 6205863Snate@binkert.org 6211869SN/A return true; 6221869SN/A} 6235863Snate@binkert.org 6245863Snate@binkert.orgtemplate<class Impl> 6254202Sbinkertn@umich.eduvoid 6266108Snate@binkert.orgLSQ<Impl>::dumpInsts() 6276108Snate@binkert.org{ 6286108Snate@binkert.org std::list<unsigned>::iterator threads = activeThreads->begin(); 6296108Snate@binkert.org std::list<unsigned>::iterator end = activeThreads->end(); 6305863Snate@binkert.org 6315863Snate@binkert.org while (threads != end) { 6325863Snate@binkert.org unsigned tid = *threads++; 6334202Sbinkertn@umich.edu 6344202Sbinkertn@umich.edu thread[tid].dumpInsts(); 6355863Snate@binkert.org } 6365742Snate@binkert.org} 6375742Snate@binkert.org