base.cc (11722:f15f02d8c79e) base.cc (11893:3033b3e6a32a)
1/*
1/*
2 * Copyright (c) 2013 ARM Limited
2 * Copyright (c) 2013,2016 ARM Limited
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2003-2005 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Authors: Erik Hallnor
41 * Ron Dreslinski
42 */
43
44/**
45 * @file
46 * Definitions of BaseTags.
47 */
48
49#include "mem/cache/tags/base.hh"
50
51#include "cpu/smt.hh" //maxThreadsPerCPU
52#include "mem/cache/base.hh"
53#include "sim/sim_exit.hh"
54
55using namespace std;
56
57BaseTags::BaseTags(const Params *p)
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2003-2005 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Authors: Erik Hallnor
41 * Ron Dreslinski
42 */
43
44/**
45 * @file
46 * Definitions of BaseTags.
47 */
48
49#include "mem/cache/tags/base.hh"
50
51#include "cpu/smt.hh" //maxThreadsPerCPU
52#include "mem/cache/base.hh"
53#include "sim/sim_exit.hh"
54
55using namespace std;
56
57BaseTags::BaseTags(const Params *p)
58 : ClockedObject(p), blkSize(p->block_size), size(p->size),
58 : ClockedObject(p), blkSize(p->block_size), blkMask(blkSize - 1),
59 size(p->size),
59 lookupLatency(p->tag_latency),
60 accessLatency(p->sequential_access ?
61 p->tag_latency + p->data_latency :
62 std::max(p->tag_latency, p->data_latency)),
63 cache(nullptr), warmupBound(0),
64 warmedUp(false), numBlocks(0)
65{
66}
67
68void
69BaseTags::setCache(BaseCache *_cache)
70{
71 assert(!cache);
72 cache = _cache;
73}
74
75void
76BaseTags::regStats()
77{
78 ClockedObject::regStats();
79
80 using namespace Stats;
81
82 replacements
83 .init(maxThreadsPerCPU)
84 .name(name() + ".replacements")
85 .desc("number of replacements")
86 .flags(total)
87 ;
88
89 tagsInUse
90 .name(name() + ".tagsinuse")
91 .desc("Cycle average of tags in use")
92 ;
93
94 totalRefs
95 .name(name() + ".total_refs")
96 .desc("Total number of references to valid blocks.")
97 ;
98
99 sampledRefs
100 .name(name() + ".sampled_refs")
101 .desc("Sample count of references to valid blocks.")
102 ;
103
104 avgRefs
105 .name(name() + ".avg_refs")
106 .desc("Average number of references to valid blocks.")
107 ;
108
109 avgRefs = totalRefs/sampledRefs;
110
111 warmupCycle
112 .name(name() + ".warmup_cycle")
113 .desc("Cycle when the warmup percentage was hit.")
114 ;
115
116 occupancies
117 .init(cache->system->maxMasters())
118 .name(name() + ".occ_blocks")
119 .desc("Average occupied blocks per requestor")
120 .flags(nozero | nonan)
121 ;
122 for (int i = 0; i < cache->system->maxMasters(); i++) {
123 occupancies.subname(i, cache->system->getMasterName(i));
124 }
125
126 avgOccs
127 .name(name() + ".occ_percent")
128 .desc("Average percentage of cache occupancy")
129 .flags(nozero | total)
130 ;
131 for (int i = 0; i < cache->system->maxMasters(); i++) {
132 avgOccs.subname(i, cache->system->getMasterName(i));
133 }
134
135 avgOccs = occupancies / Stats::constant(numBlocks);
136
137 occupanciesTaskId
138 .init(ContextSwitchTaskId::NumTaskId)
139 .name(name() + ".occ_task_id_blocks")
140 .desc("Occupied blocks per task id")
141 .flags(nozero | nonan)
142 ;
143
144 ageTaskId
145 .init(ContextSwitchTaskId::NumTaskId, 5)
146 .name(name() + ".age_task_id_blocks")
147 .desc("Occupied blocks per task id")
148 .flags(nozero | nonan)
149 ;
150
151 percentOccsTaskId
152 .name(name() + ".occ_task_id_percent")
153 .desc("Percentage of cache occupancy per task id")
154 .flags(nozero)
155 ;
156
157 percentOccsTaskId = occupanciesTaskId / Stats::constant(numBlocks);
158
159 tagAccesses
160 .name(name() + ".tag_accesses")
161 .desc("Number of tag accesses")
162 ;
163
164 dataAccesses
165 .name(name() + ".data_accesses")
166 .desc("Number of data accesses")
167 ;
168
169 registerDumpCallback(new BaseTagsDumpCallback(this));
170 registerExitCallback(new BaseTagsCallback(this));
171}
60 lookupLatency(p->tag_latency),
61 accessLatency(p->sequential_access ?
62 p->tag_latency + p->data_latency :
63 std::max(p->tag_latency, p->data_latency)),
64 cache(nullptr), warmupBound(0),
65 warmedUp(false), numBlocks(0)
66{
67}
68
69void
70BaseTags::setCache(BaseCache *_cache)
71{
72 assert(!cache);
73 cache = _cache;
74}
75
76void
77BaseTags::regStats()
78{
79 ClockedObject::regStats();
80
81 using namespace Stats;
82
83 replacements
84 .init(maxThreadsPerCPU)
85 .name(name() + ".replacements")
86 .desc("number of replacements")
87 .flags(total)
88 ;
89
90 tagsInUse
91 .name(name() + ".tagsinuse")
92 .desc("Cycle average of tags in use")
93 ;
94
95 totalRefs
96 .name(name() + ".total_refs")
97 .desc("Total number of references to valid blocks.")
98 ;
99
100 sampledRefs
101 .name(name() + ".sampled_refs")
102 .desc("Sample count of references to valid blocks.")
103 ;
104
105 avgRefs
106 .name(name() + ".avg_refs")
107 .desc("Average number of references to valid blocks.")
108 ;
109
110 avgRefs = totalRefs/sampledRefs;
111
112 warmupCycle
113 .name(name() + ".warmup_cycle")
114 .desc("Cycle when the warmup percentage was hit.")
115 ;
116
117 occupancies
118 .init(cache->system->maxMasters())
119 .name(name() + ".occ_blocks")
120 .desc("Average occupied blocks per requestor")
121 .flags(nozero | nonan)
122 ;
123 for (int i = 0; i < cache->system->maxMasters(); i++) {
124 occupancies.subname(i, cache->system->getMasterName(i));
125 }
126
127 avgOccs
128 .name(name() + ".occ_percent")
129 .desc("Average percentage of cache occupancy")
130 .flags(nozero | total)
131 ;
132 for (int i = 0; i < cache->system->maxMasters(); i++) {
133 avgOccs.subname(i, cache->system->getMasterName(i));
134 }
135
136 avgOccs = occupancies / Stats::constant(numBlocks);
137
138 occupanciesTaskId
139 .init(ContextSwitchTaskId::NumTaskId)
140 .name(name() + ".occ_task_id_blocks")
141 .desc("Occupied blocks per task id")
142 .flags(nozero | nonan)
143 ;
144
145 ageTaskId
146 .init(ContextSwitchTaskId::NumTaskId, 5)
147 .name(name() + ".age_task_id_blocks")
148 .desc("Occupied blocks per task id")
149 .flags(nozero | nonan)
150 ;
151
152 percentOccsTaskId
153 .name(name() + ".occ_task_id_percent")
154 .desc("Percentage of cache occupancy per task id")
155 .flags(nozero)
156 ;
157
158 percentOccsTaskId = occupanciesTaskId / Stats::constant(numBlocks);
159
160 tagAccesses
161 .name(name() + ".tag_accesses")
162 .desc("Number of tag accesses")
163 ;
164
165 dataAccesses
166 .name(name() + ".data_accesses")
167 .desc("Number of data accesses")
168 ;
169
170 registerDumpCallback(new BaseTagsDumpCallback(this));
171 registerExitCallback(new BaseTagsCallback(this));
172}