base.hh revision 7612
11689SN/A/* 28707Sandreas.hansson@arm.com * Copyright (c) 2003-2005 The Regents of The University of Michigan 38707Sandreas.hansson@arm.com * All rights reserved. 48707Sandreas.hansson@arm.com * 58707Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without 68707Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are 78707Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright 88707Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer; 98707Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright 108707Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the 118707Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution; 128707Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its 138707Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from 141689SN/A * this software without specific prior written permission. 157897Shestness@cs.utexas.edu * 161689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 271689SN/A * 281689SN/A * Authors: Erik Hallnor 291689SN/A * Ron Dreslinski 301689SN/A */ 311689SN/A 321689SN/A/** 331689SN/A * @file 341689SN/A * Declaration of a common base class for cache tagstore objects. 351689SN/A */ 361689SN/A 371689SN/A#ifndef __BASE_TAGS_HH__ 381689SN/A#define __BASE_TAGS_HH__ 391689SN/A 402665Ssaidi@eecs.umich.edu#include <string> 412665Ssaidi@eecs.umich.edu#include "base/statistics.hh" 422756Sksewell@umich.edu#include "base/callback.hh" 437897Shestness@cs.utexas.edu 441689SN/Aclass BaseCache; 451689SN/A 462325SN/A/** 472325SN/A * A common base class of Cache tagstore objects. 481060SN/A */ 491060SN/Aclass BaseTags 501060SN/A{ 512292SN/A protected: 522292SN/A /** Pointer to the parent cache. */ 531681SN/A BaseCache *cache; 541060SN/A 552980Sgblack@eecs.umich.edu /** Local copy of the parent cache name. Used for DPRINTF. */ 561060SN/A std::string objName; 571858SN/A 586658Snate@binkert.org /** 594598Sbinkertn@umich.edu * The number of tags that need to be touched to meet the warmup 601717SN/A * percentage. 611717SN/A */ 622292SN/A int warmupBound; 632292SN/A /** Marked true when the cache is warmed up. */ 648229Snate@binkert.org bool warmedUp; 658229Snate@binkert.org 668229Snate@binkert.org /** the number of blocks in the cache */ 678229Snate@binkert.org unsigned numBlocks; 682817Sksewell@umich.edu 698229Snate@binkert.org // Statistics 701060SN/A /** 711060SN/A * @addtogroup CacheStatistics 722316SN/A * @{ 732316SN/A */ 742680Sktlim@umich.edu 752817Sksewell@umich.edu /** Number of replacements of valid blocks per thread. */ 762817Sksewell@umich.edu Stats::Vector replacements; 772843Sktlim@umich.edu /** Per cycle average of the number of tags that hold valid data. */ 782843Sktlim@umich.edu Stats::Average tagsInUse; 792669Sktlim@umich.edu 801060SN/A /** The total number of references to a block before it is replaced. */ 811060SN/A Stats::Scalar totalRefs; 825529Snate@binkert.org 835529Snate@binkert.org /** 842733Sktlim@umich.edu * The number of reference counts sampled. This is different from 851060SN/A * replacements because we sample all the valid blocks when the simulator 861060SN/A * exits. 871060SN/A */ 885529Snate@binkert.org Stats::Scalar sampledRefs; 892292SN/A 902292SN/A /** 911060SN/A * Average number of references to a block before is was replaced. 921060SN/A * @todo This should change to an average stat once we have them. 932348SN/A */ 942348SN/A Stats::Formula avgRefs; 952348SN/A 962348SN/A /** The cycle that the warmup percentage was hit. */ 972348SN/A Stats::Scalar warmupCycle; 981060SN/A 992733Sktlim@umich.edu /** Average occupancy of each context/cpu using the cache */ 1001060SN/A Stats::AverageVector occupancies; 1011060SN/A 1022325SN/A /** Average occ % of each context/cpu using the cache */ 1031060SN/A Stats::Formula avgOccs; 1041061SN/A 1054329Sktlim@umich.edu /** 1061060SN/A * @} 1075595Sgblack@eecs.umich.edu */ 1082292SN/A 1092292SN/A public: 1102292SN/A 1112292SN/A /** 1122817Sksewell@umich.edu * Destructor. 1132829Sksewell@umich.edu */ 1141060SN/A virtual ~BaseTags() {} 1151060SN/A 1161060SN/A /** 1171060SN/A * Set the parent cache back pointer. Also copies the cache name to 1181060SN/A * objName. 1192307SN/A * @param _cache Pointer to parent cache. 1202307SN/A */ 1211060SN/A void setCache(BaseCache *_cache); 1221060SN/A 1236022Sgblack@eecs.umich.edu /** 1246022Sgblack@eecs.umich.edu * Return the parent cache name. 1253781Sgblack@eecs.umich.edu * @return the parent cache name. 1262292SN/A */ 1271060SN/A const std::string &name() const 1281060SN/A { 1292829Sksewell@umich.edu return objName; 1302829Sksewell@umich.edu } 1312829Sksewell@umich.edu 1321060SN/A /** 1338707Sandreas.hansson@arm.com * Register local statistics. 1348707Sandreas.hansson@arm.com * @param name The name to preceed each statistic name. 1358707Sandreas.hansson@arm.com */ 1368707Sandreas.hansson@arm.com void regStats(const std::string &name); 1378707Sandreas.hansson@arm.com 1388707Sandreas.hansson@arm.com /** 1398707Sandreas.hansson@arm.com * Average in the reference count for valid blocks when the simulation 1408707Sandreas.hansson@arm.com * exits. 1418707Sandreas.hansson@arm.com */ 1428707Sandreas.hansson@arm.com virtual void cleanupRefs() {} 1438707Sandreas.hansson@arm.com 1448707Sandreas.hansson@arm.com /** 1458707Sandreas.hansson@arm.com *iterated through all blocks and clear all locks 1468707Sandreas.hansson@arm.com *Needed to clear all lock tracking at once 1478707Sandreas.hansson@arm.com */ 1488707Sandreas.hansson@arm.com virtual void clearLocks() {} 1498707Sandreas.hansson@arm.com}; 1508707Sandreas.hansson@arm.com 1518707Sandreas.hansson@arm.comclass BaseTagsCallback : public Callback 1528707Sandreas.hansson@arm.com{ 1538707Sandreas.hansson@arm.com BaseTags *tags; 1548707Sandreas.hansson@arm.com public: 1558707Sandreas.hansson@arm.com BaseTagsCallback(BaseTags *t) : tags(t) {} 1568707Sandreas.hansson@arm.com virtual void process() { tags->cleanupRefs(); }; 1578707Sandreas.hansson@arm.com}; 1588707Sandreas.hansson@arm.com 1598707Sandreas.hansson@arm.com#endif //__BASE_TAGS_HH__ 1608707Sandreas.hansson@arm.com