2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Erik Hallnor
34 * Declaration of a common base class for cache tagstore objects.
37 #ifndef __BASE_TAGS_HH__
38 #define __BASE_TAGS_HH__
41 #include "base/statistics.hh"
42 #include "base/callback.hh"
47 * A common base class of Cache tagstore objects.
52 /** Pointer to the parent cache. */
55 /** Local copy of the parent cache name. Used for DPRINTF. */
59 * The number of tags that need to be touched to meet the warmup
63 /** Marked true when the cache is warmed up. */
66 /** the number of blocks in the cache */
71 * @addtogroup CacheStatistics
75 /** Number of replacements of valid blocks per thread. */
76 Stats::Vector replacements;
77 /** Per cycle average of the number of tags that hold valid data. */
78 Stats::Average tagsInUse;
80 /** The total number of references to a block before it is replaced. */
81 Stats::Scalar totalRefs;
84 * The number of reference counts sampled. This is different from
85 * replacements because we sample all the valid blocks when the simulator
88 Stats::Scalar sampledRefs;
91 * Average number of references to a block before is was replaced.
92 * @todo This should change to an average stat once we have them.
94 Stats::Formula avgRefs;
96 /** The cycle that the warmup percentage was hit. */
97 Stats::Scalar warmupCycle;
99 /** Average occupancy of each context/cpu using the cache */
100 Stats::AverageVector occupancies;
102 /** Average occ % of each context/cpu using the cache */
103 Stats::Formula avgOccs;
114 virtual ~BaseTags() {}
117 * Set the parent cache back pointer. Also copies the cache name to
119 * @param _cache Pointer to parent cache.
121 void setCache(BaseCache *_cache);
124 * Return the parent cache name.
125 * @return the parent cache name.
127 const std::string &name() const
133 * Register local statistics.
134 * @param name The name to preceed each statistic name.
136 void regStats(const std::string &name);
139 * Average in the reference count for valid blocks when the simulation
142 virtual void cleanupRefs() {}
145 *iterated through all blocks and clear all locks
146 *Needed to clear all lock tracking at once
148 virtual void clearLocks() {}
151 class BaseTagsCallback : public Callback
155 BaseTagsCallback(BaseTags *t) : tags(t) {}
156 virtual void process() { tags->cleanupRefs(); };
159 #endif //__BASE_TAGS_HH__