base_set_assoc.cc (12637:bfc3cb9c7e6c) base_set_assoc.cc (12679:6c416cb3ca06)
1/*
2 * Copyright (c) 2012-2014 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

--- 110 unchanged lines hidden (view full) ---

119BaseSetAssoc::findBlockBySetAndWay(int set, int way) const
120{
121 return sets[set].blks[way];
122}
123
124std::string
125BaseSetAssoc::print() const {
126 std::string cache_state;
1/*
2 * Copyright (c) 2012-2014 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

--- 110 unchanged lines hidden (view full) ---

119BaseSetAssoc::findBlockBySetAndWay(int set, int way) const
120{
121 return sets[set].blks[way];
122}
123
124std::string
125BaseSetAssoc::print() const {
126 std::string cache_state;
127 for (unsigned i = 0; i < numSets; ++i) {
128 // link in the data blocks
129 for (unsigned j = 0; j < assoc; ++j) {
130 BlkType *blk = sets[i].blks[j];
131 if (blk->isValid())
132 cache_state += csprintf("\tset: %d block: %d %s\n", i, j,
133 blk->print());
134 }
127 for (const CacheBlk& blk : blks) {
128 if (blk.isValid())
129 cache_state += csprintf("\tset: %d way: %d %s\n", blk.set,
130 blk.way, blk.print());
135 }
136 if (cache_state.empty())
137 cache_state = "no valid tags\n";
138 return cache_state;
139}
140
141void
142BaseSetAssoc::cleanupRefs()
143{
131 }
132 if (cache_state.empty())
133 cache_state = "no valid tags\n";
134 return cache_state;
135}
136
137void
138BaseSetAssoc::cleanupRefs()
139{
144 for (unsigned i = 0; i < numSets*assoc; ++i) {
145 if (blks[i].isValid()) {
146 totalRefs += blks[i].refCount;
140 for (const CacheBlk& blk : blks) {
141 if (blk.isValid()) {
142 totalRefs += blk.refCount;
147 ++sampledRefs;
148 }
149 }
150}
151
152void
153BaseSetAssoc::computeStats()
154{
155 for (unsigned i = 0; i < ContextSwitchTaskId::NumTaskId; ++i) {
156 occupanciesTaskId[i] = 0;
157 for (unsigned j = 0; j < 5; ++j) {
158 ageTaskId[i][j] = 0;
159 }
160 }
161
143 ++sampledRefs;
144 }
145 }
146}
147
148void
149BaseSetAssoc::computeStats()
150{
151 for (unsigned i = 0; i < ContextSwitchTaskId::NumTaskId; ++i) {
152 occupanciesTaskId[i] = 0;
153 for (unsigned j = 0; j < 5; ++j) {
154 ageTaskId[i][j] = 0;
155 }
156 }
157
162 for (unsigned i = 0; i < numSets * assoc; ++i) {
163 if (blks[i].isValid()) {
164 assert(blks[i].task_id < ContextSwitchTaskId::NumTaskId);
165 occupanciesTaskId[blks[i].task_id]++;
166 assert(blks[i].tickInserted <= curTick());
167 Tick age = curTick() - blks[i].tickInserted;
158 for (const CacheBlk& blk : blks) {
159 if (blk.isValid()) {
160 assert(blk.task_id < ContextSwitchTaskId::NumTaskId);
161 occupanciesTaskId[blk.task_id]++;
162 assert(blk.tickInserted <= curTick());
163 Tick age = curTick() - blk.tickInserted;
168
169 int age_index;
170 if (age / SimClock::Int::us < 10) { // <10us
171 age_index = 0;
172 } else if (age / SimClock::Int::us < 100) { // <100us
173 age_index = 1;
174 } else if (age / SimClock::Int::ms < 1) { // <1ms
175 age_index = 2;
176 } else if (age / SimClock::Int::ms < 10) { // <10ms
177 age_index = 3;
178 } else
179 age_index = 4; // >10ms
180
164
165 int age_index;
166 if (age / SimClock::Int::us < 10) { // <10us
167 age_index = 0;
168 } else if (age / SimClock::Int::us < 100) { // <100us
169 age_index = 1;
170 } else if (age / SimClock::Int::ms < 1) { // <1ms
171 age_index = 2;
172 } else if (age / SimClock::Int::ms < 10) { // <10ms
173 age_index = 3;
174 } else
175 age_index = 4; // >10ms
176
181 ageTaskId[blks[i].task_id][age_index]++;
177 ageTaskId[blk.task_id][age_index]++;
182 }
183 }
184}
185
186BaseSetAssoc *
187BaseSetAssocParams::create()
188{
189 return new BaseSetAssoc(this);
190}
178 }
179 }
180}
181
182BaseSetAssoc *
183BaseSetAssocParams::create()
184{
185 return new BaseSetAssoc(this);
186}