base.cc revision 10360
12810SN/A/* 29796Sprakash.ramrakhyani@arm.com * Copyright (c) 2013 ARM Limited 39796Sprakash.ramrakhyani@arm.com * All rights reserved. 49796Sprakash.ramrakhyani@arm.com * 59796Sprakash.ramrakhyani@arm.com * The license below extends only to copyright in the software and shall 69796Sprakash.ramrakhyani@arm.com * not be construed as granting a license to any other intellectual 79796Sprakash.ramrakhyani@arm.com * property including but not limited to intellectual property relating 89796Sprakash.ramrakhyani@arm.com * to a hardware implementation of the functionality of the software 99796Sprakash.ramrakhyani@arm.com * licensed hereunder. You may use the software subject to the license 109796Sprakash.ramrakhyani@arm.com * terms below provided that you ensure that this notice is replicated 119796Sprakash.ramrakhyani@arm.com * unmodified and in its entirety in all distributions of the software, 129796Sprakash.ramrakhyani@arm.com * modified or unmodified, in source code or in binary form. 139796Sprakash.ramrakhyani@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 * Ron Dreslinski 422810SN/A */ 432810SN/A 442810SN/A/** 452810SN/A * @file 462810SN/A * Definitions of BaseTags. 472810SN/A */ 482810SN/A 499850Sandreas.hansson@arm.com#include "config/the_isa.hh" 508229Snate@binkert.org#include "cpu/smt.hh" //maxThreadsPerCPU 515338Sstever@gmail.com#include "mem/cache/tags/base.hh" 525338Sstever@gmail.com#include "mem/cache/base.hh" 532810SN/A#include "sim/sim_exit.hh" 542810SN/A 552810SN/Ausing namespace std; 562810SN/A 579796Sprakash.ramrakhyani@arm.comBaseTags::BaseTags(const Params *p) 589796Sprakash.ramrakhyani@arm.com : ClockedObject(p), blkSize(p->block_size), size(p->size), 5910360Sandreas.hansson@arm.com hitLatency(p->hit_latency), cache(nullptr), warmupBound(0), 6010360Sandreas.hansson@arm.com warmedUp(false), numBlocks(0) 619796Sprakash.ramrakhyani@arm.com{ 629796Sprakash.ramrakhyani@arm.com} 639796Sprakash.ramrakhyani@arm.com 642810SN/Avoid 652810SN/ABaseTags::setCache(BaseCache *_cache) 662810SN/A{ 6710360Sandreas.hansson@arm.com assert(!cache); 682810SN/A cache = _cache; 692810SN/A} 702810SN/A 712810SN/Avoid 729796Sprakash.ramrakhyani@arm.comBaseTags::regStats() 732810SN/A{ 742810SN/A using namespace Stats; 752810SN/A replacements 762810SN/A .init(maxThreadsPerCPU) 779796Sprakash.ramrakhyani@arm.com .name(name() + ".replacements") 782810SN/A .desc("number of replacements") 792810SN/A .flags(total) 802810SN/A ; 812810SN/A 822810SN/A tagsInUse 839796Sprakash.ramrakhyani@arm.com .name(name() + ".tagsinuse") 842810SN/A .desc("Cycle average of tags in use") 852810SN/A ; 862810SN/A 872810SN/A totalRefs 889796Sprakash.ramrakhyani@arm.com .name(name() + ".total_refs") 892810SN/A .desc("Total number of references to valid blocks.") 902810SN/A ; 912810SN/A 922810SN/A sampledRefs 939796Sprakash.ramrakhyani@arm.com .name(name() + ".sampled_refs") 942810SN/A .desc("Sample count of references to valid blocks.") 952810SN/A ; 962810SN/A 972810SN/A avgRefs 989796Sprakash.ramrakhyani@arm.com .name(name() + ".avg_refs") 992810SN/A .desc("Average number of references to valid blocks.") 1002810SN/A ; 1012810SN/A 1022810SN/A avgRefs = totalRefs/sampledRefs; 1032810SN/A 1042810SN/A warmupCycle 1059796Sprakash.ramrakhyani@arm.com .name(name() + ".warmup_cycle") 1062810SN/A .desc("Cycle when the warmup percentage was hit.") 1072810SN/A ; 1082810SN/A 1096978SLisa.Hsu@amd.com occupancies 1108833Sdam.sunwoo@arm.com .init(cache->system->maxMasters()) 1119796Sprakash.ramrakhyani@arm.com .name(name() + ".occ_blocks") 1128833Sdam.sunwoo@arm.com .desc("Average occupied blocks per requestor") 1136978SLisa.Hsu@amd.com .flags(nozero | nonan) 1146978SLisa.Hsu@amd.com ; 1158833Sdam.sunwoo@arm.com for (int i = 0; i < cache->system->maxMasters(); i++) { 1168833Sdam.sunwoo@arm.com occupancies.subname(i, cache->system->getMasterName(i)); 1178833Sdam.sunwoo@arm.com } 1186978SLisa.Hsu@amd.com 1196978SLisa.Hsu@amd.com avgOccs 1209796Sprakash.ramrakhyani@arm.com .name(name() + ".occ_percent") 1216978SLisa.Hsu@amd.com .desc("Average percentage of cache occupancy") 1228833Sdam.sunwoo@arm.com .flags(nozero | total) 1236978SLisa.Hsu@amd.com ; 1248833Sdam.sunwoo@arm.com for (int i = 0; i < cache->system->maxMasters(); i++) { 1258833Sdam.sunwoo@arm.com avgOccs.subname(i, cache->system->getMasterName(i)); 1268833Sdam.sunwoo@arm.com } 1276978SLisa.Hsu@amd.com 1286978SLisa.Hsu@amd.com avgOccs = occupancies / Stats::constant(numBlocks); 1296978SLisa.Hsu@amd.com 13010024Sdam.sunwoo@arm.com occupanciesTaskId 13110024Sdam.sunwoo@arm.com .init(ContextSwitchTaskId::NumTaskId) 13210024Sdam.sunwoo@arm.com .name(name() + ".occ_task_id_blocks") 13310024Sdam.sunwoo@arm.com .desc("Occupied blocks per task id") 13410024Sdam.sunwoo@arm.com .flags(nozero | nonan) 13510024Sdam.sunwoo@arm.com ; 13610024Sdam.sunwoo@arm.com 13710024Sdam.sunwoo@arm.com ageTaskId 13810024Sdam.sunwoo@arm.com .init(ContextSwitchTaskId::NumTaskId, 5) 13910024Sdam.sunwoo@arm.com .name(name() + ".age_task_id_blocks") 14010024Sdam.sunwoo@arm.com .desc("Occupied blocks per task id") 14110024Sdam.sunwoo@arm.com .flags(nozero | nonan) 14210024Sdam.sunwoo@arm.com ; 14310024Sdam.sunwoo@arm.com 14410024Sdam.sunwoo@arm.com percentOccsTaskId 14510024Sdam.sunwoo@arm.com .name(name() + ".occ_task_id_percent") 14610024Sdam.sunwoo@arm.com .desc("Percentage of cache occupancy per task id") 14710024Sdam.sunwoo@arm.com .flags(nozero) 14810024Sdam.sunwoo@arm.com ; 14910024Sdam.sunwoo@arm.com 15010024Sdam.sunwoo@arm.com percentOccsTaskId = occupanciesTaskId / Stats::constant(numBlocks); 15110024Sdam.sunwoo@arm.com 15210025Stimothy.jones@arm.com tagAccesses 15310025Stimothy.jones@arm.com .name(name() + ".tag_accesses") 15410025Stimothy.jones@arm.com .desc("Number of tag accesses") 15510025Stimothy.jones@arm.com ; 15610025Stimothy.jones@arm.com 15710025Stimothy.jones@arm.com dataAccesses 15810025Stimothy.jones@arm.com .name(name() + ".data_accesses") 15910025Stimothy.jones@arm.com .desc("Number of data accesses") 16010025Stimothy.jones@arm.com ; 16110025Stimothy.jones@arm.com 16210024Sdam.sunwoo@arm.com registerDumpCallback(new BaseTagsDumpCallback(this)); 1632810SN/A registerExitCallback(new BaseTagsCallback(this)); 1642810SN/A} 165