base.cc revision 8833
112855Sgabeblack@google.com/* 212855Sgabeblack@google.com * Copyright (c) 2003-2005 The Regents of The University of Michigan 312855Sgabeblack@google.com * All rights reserved. 412855Sgabeblack@google.com * 512855Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 612855Sgabeblack@google.com * modification, are permitted provided that the following conditions are 712855Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 812855Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 912855Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1012855Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1112855Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1212855Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1312855Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1412855Sgabeblack@google.com * this software without specific prior written permission. 1512855Sgabeblack@google.com * 1612855Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712855Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812855Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912855Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012855Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112855Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212855Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312855Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412855Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512855Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612855Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712855Sgabeblack@google.com * 2812855Sgabeblack@google.com * Authors: Erik Hallnor 2912855Sgabeblack@google.com */ 3012855Sgabeblack@google.com 3112855Sgabeblack@google.com/** 3212855Sgabeblack@google.com * @file 3312855Sgabeblack@google.com * Definition of BaseCache functions. 3412855Sgabeblack@google.com */ 3512855Sgabeblack@google.com 3612855Sgabeblack@google.com#include "cpu/base.hh" 3712855Sgabeblack@google.com#include "cpu/smt.hh" 3812855Sgabeblack@google.com#include "debug/Cache.hh" 3912855Sgabeblack@google.com#include "mem/cache/base.hh" 4012855Sgabeblack@google.com#include "mem/cache/mshr.hh" 4112855Sgabeblack@google.com#include "sim/full_system.hh" 4212855Sgabeblack@google.com 4312855Sgabeblack@google.comusing namespace std; 4412855Sgabeblack@google.com 4512855Sgabeblack@google.comBaseCache::CachePort::CachePort(const std::string &_name, BaseCache *_cache, 4612855Sgabeblack@google.com const std::string &_label) 4712855Sgabeblack@google.com : SimpleTimingPort(_name, _cache), cache(_cache), 4812855Sgabeblack@google.com label(_label), blocked(false), mustSendRetry(false) 4912855Sgabeblack@google.com{ 5012855Sgabeblack@google.com} 5112855Sgabeblack@google.com 5212855Sgabeblack@google.com 5312855Sgabeblack@google.comBaseCache::BaseCache(const Params *p) 5412855Sgabeblack@google.com : MemObject(p), 5512855Sgabeblack@google.com mshrQueue("MSHRs", p->mshrs, 4, MSHRQueue_MSHRs), 5612855Sgabeblack@google.com writeBuffer("write buffer", p->write_buffers, p->mshrs+1000, 5712855Sgabeblack@google.com MSHRQueue_WriteBuffer), 5812855Sgabeblack@google.com blkSize(p->block_size), 5912855Sgabeblack@google.com hitLatency(p->latency), 6012855Sgabeblack@google.com numTarget(p->tgts_per_mshr), 6112855Sgabeblack@google.com forwardSnoops(p->forward_snoops), 6212855Sgabeblack@google.com isTopLevel(p->is_top_level), 6312855Sgabeblack@google.com blocked(0), 6412855Sgabeblack@google.com noTargetMSHR(NULL), 6512855Sgabeblack@google.com missCount(p->max_miss_count), 6612855Sgabeblack@google.com drainEvent(NULL), 6712855Sgabeblack@google.com addrRange(p->addr_range), 6812855Sgabeblack@google.com system(p->system) 6912855Sgabeblack@google.com{ 7012855Sgabeblack@google.com} 7112855Sgabeblack@google.com 7212855Sgabeblack@google.com 7312855Sgabeblack@google.combool 7412855Sgabeblack@google.comBaseCache::CachePort::checkFunctional(PacketPtr pkt) 7512855Sgabeblack@google.com{ 7612855Sgabeblack@google.com pkt->pushLabel(label); 7712855Sgabeblack@google.com bool done = SimpleTimingPort::checkFunctional(pkt); 7812855Sgabeblack@google.com pkt->popLabel(); 7912855Sgabeblack@google.com return done; 8012855Sgabeblack@google.com} 8112855Sgabeblack@google.com 8212855Sgabeblack@google.com 8312855Sgabeblack@google.comunsigned 8412855Sgabeblack@google.comBaseCache::CachePort::deviceBlockSize() const 8512855Sgabeblack@google.com{ 8612855Sgabeblack@google.com return cache->getBlockSize(); 8712855Sgabeblack@google.com} 8812855Sgabeblack@google.com 8912855Sgabeblack@google.com 9012855Sgabeblack@google.combool 9112855Sgabeblack@google.comBaseCache::CachePort::recvRetryCommon() 9212855Sgabeblack@google.com{ 9312855Sgabeblack@google.com assert(waitingOnRetry); 9412855Sgabeblack@google.com waitingOnRetry = false; 9512855Sgabeblack@google.com return false; 9612855Sgabeblack@google.com} 9712855Sgabeblack@google.com 9812855Sgabeblack@google.com 9912855Sgabeblack@google.comvoid 10012855Sgabeblack@google.comBaseCache::CachePort::setBlocked() 10112855Sgabeblack@google.com{ 10212855Sgabeblack@google.com assert(!blocked); 10312855Sgabeblack@google.com DPRINTF(Cache, "Cache Blocking\n"); 10412855Sgabeblack@google.com blocked = true; 10512855Sgabeblack@google.com //Clear the retry flag 10612855Sgabeblack@google.com mustSendRetry = false; 10712855Sgabeblack@google.com} 10812855Sgabeblack@google.com 10912855Sgabeblack@google.comvoid 11012855Sgabeblack@google.comBaseCache::CachePort::clearBlocked() 11112855Sgabeblack@google.com{ 11212855Sgabeblack@google.com assert(blocked); 11312855Sgabeblack@google.com DPRINTF(Cache, "Cache Unblocking\n"); 11412855Sgabeblack@google.com blocked = false; 11512855Sgabeblack@google.com if (mustSendRetry) 11612855Sgabeblack@google.com { 11712855Sgabeblack@google.com DPRINTF(Cache, "Cache Sending Retry\n"); 11812855Sgabeblack@google.com mustSendRetry = false; 11912855Sgabeblack@google.com SendRetryEvent *ev = new SendRetryEvent(this, true); 12012855Sgabeblack@google.com // @TODO: need to find a better time (next bus cycle?) 12112855Sgabeblack@google.com cache->schedule(ev, curTick() + 1); 12212855Sgabeblack@google.com } 12312855Sgabeblack@google.com} 12412855Sgabeblack@google.com 12512855Sgabeblack@google.com 12612855Sgabeblack@google.comvoid 12712855Sgabeblack@google.comBaseCache::init() 12812855Sgabeblack@google.com{ 12912855Sgabeblack@google.com if (!cpuSidePort || !memSidePort) 13012855Sgabeblack@google.com panic("Cache not hooked up on both sides\n"); 13112855Sgabeblack@google.com cpuSidePort->sendRangeChange(); 13212855Sgabeblack@google.com} 13312855Sgabeblack@google.com 13412855Sgabeblack@google.com 13512855Sgabeblack@google.comvoid 13612855Sgabeblack@google.comBaseCache::regStats() 13712855Sgabeblack@google.com{ 13812855Sgabeblack@google.com using namespace Stats; 13912855Sgabeblack@google.com 14012855Sgabeblack@google.com // Hit statistics 14112855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 14212855Sgabeblack@google.com MemCmd cmd(access_idx); 14312855Sgabeblack@google.com const string &cstr = cmd.toString(); 14412855Sgabeblack@google.com 14512855Sgabeblack@google.com hits[access_idx] 14612855Sgabeblack@google.com .init(system->maxMasters()) 14712855Sgabeblack@google.com .name(name() + "." + cstr + "_hits") 14812855Sgabeblack@google.com .desc("number of " + cstr + " hits") 14912855Sgabeblack@google.com .flags(total | nozero | nonan) 15012855Sgabeblack@google.com ; 15112855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 15212855Sgabeblack@google.com hits[access_idx].subname(i, system->getMasterName(i)); 15312855Sgabeblack@google.com } 15412855Sgabeblack@google.com } 15512855Sgabeblack@google.com 15612855Sgabeblack@google.com// These macros make it easier to sum the right subset of commands and 15712855Sgabeblack@google.com// to change the subset of commands that are considered "demand" vs 15812855Sgabeblack@google.com// "non-demand" 15912855Sgabeblack@google.com#define SUM_DEMAND(s) \ 16012855Sgabeblack@google.com (s[MemCmd::ReadReq] + s[MemCmd::WriteReq] + s[MemCmd::ReadExReq]) 16112855Sgabeblack@google.com 16212855Sgabeblack@google.com// should writebacks be included here? prior code was inconsistent... 16312855Sgabeblack@google.com#define SUM_NON_DEMAND(s) \ 16412855Sgabeblack@google.com (s[MemCmd::SoftPFReq] + s[MemCmd::HardPFReq]) 16512855Sgabeblack@google.com 16612855Sgabeblack@google.com demandHits 16712855Sgabeblack@google.com .name(name() + ".demand_hits") 16812855Sgabeblack@google.com .desc("number of demand (read+write) hits") 16912855Sgabeblack@google.com .flags(total | nozero | nonan) 17012855Sgabeblack@google.com ; 17112855Sgabeblack@google.com demandHits = SUM_DEMAND(hits); 17212855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 17312855Sgabeblack@google.com demandHits.subname(i, system->getMasterName(i)); 17412855Sgabeblack@google.com } 17512855Sgabeblack@google.com 17612855Sgabeblack@google.com overallHits 17712855Sgabeblack@google.com .name(name() + ".overall_hits") 17812855Sgabeblack@google.com .desc("number of overall hits") 17912855Sgabeblack@google.com .flags(total | nozero | nonan) 18012855Sgabeblack@google.com ; 18112855Sgabeblack@google.com overallHits = demandHits + SUM_NON_DEMAND(hits); 18212855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 18312855Sgabeblack@google.com overallHits.subname(i, system->getMasterName(i)); 18412855Sgabeblack@google.com } 18512855Sgabeblack@google.com 18612855Sgabeblack@google.com // Miss statistics 18712855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 18812855Sgabeblack@google.com MemCmd cmd(access_idx); 18912855Sgabeblack@google.com const string &cstr = cmd.toString(); 19012855Sgabeblack@google.com 19112855Sgabeblack@google.com misses[access_idx] 19212855Sgabeblack@google.com .init(system->maxMasters()) 19312855Sgabeblack@google.com .name(name() + "." + cstr + "_misses") 19412855Sgabeblack@google.com .desc("number of " + cstr + " misses") 19512855Sgabeblack@google.com .flags(total | nozero | nonan) 19612855Sgabeblack@google.com ; 19712855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 19812855Sgabeblack@google.com misses[access_idx].subname(i, system->getMasterName(i)); 19912855Sgabeblack@google.com } 20012855Sgabeblack@google.com } 20112855Sgabeblack@google.com 20212855Sgabeblack@google.com demandMisses 20312855Sgabeblack@google.com .name(name() + ".demand_misses") 20412855Sgabeblack@google.com .desc("number of demand (read+write) misses") 20512855Sgabeblack@google.com .flags(total | nozero | nonan) 20612855Sgabeblack@google.com ; 20712855Sgabeblack@google.com demandMisses = SUM_DEMAND(misses); 20812855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 20912855Sgabeblack@google.com demandMisses.subname(i, system->getMasterName(i)); 21012855Sgabeblack@google.com } 21112855Sgabeblack@google.com 21212855Sgabeblack@google.com overallMisses 21312855Sgabeblack@google.com .name(name() + ".overall_misses") 21412855Sgabeblack@google.com .desc("number of overall misses") 21512855Sgabeblack@google.com .flags(total | nozero | nonan) 21612855Sgabeblack@google.com ; 21712855Sgabeblack@google.com overallMisses = demandMisses + SUM_NON_DEMAND(misses); 21812855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 21912855Sgabeblack@google.com overallMisses.subname(i, system->getMasterName(i)); 22012855Sgabeblack@google.com } 22112855Sgabeblack@google.com 22212855Sgabeblack@google.com // Miss latency statistics 22312855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 22412855Sgabeblack@google.com MemCmd cmd(access_idx); 22512855Sgabeblack@google.com const string &cstr = cmd.toString(); 22612855Sgabeblack@google.com 22712855Sgabeblack@google.com missLatency[access_idx] 22812855Sgabeblack@google.com .init(system->maxMasters()) 22912855Sgabeblack@google.com .name(name() + "." + cstr + "_miss_latency") 23012855Sgabeblack@google.com .desc("number of " + cstr + " miss cycles") 23112855Sgabeblack@google.com .flags(total | nozero | nonan) 23212855Sgabeblack@google.com ; 23312855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 23412855Sgabeblack@google.com missLatency[access_idx].subname(i, system->getMasterName(i)); 23512855Sgabeblack@google.com } 23612855Sgabeblack@google.com } 23712855Sgabeblack@google.com 23812855Sgabeblack@google.com demandMissLatency 23912855Sgabeblack@google.com .name(name() + ".demand_miss_latency") 24012855Sgabeblack@google.com .desc("number of demand (read+write) miss cycles") 24112855Sgabeblack@google.com .flags(total | nozero | nonan) 24212855Sgabeblack@google.com ; 24312855Sgabeblack@google.com demandMissLatency = SUM_DEMAND(missLatency); 24412855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 24512855Sgabeblack@google.com demandMissLatency.subname(i, system->getMasterName(i)); 24612855Sgabeblack@google.com } 24712855Sgabeblack@google.com 24812855Sgabeblack@google.com overallMissLatency 24912855Sgabeblack@google.com .name(name() + ".overall_miss_latency") 25012855Sgabeblack@google.com .desc("number of overall miss cycles") 25112855Sgabeblack@google.com .flags(total | nozero | nonan) 25212855Sgabeblack@google.com ; 25312855Sgabeblack@google.com overallMissLatency = demandMissLatency + SUM_NON_DEMAND(missLatency); 25412855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 25512855Sgabeblack@google.com overallMissLatency.subname(i, system->getMasterName(i)); 25612855Sgabeblack@google.com } 25712855Sgabeblack@google.com 25812855Sgabeblack@google.com // access formulas 25912855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 26012855Sgabeblack@google.com MemCmd cmd(access_idx); 26112855Sgabeblack@google.com const string &cstr = cmd.toString(); 26212855Sgabeblack@google.com 26312855Sgabeblack@google.com accesses[access_idx] 26412855Sgabeblack@google.com .name(name() + "." + cstr + "_accesses") 26512855Sgabeblack@google.com .desc("number of " + cstr + " accesses(hits+misses)") 26612855Sgabeblack@google.com .flags(total | nozero | nonan) 26712855Sgabeblack@google.com ; 26812855Sgabeblack@google.com accesses[access_idx] = hits[access_idx] + misses[access_idx]; 26912855Sgabeblack@google.com 27012855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 27112855Sgabeblack@google.com accesses[access_idx].subname(i, system->getMasterName(i)); 27212855Sgabeblack@google.com } 27312855Sgabeblack@google.com } 27412855Sgabeblack@google.com 27512855Sgabeblack@google.com demandAccesses 27612855Sgabeblack@google.com .name(name() + ".demand_accesses") 27712855Sgabeblack@google.com .desc("number of demand (read+write) accesses") 27812855Sgabeblack@google.com .flags(total | nozero | nonan) 27912855Sgabeblack@google.com ; 28012855Sgabeblack@google.com demandAccesses = demandHits + demandMisses; 28112855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 28212855Sgabeblack@google.com demandAccesses.subname(i, system->getMasterName(i)); 28312855Sgabeblack@google.com } 28412855Sgabeblack@google.com 28512855Sgabeblack@google.com overallAccesses 28612855Sgabeblack@google.com .name(name() + ".overall_accesses") 28712855Sgabeblack@google.com .desc("number of overall (read+write) accesses") 28812855Sgabeblack@google.com .flags(total | nozero | nonan) 28912855Sgabeblack@google.com ; 29012855Sgabeblack@google.com overallAccesses = overallHits + overallMisses; 29112855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 29212855Sgabeblack@google.com overallAccesses.subname(i, system->getMasterName(i)); 29312855Sgabeblack@google.com } 29412855Sgabeblack@google.com 29512855Sgabeblack@google.com // miss rate formulas 29612855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 29712855Sgabeblack@google.com MemCmd cmd(access_idx); 29812855Sgabeblack@google.com const string &cstr = cmd.toString(); 29912855Sgabeblack@google.com 30012855Sgabeblack@google.com missRate[access_idx] 30112855Sgabeblack@google.com .name(name() + "." + cstr + "_miss_rate") 30212855Sgabeblack@google.com .desc("miss rate for " + cstr + " accesses") 30312855Sgabeblack@google.com .flags(total | nozero | nonan) 30412855Sgabeblack@google.com ; 30512855Sgabeblack@google.com missRate[access_idx] = misses[access_idx] / accesses[access_idx]; 30612855Sgabeblack@google.com 30712855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 30812855Sgabeblack@google.com missRate[access_idx].subname(i, system->getMasterName(i)); 30912855Sgabeblack@google.com } 31012855Sgabeblack@google.com } 31112855Sgabeblack@google.com 31212855Sgabeblack@google.com demandMissRate 31312855Sgabeblack@google.com .name(name() + ".demand_miss_rate") 31412855Sgabeblack@google.com .desc("miss rate for demand accesses") 31512855Sgabeblack@google.com .flags(total | nozero | nonan) 31612855Sgabeblack@google.com ; 31712855Sgabeblack@google.com demandMissRate = demandMisses / demandAccesses; 31812855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 31912855Sgabeblack@google.com demandMissRate.subname(i, system->getMasterName(i)); 32012855Sgabeblack@google.com } 32112855Sgabeblack@google.com 32212855Sgabeblack@google.com overallMissRate 32312855Sgabeblack@google.com .name(name() + ".overall_miss_rate") 32412855Sgabeblack@google.com .desc("miss rate for overall accesses") 32512855Sgabeblack@google.com .flags(total | nozero | nonan) 32612855Sgabeblack@google.com ; 32712855Sgabeblack@google.com overallMissRate = overallMisses / overallAccesses; 32812855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 32912855Sgabeblack@google.com overallMissRate.subname(i, system->getMasterName(i)); 33012855Sgabeblack@google.com } 33112855Sgabeblack@google.com 33212855Sgabeblack@google.com // miss latency formulas 33312855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 33412855Sgabeblack@google.com MemCmd cmd(access_idx); 33512855Sgabeblack@google.com const string &cstr = cmd.toString(); 33612855Sgabeblack@google.com 33712855Sgabeblack@google.com avgMissLatency[access_idx] 33812855Sgabeblack@google.com .name(name() + "." + cstr + "_avg_miss_latency") 33912855Sgabeblack@google.com .desc("average " + cstr + " miss latency") 34012855Sgabeblack@google.com .flags(total | nozero | nonan) 34112855Sgabeblack@google.com ; 34212855Sgabeblack@google.com avgMissLatency[access_idx] = 34312855Sgabeblack@google.com missLatency[access_idx] / misses[access_idx]; 34412855Sgabeblack@google.com 34512855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 34612855Sgabeblack@google.com avgMissLatency[access_idx].subname(i, system->getMasterName(i)); 34712855Sgabeblack@google.com } 34812855Sgabeblack@google.com } 34912855Sgabeblack@google.com 35012855Sgabeblack@google.com demandAvgMissLatency 35112855Sgabeblack@google.com .name(name() + ".demand_avg_miss_latency") 35212855Sgabeblack@google.com .desc("average overall miss latency") 35312855Sgabeblack@google.com .flags(total | nozero | nonan) 35412855Sgabeblack@google.com ; 35512855Sgabeblack@google.com demandAvgMissLatency = demandMissLatency / demandMisses; 35612855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 35712855Sgabeblack@google.com demandAvgMissLatency.subname(i, system->getMasterName(i)); 35812855Sgabeblack@google.com } 35912855Sgabeblack@google.com 36012855Sgabeblack@google.com overallAvgMissLatency 36112855Sgabeblack@google.com .name(name() + ".overall_avg_miss_latency") 36212855Sgabeblack@google.com .desc("average overall miss latency") 36312855Sgabeblack@google.com .flags(total | nozero | nonan) 36412855Sgabeblack@google.com ; 36512855Sgabeblack@google.com overallAvgMissLatency = overallMissLatency / overallMisses; 36612855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 36712855Sgabeblack@google.com overallAvgMissLatency.subname(i, system->getMasterName(i)); 36812855Sgabeblack@google.com } 36912855Sgabeblack@google.com 37012855Sgabeblack@google.com blocked_cycles.init(NUM_BLOCKED_CAUSES); 37112855Sgabeblack@google.com blocked_cycles 37212855Sgabeblack@google.com .name(name() + ".blocked_cycles") 37312855Sgabeblack@google.com .desc("number of cycles access was blocked") 37412855Sgabeblack@google.com .subname(Blocked_NoMSHRs, "no_mshrs") 37512855Sgabeblack@google.com .subname(Blocked_NoTargets, "no_targets") 37612855Sgabeblack@google.com ; 37712855Sgabeblack@google.com 37812855Sgabeblack@google.com 37912855Sgabeblack@google.com blocked_causes.init(NUM_BLOCKED_CAUSES); 38012855Sgabeblack@google.com blocked_causes 38112855Sgabeblack@google.com .name(name() + ".blocked") 38212855Sgabeblack@google.com .desc("number of cycles access was blocked") 38312855Sgabeblack@google.com .subname(Blocked_NoMSHRs, "no_mshrs") 38412855Sgabeblack@google.com .subname(Blocked_NoTargets, "no_targets") 38512855Sgabeblack@google.com ; 38612855Sgabeblack@google.com 38712855Sgabeblack@google.com avg_blocked 38812855Sgabeblack@google.com .name(name() + ".avg_blocked_cycles") 38912855Sgabeblack@google.com .desc("average number of cycles each access was blocked") 39012855Sgabeblack@google.com .subname(Blocked_NoMSHRs, "no_mshrs") 39112855Sgabeblack@google.com .subname(Blocked_NoTargets, "no_targets") 39212855Sgabeblack@google.com ; 39312855Sgabeblack@google.com 39412855Sgabeblack@google.com avg_blocked = blocked_cycles / blocked_causes; 39512855Sgabeblack@google.com 39612855Sgabeblack@google.com fastWrites 39712855Sgabeblack@google.com .name(name() + ".fast_writes") 39812855Sgabeblack@google.com .desc("number of fast writes performed") 39912855Sgabeblack@google.com ; 40012855Sgabeblack@google.com 40112855Sgabeblack@google.com cacheCopies 40212855Sgabeblack@google.com .name(name() + ".cache_copies") 40312855Sgabeblack@google.com .desc("number of cache copies performed") 40412855Sgabeblack@google.com ; 40512855Sgabeblack@google.com 40612855Sgabeblack@google.com writebacks 40712855Sgabeblack@google.com .init(system->maxMasters()) 40812855Sgabeblack@google.com .name(name() + ".writebacks") 40912855Sgabeblack@google.com .desc("number of writebacks") 41012855Sgabeblack@google.com .flags(total | nozero | nonan) 41112855Sgabeblack@google.com ; 41212855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 41312855Sgabeblack@google.com writebacks.subname(i, system->getMasterName(i)); 41412855Sgabeblack@google.com } 41512855Sgabeblack@google.com 41612855Sgabeblack@google.com // MSHR statistics 41712855Sgabeblack@google.com // MSHR hit statistics 41812855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 41912855Sgabeblack@google.com MemCmd cmd(access_idx); 42012855Sgabeblack@google.com const string &cstr = cmd.toString(); 42112855Sgabeblack@google.com 42212855Sgabeblack@google.com mshr_hits[access_idx] 42312855Sgabeblack@google.com .init(system->maxMasters()) 42412855Sgabeblack@google.com .name(name() + "." + cstr + "_mshr_hits") 42512855Sgabeblack@google.com .desc("number of " + cstr + " MSHR hits") 42612855Sgabeblack@google.com .flags(total | nozero | nonan) 42712855Sgabeblack@google.com ; 42812855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 42912855Sgabeblack@google.com mshr_hits[access_idx].subname(i, system->getMasterName(i)); 43012855Sgabeblack@google.com } 43112855Sgabeblack@google.com } 43212855Sgabeblack@google.com 43312855Sgabeblack@google.com demandMshrHits 43412855Sgabeblack@google.com .name(name() + ".demand_mshr_hits") 43512855Sgabeblack@google.com .desc("number of demand (read+write) MSHR hits") 43612855Sgabeblack@google.com .flags(total | nozero | nonan) 43712855Sgabeblack@google.com ; 43812855Sgabeblack@google.com demandMshrHits = SUM_DEMAND(mshr_hits); 43912855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 44012855Sgabeblack@google.com demandMshrHits.subname(i, system->getMasterName(i)); 44112855Sgabeblack@google.com } 44212855Sgabeblack@google.com 44312855Sgabeblack@google.com overallMshrHits 44412855Sgabeblack@google.com .name(name() + ".overall_mshr_hits") 44512855Sgabeblack@google.com .desc("number of overall MSHR hits") 44612855Sgabeblack@google.com .flags(total | nozero | nonan) 44712855Sgabeblack@google.com ; 44812855Sgabeblack@google.com overallMshrHits = demandMshrHits + SUM_NON_DEMAND(mshr_hits); 44912855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 45012855Sgabeblack@google.com overallMshrHits.subname(i, system->getMasterName(i)); 45112855Sgabeblack@google.com } 45212855Sgabeblack@google.com 45312855Sgabeblack@google.com // MSHR miss statistics 45412855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 45512855Sgabeblack@google.com MemCmd cmd(access_idx); 45612855Sgabeblack@google.com const string &cstr = cmd.toString(); 45712855Sgabeblack@google.com 45812855Sgabeblack@google.com mshr_misses[access_idx] 45912855Sgabeblack@google.com .init(system->maxMasters()) 46012855Sgabeblack@google.com .name(name() + "." + cstr + "_mshr_misses") 46112855Sgabeblack@google.com .desc("number of " + cstr + " MSHR misses") 46212855Sgabeblack@google.com .flags(total | nozero | nonan) 46312855Sgabeblack@google.com ; 46412855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 46512855Sgabeblack@google.com mshr_misses[access_idx].subname(i, system->getMasterName(i)); 46612855Sgabeblack@google.com } 46712855Sgabeblack@google.com } 46812855Sgabeblack@google.com 46912855Sgabeblack@google.com demandMshrMisses 47012855Sgabeblack@google.com .name(name() + ".demand_mshr_misses") 47112855Sgabeblack@google.com .desc("number of demand (read+write) MSHR misses") 47212855Sgabeblack@google.com .flags(total | nozero | nonan) 47312855Sgabeblack@google.com ; 47412855Sgabeblack@google.com demandMshrMisses = SUM_DEMAND(mshr_misses); 47512855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 47612855Sgabeblack@google.com demandMshrMisses.subname(i, system->getMasterName(i)); 47712855Sgabeblack@google.com } 47812855Sgabeblack@google.com 47912855Sgabeblack@google.com overallMshrMisses 48012855Sgabeblack@google.com .name(name() + ".overall_mshr_misses") 48112855Sgabeblack@google.com .desc("number of overall MSHR misses") 48212855Sgabeblack@google.com .flags(total | nozero | nonan) 48312855Sgabeblack@google.com ; 48412855Sgabeblack@google.com overallMshrMisses = demandMshrMisses + SUM_NON_DEMAND(mshr_misses); 48512855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 48612855Sgabeblack@google.com overallMshrMisses.subname(i, system->getMasterName(i)); 48712855Sgabeblack@google.com } 48812855Sgabeblack@google.com 48912855Sgabeblack@google.com // MSHR miss latency statistics 49012855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 49112855Sgabeblack@google.com MemCmd cmd(access_idx); 49212855Sgabeblack@google.com const string &cstr = cmd.toString(); 49312855Sgabeblack@google.com 49412855Sgabeblack@google.com mshr_miss_latency[access_idx] 49512855Sgabeblack@google.com .init(system->maxMasters()) 49612855Sgabeblack@google.com .name(name() + "." + cstr + "_mshr_miss_latency") 49712855Sgabeblack@google.com .desc("number of " + cstr + " MSHR miss cycles") 49812855Sgabeblack@google.com .flags(total | nozero | nonan) 49912855Sgabeblack@google.com ; 50012855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 50112855Sgabeblack@google.com mshr_miss_latency[access_idx].subname(i, system->getMasterName(i)); 50212855Sgabeblack@google.com } 50312855Sgabeblack@google.com } 50412855Sgabeblack@google.com 50512855Sgabeblack@google.com demandMshrMissLatency 50612855Sgabeblack@google.com .name(name() + ".demand_mshr_miss_latency") 50712855Sgabeblack@google.com .desc("number of demand (read+write) MSHR miss cycles") 50812855Sgabeblack@google.com .flags(total | nozero | nonan) 50912855Sgabeblack@google.com ; 51012855Sgabeblack@google.com demandMshrMissLatency = SUM_DEMAND(mshr_miss_latency); 51112855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 51212855Sgabeblack@google.com demandMshrMissLatency.subname(i, system->getMasterName(i)); 51312855Sgabeblack@google.com } 51412855Sgabeblack@google.com 51512855Sgabeblack@google.com overallMshrMissLatency 51612855Sgabeblack@google.com .name(name() + ".overall_mshr_miss_latency") 51712855Sgabeblack@google.com .desc("number of overall MSHR miss cycles") 51812855Sgabeblack@google.com .flags(total | nozero | nonan) 51912855Sgabeblack@google.com ; 52012855Sgabeblack@google.com overallMshrMissLatency = 52112855Sgabeblack@google.com demandMshrMissLatency + SUM_NON_DEMAND(mshr_miss_latency); 52212855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 52312855Sgabeblack@google.com overallMshrMissLatency.subname(i, system->getMasterName(i)); 52412855Sgabeblack@google.com } 52512855Sgabeblack@google.com 52612855Sgabeblack@google.com // MSHR uncacheable statistics 52712855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 52812855Sgabeblack@google.com MemCmd cmd(access_idx); 52912855Sgabeblack@google.com const string &cstr = cmd.toString(); 53012855Sgabeblack@google.com 53112855Sgabeblack@google.com mshr_uncacheable[access_idx] 53212855Sgabeblack@google.com .init(system->maxMasters()) 53312855Sgabeblack@google.com .name(name() + "." + cstr + "_mshr_uncacheable") 53412855Sgabeblack@google.com .desc("number of " + cstr + " MSHR uncacheable") 53512855Sgabeblack@google.com .flags(total | nozero | nonan) 53612855Sgabeblack@google.com ; 53712855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 53812855Sgabeblack@google.com mshr_uncacheable[access_idx].subname(i, system->getMasterName(i)); 53912855Sgabeblack@google.com } 54012855Sgabeblack@google.com } 54112855Sgabeblack@google.com 54212855Sgabeblack@google.com overallMshrUncacheable 54312855Sgabeblack@google.com .name(name() + ".overall_mshr_uncacheable_misses") 54412855Sgabeblack@google.com .desc("number of overall MSHR uncacheable misses") 54512855Sgabeblack@google.com .flags(total | nozero | nonan) 54612855Sgabeblack@google.com ; 54712855Sgabeblack@google.com overallMshrUncacheable = 54812855Sgabeblack@google.com SUM_DEMAND(mshr_uncacheable) + SUM_NON_DEMAND(mshr_uncacheable); 54912855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 55012855Sgabeblack@google.com overallMshrUncacheable.subname(i, system->getMasterName(i)); 55112855Sgabeblack@google.com } 55212855Sgabeblack@google.com 55312855Sgabeblack@google.com // MSHR miss latency statistics 55412855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 55512855Sgabeblack@google.com MemCmd cmd(access_idx); 55612855Sgabeblack@google.com const string &cstr = cmd.toString(); 55712855Sgabeblack@google.com 55812855Sgabeblack@google.com mshr_uncacheable_lat[access_idx] 55912855Sgabeblack@google.com .init(system->maxMasters()) 56012855Sgabeblack@google.com .name(name() + "." + cstr + "_mshr_uncacheable_latency") 56112855Sgabeblack@google.com .desc("number of " + cstr + " MSHR uncacheable cycles") 56212855Sgabeblack@google.com .flags(total | nozero | nonan) 56312855Sgabeblack@google.com ; 56412855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 56512855Sgabeblack@google.com mshr_uncacheable_lat[access_idx].subname(i, system->getMasterName(i)); 56612855Sgabeblack@google.com } 56712855Sgabeblack@google.com } 56812855Sgabeblack@google.com 56912855Sgabeblack@google.com overallMshrUncacheableLatency 57012855Sgabeblack@google.com .name(name() + ".overall_mshr_uncacheable_latency") 57112855Sgabeblack@google.com .desc("number of overall MSHR uncacheable cycles") 57212855Sgabeblack@google.com .flags(total | nozero | nonan) 57312855Sgabeblack@google.com ; 57412855Sgabeblack@google.com overallMshrUncacheableLatency = 57512855Sgabeblack@google.com SUM_DEMAND(mshr_uncacheable_lat) + 57612855Sgabeblack@google.com SUM_NON_DEMAND(mshr_uncacheable_lat); 57712855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 57812855Sgabeblack@google.com overallMshrUncacheableLatency.subname(i, system->getMasterName(i)); 57912855Sgabeblack@google.com } 58012855Sgabeblack@google.com 58112855Sgabeblack@google.com#if 0 58212855Sgabeblack@google.com // MSHR access formulas 58312855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 58412855Sgabeblack@google.com MemCmd cmd(access_idx); 58512855Sgabeblack@google.com const string &cstr = cmd.toString(); 58612855Sgabeblack@google.com 58712855Sgabeblack@google.com mshrAccesses[access_idx] 58812855Sgabeblack@google.com .name(name() + "." + cstr + "_mshr_accesses") 58912855Sgabeblack@google.com .desc("number of " + cstr + " mshr accesses(hits+misses)") 59012855Sgabeblack@google.com .flags(total | nozero | nonan) 59112855Sgabeblack@google.com ; 59212855Sgabeblack@google.com mshrAccesses[access_idx] = 59312855Sgabeblack@google.com mshr_hits[access_idx] + mshr_misses[access_idx] 59412855Sgabeblack@google.com + mshr_uncacheable[access_idx]; 59512855Sgabeblack@google.com } 59612855Sgabeblack@google.com 59712855Sgabeblack@google.com demandMshrAccesses 59812855Sgabeblack@google.com .name(name() + ".demand_mshr_accesses") 59912855Sgabeblack@google.com .desc("number of demand (read+write) mshr accesses") 60012855Sgabeblack@google.com .flags(total | nozero | nonan) 60112855Sgabeblack@google.com ; 60212855Sgabeblack@google.com demandMshrAccesses = demandMshrHits + demandMshrMisses; 60312855Sgabeblack@google.com 60412855Sgabeblack@google.com overallMshrAccesses 60512855Sgabeblack@google.com .name(name() + ".overall_mshr_accesses") 60612855Sgabeblack@google.com .desc("number of overall (read+write) mshr accesses") 60712855Sgabeblack@google.com .flags(total | nozero | nonan) 60812855Sgabeblack@google.com ; 60912855Sgabeblack@google.com overallMshrAccesses = overallMshrHits + overallMshrMisses 61012855Sgabeblack@google.com + overallMshrUncacheable; 61112855Sgabeblack@google.com#endif 61212855Sgabeblack@google.com 61312855Sgabeblack@google.com // MSHR miss rate formulas 61412855Sgabeblack@google.com for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 61512855Sgabeblack@google.com MemCmd cmd(access_idx); 61612855Sgabeblack@google.com const string &cstr = cmd.toString(); 61712855Sgabeblack@google.com 61812855Sgabeblack@google.com mshrMissRate[access_idx] 61912855Sgabeblack@google.com .name(name() + "." + cstr + "_mshr_miss_rate") 62012855Sgabeblack@google.com .desc("mshr miss rate for " + cstr + " accesses") 62112855Sgabeblack@google.com .flags(total | nozero | nonan) 62212855Sgabeblack@google.com ; 62312855Sgabeblack@google.com mshrMissRate[access_idx] = 62412855Sgabeblack@google.com mshr_misses[access_idx] / accesses[access_idx]; 62512855Sgabeblack@google.com 62612855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 62712855Sgabeblack@google.com mshrMissRate[access_idx].subname(i, system->getMasterName(i)); 62812855Sgabeblack@google.com } 62912855Sgabeblack@google.com } 63012855Sgabeblack@google.com 63112855Sgabeblack@google.com demandMshrMissRate 63212855Sgabeblack@google.com .name(name() + ".demand_mshr_miss_rate") 63312855Sgabeblack@google.com .desc("mshr miss rate for demand accesses") 63412855Sgabeblack@google.com .flags(total | nozero | nonan) 63512855Sgabeblack@google.com ; 63612855Sgabeblack@google.com demandMshrMissRate = demandMshrMisses / demandAccesses; 63712855Sgabeblack@google.com for (int i = 0; i < system->maxMasters(); i++) { 638 demandMshrMissRate.subname(i, system->getMasterName(i)); 639 } 640 641 overallMshrMissRate 642 .name(name() + ".overall_mshr_miss_rate") 643 .desc("mshr miss rate for overall accesses") 644 .flags(total | nozero | nonan) 645 ; 646 overallMshrMissRate = overallMshrMisses / overallAccesses; 647 for (int i = 0; i < system->maxMasters(); i++) { 648 overallMshrMissRate.subname(i, system->getMasterName(i)); 649 } 650 651 // mshrMiss latency formulas 652 for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 653 MemCmd cmd(access_idx); 654 const string &cstr = cmd.toString(); 655 656 avgMshrMissLatency[access_idx] 657 .name(name() + "." + cstr + "_avg_mshr_miss_latency") 658 .desc("average " + cstr + " mshr miss latency") 659 .flags(total | nozero | nonan) 660 ; 661 avgMshrMissLatency[access_idx] = 662 mshr_miss_latency[access_idx] / mshr_misses[access_idx]; 663 664 for (int i = 0; i < system->maxMasters(); i++) { 665 avgMshrMissLatency[access_idx].subname(i, system->getMasterName(i)); 666 } 667 } 668 669 demandAvgMshrMissLatency 670 .name(name() + ".demand_avg_mshr_miss_latency") 671 .desc("average overall mshr miss latency") 672 .flags(total | nozero | nonan) 673 ; 674 demandAvgMshrMissLatency = demandMshrMissLatency / demandMshrMisses; 675 for (int i = 0; i < system->maxMasters(); i++) { 676 demandAvgMshrMissLatency.subname(i, system->getMasterName(i)); 677 } 678 679 overallAvgMshrMissLatency 680 .name(name() + ".overall_avg_mshr_miss_latency") 681 .desc("average overall mshr miss latency") 682 .flags(total | nozero | nonan) 683 ; 684 overallAvgMshrMissLatency = overallMshrMissLatency / overallMshrMisses; 685 for (int i = 0; i < system->maxMasters(); i++) { 686 overallAvgMshrMissLatency.subname(i, system->getMasterName(i)); 687 } 688 689 // mshrUncacheable latency formulas 690 for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 691 MemCmd cmd(access_idx); 692 const string &cstr = cmd.toString(); 693 694 avgMshrUncacheableLatency[access_idx] 695 .name(name() + "." + cstr + "_avg_mshr_uncacheable_latency") 696 .desc("average " + cstr + " mshr uncacheable latency") 697 .flags(total | nozero | nonan) 698 ; 699 avgMshrUncacheableLatency[access_idx] = 700 mshr_uncacheable_lat[access_idx] / mshr_uncacheable[access_idx]; 701 702 for (int i = 0; i < system->maxMasters(); i++) { 703 avgMshrUncacheableLatency[access_idx].subname(i, system->getMasterName(i)); 704 } 705 } 706 707 overallAvgMshrUncacheableLatency 708 .name(name() + ".overall_avg_mshr_uncacheable_latency") 709 .desc("average overall mshr uncacheable latency") 710 .flags(total | nozero | nonan) 711 ; 712 overallAvgMshrUncacheableLatency = overallMshrUncacheableLatency / overallMshrUncacheable; 713 for (int i = 0; i < system->maxMasters(); i++) { 714 overallAvgMshrUncacheableLatency.subname(i, system->getMasterName(i)); 715 } 716 717 mshr_cap_events 718 .init(system->maxMasters()) 719 .name(name() + ".mshr_cap_events") 720 .desc("number of times MSHR cap was activated") 721 .flags(total | nozero | nonan) 722 ; 723 for (int i = 0; i < system->maxMasters(); i++) { 724 mshr_cap_events.subname(i, system->getMasterName(i)); 725 } 726 727 //software prefetching stats 728 soft_prefetch_mshr_full 729 .init(system->maxMasters()) 730 .name(name() + ".soft_prefetch_mshr_full") 731 .desc("number of mshr full events for SW prefetching instrutions") 732 .flags(total | nozero | nonan) 733 ; 734 for (int i = 0; i < system->maxMasters(); i++) { 735 soft_prefetch_mshr_full.subname(i, system->getMasterName(i)); 736 } 737 738 mshr_no_allocate_misses 739 .name(name() +".no_allocate_misses") 740 .desc("Number of misses that were no-allocate") 741 ; 742 743} 744 745unsigned int 746BaseCache::drain(Event *de) 747{ 748 int count = memSidePort->drain(de) + cpuSidePort->drain(de); 749 750 // Set status 751 if (count != 0) { 752 drainEvent = de; 753 754 changeState(SimObject::Draining); 755 return count; 756 } 757 758 changeState(SimObject::Drained); 759 return 0; 760} 761