base.cc revision 11053
12810SN/A/* 29614Srene.dejong@arm.com * Copyright (c) 2012-2013 ARM Limited 38856Sandreas.hansson@arm.com * All rights reserved. 48856Sandreas.hansson@arm.com * 58856Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 68856Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 78856Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 88856Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 98856Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 108856Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 118856Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 128856Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 138856Sandreas.hansson@arm.com * 142810SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan 152810SN/A * All rights reserved. 162810SN/A * 172810SN/A * Redistribution and use in source and binary forms, with or without 182810SN/A * modification, are permitted provided that the following conditions are 192810SN/A * met: redistributions of source code must retain the above copyright 202810SN/A * notice, this list of conditions and the following disclaimer; 212810SN/A * redistributions in binary form must reproduce the above copyright 222810SN/A * notice, this list of conditions and the following disclaimer in the 232810SN/A * documentation and/or other materials provided with the distribution; 242810SN/A * neither the name of the copyright holders nor the names of its 252810SN/A * contributors may be used to endorse or promote products derived from 262810SN/A * this software without specific prior written permission. 272810SN/A * 282810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 292810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 302810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 312810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 322810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 332810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 342810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 352810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 362810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 372810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 382810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392810SN/A * 402810SN/A * Authors: Erik Hallnor 412810SN/A */ 422810SN/A 432810SN/A/** 442810SN/A * @file 452810SN/A * Definition of BaseCache functions. 462810SN/A */ 472810SN/A 488232Snate@binkert.org#include "debug/Cache.hh" 499152Satgutier@umich.edu#include "debug/Drain.hh" 509795Sandreas.hansson@arm.com#include "mem/cache/tags/fa_lru.hh" 519795Sandreas.hansson@arm.com#include "mem/cache/tags/lru.hh" 5210263Satgutier@umich.edu#include "mem/cache/tags/random_repl.hh" 535338Sstever@gmail.com#include "mem/cache/base.hh" 549795Sandreas.hansson@arm.com#include "mem/cache/cache.hh" 555338Sstever@gmail.com#include "mem/cache/mshr.hh" 568786Sgblack@eecs.umich.edu#include "sim/full_system.hh" 572810SN/A 582810SN/Ausing namespace std; 592810SN/A 608856Sandreas.hansson@arm.comBaseCache::CacheSlavePort::CacheSlavePort(const std::string &_name, 618856Sandreas.hansson@arm.com BaseCache *_cache, 628856Sandreas.hansson@arm.com const std::string &_label) 638922Swilliam.wang@arm.com : QueuedSlavePort(_name, _cache, queue), queue(*_cache, *this, _label), 648914Sandreas.hansson@arm.com blocked(false), mustSendRetry(false), sendRetryEvent(this) 658856Sandreas.hansson@arm.com{ 668856Sandreas.hansson@arm.com} 674475SN/A 6811053Sandreas.hansson@arm.comBaseCache::BaseCache(const BaseCacheParams *p, unsigned blk_size) 695034SN/A : MemObject(p), 7010360Sandreas.hansson@arm.com cpuSidePort(nullptr), memSidePort(nullptr), 7110622Smitch.hayenga@arm.com mshrQueue("MSHRs", p->mshrs, 4, p->demand_mshr_reserve, MSHRQueue_MSHRs), 7210622Smitch.hayenga@arm.com writeBuffer("write buffer", p->write_buffers, p->mshrs+1000, 0, 734628SN/A MSHRQueue_WriteBuffer), 7411053Sandreas.hansson@arm.com blkSize(blk_size), 7510693SMarco.Balboni@ARM.com lookupLatency(p->hit_latency), 7610693SMarco.Balboni@ARM.com forwardLatency(p->hit_latency), 7710693SMarco.Balboni@ARM.com fillLatency(p->response_latency), 789263Smrinmoy.ghosh@arm.com responseLatency(p->response_latency), 795034SN/A numTarget(p->tgts_per_mshr), 806122SSteve.Reinhardt@amd.com forwardSnoops(p->forward_snoops), 8110884Sandreas.hansson@arm.com isReadOnly(p->is_read_only), 824626SN/A blocked(0), 8310360Sandreas.hansson@arm.com order(0), 844626SN/A noTargetMSHR(NULL), 855034SN/A missCount(p->max_miss_count), 868883SAli.Saidi@ARM.com addrRanges(p->addr_ranges.begin(), p->addr_ranges.end()), 878833Sdam.sunwoo@arm.com system(p->system) 884458SN/A{ 892810SN/A} 902810SN/A 913013SN/Avoid 928856Sandreas.hansson@arm.comBaseCache::CacheSlavePort::setBlocked() 932810SN/A{ 943013SN/A assert(!blocked); 9510714Sandreas.hansson@arm.com DPRINTF(CachePort, "Port is blocking new requests\n"); 962810SN/A blocked = true; 979614Srene.dejong@arm.com // if we already scheduled a retry in this cycle, but it has not yet 989614Srene.dejong@arm.com // happened, cancel it 999614Srene.dejong@arm.com if (sendRetryEvent.scheduled()) { 10010345SCurtis.Dunham@arm.com owner.deschedule(sendRetryEvent); 10110714Sandreas.hansson@arm.com DPRINTF(CachePort, "Port descheduled retry\n"); 10210345SCurtis.Dunham@arm.com mustSendRetry = true; 1039614Srene.dejong@arm.com } 1042810SN/A} 1052810SN/A 1062810SN/Avoid 1078856Sandreas.hansson@arm.comBaseCache::CacheSlavePort::clearBlocked() 1082810SN/A{ 1093013SN/A assert(blocked); 11010714Sandreas.hansson@arm.com DPRINTF(CachePort, "Port is accepting new requests\n"); 1113013SN/A blocked = false; 1128856Sandreas.hansson@arm.com if (mustSendRetry) { 11310714Sandreas.hansson@arm.com // @TODO: need to find a better time (next cycle?) 1148922Swilliam.wang@arm.com owner.schedule(sendRetryEvent, curTick() + 1); 1152897SN/A } 1162810SN/A} 1172810SN/A 11810344Sandreas.hansson@arm.comvoid 11910344Sandreas.hansson@arm.comBaseCache::CacheSlavePort::processSendRetry() 12010344Sandreas.hansson@arm.com{ 12110714Sandreas.hansson@arm.com DPRINTF(CachePort, "Port is sending retry\n"); 12210344Sandreas.hansson@arm.com 12310344Sandreas.hansson@arm.com // reset the flag and call retry 12410344Sandreas.hansson@arm.com mustSendRetry = false; 12510713Sandreas.hansson@arm.com sendRetryReq(); 12610344Sandreas.hansson@arm.com} 1272844SN/A 1282810SN/Avoid 1292858SN/ABaseCache::init() 1302858SN/A{ 1318856Sandreas.hansson@arm.com if (!cpuSidePort->isConnected() || !memSidePort->isConnected()) 1328922Swilliam.wang@arm.com fatal("Cache ports on %s are not connected\n", name()); 1338711Sandreas.hansson@arm.com cpuSidePort->sendRangeChange(); 1342858SN/A} 1352858SN/A 1369294Sandreas.hansson@arm.comBaseMasterPort & 1379294Sandreas.hansson@arm.comBaseCache::getMasterPort(const std::string &if_name, PortID idx) 1388922Swilliam.wang@arm.com{ 1398922Swilliam.wang@arm.com if (if_name == "mem_side") { 1408922Swilliam.wang@arm.com return *memSidePort; 1418922Swilliam.wang@arm.com } else { 1428922Swilliam.wang@arm.com return MemObject::getMasterPort(if_name, idx); 1438922Swilliam.wang@arm.com } 1448922Swilliam.wang@arm.com} 1458922Swilliam.wang@arm.com 1469294Sandreas.hansson@arm.comBaseSlavePort & 1479294Sandreas.hansson@arm.comBaseCache::getSlavePort(const std::string &if_name, PortID idx) 1488922Swilliam.wang@arm.com{ 1498922Swilliam.wang@arm.com if (if_name == "cpu_side") { 1508922Swilliam.wang@arm.com return *cpuSidePort; 1518922Swilliam.wang@arm.com } else { 1528922Swilliam.wang@arm.com return MemObject::getSlavePort(if_name, idx); 1538922Swilliam.wang@arm.com } 1548922Swilliam.wang@arm.com} 1554628SN/A 15610821Sandreas.hansson@arm.combool 15710821Sandreas.hansson@arm.comBaseCache::inRange(Addr addr) const 15810821Sandreas.hansson@arm.com{ 15910821Sandreas.hansson@arm.com for (const auto& r : addrRanges) { 16010821Sandreas.hansson@arm.com if (r.contains(addr)) { 16110821Sandreas.hansson@arm.com return true; 16210821Sandreas.hansson@arm.com } 16310821Sandreas.hansson@arm.com } 16410821Sandreas.hansson@arm.com return false; 16510821Sandreas.hansson@arm.com} 16610821Sandreas.hansson@arm.com 1672858SN/Avoid 1682810SN/ABaseCache::regStats() 1692810SN/A{ 1702810SN/A using namespace Stats; 1712810SN/A 1722810SN/A // Hit statistics 1734022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 1744022SN/A MemCmd cmd(access_idx); 1754022SN/A const string &cstr = cmd.toString(); 1762810SN/A 1772810SN/A hits[access_idx] 1788833Sdam.sunwoo@arm.com .init(system->maxMasters()) 1792810SN/A .name(name() + "." + cstr + "_hits") 1802810SN/A .desc("number of " + cstr + " hits") 1812810SN/A .flags(total | nozero | nonan) 1822810SN/A ; 1838833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 1848833Sdam.sunwoo@arm.com hits[access_idx].subname(i, system->getMasterName(i)); 1858833Sdam.sunwoo@arm.com } 1862810SN/A } 1872810SN/A 1884871SN/A// These macros make it easier to sum the right subset of commands and 1894871SN/A// to change the subset of commands that are considered "demand" vs 1904871SN/A// "non-demand" 1914871SN/A#define SUM_DEMAND(s) \ 19210885Sandreas.hansson@arm.com (s[MemCmd::ReadReq] + s[MemCmd::WriteReq] + \ 19310885Sandreas.hansson@arm.com s[MemCmd::ReadExReq] + s[MemCmd::ReadCleanReq] + s[MemCmd::ReadSharedReq]) 1944871SN/A 1954871SN/A// should writebacks be included here? prior code was inconsistent... 1964871SN/A#define SUM_NON_DEMAND(s) \ 1974871SN/A (s[MemCmd::SoftPFReq] + s[MemCmd::HardPFReq]) 1984871SN/A 1992810SN/A demandHits 2002810SN/A .name(name() + ".demand_hits") 2012810SN/A .desc("number of demand (read+write) hits") 2028833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2032810SN/A ; 2044871SN/A demandHits = SUM_DEMAND(hits); 2058833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2068833Sdam.sunwoo@arm.com demandHits.subname(i, system->getMasterName(i)); 2078833Sdam.sunwoo@arm.com } 2082810SN/A 2092810SN/A overallHits 2102810SN/A .name(name() + ".overall_hits") 2112810SN/A .desc("number of overall hits") 2128833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2132810SN/A ; 2144871SN/A overallHits = demandHits + SUM_NON_DEMAND(hits); 2158833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2168833Sdam.sunwoo@arm.com overallHits.subname(i, system->getMasterName(i)); 2178833Sdam.sunwoo@arm.com } 2182810SN/A 2192810SN/A // Miss statistics 2204022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 2214022SN/A MemCmd cmd(access_idx); 2224022SN/A const string &cstr = cmd.toString(); 2232810SN/A 2242810SN/A misses[access_idx] 2258833Sdam.sunwoo@arm.com .init(system->maxMasters()) 2262810SN/A .name(name() + "." + cstr + "_misses") 2272810SN/A .desc("number of " + cstr + " misses") 2282810SN/A .flags(total | nozero | nonan) 2292810SN/A ; 2308833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2318833Sdam.sunwoo@arm.com misses[access_idx].subname(i, system->getMasterName(i)); 2328833Sdam.sunwoo@arm.com } 2332810SN/A } 2342810SN/A 2352810SN/A demandMisses 2362810SN/A .name(name() + ".demand_misses") 2372810SN/A .desc("number of demand (read+write) misses") 2388833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2392810SN/A ; 2404871SN/A demandMisses = SUM_DEMAND(misses); 2418833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2428833Sdam.sunwoo@arm.com demandMisses.subname(i, system->getMasterName(i)); 2438833Sdam.sunwoo@arm.com } 2442810SN/A 2452810SN/A overallMisses 2462810SN/A .name(name() + ".overall_misses") 2472810SN/A .desc("number of overall misses") 2488833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2492810SN/A ; 2504871SN/A overallMisses = demandMisses + SUM_NON_DEMAND(misses); 2518833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2528833Sdam.sunwoo@arm.com overallMisses.subname(i, system->getMasterName(i)); 2538833Sdam.sunwoo@arm.com } 2542810SN/A 2552810SN/A // Miss latency statistics 2564022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 2574022SN/A MemCmd cmd(access_idx); 2584022SN/A const string &cstr = cmd.toString(); 2592810SN/A 2602810SN/A missLatency[access_idx] 2618833Sdam.sunwoo@arm.com .init(system->maxMasters()) 2622810SN/A .name(name() + "." + cstr + "_miss_latency") 2632810SN/A .desc("number of " + cstr + " miss cycles") 2642810SN/A .flags(total | nozero | nonan) 2652810SN/A ; 2668833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2678833Sdam.sunwoo@arm.com missLatency[access_idx].subname(i, system->getMasterName(i)); 2688833Sdam.sunwoo@arm.com } 2692810SN/A } 2702810SN/A 2712810SN/A demandMissLatency 2722810SN/A .name(name() + ".demand_miss_latency") 2732810SN/A .desc("number of demand (read+write) miss cycles") 2748833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2752810SN/A ; 2764871SN/A demandMissLatency = SUM_DEMAND(missLatency); 2778833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2788833Sdam.sunwoo@arm.com demandMissLatency.subname(i, system->getMasterName(i)); 2798833Sdam.sunwoo@arm.com } 2802810SN/A 2812810SN/A overallMissLatency 2822810SN/A .name(name() + ".overall_miss_latency") 2832810SN/A .desc("number of overall miss cycles") 2848833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2852810SN/A ; 2864871SN/A overallMissLatency = demandMissLatency + SUM_NON_DEMAND(missLatency); 2878833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2888833Sdam.sunwoo@arm.com overallMissLatency.subname(i, system->getMasterName(i)); 2898833Sdam.sunwoo@arm.com } 2902810SN/A 2912810SN/A // access formulas 2924022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 2934022SN/A MemCmd cmd(access_idx); 2944022SN/A const string &cstr = cmd.toString(); 2952810SN/A 2962810SN/A accesses[access_idx] 2972810SN/A .name(name() + "." + cstr + "_accesses") 2982810SN/A .desc("number of " + cstr + " accesses(hits+misses)") 2992810SN/A .flags(total | nozero | nonan) 3002810SN/A ; 3018833Sdam.sunwoo@arm.com accesses[access_idx] = hits[access_idx] + misses[access_idx]; 3022810SN/A 3038833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3048833Sdam.sunwoo@arm.com accesses[access_idx].subname(i, system->getMasterName(i)); 3058833Sdam.sunwoo@arm.com } 3062810SN/A } 3072810SN/A 3082810SN/A demandAccesses 3092810SN/A .name(name() + ".demand_accesses") 3102810SN/A .desc("number of demand (read+write) accesses") 3118833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3122810SN/A ; 3132810SN/A demandAccesses = demandHits + demandMisses; 3148833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3158833Sdam.sunwoo@arm.com demandAccesses.subname(i, system->getMasterName(i)); 3168833Sdam.sunwoo@arm.com } 3172810SN/A 3182810SN/A overallAccesses 3192810SN/A .name(name() + ".overall_accesses") 3202810SN/A .desc("number of overall (read+write) accesses") 3218833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3222810SN/A ; 3232810SN/A overallAccesses = overallHits + overallMisses; 3248833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3258833Sdam.sunwoo@arm.com overallAccesses.subname(i, system->getMasterName(i)); 3268833Sdam.sunwoo@arm.com } 3272810SN/A 3282810SN/A // miss rate formulas 3294022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 3304022SN/A MemCmd cmd(access_idx); 3314022SN/A const string &cstr = cmd.toString(); 3322810SN/A 3332810SN/A missRate[access_idx] 3342810SN/A .name(name() + "." + cstr + "_miss_rate") 3352810SN/A .desc("miss rate for " + cstr + " accesses") 3362810SN/A .flags(total | nozero | nonan) 3372810SN/A ; 3388833Sdam.sunwoo@arm.com missRate[access_idx] = misses[access_idx] / accesses[access_idx]; 3392810SN/A 3408833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3418833Sdam.sunwoo@arm.com missRate[access_idx].subname(i, system->getMasterName(i)); 3428833Sdam.sunwoo@arm.com } 3432810SN/A } 3442810SN/A 3452810SN/A demandMissRate 3462810SN/A .name(name() + ".demand_miss_rate") 3472810SN/A .desc("miss rate for demand accesses") 3488833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3492810SN/A ; 3502810SN/A demandMissRate = demandMisses / demandAccesses; 3518833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3528833Sdam.sunwoo@arm.com demandMissRate.subname(i, system->getMasterName(i)); 3538833Sdam.sunwoo@arm.com } 3542810SN/A 3552810SN/A overallMissRate 3562810SN/A .name(name() + ".overall_miss_rate") 3572810SN/A .desc("miss rate for overall accesses") 3588833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3592810SN/A ; 3602810SN/A overallMissRate = overallMisses / overallAccesses; 3618833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3628833Sdam.sunwoo@arm.com overallMissRate.subname(i, system->getMasterName(i)); 3638833Sdam.sunwoo@arm.com } 3642810SN/A 3652810SN/A // miss latency formulas 3664022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 3674022SN/A MemCmd cmd(access_idx); 3684022SN/A const string &cstr = cmd.toString(); 3692810SN/A 3702810SN/A avgMissLatency[access_idx] 3712810SN/A .name(name() + "." + cstr + "_avg_miss_latency") 3722810SN/A .desc("average " + cstr + " miss latency") 3732810SN/A .flags(total | nozero | nonan) 3742810SN/A ; 3752810SN/A avgMissLatency[access_idx] = 3762810SN/A missLatency[access_idx] / misses[access_idx]; 3778833Sdam.sunwoo@arm.com 3788833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3798833Sdam.sunwoo@arm.com avgMissLatency[access_idx].subname(i, system->getMasterName(i)); 3808833Sdam.sunwoo@arm.com } 3812810SN/A } 3822810SN/A 3832810SN/A demandAvgMissLatency 3842810SN/A .name(name() + ".demand_avg_miss_latency") 3852810SN/A .desc("average overall miss latency") 3868833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3872810SN/A ; 3882810SN/A demandAvgMissLatency = demandMissLatency / demandMisses; 3898833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3908833Sdam.sunwoo@arm.com demandAvgMissLatency.subname(i, system->getMasterName(i)); 3918833Sdam.sunwoo@arm.com } 3922810SN/A 3932810SN/A overallAvgMissLatency 3942810SN/A .name(name() + ".overall_avg_miss_latency") 3952810SN/A .desc("average overall miss latency") 3968833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3972810SN/A ; 3982810SN/A overallAvgMissLatency = overallMissLatency / overallMisses; 3998833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4008833Sdam.sunwoo@arm.com overallAvgMissLatency.subname(i, system->getMasterName(i)); 4018833Sdam.sunwoo@arm.com } 4022810SN/A 4032810SN/A blocked_cycles.init(NUM_BLOCKED_CAUSES); 4042810SN/A blocked_cycles 4052810SN/A .name(name() + ".blocked_cycles") 4062810SN/A .desc("number of cycles access was blocked") 4072810SN/A .subname(Blocked_NoMSHRs, "no_mshrs") 4082810SN/A .subname(Blocked_NoTargets, "no_targets") 4092810SN/A ; 4102810SN/A 4112810SN/A 4122810SN/A blocked_causes.init(NUM_BLOCKED_CAUSES); 4132810SN/A blocked_causes 4142810SN/A .name(name() + ".blocked") 4152810SN/A .desc("number of cycles access was blocked") 4162810SN/A .subname(Blocked_NoMSHRs, "no_mshrs") 4172810SN/A .subname(Blocked_NoTargets, "no_targets") 4182810SN/A ; 4192810SN/A 4202810SN/A avg_blocked 4212810SN/A .name(name() + ".avg_blocked_cycles") 4222810SN/A .desc("average number of cycles each access was blocked") 4232810SN/A .subname(Blocked_NoMSHRs, "no_mshrs") 4242810SN/A .subname(Blocked_NoTargets, "no_targets") 4252810SN/A ; 4262810SN/A 4272810SN/A avg_blocked = blocked_cycles / blocked_causes; 4282810SN/A 4292810SN/A fastWrites 4302810SN/A .name(name() + ".fast_writes") 4312810SN/A .desc("number of fast writes performed") 4322810SN/A ; 4332810SN/A 4342810SN/A cacheCopies 4352810SN/A .name(name() + ".cache_copies") 4362810SN/A .desc("number of cache copies performed") 4372810SN/A ; 4382826SN/A 4394626SN/A writebacks 4408833Sdam.sunwoo@arm.com .init(system->maxMasters()) 4414626SN/A .name(name() + ".writebacks") 4424626SN/A .desc("number of writebacks") 4438833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4444626SN/A ; 4458833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4468833Sdam.sunwoo@arm.com writebacks.subname(i, system->getMasterName(i)); 4478833Sdam.sunwoo@arm.com } 4484626SN/A 4494626SN/A // MSHR statistics 4504626SN/A // MSHR hit statistics 4514626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 4524626SN/A MemCmd cmd(access_idx); 4534626SN/A const string &cstr = cmd.toString(); 4544626SN/A 4554626SN/A mshr_hits[access_idx] 4568833Sdam.sunwoo@arm.com .init(system->maxMasters()) 4574626SN/A .name(name() + "." + cstr + "_mshr_hits") 4584626SN/A .desc("number of " + cstr + " MSHR hits") 4594626SN/A .flags(total | nozero | nonan) 4604626SN/A ; 4618833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4628833Sdam.sunwoo@arm.com mshr_hits[access_idx].subname(i, system->getMasterName(i)); 4638833Sdam.sunwoo@arm.com } 4644626SN/A } 4654626SN/A 4664626SN/A demandMshrHits 4674626SN/A .name(name() + ".demand_mshr_hits") 4684626SN/A .desc("number of demand (read+write) MSHR hits") 4698833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4704626SN/A ; 4714871SN/A demandMshrHits = SUM_DEMAND(mshr_hits); 4728833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4738833Sdam.sunwoo@arm.com demandMshrHits.subname(i, system->getMasterName(i)); 4748833Sdam.sunwoo@arm.com } 4754626SN/A 4764626SN/A overallMshrHits 4774626SN/A .name(name() + ".overall_mshr_hits") 4784626SN/A .desc("number of overall MSHR hits") 4798833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4804626SN/A ; 4814871SN/A overallMshrHits = demandMshrHits + SUM_NON_DEMAND(mshr_hits); 4828833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4838833Sdam.sunwoo@arm.com overallMshrHits.subname(i, system->getMasterName(i)); 4848833Sdam.sunwoo@arm.com } 4854626SN/A 4864626SN/A // MSHR miss statistics 4874626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 4884626SN/A MemCmd cmd(access_idx); 4894626SN/A const string &cstr = cmd.toString(); 4904626SN/A 4914626SN/A mshr_misses[access_idx] 4928833Sdam.sunwoo@arm.com .init(system->maxMasters()) 4934626SN/A .name(name() + "." + cstr + "_mshr_misses") 4944626SN/A .desc("number of " + cstr + " MSHR misses") 4954626SN/A .flags(total | nozero | nonan) 4964626SN/A ; 4978833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4988833Sdam.sunwoo@arm.com mshr_misses[access_idx].subname(i, system->getMasterName(i)); 4998833Sdam.sunwoo@arm.com } 5004626SN/A } 5014626SN/A 5024626SN/A demandMshrMisses 5034626SN/A .name(name() + ".demand_mshr_misses") 5044626SN/A .desc("number of demand (read+write) MSHR misses") 5058833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 5064626SN/A ; 5074871SN/A demandMshrMisses = SUM_DEMAND(mshr_misses); 5088833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5098833Sdam.sunwoo@arm.com demandMshrMisses.subname(i, system->getMasterName(i)); 5108833Sdam.sunwoo@arm.com } 5114626SN/A 5124626SN/A overallMshrMisses 5134626SN/A .name(name() + ".overall_mshr_misses") 5144626SN/A .desc("number of overall MSHR misses") 5158833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 5164626SN/A ; 5174871SN/A overallMshrMisses = demandMshrMisses + SUM_NON_DEMAND(mshr_misses); 5188833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5198833Sdam.sunwoo@arm.com overallMshrMisses.subname(i, system->getMasterName(i)); 5208833Sdam.sunwoo@arm.com } 5214626SN/A 5224626SN/A // MSHR miss latency statistics 5234626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 5244626SN/A MemCmd cmd(access_idx); 5254626SN/A const string &cstr = cmd.toString(); 5264626SN/A 5274626SN/A mshr_miss_latency[access_idx] 5288833Sdam.sunwoo@arm.com .init(system->maxMasters()) 5294626SN/A .name(name() + "." + cstr + "_mshr_miss_latency") 5304626SN/A .desc("number of " + cstr + " MSHR miss cycles") 5314626SN/A .flags(total | nozero | nonan) 5324626SN/A ; 5338833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5348833Sdam.sunwoo@arm.com mshr_miss_latency[access_idx].subname(i, system->getMasterName(i)); 5358833Sdam.sunwoo@arm.com } 5364626SN/A } 5374626SN/A 5384626SN/A demandMshrMissLatency 5394626SN/A .name(name() + ".demand_mshr_miss_latency") 5404626SN/A .desc("number of demand (read+write) MSHR miss cycles") 5418833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 5424626SN/A ; 5434871SN/A demandMshrMissLatency = SUM_DEMAND(mshr_miss_latency); 5448833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5458833Sdam.sunwoo@arm.com demandMshrMissLatency.subname(i, system->getMasterName(i)); 5468833Sdam.sunwoo@arm.com } 5474626SN/A 5484626SN/A overallMshrMissLatency 5494626SN/A .name(name() + ".overall_mshr_miss_latency") 5504626SN/A .desc("number of overall MSHR miss cycles") 5518833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 5524626SN/A ; 5534871SN/A overallMshrMissLatency = 5544871SN/A demandMshrMissLatency + SUM_NON_DEMAND(mshr_miss_latency); 5558833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5568833Sdam.sunwoo@arm.com overallMshrMissLatency.subname(i, system->getMasterName(i)); 5578833Sdam.sunwoo@arm.com } 5584626SN/A 5594626SN/A // MSHR uncacheable statistics 5604626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 5614626SN/A MemCmd cmd(access_idx); 5624626SN/A const string &cstr = cmd.toString(); 5634626SN/A 5644626SN/A mshr_uncacheable[access_idx] 5658833Sdam.sunwoo@arm.com .init(system->maxMasters()) 5664626SN/A .name(name() + "." + cstr + "_mshr_uncacheable") 5674626SN/A .desc("number of " + cstr + " MSHR uncacheable") 5684626SN/A .flags(total | nozero | nonan) 5694626SN/A ; 5708833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5718833Sdam.sunwoo@arm.com mshr_uncacheable[access_idx].subname(i, system->getMasterName(i)); 5728833Sdam.sunwoo@arm.com } 5734626SN/A } 5744626SN/A 5754626SN/A overallMshrUncacheable 5764626SN/A .name(name() + ".overall_mshr_uncacheable_misses") 5774626SN/A .desc("number of overall MSHR uncacheable misses") 5788833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 5794626SN/A ; 5804871SN/A overallMshrUncacheable = 5814871SN/A SUM_DEMAND(mshr_uncacheable) + SUM_NON_DEMAND(mshr_uncacheable); 5828833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5838833Sdam.sunwoo@arm.com overallMshrUncacheable.subname(i, system->getMasterName(i)); 5848833Sdam.sunwoo@arm.com } 5854626SN/A 5864626SN/A // MSHR miss latency statistics 5874626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 5884626SN/A MemCmd cmd(access_idx); 5894626SN/A const string &cstr = cmd.toString(); 5904626SN/A 5914626SN/A mshr_uncacheable_lat[access_idx] 5928833Sdam.sunwoo@arm.com .init(system->maxMasters()) 5934626SN/A .name(name() + "." + cstr + "_mshr_uncacheable_latency") 5944626SN/A .desc("number of " + cstr + " MSHR uncacheable cycles") 5954626SN/A .flags(total | nozero | nonan) 5964626SN/A ; 5978833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5988833Sdam.sunwoo@arm.com mshr_uncacheable_lat[access_idx].subname(i, system->getMasterName(i)); 5998833Sdam.sunwoo@arm.com } 6004626SN/A } 6014626SN/A 6024626SN/A overallMshrUncacheableLatency 6034626SN/A .name(name() + ".overall_mshr_uncacheable_latency") 6044626SN/A .desc("number of overall MSHR uncacheable cycles") 6058833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 6064626SN/A ; 6074871SN/A overallMshrUncacheableLatency = 6084871SN/A SUM_DEMAND(mshr_uncacheable_lat) + 6094871SN/A SUM_NON_DEMAND(mshr_uncacheable_lat); 6108833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6118833Sdam.sunwoo@arm.com overallMshrUncacheableLatency.subname(i, system->getMasterName(i)); 6128833Sdam.sunwoo@arm.com } 6134626SN/A 6144626SN/A#if 0 6154626SN/A // MSHR access formulas 6164626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 6174626SN/A MemCmd cmd(access_idx); 6184626SN/A const string &cstr = cmd.toString(); 6194626SN/A 6204626SN/A mshrAccesses[access_idx] 6214626SN/A .name(name() + "." + cstr + "_mshr_accesses") 6224626SN/A .desc("number of " + cstr + " mshr accesses(hits+misses)") 6234626SN/A .flags(total | nozero | nonan) 6244626SN/A ; 6254626SN/A mshrAccesses[access_idx] = 6264626SN/A mshr_hits[access_idx] + mshr_misses[access_idx] 6274626SN/A + mshr_uncacheable[access_idx]; 6284626SN/A } 6294626SN/A 6304626SN/A demandMshrAccesses 6314626SN/A .name(name() + ".demand_mshr_accesses") 6324626SN/A .desc("number of demand (read+write) mshr accesses") 6334626SN/A .flags(total | nozero | nonan) 6344626SN/A ; 6354626SN/A demandMshrAccesses = demandMshrHits + demandMshrMisses; 6364626SN/A 6374626SN/A overallMshrAccesses 6384626SN/A .name(name() + ".overall_mshr_accesses") 6394626SN/A .desc("number of overall (read+write) mshr accesses") 6404626SN/A .flags(total | nozero | nonan) 6414626SN/A ; 6424626SN/A overallMshrAccesses = overallMshrHits + overallMshrMisses 6434626SN/A + overallMshrUncacheable; 6444626SN/A#endif 6454626SN/A 6464626SN/A // MSHR miss rate formulas 6474626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 6484626SN/A MemCmd cmd(access_idx); 6494626SN/A const string &cstr = cmd.toString(); 6504626SN/A 6514626SN/A mshrMissRate[access_idx] 6524626SN/A .name(name() + "." + cstr + "_mshr_miss_rate") 6534626SN/A .desc("mshr miss rate for " + cstr + " accesses") 6544626SN/A .flags(total | nozero | nonan) 6554626SN/A ; 6564626SN/A mshrMissRate[access_idx] = 6574626SN/A mshr_misses[access_idx] / accesses[access_idx]; 6588833Sdam.sunwoo@arm.com 6598833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6608833Sdam.sunwoo@arm.com mshrMissRate[access_idx].subname(i, system->getMasterName(i)); 6618833Sdam.sunwoo@arm.com } 6624626SN/A } 6634626SN/A 6644626SN/A demandMshrMissRate 6654626SN/A .name(name() + ".demand_mshr_miss_rate") 6664626SN/A .desc("mshr miss rate for demand accesses") 6678833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 6684626SN/A ; 6694626SN/A demandMshrMissRate = demandMshrMisses / demandAccesses; 6708833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6718833Sdam.sunwoo@arm.com demandMshrMissRate.subname(i, system->getMasterName(i)); 6728833Sdam.sunwoo@arm.com } 6734626SN/A 6744626SN/A overallMshrMissRate 6754626SN/A .name(name() + ".overall_mshr_miss_rate") 6764626SN/A .desc("mshr miss rate for overall accesses") 6778833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 6784626SN/A ; 6794626SN/A overallMshrMissRate = overallMshrMisses / overallAccesses; 6808833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6818833Sdam.sunwoo@arm.com overallMshrMissRate.subname(i, system->getMasterName(i)); 6828833Sdam.sunwoo@arm.com } 6834626SN/A 6844626SN/A // mshrMiss latency formulas 6854626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 6864626SN/A MemCmd cmd(access_idx); 6874626SN/A const string &cstr = cmd.toString(); 6884626SN/A 6894626SN/A avgMshrMissLatency[access_idx] 6904626SN/A .name(name() + "." + cstr + "_avg_mshr_miss_latency") 6914626SN/A .desc("average " + cstr + " mshr miss latency") 6924626SN/A .flags(total | nozero | nonan) 6934626SN/A ; 6944626SN/A avgMshrMissLatency[access_idx] = 6954626SN/A mshr_miss_latency[access_idx] / mshr_misses[access_idx]; 6968833Sdam.sunwoo@arm.com 6978833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6988833Sdam.sunwoo@arm.com avgMshrMissLatency[access_idx].subname(i, system->getMasterName(i)); 6998833Sdam.sunwoo@arm.com } 7004626SN/A } 7014626SN/A 7024626SN/A demandAvgMshrMissLatency 7034626SN/A .name(name() + ".demand_avg_mshr_miss_latency") 7044626SN/A .desc("average overall mshr miss latency") 7058833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 7064626SN/A ; 7074626SN/A demandAvgMshrMissLatency = demandMshrMissLatency / demandMshrMisses; 7088833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 7098833Sdam.sunwoo@arm.com demandAvgMshrMissLatency.subname(i, system->getMasterName(i)); 7108833Sdam.sunwoo@arm.com } 7114626SN/A 7124626SN/A overallAvgMshrMissLatency 7134626SN/A .name(name() + ".overall_avg_mshr_miss_latency") 7144626SN/A .desc("average overall mshr miss latency") 7158833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 7164626SN/A ; 7174626SN/A overallAvgMshrMissLatency = overallMshrMissLatency / overallMshrMisses; 7188833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 7198833Sdam.sunwoo@arm.com overallAvgMshrMissLatency.subname(i, system->getMasterName(i)); 7208833Sdam.sunwoo@arm.com } 7214626SN/A 7224626SN/A // mshrUncacheable latency formulas 7234626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 7244626SN/A MemCmd cmd(access_idx); 7254626SN/A const string &cstr = cmd.toString(); 7264626SN/A 7274626SN/A avgMshrUncacheableLatency[access_idx] 7284626SN/A .name(name() + "." + cstr + "_avg_mshr_uncacheable_latency") 7294626SN/A .desc("average " + cstr + " mshr uncacheable latency") 7304626SN/A .flags(total | nozero | nonan) 7314626SN/A ; 7324626SN/A avgMshrUncacheableLatency[access_idx] = 7334626SN/A mshr_uncacheable_lat[access_idx] / mshr_uncacheable[access_idx]; 7348833Sdam.sunwoo@arm.com 7358833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 7368833Sdam.sunwoo@arm.com avgMshrUncacheableLatency[access_idx].subname(i, system->getMasterName(i)); 7378833Sdam.sunwoo@arm.com } 7384626SN/A } 7394626SN/A 7404626SN/A overallAvgMshrUncacheableLatency 7414626SN/A .name(name() + ".overall_avg_mshr_uncacheable_latency") 7424626SN/A .desc("average overall mshr uncacheable latency") 7438833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 7444626SN/A ; 7454626SN/A overallAvgMshrUncacheableLatency = overallMshrUncacheableLatency / overallMshrUncacheable; 7468833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 7478833Sdam.sunwoo@arm.com overallAvgMshrUncacheableLatency.subname(i, system->getMasterName(i)); 7488833Sdam.sunwoo@arm.com } 7494626SN/A 7504626SN/A mshr_cap_events 7518833Sdam.sunwoo@arm.com .init(system->maxMasters()) 7524626SN/A .name(name() + ".mshr_cap_events") 7534626SN/A .desc("number of times MSHR cap was activated") 7548833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 7554626SN/A ; 7568833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 7578833Sdam.sunwoo@arm.com mshr_cap_events.subname(i, system->getMasterName(i)); 7588833Sdam.sunwoo@arm.com } 7594626SN/A 7604626SN/A //software prefetching stats 7614626SN/A soft_prefetch_mshr_full 7628833Sdam.sunwoo@arm.com .init(system->maxMasters()) 7634626SN/A .name(name() + ".soft_prefetch_mshr_full") 7644626SN/A .desc("number of mshr full events for SW prefetching instrutions") 7658833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 7664626SN/A ; 7678833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 7688833Sdam.sunwoo@arm.com soft_prefetch_mshr_full.subname(i, system->getMasterName(i)); 7698833Sdam.sunwoo@arm.com } 7704626SN/A 7714626SN/A mshr_no_allocate_misses 7724626SN/A .name(name() +".no_allocate_misses") 7734626SN/A .desc("Number of misses that were no-allocate") 7744626SN/A ; 7754626SN/A 7762810SN/A} 777