base.hh revision 5999
12810Srdreslin@umich.edu/* 212665Snikos.nikoleris@arm.com * Copyright (c) 2003-2005 The Regents of The University of Michigan 39796Sprakash.ramrakhyani@arm.com * All rights reserved. 49796Sprakash.ramrakhyani@arm.com * 59796Sprakash.ramrakhyani@arm.com * Redistribution and use in source and binary forms, with or without 69796Sprakash.ramrakhyani@arm.com * modification, are permitted provided that the following conditions are 79796Sprakash.ramrakhyani@arm.com * met: redistributions of source code must retain the above copyright 89796Sprakash.ramrakhyani@arm.com * notice, this list of conditions and the following disclaimer; 99796Sprakash.ramrakhyani@arm.com * redistributions in binary form must reproduce the above copyright 109796Sprakash.ramrakhyani@arm.com * notice, this list of conditions and the following disclaimer in the 119796Sprakash.ramrakhyani@arm.com * documentation and/or other materials provided with the distribution; 129796Sprakash.ramrakhyani@arm.com * neither the name of the copyright holders nor the names of its 139796Sprakash.ramrakhyani@arm.com * contributors may be used to endorse or promote products derived from 142810Srdreslin@umich.edu * this software without specific prior written permission. 152810Srdreslin@umich.edu * 162810Srdreslin@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172810Srdreslin@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182810Srdreslin@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192810Srdreslin@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202810Srdreslin@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212810Srdreslin@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222810Srdreslin@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232810Srdreslin@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242810Srdreslin@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252810Srdreslin@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262810Srdreslin@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272810Srdreslin@umich.edu * 282810Srdreslin@umich.edu * Authors: Erik Hallnor 292810Srdreslin@umich.edu * Ron Dreslinski 302810Srdreslin@umich.edu */ 312810Srdreslin@umich.edu 322810Srdreslin@umich.edu/** 332810Srdreslin@umich.edu * @file 342810Srdreslin@umich.edu * Declaration of a common base class for cache tagstore objects. 352810Srdreslin@umich.edu */ 362810Srdreslin@umich.edu 372810Srdreslin@umich.edu#ifndef __BASE_TAGS_HH__ 382810Srdreslin@umich.edu#define __BASE_TAGS_HH__ 392810Srdreslin@umich.edu 402810Srdreslin@umich.edu#include <string> 4112665Snikos.nikoleris@arm.com#include "base/statistics.hh" 422810Srdreslin@umich.edu#include "base/callback.hh" 432810Srdreslin@umich.edu 442810Srdreslin@umich.educlass BaseCache; 452810Srdreslin@umich.edu 462810Srdreslin@umich.edu/** 472810Srdreslin@umich.edu * A common base class of Cache tagstore objects. 482810Srdreslin@umich.edu */ 4911486Snikos.nikoleris@arm.comclass BaseTags 5011486Snikos.nikoleris@arm.com{ 516216Snate@binkert.org protected: 522810Srdreslin@umich.edu /** Pointer to the parent cache. */ 532810Srdreslin@umich.edu BaseCache *cache; 542810Srdreslin@umich.edu 5512334Sgabeblack@google.com /** Local copy of the parent cache name. Used for DPRINTF. */ 5612727Snikos.nikoleris@arm.com std::string objName; 572810Srdreslin@umich.edu 589796Sprakash.ramrakhyani@arm.com /** 5912665Snikos.nikoleris@arm.com * The number of tags that need to be touched to meet the warmup 6012665Snikos.nikoleris@arm.com * percentage. 6112665Snikos.nikoleris@arm.com */ 622810Srdreslin@umich.edu int warmupBound; 632810Srdreslin@umich.edu /** Marked true when the cache is warmed up. */ 642810Srdreslin@umich.edu bool warmedUp; 652810Srdreslin@umich.edu 662810Srdreslin@umich.edu // Statistics 672810Srdreslin@umich.edu /** 682810Srdreslin@umich.edu * @addtogroup CacheStatistics 6912665Snikos.nikoleris@arm.com * @{ 702810Srdreslin@umich.edu */ 712810Srdreslin@umich.edu 7211484Snikos.nikoleris@arm.com /** Number of replacements of valid blocks per thread. */ 732810Srdreslin@umich.edu Stats::Vector replacements; 7412665Snikos.nikoleris@arm.com /** Per cycle average of the number of tags that hold valid data. */ 7512665Snikos.nikoleris@arm.com Stats::Average tagsInUse; 7612629Sodanrc@yahoo.com.br 772810Srdreslin@umich.edu /** The total number of references to a block before it is replaced. */ 786978SLisa.Hsu@amd.com Stats::Scalar totalRefs; 792810Srdreslin@umich.edu 802810Srdreslin@umich.edu /** 8110941Sdavid.guillen@arm.com * The number of reference counts sampled. This is different from 8210941Sdavid.guillen@arm.com * replacements because we sample all the valid blocks when the simulator 8312629Sodanrc@yahoo.com.br * exits. 8412629Sodanrc@yahoo.com.br */ 8512629Sodanrc@yahoo.com.br Stats::Scalar sampledRefs; 862810Srdreslin@umich.edu 8712665Snikos.nikoleris@arm.com /** 8812665Snikos.nikoleris@arm.com * Average number of references to a block before is was replaced. 8912665Snikos.nikoleris@arm.com * @todo This should change to an average stat once we have them. 9012665Snikos.nikoleris@arm.com */ 9112665Snikos.nikoleris@arm.com Stats::Formula avgRefs; 9212665Snikos.nikoleris@arm.com 9312665Snikos.nikoleris@arm.com /** The cycle that the warmup percentage was hit. */ 9412665Snikos.nikoleris@arm.com Stats::Scalar warmupCycle; 9512665Snikos.nikoleris@arm.com /** 962810Srdreslin@umich.edu * @} 972810Srdreslin@umich.edu */ 989086Sandreas.hansson@arm.com 999086Sandreas.hansson@arm.com public: 1009086Sandreas.hansson@arm.com 1019086Sandreas.hansson@arm.com /** 1029086Sandreas.hansson@arm.com * Destructor. 1032810Srdreslin@umich.edu */ 1049796Sprakash.ramrakhyani@arm.com virtual ~BaseTags() {} 1052810Srdreslin@umich.edu 1069796Sprakash.ramrakhyani@arm.com /** 10712665Snikos.nikoleris@arm.com * Set the parent cache back pointer. Also copies the cache name to 1082810Srdreslin@umich.edu * objName. 1092810Srdreslin@umich.edu * @param _cache Pointer to parent cache. 1102810Srdreslin@umich.edu */ 11110815Sdavid.guillen@arm.com void setCache(BaseCache *_cache); 1122810Srdreslin@umich.edu 11312566Snikos.nikoleris@arm.com /** 11412636Sodanrc@yahoo.com.br * Return the parent cache name. 11512745Sodanrc@yahoo.com.br * @return the parent cache name. 11612745Sodanrc@yahoo.com.br */ 11712745Sodanrc@yahoo.com.br const std::string &name() const 11812648Sodanrc@yahoo.com.br { 11912648Sodanrc@yahoo.com.br return objName; 12012648Sodanrc@yahoo.com.br } 12112636Sodanrc@yahoo.com.br 12212775Snikos.nikoleris@arm.com /** 1232810Srdreslin@umich.edu * Register local statistics. 1242810Srdreslin@umich.edu * @param name The name to preceed each statistic name. 12510815Sdavid.guillen@arm.com */ 12611870Snikos.nikoleris@arm.com void regStats(const std::string &name); 12710815Sdavid.guillen@arm.com 12811870Snikos.nikoleris@arm.com /** 12910815Sdavid.guillen@arm.com * Average in the reference count for valid blocks when the simulation 13010815Sdavid.guillen@arm.com * exits. 13110815Sdavid.guillen@arm.com */ 13212665Snikos.nikoleris@arm.com virtual void cleanupRefs() {} 13312665Snikos.nikoleris@arm.com}; 1342810Srdreslin@umich.edu 13512665Snikos.nikoleris@arm.comclass BaseTagsCallback : public Callback 13612677Sodanrc@yahoo.com.br{ 1372810Srdreslin@umich.edu BaseTags *tags; 13812775Snikos.nikoleris@arm.com public: 13911722Ssophiane.senni@gmail.com BaseTagsCallback(BaseTags *t) : tags(t) {} 14011722Ssophiane.senni@gmail.com virtual void process() { tags->cleanupRefs(); }; 14111722Ssophiane.senni@gmail.com}; 14211722Ssophiane.senni@gmail.com 14311722Ssophiane.senni@gmail.com#endif //__BASE_TAGS_HH__ 14411722Ssophiane.senni@gmail.com