base.cc revision 9690
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 483348SN/A#include "cpu/base.hh" 493348SN/A#include "cpu/smt.hh" 508232Snate@binkert.org#include "debug/Cache.hh" 519152Satgutier@umich.edu#include "debug/Drain.hh" 525338Sstever@gmail.com#include "mem/cache/base.hh" 535338Sstever@gmail.com#include "mem/cache/mshr.hh" 548786Sgblack@eecs.umich.edu#include "sim/full_system.hh" 552810SN/A 562810SN/Ausing namespace std; 572810SN/A 588856Sandreas.hansson@arm.comBaseCache::CacheSlavePort::CacheSlavePort(const std::string &_name, 598856Sandreas.hansson@arm.com BaseCache *_cache, 608856Sandreas.hansson@arm.com const std::string &_label) 618922Swilliam.wang@arm.com : QueuedSlavePort(_name, _cache, queue), queue(*_cache, *this, _label), 628914Sandreas.hansson@arm.com blocked(false), mustSendRetry(false), sendRetryEvent(this) 638856Sandreas.hansson@arm.com{ 648856Sandreas.hansson@arm.com} 654475SN/A 665034SN/ABaseCache::BaseCache(const Params *p) 675034SN/A : MemObject(p), 685314SN/A mshrQueue("MSHRs", p->mshrs, 4, MSHRQueue_MSHRs), 695314SN/A writeBuffer("write buffer", p->write_buffers, p->mshrs+1000, 704628SN/A MSHRQueue_WriteBuffer), 715034SN/A blkSize(p->block_size), 729263Smrinmoy.ghosh@arm.com hitLatency(p->hit_latency), 739263Smrinmoy.ghosh@arm.com responseLatency(p->response_latency), 745034SN/A numTarget(p->tgts_per_mshr), 756122SSteve.Reinhardt@amd.com forwardSnoops(p->forward_snoops), 768134SAli.Saidi@ARM.com isTopLevel(p->is_top_level), 774626SN/A blocked(0), 784626SN/A noTargetMSHR(NULL), 795034SN/A missCount(p->max_miss_count), 808883SAli.Saidi@ARM.com addrRanges(p->addr_ranges.begin(), p->addr_ranges.end()), 818833Sdam.sunwoo@arm.com system(p->system) 824458SN/A{ 832810SN/A} 842810SN/A 853013SN/Avoid 868856Sandreas.hansson@arm.comBaseCache::CacheSlavePort::setBlocked() 872810SN/A{ 883013SN/A assert(!blocked); 898856Sandreas.hansson@arm.com DPRINTF(CachePort, "Cache port %s blocking new requests\n", name()); 902810SN/A blocked = true; 919614Srene.dejong@arm.com // if we already scheduled a retry in this cycle, but it has not yet 929614Srene.dejong@arm.com // happened, cancel it 939614Srene.dejong@arm.com if (sendRetryEvent.scheduled()) { 949614Srene.dejong@arm.com owner.deschedule(sendRetryEvent); 959614Srene.dejong@arm.com DPRINTF(CachePort, "Cache port %s deschedule retry\n", name()); 969614Srene.dejong@arm.com mustSendRetry = true; 979614Srene.dejong@arm.com } 982810SN/A} 992810SN/A 1002810SN/Avoid 1018856Sandreas.hansson@arm.comBaseCache::CacheSlavePort::clearBlocked() 1022810SN/A{ 1033013SN/A assert(blocked); 1048856Sandreas.hansson@arm.com DPRINTF(CachePort, "Cache port %s accepting new requests\n", name()); 1053013SN/A blocked = false; 1068856Sandreas.hansson@arm.com if (mustSendRetry) { 1078856Sandreas.hansson@arm.com DPRINTF(CachePort, "Cache port %s sending retry\n", name()); 1082897SN/A mustSendRetry = false; 1094666SN/A // @TODO: need to find a better time (next bus cycle?) 1108922Swilliam.wang@arm.com owner.schedule(sendRetryEvent, curTick() + 1); 1112897SN/A } 1122810SN/A} 1132810SN/A 1142844SN/A 1152810SN/Avoid 1162858SN/ABaseCache::init() 1172858SN/A{ 1188856Sandreas.hansson@arm.com if (!cpuSidePort->isConnected() || !memSidePort->isConnected()) 1198922Swilliam.wang@arm.com fatal("Cache ports on %s are not connected\n", name()); 1208711Sandreas.hansson@arm.com cpuSidePort->sendRangeChange(); 1212858SN/A} 1222858SN/A 1239294Sandreas.hansson@arm.comBaseMasterPort & 1249294Sandreas.hansson@arm.comBaseCache::getMasterPort(const std::string &if_name, PortID idx) 1258922Swilliam.wang@arm.com{ 1268922Swilliam.wang@arm.com if (if_name == "mem_side") { 1278922Swilliam.wang@arm.com return *memSidePort; 1288922Swilliam.wang@arm.com } else { 1298922Swilliam.wang@arm.com return MemObject::getMasterPort(if_name, idx); 1308922Swilliam.wang@arm.com } 1318922Swilliam.wang@arm.com} 1328922Swilliam.wang@arm.com 1339294Sandreas.hansson@arm.comBaseSlavePort & 1349294Sandreas.hansson@arm.comBaseCache::getSlavePort(const std::string &if_name, PortID idx) 1358922Swilliam.wang@arm.com{ 1368922Swilliam.wang@arm.com if (if_name == "cpu_side") { 1378922Swilliam.wang@arm.com return *cpuSidePort; 1388922Swilliam.wang@arm.com } else { 1398922Swilliam.wang@arm.com return MemObject::getSlavePort(if_name, idx); 1408922Swilliam.wang@arm.com } 1418922Swilliam.wang@arm.com} 1424628SN/A 1432858SN/Avoid 1442810SN/ABaseCache::regStats() 1452810SN/A{ 1462810SN/A using namespace Stats; 1472810SN/A 1482810SN/A // Hit statistics 1494022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 1504022SN/A MemCmd cmd(access_idx); 1514022SN/A const string &cstr = cmd.toString(); 1522810SN/A 1532810SN/A hits[access_idx] 1548833Sdam.sunwoo@arm.com .init(system->maxMasters()) 1552810SN/A .name(name() + "." + cstr + "_hits") 1562810SN/A .desc("number of " + cstr + " hits") 1572810SN/A .flags(total | nozero | nonan) 1582810SN/A ; 1598833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 1608833Sdam.sunwoo@arm.com hits[access_idx].subname(i, system->getMasterName(i)); 1618833Sdam.sunwoo@arm.com } 1622810SN/A } 1632810SN/A 1644871SN/A// These macros make it easier to sum the right subset of commands and 1654871SN/A// to change the subset of commands that are considered "demand" vs 1664871SN/A// "non-demand" 1674871SN/A#define SUM_DEMAND(s) \ 1684871SN/A (s[MemCmd::ReadReq] + s[MemCmd::WriteReq] + s[MemCmd::ReadExReq]) 1694871SN/A 1704871SN/A// should writebacks be included here? prior code was inconsistent... 1714871SN/A#define SUM_NON_DEMAND(s) \ 1724871SN/A (s[MemCmd::SoftPFReq] + s[MemCmd::HardPFReq]) 1734871SN/A 1742810SN/A demandHits 1752810SN/A .name(name() + ".demand_hits") 1762810SN/A .desc("number of demand (read+write) hits") 1778833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 1782810SN/A ; 1794871SN/A demandHits = SUM_DEMAND(hits); 1808833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 1818833Sdam.sunwoo@arm.com demandHits.subname(i, system->getMasterName(i)); 1828833Sdam.sunwoo@arm.com } 1832810SN/A 1842810SN/A overallHits 1852810SN/A .name(name() + ".overall_hits") 1862810SN/A .desc("number of overall hits") 1878833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 1882810SN/A ; 1894871SN/A overallHits = demandHits + SUM_NON_DEMAND(hits); 1908833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 1918833Sdam.sunwoo@arm.com overallHits.subname(i, system->getMasterName(i)); 1928833Sdam.sunwoo@arm.com } 1932810SN/A 1942810SN/A // Miss statistics 1954022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 1964022SN/A MemCmd cmd(access_idx); 1974022SN/A const string &cstr = cmd.toString(); 1982810SN/A 1992810SN/A misses[access_idx] 2008833Sdam.sunwoo@arm.com .init(system->maxMasters()) 2012810SN/A .name(name() + "." + cstr + "_misses") 2022810SN/A .desc("number of " + cstr + " misses") 2032810SN/A .flags(total | nozero | nonan) 2042810SN/A ; 2058833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2068833Sdam.sunwoo@arm.com misses[access_idx].subname(i, system->getMasterName(i)); 2078833Sdam.sunwoo@arm.com } 2082810SN/A } 2092810SN/A 2102810SN/A demandMisses 2112810SN/A .name(name() + ".demand_misses") 2122810SN/A .desc("number of demand (read+write) misses") 2138833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2142810SN/A ; 2154871SN/A demandMisses = SUM_DEMAND(misses); 2168833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2178833Sdam.sunwoo@arm.com demandMisses.subname(i, system->getMasterName(i)); 2188833Sdam.sunwoo@arm.com } 2192810SN/A 2202810SN/A overallMisses 2212810SN/A .name(name() + ".overall_misses") 2222810SN/A .desc("number of overall misses") 2238833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2242810SN/A ; 2254871SN/A overallMisses = demandMisses + SUM_NON_DEMAND(misses); 2268833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2278833Sdam.sunwoo@arm.com overallMisses.subname(i, system->getMasterName(i)); 2288833Sdam.sunwoo@arm.com } 2292810SN/A 2302810SN/A // Miss latency statistics 2314022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 2324022SN/A MemCmd cmd(access_idx); 2334022SN/A const string &cstr = cmd.toString(); 2342810SN/A 2352810SN/A missLatency[access_idx] 2368833Sdam.sunwoo@arm.com .init(system->maxMasters()) 2372810SN/A .name(name() + "." + cstr + "_miss_latency") 2382810SN/A .desc("number of " + cstr + " miss cycles") 2392810SN/A .flags(total | nozero | nonan) 2402810SN/A ; 2418833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2428833Sdam.sunwoo@arm.com missLatency[access_idx].subname(i, system->getMasterName(i)); 2438833Sdam.sunwoo@arm.com } 2442810SN/A } 2452810SN/A 2462810SN/A demandMissLatency 2472810SN/A .name(name() + ".demand_miss_latency") 2482810SN/A .desc("number of demand (read+write) miss cycles") 2498833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2502810SN/A ; 2514871SN/A demandMissLatency = SUM_DEMAND(missLatency); 2528833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2538833Sdam.sunwoo@arm.com demandMissLatency.subname(i, system->getMasterName(i)); 2548833Sdam.sunwoo@arm.com } 2552810SN/A 2562810SN/A overallMissLatency 2572810SN/A .name(name() + ".overall_miss_latency") 2582810SN/A .desc("number of overall miss cycles") 2598833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2602810SN/A ; 2614871SN/A overallMissLatency = demandMissLatency + SUM_NON_DEMAND(missLatency); 2628833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2638833Sdam.sunwoo@arm.com overallMissLatency.subname(i, system->getMasterName(i)); 2648833Sdam.sunwoo@arm.com } 2652810SN/A 2662810SN/A // access formulas 2674022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 2684022SN/A MemCmd cmd(access_idx); 2694022SN/A const string &cstr = cmd.toString(); 2702810SN/A 2712810SN/A accesses[access_idx] 2722810SN/A .name(name() + "." + cstr + "_accesses") 2732810SN/A .desc("number of " + cstr + " accesses(hits+misses)") 2742810SN/A .flags(total | nozero | nonan) 2752810SN/A ; 2768833Sdam.sunwoo@arm.com accesses[access_idx] = hits[access_idx] + misses[access_idx]; 2772810SN/A 2788833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2798833Sdam.sunwoo@arm.com accesses[access_idx].subname(i, system->getMasterName(i)); 2808833Sdam.sunwoo@arm.com } 2812810SN/A } 2822810SN/A 2832810SN/A demandAccesses 2842810SN/A .name(name() + ".demand_accesses") 2852810SN/A .desc("number of demand (read+write) accesses") 2868833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2872810SN/A ; 2882810SN/A demandAccesses = demandHits + demandMisses; 2898833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2908833Sdam.sunwoo@arm.com demandAccesses.subname(i, system->getMasterName(i)); 2918833Sdam.sunwoo@arm.com } 2922810SN/A 2932810SN/A overallAccesses 2942810SN/A .name(name() + ".overall_accesses") 2952810SN/A .desc("number of overall (read+write) accesses") 2968833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2972810SN/A ; 2982810SN/A overallAccesses = overallHits + overallMisses; 2998833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3008833Sdam.sunwoo@arm.com overallAccesses.subname(i, system->getMasterName(i)); 3018833Sdam.sunwoo@arm.com } 3022810SN/A 3032810SN/A // miss rate formulas 3044022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 3054022SN/A MemCmd cmd(access_idx); 3064022SN/A const string &cstr = cmd.toString(); 3072810SN/A 3082810SN/A missRate[access_idx] 3092810SN/A .name(name() + "." + cstr + "_miss_rate") 3102810SN/A .desc("miss rate for " + cstr + " accesses") 3112810SN/A .flags(total | nozero | nonan) 3122810SN/A ; 3138833Sdam.sunwoo@arm.com missRate[access_idx] = misses[access_idx] / accesses[access_idx]; 3142810SN/A 3158833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3168833Sdam.sunwoo@arm.com missRate[access_idx].subname(i, system->getMasterName(i)); 3178833Sdam.sunwoo@arm.com } 3182810SN/A } 3192810SN/A 3202810SN/A demandMissRate 3212810SN/A .name(name() + ".demand_miss_rate") 3222810SN/A .desc("miss rate for demand accesses") 3238833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3242810SN/A ; 3252810SN/A demandMissRate = demandMisses / demandAccesses; 3268833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3278833Sdam.sunwoo@arm.com demandMissRate.subname(i, system->getMasterName(i)); 3288833Sdam.sunwoo@arm.com } 3292810SN/A 3302810SN/A overallMissRate 3312810SN/A .name(name() + ".overall_miss_rate") 3322810SN/A .desc("miss rate for overall accesses") 3338833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3342810SN/A ; 3352810SN/A overallMissRate = overallMisses / overallAccesses; 3368833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3378833Sdam.sunwoo@arm.com overallMissRate.subname(i, system->getMasterName(i)); 3388833Sdam.sunwoo@arm.com } 3392810SN/A 3402810SN/A // miss latency formulas 3414022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 3424022SN/A MemCmd cmd(access_idx); 3434022SN/A const string &cstr = cmd.toString(); 3442810SN/A 3452810SN/A avgMissLatency[access_idx] 3462810SN/A .name(name() + "." + cstr + "_avg_miss_latency") 3472810SN/A .desc("average " + cstr + " miss latency") 3482810SN/A .flags(total | nozero | nonan) 3492810SN/A ; 3502810SN/A avgMissLatency[access_idx] = 3512810SN/A missLatency[access_idx] / misses[access_idx]; 3528833Sdam.sunwoo@arm.com 3538833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3548833Sdam.sunwoo@arm.com avgMissLatency[access_idx].subname(i, system->getMasterName(i)); 3558833Sdam.sunwoo@arm.com } 3562810SN/A } 3572810SN/A 3582810SN/A demandAvgMissLatency 3592810SN/A .name(name() + ".demand_avg_miss_latency") 3602810SN/A .desc("average overall miss latency") 3618833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3622810SN/A ; 3632810SN/A demandAvgMissLatency = demandMissLatency / demandMisses; 3648833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3658833Sdam.sunwoo@arm.com demandAvgMissLatency.subname(i, system->getMasterName(i)); 3668833Sdam.sunwoo@arm.com } 3672810SN/A 3682810SN/A overallAvgMissLatency 3692810SN/A .name(name() + ".overall_avg_miss_latency") 3702810SN/A .desc("average overall miss latency") 3718833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3722810SN/A ; 3732810SN/A overallAvgMissLatency = overallMissLatency / overallMisses; 3748833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3758833Sdam.sunwoo@arm.com overallAvgMissLatency.subname(i, system->getMasterName(i)); 3768833Sdam.sunwoo@arm.com } 3772810SN/A 3782810SN/A blocked_cycles.init(NUM_BLOCKED_CAUSES); 3792810SN/A blocked_cycles 3802810SN/A .name(name() + ".blocked_cycles") 3812810SN/A .desc("number of cycles access was blocked") 3822810SN/A .subname(Blocked_NoMSHRs, "no_mshrs") 3832810SN/A .subname(Blocked_NoTargets, "no_targets") 3842810SN/A ; 3852810SN/A 3862810SN/A 3872810SN/A blocked_causes.init(NUM_BLOCKED_CAUSES); 3882810SN/A blocked_causes 3892810SN/A .name(name() + ".blocked") 3902810SN/A .desc("number of cycles access was blocked") 3912810SN/A .subname(Blocked_NoMSHRs, "no_mshrs") 3922810SN/A .subname(Blocked_NoTargets, "no_targets") 3932810SN/A ; 3942810SN/A 3952810SN/A avg_blocked 3962810SN/A .name(name() + ".avg_blocked_cycles") 3972810SN/A .desc("average number of cycles each access was blocked") 3982810SN/A .subname(Blocked_NoMSHRs, "no_mshrs") 3992810SN/A .subname(Blocked_NoTargets, "no_targets") 4002810SN/A ; 4012810SN/A 4022810SN/A avg_blocked = blocked_cycles / blocked_causes; 4032810SN/A 4042810SN/A fastWrites 4052810SN/A .name(name() + ".fast_writes") 4062810SN/A .desc("number of fast writes performed") 4072810SN/A ; 4082810SN/A 4092810SN/A cacheCopies 4102810SN/A .name(name() + ".cache_copies") 4112810SN/A .desc("number of cache copies performed") 4122810SN/A ; 4132826SN/A 4144626SN/A writebacks 4158833Sdam.sunwoo@arm.com .init(system->maxMasters()) 4164626SN/A .name(name() + ".writebacks") 4174626SN/A .desc("number of writebacks") 4188833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4194626SN/A ; 4208833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4218833Sdam.sunwoo@arm.com writebacks.subname(i, system->getMasterName(i)); 4228833Sdam.sunwoo@arm.com } 4234626SN/A 4244626SN/A // MSHR statistics 4254626SN/A // MSHR hit statistics 4264626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 4274626SN/A MemCmd cmd(access_idx); 4284626SN/A const string &cstr = cmd.toString(); 4294626SN/A 4304626SN/A mshr_hits[access_idx] 4318833Sdam.sunwoo@arm.com .init(system->maxMasters()) 4324626SN/A .name(name() + "." + cstr + "_mshr_hits") 4334626SN/A .desc("number of " + cstr + " MSHR hits") 4344626SN/A .flags(total | nozero | nonan) 4354626SN/A ; 4368833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4378833Sdam.sunwoo@arm.com mshr_hits[access_idx].subname(i, system->getMasterName(i)); 4388833Sdam.sunwoo@arm.com } 4394626SN/A } 4404626SN/A 4414626SN/A demandMshrHits 4424626SN/A .name(name() + ".demand_mshr_hits") 4434626SN/A .desc("number of demand (read+write) MSHR hits") 4448833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4454626SN/A ; 4464871SN/A demandMshrHits = SUM_DEMAND(mshr_hits); 4478833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4488833Sdam.sunwoo@arm.com demandMshrHits.subname(i, system->getMasterName(i)); 4498833Sdam.sunwoo@arm.com } 4504626SN/A 4514626SN/A overallMshrHits 4524626SN/A .name(name() + ".overall_mshr_hits") 4534626SN/A .desc("number of overall MSHR hits") 4548833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4554626SN/A ; 4564871SN/A overallMshrHits = demandMshrHits + SUM_NON_DEMAND(mshr_hits); 4578833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4588833Sdam.sunwoo@arm.com overallMshrHits.subname(i, system->getMasterName(i)); 4598833Sdam.sunwoo@arm.com } 4604626SN/A 4614626SN/A // MSHR miss statistics 4624626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 4634626SN/A MemCmd cmd(access_idx); 4644626SN/A const string &cstr = cmd.toString(); 4654626SN/A 4664626SN/A mshr_misses[access_idx] 4678833Sdam.sunwoo@arm.com .init(system->maxMasters()) 4684626SN/A .name(name() + "." + cstr + "_mshr_misses") 4694626SN/A .desc("number of " + cstr + " MSHR misses") 4704626SN/A .flags(total | nozero | nonan) 4714626SN/A ; 4728833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4738833Sdam.sunwoo@arm.com mshr_misses[access_idx].subname(i, system->getMasterName(i)); 4748833Sdam.sunwoo@arm.com } 4754626SN/A } 4764626SN/A 4774626SN/A demandMshrMisses 4784626SN/A .name(name() + ".demand_mshr_misses") 4794626SN/A .desc("number of demand (read+write) MSHR misses") 4808833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4814626SN/A ; 4824871SN/A demandMshrMisses = SUM_DEMAND(mshr_misses); 4838833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4848833Sdam.sunwoo@arm.com demandMshrMisses.subname(i, system->getMasterName(i)); 4858833Sdam.sunwoo@arm.com } 4864626SN/A 4874626SN/A overallMshrMisses 4884626SN/A .name(name() + ".overall_mshr_misses") 4894626SN/A .desc("number of overall MSHR misses") 4908833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4914626SN/A ; 4924871SN/A overallMshrMisses = demandMshrMisses + SUM_NON_DEMAND(mshr_misses); 4938833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4948833Sdam.sunwoo@arm.com overallMshrMisses.subname(i, system->getMasterName(i)); 4958833Sdam.sunwoo@arm.com } 4964626SN/A 4974626SN/A // MSHR miss latency statistics 4984626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 4994626SN/A MemCmd cmd(access_idx); 5004626SN/A const string &cstr = cmd.toString(); 5014626SN/A 5024626SN/A mshr_miss_latency[access_idx] 5038833Sdam.sunwoo@arm.com .init(system->maxMasters()) 5044626SN/A .name(name() + "." + cstr + "_mshr_miss_latency") 5054626SN/A .desc("number of " + cstr + " MSHR miss cycles") 5064626SN/A .flags(total | nozero | nonan) 5074626SN/A ; 5088833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5098833Sdam.sunwoo@arm.com mshr_miss_latency[access_idx].subname(i, system->getMasterName(i)); 5108833Sdam.sunwoo@arm.com } 5114626SN/A } 5124626SN/A 5134626SN/A demandMshrMissLatency 5144626SN/A .name(name() + ".demand_mshr_miss_latency") 5154626SN/A .desc("number of demand (read+write) MSHR miss cycles") 5168833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 5174626SN/A ; 5184871SN/A demandMshrMissLatency = SUM_DEMAND(mshr_miss_latency); 5198833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5208833Sdam.sunwoo@arm.com demandMshrMissLatency.subname(i, system->getMasterName(i)); 5218833Sdam.sunwoo@arm.com } 5224626SN/A 5234626SN/A overallMshrMissLatency 5244626SN/A .name(name() + ".overall_mshr_miss_latency") 5254626SN/A .desc("number of overall MSHR miss cycles") 5268833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 5274626SN/A ; 5284871SN/A overallMshrMissLatency = 5294871SN/A demandMshrMissLatency + SUM_NON_DEMAND(mshr_miss_latency); 5308833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5318833Sdam.sunwoo@arm.com overallMshrMissLatency.subname(i, system->getMasterName(i)); 5328833Sdam.sunwoo@arm.com } 5334626SN/A 5344626SN/A // MSHR uncacheable statistics 5354626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 5364626SN/A MemCmd cmd(access_idx); 5374626SN/A const string &cstr = cmd.toString(); 5384626SN/A 5394626SN/A mshr_uncacheable[access_idx] 5408833Sdam.sunwoo@arm.com .init(system->maxMasters()) 5414626SN/A .name(name() + "." + cstr + "_mshr_uncacheable") 5424626SN/A .desc("number of " + cstr + " MSHR uncacheable") 5434626SN/A .flags(total | nozero | nonan) 5444626SN/A ; 5458833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5468833Sdam.sunwoo@arm.com mshr_uncacheable[access_idx].subname(i, system->getMasterName(i)); 5478833Sdam.sunwoo@arm.com } 5484626SN/A } 5494626SN/A 5504626SN/A overallMshrUncacheable 5514626SN/A .name(name() + ".overall_mshr_uncacheable_misses") 5524626SN/A .desc("number of overall MSHR uncacheable misses") 5538833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 5544626SN/A ; 5554871SN/A overallMshrUncacheable = 5564871SN/A SUM_DEMAND(mshr_uncacheable) + SUM_NON_DEMAND(mshr_uncacheable); 5578833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5588833Sdam.sunwoo@arm.com overallMshrUncacheable.subname(i, system->getMasterName(i)); 5598833Sdam.sunwoo@arm.com } 5604626SN/A 5614626SN/A // MSHR miss latency statistics 5624626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 5634626SN/A MemCmd cmd(access_idx); 5644626SN/A const string &cstr = cmd.toString(); 5654626SN/A 5664626SN/A mshr_uncacheable_lat[access_idx] 5678833Sdam.sunwoo@arm.com .init(system->maxMasters()) 5684626SN/A .name(name() + "." + cstr + "_mshr_uncacheable_latency") 5694626SN/A .desc("number of " + cstr + " MSHR uncacheable cycles") 5704626SN/A .flags(total | nozero | nonan) 5714626SN/A ; 5728833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5738833Sdam.sunwoo@arm.com mshr_uncacheable_lat[access_idx].subname(i, system->getMasterName(i)); 5748833Sdam.sunwoo@arm.com } 5754626SN/A } 5764626SN/A 5774626SN/A overallMshrUncacheableLatency 5784626SN/A .name(name() + ".overall_mshr_uncacheable_latency") 5794626SN/A .desc("number of overall MSHR uncacheable cycles") 5808833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 5814626SN/A ; 5824871SN/A overallMshrUncacheableLatency = 5834871SN/A SUM_DEMAND(mshr_uncacheable_lat) + 5844871SN/A SUM_NON_DEMAND(mshr_uncacheable_lat); 5858833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5868833Sdam.sunwoo@arm.com overallMshrUncacheableLatency.subname(i, system->getMasterName(i)); 5878833Sdam.sunwoo@arm.com } 5884626SN/A 5894626SN/A#if 0 5904626SN/A // MSHR access formulas 5914626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 5924626SN/A MemCmd cmd(access_idx); 5934626SN/A const string &cstr = cmd.toString(); 5944626SN/A 5954626SN/A mshrAccesses[access_idx] 5964626SN/A .name(name() + "." + cstr + "_mshr_accesses") 5974626SN/A .desc("number of " + cstr + " mshr accesses(hits+misses)") 5984626SN/A .flags(total | nozero | nonan) 5994626SN/A ; 6004626SN/A mshrAccesses[access_idx] = 6014626SN/A mshr_hits[access_idx] + mshr_misses[access_idx] 6024626SN/A + mshr_uncacheable[access_idx]; 6034626SN/A } 6044626SN/A 6054626SN/A demandMshrAccesses 6064626SN/A .name(name() + ".demand_mshr_accesses") 6074626SN/A .desc("number of demand (read+write) mshr accesses") 6084626SN/A .flags(total | nozero | nonan) 6094626SN/A ; 6104626SN/A demandMshrAccesses = demandMshrHits + demandMshrMisses; 6114626SN/A 6124626SN/A overallMshrAccesses 6134626SN/A .name(name() + ".overall_mshr_accesses") 6144626SN/A .desc("number of overall (read+write) mshr accesses") 6154626SN/A .flags(total | nozero | nonan) 6164626SN/A ; 6174626SN/A overallMshrAccesses = overallMshrHits + overallMshrMisses 6184626SN/A + overallMshrUncacheable; 6194626SN/A#endif 6204626SN/A 6214626SN/A // MSHR miss rate formulas 6224626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 6234626SN/A MemCmd cmd(access_idx); 6244626SN/A const string &cstr = cmd.toString(); 6254626SN/A 6264626SN/A mshrMissRate[access_idx] 6274626SN/A .name(name() + "." + cstr + "_mshr_miss_rate") 6284626SN/A .desc("mshr miss rate for " + cstr + " accesses") 6294626SN/A .flags(total | nozero | nonan) 6304626SN/A ; 6314626SN/A mshrMissRate[access_idx] = 6324626SN/A mshr_misses[access_idx] / accesses[access_idx]; 6338833Sdam.sunwoo@arm.com 6348833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6358833Sdam.sunwoo@arm.com mshrMissRate[access_idx].subname(i, system->getMasterName(i)); 6368833Sdam.sunwoo@arm.com } 6374626SN/A } 6384626SN/A 6394626SN/A demandMshrMissRate 6404626SN/A .name(name() + ".demand_mshr_miss_rate") 6414626SN/A .desc("mshr miss rate for demand accesses") 6428833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 6434626SN/A ; 6444626SN/A demandMshrMissRate = demandMshrMisses / demandAccesses; 6458833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6468833Sdam.sunwoo@arm.com demandMshrMissRate.subname(i, system->getMasterName(i)); 6478833Sdam.sunwoo@arm.com } 6484626SN/A 6494626SN/A overallMshrMissRate 6504626SN/A .name(name() + ".overall_mshr_miss_rate") 6514626SN/A .desc("mshr miss rate for overall accesses") 6528833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 6534626SN/A ; 6544626SN/A overallMshrMissRate = overallMshrMisses / overallAccesses; 6558833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6568833Sdam.sunwoo@arm.com overallMshrMissRate.subname(i, system->getMasterName(i)); 6578833Sdam.sunwoo@arm.com } 6584626SN/A 6594626SN/A // mshrMiss latency formulas 6604626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 6614626SN/A MemCmd cmd(access_idx); 6624626SN/A const string &cstr = cmd.toString(); 6634626SN/A 6644626SN/A avgMshrMissLatency[access_idx] 6654626SN/A .name(name() + "." + cstr + "_avg_mshr_miss_latency") 6664626SN/A .desc("average " + cstr + " mshr miss latency") 6674626SN/A .flags(total | nozero | nonan) 6684626SN/A ; 6694626SN/A avgMshrMissLatency[access_idx] = 6704626SN/A mshr_miss_latency[access_idx] / mshr_misses[access_idx]; 6718833Sdam.sunwoo@arm.com 6728833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6738833Sdam.sunwoo@arm.com avgMshrMissLatency[access_idx].subname(i, system->getMasterName(i)); 6748833Sdam.sunwoo@arm.com } 6754626SN/A } 6764626SN/A 6774626SN/A demandAvgMshrMissLatency 6784626SN/A .name(name() + ".demand_avg_mshr_miss_latency") 6794626SN/A .desc("average overall mshr miss latency") 6808833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 6814626SN/A ; 6824626SN/A demandAvgMshrMissLatency = demandMshrMissLatency / demandMshrMisses; 6838833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6848833Sdam.sunwoo@arm.com demandAvgMshrMissLatency.subname(i, system->getMasterName(i)); 6858833Sdam.sunwoo@arm.com } 6864626SN/A 6874626SN/A overallAvgMshrMissLatency 6884626SN/A .name(name() + ".overall_avg_mshr_miss_latency") 6894626SN/A .desc("average overall mshr miss latency") 6908833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 6914626SN/A ; 6924626SN/A overallAvgMshrMissLatency = overallMshrMissLatency / overallMshrMisses; 6938833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6948833Sdam.sunwoo@arm.com overallAvgMshrMissLatency.subname(i, system->getMasterName(i)); 6958833Sdam.sunwoo@arm.com } 6964626SN/A 6974626SN/A // mshrUncacheable latency formulas 6984626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 6994626SN/A MemCmd cmd(access_idx); 7004626SN/A const string &cstr = cmd.toString(); 7014626SN/A 7024626SN/A avgMshrUncacheableLatency[access_idx] 7034626SN/A .name(name() + "." + cstr + "_avg_mshr_uncacheable_latency") 7044626SN/A .desc("average " + cstr + " mshr uncacheable latency") 7054626SN/A .flags(total | nozero | nonan) 7064626SN/A ; 7074626SN/A avgMshrUncacheableLatency[access_idx] = 7084626SN/A mshr_uncacheable_lat[access_idx] / mshr_uncacheable[access_idx]; 7098833Sdam.sunwoo@arm.com 7108833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 7118833Sdam.sunwoo@arm.com avgMshrUncacheableLatency[access_idx].subname(i, system->getMasterName(i)); 7128833Sdam.sunwoo@arm.com } 7134626SN/A } 7144626SN/A 7154626SN/A overallAvgMshrUncacheableLatency 7164626SN/A .name(name() + ".overall_avg_mshr_uncacheable_latency") 7174626SN/A .desc("average overall mshr uncacheable latency") 7188833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 7194626SN/A ; 7204626SN/A overallAvgMshrUncacheableLatency = overallMshrUncacheableLatency / overallMshrUncacheable; 7218833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 7228833Sdam.sunwoo@arm.com overallAvgMshrUncacheableLatency.subname(i, system->getMasterName(i)); 7238833Sdam.sunwoo@arm.com } 7244626SN/A 7254626SN/A mshr_cap_events 7268833Sdam.sunwoo@arm.com .init(system->maxMasters()) 7274626SN/A .name(name() + ".mshr_cap_events") 7284626SN/A .desc("number of times MSHR cap was activated") 7298833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 7304626SN/A ; 7318833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 7328833Sdam.sunwoo@arm.com mshr_cap_events.subname(i, system->getMasterName(i)); 7338833Sdam.sunwoo@arm.com } 7344626SN/A 7354626SN/A //software prefetching stats 7364626SN/A soft_prefetch_mshr_full 7378833Sdam.sunwoo@arm.com .init(system->maxMasters()) 7384626SN/A .name(name() + ".soft_prefetch_mshr_full") 7394626SN/A .desc("number of mshr full events for SW prefetching instrutions") 7408833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 7414626SN/A ; 7428833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 7438833Sdam.sunwoo@arm.com soft_prefetch_mshr_full.subname(i, system->getMasterName(i)); 7448833Sdam.sunwoo@arm.com } 7454626SN/A 7464626SN/A mshr_no_allocate_misses 7474626SN/A .name(name() +".no_allocate_misses") 7484626SN/A .desc("Number of misses that were no-allocate") 7494626SN/A ; 7504626SN/A 7512810SN/A} 7523503SN/A 7533503SN/Aunsigned int 7549342SAndreas.Sandberg@arm.comBaseCache::drain(DrainManager *dm) 7553503SN/A{ 7569347SAndreas.Sandberg@arm.com int count = memSidePort->drain(dm) + cpuSidePort->drain(dm) + 7579347SAndreas.Sandberg@arm.com mshrQueue.drain(dm) + writeBuffer.drain(dm); 7584626SN/A 7593503SN/A // Set status 7604626SN/A if (count != 0) { 7619342SAndreas.Sandberg@arm.com setDrainState(Drainable::Draining); 7629152Satgutier@umich.edu DPRINTF(Drain, "Cache not drained\n"); 7634626SN/A return count; 7643503SN/A } 7653503SN/A 7669342SAndreas.Sandberg@arm.com setDrainState(Drainable::Drained); 7673503SN/A return 0; 7683503SN/A} 769