Deleted Added
sdiff udiff text old ( 12637:bfc3cb9c7e6c ) new ( 12679:6c416cb3ca06 )
full compact
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 }
135 }
136 if (cache_state.empty())
137 cache_state = "no valid tags\n";
138 return cache_state;
139}
140
141void
142BaseSetAssoc::cleanupRefs()
143{
144 for (unsigned i = 0; i < numSets*assoc; ++i) {
145 if (blks[i].isValid()) {
146 totalRefs += blks[i].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
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;
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
181 ageTaskId[blks[i].task_id][age_index]++;
182 }
183 }
184}
185
186BaseSetAssoc *
187BaseSetAssocParams::create()
188{
189 return new BaseSetAssoc(this);
190}