base.cc revision 8914
12810SN/A/* 28856Sandreas.hansson@arm.com * Copyright (c) 2012 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" 515338Sstever@gmail.com#include "mem/cache/base.hh" 525338Sstever@gmail.com#include "mem/cache/mshr.hh" 538786Sgblack@eecs.umich.edu#include "sim/full_system.hh" 542810SN/A 552810SN/Ausing namespace std; 562810SN/A 578856Sandreas.hansson@arm.comBaseCache::CacheSlavePort::CacheSlavePort(const std::string &_name, 588856Sandreas.hansson@arm.com BaseCache *_cache, 598856Sandreas.hansson@arm.com const std::string &_label) 608914Sandreas.hansson@arm.com : QueuedPort(_name, _cache, queue), queue(*_cache, *this, _label), 618914Sandreas.hansson@arm.com blocked(false), mustSendRetry(false), sendRetryEvent(this) 628856Sandreas.hansson@arm.com{ 638856Sandreas.hansson@arm.com} 644475SN/A 655034SN/ABaseCache::BaseCache(const Params *p) 665034SN/A : MemObject(p), 675314SN/A mshrQueue("MSHRs", p->mshrs, 4, MSHRQueue_MSHRs), 685314SN/A writeBuffer("write buffer", p->write_buffers, p->mshrs+1000, 694628SN/A MSHRQueue_WriteBuffer), 705034SN/A blkSize(p->block_size), 715034SN/A hitLatency(p->latency), 725034SN/A numTarget(p->tgts_per_mshr), 736122SSteve.Reinhardt@amd.com forwardSnoops(p->forward_snoops), 748134SAli.Saidi@ARM.com isTopLevel(p->is_top_level), 754626SN/A blocked(0), 764626SN/A noTargetMSHR(NULL), 775034SN/A missCount(p->max_miss_count), 786122SSteve.Reinhardt@amd.com drainEvent(NULL), 798883SAli.Saidi@ARM.com addrRanges(p->addr_ranges.begin(), p->addr_ranges.end()), 808833Sdam.sunwoo@arm.com system(p->system) 814458SN/A{ 822810SN/A} 832810SN/A 843013SN/Avoid 858856Sandreas.hansson@arm.comBaseCache::CacheSlavePort::setBlocked() 862810SN/A{ 873013SN/A assert(!blocked); 888856Sandreas.hansson@arm.com DPRINTF(CachePort, "Cache port %s blocking new requests\n", name()); 892810SN/A blocked = true; 902810SN/A} 912810SN/A 922810SN/Avoid 938856Sandreas.hansson@arm.comBaseCache::CacheSlavePort::clearBlocked() 942810SN/A{ 953013SN/A assert(blocked); 968856Sandreas.hansson@arm.com DPRINTF(CachePort, "Cache port %s accepting new requests\n", name()); 973013SN/A blocked = false; 988856Sandreas.hansson@arm.com if (mustSendRetry) { 998856Sandreas.hansson@arm.com DPRINTF(CachePort, "Cache port %s sending retry\n", name()); 1002897SN/A mustSendRetry = false; 1014666SN/A // @TODO: need to find a better time (next bus cycle?) 1028856Sandreas.hansson@arm.com owner->schedule(sendRetryEvent, curTick() + 1); 1032897SN/A } 1042810SN/A} 1052810SN/A 1062844SN/A 1072810SN/Avoid 1082858SN/ABaseCache::init() 1092858SN/A{ 1108856Sandreas.hansson@arm.com if (!cpuSidePort->isConnected() || !memSidePort->isConnected()) 1118856Sandreas.hansson@arm.com panic("Cache %s not hooked up on both sides\n", name()); 1128711Sandreas.hansson@arm.com cpuSidePort->sendRangeChange(); 1132858SN/A} 1142858SN/A 1154628SN/A 1162858SN/Avoid 1172810SN/ABaseCache::regStats() 1182810SN/A{ 1192810SN/A using namespace Stats; 1202810SN/A 1212810SN/A // Hit statistics 1224022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 1234022SN/A MemCmd cmd(access_idx); 1244022SN/A const string &cstr = cmd.toString(); 1252810SN/A 1262810SN/A hits[access_idx] 1278833Sdam.sunwoo@arm.com .init(system->maxMasters()) 1282810SN/A .name(name() + "." + cstr + "_hits") 1292810SN/A .desc("number of " + cstr + " hits") 1302810SN/A .flags(total | nozero | nonan) 1312810SN/A ; 1328833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 1338833Sdam.sunwoo@arm.com hits[access_idx].subname(i, system->getMasterName(i)); 1348833Sdam.sunwoo@arm.com } 1352810SN/A } 1362810SN/A 1374871SN/A// These macros make it easier to sum the right subset of commands and 1384871SN/A// to change the subset of commands that are considered "demand" vs 1394871SN/A// "non-demand" 1404871SN/A#define SUM_DEMAND(s) \ 1414871SN/A (s[MemCmd::ReadReq] + s[MemCmd::WriteReq] + s[MemCmd::ReadExReq]) 1424871SN/A 1434871SN/A// should writebacks be included here? prior code was inconsistent... 1444871SN/A#define SUM_NON_DEMAND(s) \ 1454871SN/A (s[MemCmd::SoftPFReq] + s[MemCmd::HardPFReq]) 1464871SN/A 1472810SN/A demandHits 1482810SN/A .name(name() + ".demand_hits") 1492810SN/A .desc("number of demand (read+write) hits") 1508833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 1512810SN/A ; 1524871SN/A demandHits = SUM_DEMAND(hits); 1538833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 1548833Sdam.sunwoo@arm.com demandHits.subname(i, system->getMasterName(i)); 1558833Sdam.sunwoo@arm.com } 1562810SN/A 1572810SN/A overallHits 1582810SN/A .name(name() + ".overall_hits") 1592810SN/A .desc("number of overall hits") 1608833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 1612810SN/A ; 1624871SN/A overallHits = demandHits + SUM_NON_DEMAND(hits); 1638833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 1648833Sdam.sunwoo@arm.com overallHits.subname(i, system->getMasterName(i)); 1658833Sdam.sunwoo@arm.com } 1662810SN/A 1672810SN/A // Miss statistics 1684022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 1694022SN/A MemCmd cmd(access_idx); 1704022SN/A const string &cstr = cmd.toString(); 1712810SN/A 1722810SN/A misses[access_idx] 1738833Sdam.sunwoo@arm.com .init(system->maxMasters()) 1742810SN/A .name(name() + "." + cstr + "_misses") 1752810SN/A .desc("number of " + cstr + " misses") 1762810SN/A .flags(total | nozero | nonan) 1772810SN/A ; 1788833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 1798833Sdam.sunwoo@arm.com misses[access_idx].subname(i, system->getMasterName(i)); 1808833Sdam.sunwoo@arm.com } 1812810SN/A } 1822810SN/A 1832810SN/A demandMisses 1842810SN/A .name(name() + ".demand_misses") 1852810SN/A .desc("number of demand (read+write) misses") 1868833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 1872810SN/A ; 1884871SN/A demandMisses = SUM_DEMAND(misses); 1898833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 1908833Sdam.sunwoo@arm.com demandMisses.subname(i, system->getMasterName(i)); 1918833Sdam.sunwoo@arm.com } 1922810SN/A 1932810SN/A overallMisses 1942810SN/A .name(name() + ".overall_misses") 1952810SN/A .desc("number of overall misses") 1968833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 1972810SN/A ; 1984871SN/A overallMisses = demandMisses + SUM_NON_DEMAND(misses); 1998833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2008833Sdam.sunwoo@arm.com overallMisses.subname(i, system->getMasterName(i)); 2018833Sdam.sunwoo@arm.com } 2022810SN/A 2032810SN/A // Miss latency statistics 2044022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 2054022SN/A MemCmd cmd(access_idx); 2064022SN/A const string &cstr = cmd.toString(); 2072810SN/A 2082810SN/A missLatency[access_idx] 2098833Sdam.sunwoo@arm.com .init(system->maxMasters()) 2102810SN/A .name(name() + "." + cstr + "_miss_latency") 2112810SN/A .desc("number of " + cstr + " miss cycles") 2122810SN/A .flags(total | nozero | nonan) 2132810SN/A ; 2148833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2158833Sdam.sunwoo@arm.com missLatency[access_idx].subname(i, system->getMasterName(i)); 2168833Sdam.sunwoo@arm.com } 2172810SN/A } 2182810SN/A 2192810SN/A demandMissLatency 2202810SN/A .name(name() + ".demand_miss_latency") 2212810SN/A .desc("number of demand (read+write) miss cycles") 2228833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2232810SN/A ; 2244871SN/A demandMissLatency = SUM_DEMAND(missLatency); 2258833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2268833Sdam.sunwoo@arm.com demandMissLatency.subname(i, system->getMasterName(i)); 2278833Sdam.sunwoo@arm.com } 2282810SN/A 2292810SN/A overallMissLatency 2302810SN/A .name(name() + ".overall_miss_latency") 2312810SN/A .desc("number of overall miss cycles") 2328833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2332810SN/A ; 2344871SN/A overallMissLatency = demandMissLatency + SUM_NON_DEMAND(missLatency); 2358833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2368833Sdam.sunwoo@arm.com overallMissLatency.subname(i, system->getMasterName(i)); 2378833Sdam.sunwoo@arm.com } 2382810SN/A 2392810SN/A // access formulas 2404022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 2414022SN/A MemCmd cmd(access_idx); 2424022SN/A const string &cstr = cmd.toString(); 2432810SN/A 2442810SN/A accesses[access_idx] 2452810SN/A .name(name() + "." + cstr + "_accesses") 2462810SN/A .desc("number of " + cstr + " accesses(hits+misses)") 2472810SN/A .flags(total | nozero | nonan) 2482810SN/A ; 2498833Sdam.sunwoo@arm.com accesses[access_idx] = hits[access_idx] + misses[access_idx]; 2502810SN/A 2518833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2528833Sdam.sunwoo@arm.com accesses[access_idx].subname(i, system->getMasterName(i)); 2538833Sdam.sunwoo@arm.com } 2542810SN/A } 2552810SN/A 2562810SN/A demandAccesses 2572810SN/A .name(name() + ".demand_accesses") 2582810SN/A .desc("number of demand (read+write) accesses") 2598833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2602810SN/A ; 2612810SN/A demandAccesses = demandHits + demandMisses; 2628833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2638833Sdam.sunwoo@arm.com demandAccesses.subname(i, system->getMasterName(i)); 2648833Sdam.sunwoo@arm.com } 2652810SN/A 2662810SN/A overallAccesses 2672810SN/A .name(name() + ".overall_accesses") 2682810SN/A .desc("number of overall (read+write) accesses") 2698833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2702810SN/A ; 2712810SN/A overallAccesses = overallHits + overallMisses; 2728833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2738833Sdam.sunwoo@arm.com overallAccesses.subname(i, system->getMasterName(i)); 2748833Sdam.sunwoo@arm.com } 2752810SN/A 2762810SN/A // miss rate formulas 2774022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 2784022SN/A MemCmd cmd(access_idx); 2794022SN/A const string &cstr = cmd.toString(); 2802810SN/A 2812810SN/A missRate[access_idx] 2822810SN/A .name(name() + "." + cstr + "_miss_rate") 2832810SN/A .desc("miss rate for " + cstr + " accesses") 2842810SN/A .flags(total | nozero | nonan) 2852810SN/A ; 2868833Sdam.sunwoo@arm.com missRate[access_idx] = misses[access_idx] / accesses[access_idx]; 2872810SN/A 2888833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 2898833Sdam.sunwoo@arm.com missRate[access_idx].subname(i, system->getMasterName(i)); 2908833Sdam.sunwoo@arm.com } 2912810SN/A } 2922810SN/A 2932810SN/A demandMissRate 2942810SN/A .name(name() + ".demand_miss_rate") 2952810SN/A .desc("miss rate for demand accesses") 2968833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 2972810SN/A ; 2982810SN/A demandMissRate = demandMisses / demandAccesses; 2998833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3008833Sdam.sunwoo@arm.com demandMissRate.subname(i, system->getMasterName(i)); 3018833Sdam.sunwoo@arm.com } 3022810SN/A 3032810SN/A overallMissRate 3042810SN/A .name(name() + ".overall_miss_rate") 3052810SN/A .desc("miss rate for overall accesses") 3068833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3072810SN/A ; 3082810SN/A overallMissRate = overallMisses / overallAccesses; 3098833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3108833Sdam.sunwoo@arm.com overallMissRate.subname(i, system->getMasterName(i)); 3118833Sdam.sunwoo@arm.com } 3122810SN/A 3132810SN/A // miss latency formulas 3144022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 3154022SN/A MemCmd cmd(access_idx); 3164022SN/A const string &cstr = cmd.toString(); 3172810SN/A 3182810SN/A avgMissLatency[access_idx] 3192810SN/A .name(name() + "." + cstr + "_avg_miss_latency") 3202810SN/A .desc("average " + cstr + " miss latency") 3212810SN/A .flags(total | nozero | nonan) 3222810SN/A ; 3232810SN/A avgMissLatency[access_idx] = 3242810SN/A missLatency[access_idx] / misses[access_idx]; 3258833Sdam.sunwoo@arm.com 3268833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3278833Sdam.sunwoo@arm.com avgMissLatency[access_idx].subname(i, system->getMasterName(i)); 3288833Sdam.sunwoo@arm.com } 3292810SN/A } 3302810SN/A 3312810SN/A demandAvgMissLatency 3322810SN/A .name(name() + ".demand_avg_miss_latency") 3332810SN/A .desc("average overall miss latency") 3348833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3352810SN/A ; 3362810SN/A demandAvgMissLatency = demandMissLatency / demandMisses; 3378833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3388833Sdam.sunwoo@arm.com demandAvgMissLatency.subname(i, system->getMasterName(i)); 3398833Sdam.sunwoo@arm.com } 3402810SN/A 3412810SN/A overallAvgMissLatency 3422810SN/A .name(name() + ".overall_avg_miss_latency") 3432810SN/A .desc("average overall miss latency") 3448833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3452810SN/A ; 3462810SN/A overallAvgMissLatency = overallMissLatency / overallMisses; 3478833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3488833Sdam.sunwoo@arm.com overallAvgMissLatency.subname(i, system->getMasterName(i)); 3498833Sdam.sunwoo@arm.com } 3502810SN/A 3512810SN/A blocked_cycles.init(NUM_BLOCKED_CAUSES); 3522810SN/A blocked_cycles 3532810SN/A .name(name() + ".blocked_cycles") 3542810SN/A .desc("number of cycles access was blocked") 3552810SN/A .subname(Blocked_NoMSHRs, "no_mshrs") 3562810SN/A .subname(Blocked_NoTargets, "no_targets") 3572810SN/A ; 3582810SN/A 3592810SN/A 3602810SN/A blocked_causes.init(NUM_BLOCKED_CAUSES); 3612810SN/A blocked_causes 3622810SN/A .name(name() + ".blocked") 3632810SN/A .desc("number of cycles access was blocked") 3642810SN/A .subname(Blocked_NoMSHRs, "no_mshrs") 3652810SN/A .subname(Blocked_NoTargets, "no_targets") 3662810SN/A ; 3672810SN/A 3682810SN/A avg_blocked 3692810SN/A .name(name() + ".avg_blocked_cycles") 3702810SN/A .desc("average number of cycles each access was blocked") 3712810SN/A .subname(Blocked_NoMSHRs, "no_mshrs") 3722810SN/A .subname(Blocked_NoTargets, "no_targets") 3732810SN/A ; 3742810SN/A 3752810SN/A avg_blocked = blocked_cycles / blocked_causes; 3762810SN/A 3772810SN/A fastWrites 3782810SN/A .name(name() + ".fast_writes") 3792810SN/A .desc("number of fast writes performed") 3802810SN/A ; 3812810SN/A 3822810SN/A cacheCopies 3832810SN/A .name(name() + ".cache_copies") 3842810SN/A .desc("number of cache copies performed") 3852810SN/A ; 3862826SN/A 3874626SN/A writebacks 3888833Sdam.sunwoo@arm.com .init(system->maxMasters()) 3894626SN/A .name(name() + ".writebacks") 3904626SN/A .desc("number of writebacks") 3918833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 3924626SN/A ; 3938833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 3948833Sdam.sunwoo@arm.com writebacks.subname(i, system->getMasterName(i)); 3958833Sdam.sunwoo@arm.com } 3964626SN/A 3974626SN/A // MSHR statistics 3984626SN/A // MSHR hit statistics 3994626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 4004626SN/A MemCmd cmd(access_idx); 4014626SN/A const string &cstr = cmd.toString(); 4024626SN/A 4034626SN/A mshr_hits[access_idx] 4048833Sdam.sunwoo@arm.com .init(system->maxMasters()) 4054626SN/A .name(name() + "." + cstr + "_mshr_hits") 4064626SN/A .desc("number of " + cstr + " MSHR hits") 4074626SN/A .flags(total | nozero | nonan) 4084626SN/A ; 4098833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4108833Sdam.sunwoo@arm.com mshr_hits[access_idx].subname(i, system->getMasterName(i)); 4118833Sdam.sunwoo@arm.com } 4124626SN/A } 4134626SN/A 4144626SN/A demandMshrHits 4154626SN/A .name(name() + ".demand_mshr_hits") 4164626SN/A .desc("number of demand (read+write) MSHR hits") 4178833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4184626SN/A ; 4194871SN/A demandMshrHits = SUM_DEMAND(mshr_hits); 4208833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4218833Sdam.sunwoo@arm.com demandMshrHits.subname(i, system->getMasterName(i)); 4228833Sdam.sunwoo@arm.com } 4234626SN/A 4244626SN/A overallMshrHits 4254626SN/A .name(name() + ".overall_mshr_hits") 4264626SN/A .desc("number of overall MSHR hits") 4278833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4284626SN/A ; 4294871SN/A overallMshrHits = demandMshrHits + SUM_NON_DEMAND(mshr_hits); 4308833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4318833Sdam.sunwoo@arm.com overallMshrHits.subname(i, system->getMasterName(i)); 4328833Sdam.sunwoo@arm.com } 4334626SN/A 4344626SN/A // MSHR miss statistics 4354626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 4364626SN/A MemCmd cmd(access_idx); 4374626SN/A const string &cstr = cmd.toString(); 4384626SN/A 4394626SN/A mshr_misses[access_idx] 4408833Sdam.sunwoo@arm.com .init(system->maxMasters()) 4414626SN/A .name(name() + "." + cstr + "_mshr_misses") 4424626SN/A .desc("number of " + cstr + " MSHR misses") 4434626SN/A .flags(total | nozero | nonan) 4444626SN/A ; 4458833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4468833Sdam.sunwoo@arm.com mshr_misses[access_idx].subname(i, system->getMasterName(i)); 4478833Sdam.sunwoo@arm.com } 4484626SN/A } 4494626SN/A 4504626SN/A demandMshrMisses 4514626SN/A .name(name() + ".demand_mshr_misses") 4524626SN/A .desc("number of demand (read+write) MSHR misses") 4538833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4544626SN/A ; 4554871SN/A demandMshrMisses = SUM_DEMAND(mshr_misses); 4568833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4578833Sdam.sunwoo@arm.com demandMshrMisses.subname(i, system->getMasterName(i)); 4588833Sdam.sunwoo@arm.com } 4594626SN/A 4604626SN/A overallMshrMisses 4614626SN/A .name(name() + ".overall_mshr_misses") 4624626SN/A .desc("number of overall MSHR misses") 4638833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4644626SN/A ; 4654871SN/A overallMshrMisses = demandMshrMisses + SUM_NON_DEMAND(mshr_misses); 4668833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4678833Sdam.sunwoo@arm.com overallMshrMisses.subname(i, system->getMasterName(i)); 4688833Sdam.sunwoo@arm.com } 4694626SN/A 4704626SN/A // MSHR miss latency statistics 4714626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 4724626SN/A MemCmd cmd(access_idx); 4734626SN/A const string &cstr = cmd.toString(); 4744626SN/A 4754626SN/A mshr_miss_latency[access_idx] 4768833Sdam.sunwoo@arm.com .init(system->maxMasters()) 4774626SN/A .name(name() + "." + cstr + "_mshr_miss_latency") 4784626SN/A .desc("number of " + cstr + " MSHR miss cycles") 4794626SN/A .flags(total | nozero | nonan) 4804626SN/A ; 4818833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4828833Sdam.sunwoo@arm.com mshr_miss_latency[access_idx].subname(i, system->getMasterName(i)); 4838833Sdam.sunwoo@arm.com } 4844626SN/A } 4854626SN/A 4864626SN/A demandMshrMissLatency 4874626SN/A .name(name() + ".demand_mshr_miss_latency") 4884626SN/A .desc("number of demand (read+write) MSHR miss cycles") 4898833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 4904626SN/A ; 4914871SN/A demandMshrMissLatency = SUM_DEMAND(mshr_miss_latency); 4928833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 4938833Sdam.sunwoo@arm.com demandMshrMissLatency.subname(i, system->getMasterName(i)); 4948833Sdam.sunwoo@arm.com } 4954626SN/A 4964626SN/A overallMshrMissLatency 4974626SN/A .name(name() + ".overall_mshr_miss_latency") 4984626SN/A .desc("number of overall MSHR miss cycles") 4998833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 5004626SN/A ; 5014871SN/A overallMshrMissLatency = 5024871SN/A demandMshrMissLatency + SUM_NON_DEMAND(mshr_miss_latency); 5038833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5048833Sdam.sunwoo@arm.com overallMshrMissLatency.subname(i, system->getMasterName(i)); 5058833Sdam.sunwoo@arm.com } 5064626SN/A 5074626SN/A // MSHR uncacheable statistics 5084626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 5094626SN/A MemCmd cmd(access_idx); 5104626SN/A const string &cstr = cmd.toString(); 5114626SN/A 5124626SN/A mshr_uncacheable[access_idx] 5138833Sdam.sunwoo@arm.com .init(system->maxMasters()) 5144626SN/A .name(name() + "." + cstr + "_mshr_uncacheable") 5154626SN/A .desc("number of " + cstr + " MSHR uncacheable") 5164626SN/A .flags(total | nozero | nonan) 5174626SN/A ; 5188833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5198833Sdam.sunwoo@arm.com mshr_uncacheable[access_idx].subname(i, system->getMasterName(i)); 5208833Sdam.sunwoo@arm.com } 5214626SN/A } 5224626SN/A 5234626SN/A overallMshrUncacheable 5244626SN/A .name(name() + ".overall_mshr_uncacheable_misses") 5254626SN/A .desc("number of overall MSHR uncacheable misses") 5268833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 5274626SN/A ; 5284871SN/A overallMshrUncacheable = 5294871SN/A SUM_DEMAND(mshr_uncacheable) + SUM_NON_DEMAND(mshr_uncacheable); 5308833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5318833Sdam.sunwoo@arm.com overallMshrUncacheable.subname(i, system->getMasterName(i)); 5328833Sdam.sunwoo@arm.com } 5334626SN/A 5344626SN/A // MSHR miss latency 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_lat[access_idx] 5408833Sdam.sunwoo@arm.com .init(system->maxMasters()) 5414626SN/A .name(name() + "." + cstr + "_mshr_uncacheable_latency") 5424626SN/A .desc("number of " + cstr + " MSHR uncacheable cycles") 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_lat[access_idx].subname(i, system->getMasterName(i)); 5478833Sdam.sunwoo@arm.com } 5484626SN/A } 5494626SN/A 5504626SN/A overallMshrUncacheableLatency 5514626SN/A .name(name() + ".overall_mshr_uncacheable_latency") 5524626SN/A .desc("number of overall MSHR uncacheable cycles") 5538833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 5544626SN/A ; 5554871SN/A overallMshrUncacheableLatency = 5564871SN/A SUM_DEMAND(mshr_uncacheable_lat) + 5574871SN/A SUM_NON_DEMAND(mshr_uncacheable_lat); 5588833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 5598833Sdam.sunwoo@arm.com overallMshrUncacheableLatency.subname(i, system->getMasterName(i)); 5608833Sdam.sunwoo@arm.com } 5614626SN/A 5624626SN/A#if 0 5634626SN/A // MSHR access formulas 5644626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 5654626SN/A MemCmd cmd(access_idx); 5664626SN/A const string &cstr = cmd.toString(); 5674626SN/A 5684626SN/A mshrAccesses[access_idx] 5694626SN/A .name(name() + "." + cstr + "_mshr_accesses") 5704626SN/A .desc("number of " + cstr + " mshr accesses(hits+misses)") 5714626SN/A .flags(total | nozero | nonan) 5724626SN/A ; 5734626SN/A mshrAccesses[access_idx] = 5744626SN/A mshr_hits[access_idx] + mshr_misses[access_idx] 5754626SN/A + mshr_uncacheable[access_idx]; 5764626SN/A } 5774626SN/A 5784626SN/A demandMshrAccesses 5794626SN/A .name(name() + ".demand_mshr_accesses") 5804626SN/A .desc("number of demand (read+write) mshr accesses") 5814626SN/A .flags(total | nozero | nonan) 5824626SN/A ; 5834626SN/A demandMshrAccesses = demandMshrHits + demandMshrMisses; 5844626SN/A 5854626SN/A overallMshrAccesses 5864626SN/A .name(name() + ".overall_mshr_accesses") 5874626SN/A .desc("number of overall (read+write) mshr accesses") 5884626SN/A .flags(total | nozero | nonan) 5894626SN/A ; 5904626SN/A overallMshrAccesses = overallMshrHits + overallMshrMisses 5914626SN/A + overallMshrUncacheable; 5924626SN/A#endif 5934626SN/A 5944626SN/A // MSHR miss rate formulas 5954626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 5964626SN/A MemCmd cmd(access_idx); 5974626SN/A const string &cstr = cmd.toString(); 5984626SN/A 5994626SN/A mshrMissRate[access_idx] 6004626SN/A .name(name() + "." + cstr + "_mshr_miss_rate") 6014626SN/A .desc("mshr miss rate for " + cstr + " accesses") 6024626SN/A .flags(total | nozero | nonan) 6034626SN/A ; 6044626SN/A mshrMissRate[access_idx] = 6054626SN/A mshr_misses[access_idx] / accesses[access_idx]; 6068833Sdam.sunwoo@arm.com 6078833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6088833Sdam.sunwoo@arm.com mshrMissRate[access_idx].subname(i, system->getMasterName(i)); 6098833Sdam.sunwoo@arm.com } 6104626SN/A } 6114626SN/A 6124626SN/A demandMshrMissRate 6134626SN/A .name(name() + ".demand_mshr_miss_rate") 6144626SN/A .desc("mshr miss rate for demand accesses") 6158833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 6164626SN/A ; 6174626SN/A demandMshrMissRate = demandMshrMisses / demandAccesses; 6188833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6198833Sdam.sunwoo@arm.com demandMshrMissRate.subname(i, system->getMasterName(i)); 6208833Sdam.sunwoo@arm.com } 6214626SN/A 6224626SN/A overallMshrMissRate 6234626SN/A .name(name() + ".overall_mshr_miss_rate") 6244626SN/A .desc("mshr miss rate for overall accesses") 6258833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 6264626SN/A ; 6274626SN/A overallMshrMissRate = overallMshrMisses / overallAccesses; 6288833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6298833Sdam.sunwoo@arm.com overallMshrMissRate.subname(i, system->getMasterName(i)); 6308833Sdam.sunwoo@arm.com } 6314626SN/A 6324626SN/A // mshrMiss latency formulas 6334626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 6344626SN/A MemCmd cmd(access_idx); 6354626SN/A const string &cstr = cmd.toString(); 6364626SN/A 6374626SN/A avgMshrMissLatency[access_idx] 6384626SN/A .name(name() + "." + cstr + "_avg_mshr_miss_latency") 6394626SN/A .desc("average " + cstr + " mshr miss latency") 6404626SN/A .flags(total | nozero | nonan) 6414626SN/A ; 6424626SN/A avgMshrMissLatency[access_idx] = 6434626SN/A mshr_miss_latency[access_idx] / mshr_misses[access_idx]; 6448833Sdam.sunwoo@arm.com 6458833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6468833Sdam.sunwoo@arm.com avgMshrMissLatency[access_idx].subname(i, system->getMasterName(i)); 6478833Sdam.sunwoo@arm.com } 6484626SN/A } 6494626SN/A 6504626SN/A demandAvgMshrMissLatency 6514626SN/A .name(name() + ".demand_avg_mshr_miss_latency") 6524626SN/A .desc("average overall mshr miss latency") 6538833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 6544626SN/A ; 6554626SN/A demandAvgMshrMissLatency = demandMshrMissLatency / demandMshrMisses; 6568833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6578833Sdam.sunwoo@arm.com demandAvgMshrMissLatency.subname(i, system->getMasterName(i)); 6588833Sdam.sunwoo@arm.com } 6594626SN/A 6604626SN/A overallAvgMshrMissLatency 6614626SN/A .name(name() + ".overall_avg_mshr_miss_latency") 6624626SN/A .desc("average overall mshr miss latency") 6638833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 6644626SN/A ; 6654626SN/A overallAvgMshrMissLatency = overallMshrMissLatency / overallMshrMisses; 6668833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6678833Sdam.sunwoo@arm.com overallAvgMshrMissLatency.subname(i, system->getMasterName(i)); 6688833Sdam.sunwoo@arm.com } 6694626SN/A 6704626SN/A // mshrUncacheable latency formulas 6714626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 6724626SN/A MemCmd cmd(access_idx); 6734626SN/A const string &cstr = cmd.toString(); 6744626SN/A 6754626SN/A avgMshrUncacheableLatency[access_idx] 6764626SN/A .name(name() + "." + cstr + "_avg_mshr_uncacheable_latency") 6774626SN/A .desc("average " + cstr + " mshr uncacheable latency") 6784626SN/A .flags(total | nozero | nonan) 6794626SN/A ; 6804626SN/A avgMshrUncacheableLatency[access_idx] = 6814626SN/A mshr_uncacheable_lat[access_idx] / mshr_uncacheable[access_idx]; 6828833Sdam.sunwoo@arm.com 6838833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6848833Sdam.sunwoo@arm.com avgMshrUncacheableLatency[access_idx].subname(i, system->getMasterName(i)); 6858833Sdam.sunwoo@arm.com } 6864626SN/A } 6874626SN/A 6884626SN/A overallAvgMshrUncacheableLatency 6894626SN/A .name(name() + ".overall_avg_mshr_uncacheable_latency") 6904626SN/A .desc("average overall mshr uncacheable latency") 6918833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 6924626SN/A ; 6934626SN/A overallAvgMshrUncacheableLatency = overallMshrUncacheableLatency / overallMshrUncacheable; 6948833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 6958833Sdam.sunwoo@arm.com overallAvgMshrUncacheableLatency.subname(i, system->getMasterName(i)); 6968833Sdam.sunwoo@arm.com } 6974626SN/A 6984626SN/A mshr_cap_events 6998833Sdam.sunwoo@arm.com .init(system->maxMasters()) 7004626SN/A .name(name() + ".mshr_cap_events") 7014626SN/A .desc("number of times MSHR cap was activated") 7028833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 7034626SN/A ; 7048833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 7058833Sdam.sunwoo@arm.com mshr_cap_events.subname(i, system->getMasterName(i)); 7068833Sdam.sunwoo@arm.com } 7074626SN/A 7084626SN/A //software prefetching stats 7094626SN/A soft_prefetch_mshr_full 7108833Sdam.sunwoo@arm.com .init(system->maxMasters()) 7114626SN/A .name(name() + ".soft_prefetch_mshr_full") 7124626SN/A .desc("number of mshr full events for SW prefetching instrutions") 7138833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 7144626SN/A ; 7158833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 7168833Sdam.sunwoo@arm.com soft_prefetch_mshr_full.subname(i, system->getMasterName(i)); 7178833Sdam.sunwoo@arm.com } 7184626SN/A 7194626SN/A mshr_no_allocate_misses 7204626SN/A .name(name() +".no_allocate_misses") 7214626SN/A .desc("Number of misses that were no-allocate") 7224626SN/A ; 7234626SN/A 7242810SN/A} 7253503SN/A 7263503SN/Aunsigned int 7273503SN/ABaseCache::drain(Event *de) 7283503SN/A{ 7294626SN/A int count = memSidePort->drain(de) + cpuSidePort->drain(de); 7304626SN/A 7313503SN/A // Set status 7324626SN/A if (count != 0) { 7333503SN/A drainEvent = de; 7343503SN/A 7353503SN/A changeState(SimObject::Draining); 7364626SN/A return count; 7373503SN/A } 7383503SN/A 7393503SN/A changeState(SimObject::Drained); 7403503SN/A return 0; 7413503SN/A} 742