1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 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. 15 * 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. 27 */ 28
| 1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 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. 15 * 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. 27 */ 28
|
84 for (int i = 0; i < m_touched_vec.size(); i++) { 85 m_touched_vec[i] = 0; 86 m_touched_weighted_vec[i] = 0; 87 } 88 89 int counter = 0; 90 while (heap.size() > 0 && counter < records_printed) { 91 AccessTraceForAddress* record = heap.extractMin(); 92 double percent = 100.0 * (record->getTotal() / double(misses)); 93 out << description << " | " << percent << " % " << *record << endl; 94 all_records.add(record->getTotal()); 95 all_records_log.add(record->getTotal()); 96 counter++; 97 m_touched_vec[record->getTouchedBy()]++; 98 m_touched_weighted_vec[record->getTouchedBy()] += record->getTotal(); 99 } 100 101 while (heap.size() > 0) { 102 AccessTraceForAddress* record = heap.extractMin(); 103 all_records.add(record->getTotal()); 104 remaining_records.add(record->getTotal()); 105 all_records_log.add(record->getTotal()); 106 remaining_records_log.add(record->getTotal()); 107 m_touched_vec[record->getTouchedBy()]++; 108 m_touched_weighted_vec[record->getTouchedBy()] += record->getTotal(); 109 } 110 out << endl; 111 out << "all_records_" << description << ": " 112 << all_records << endl 113 << "all_records_log_" << description << ": " 114 << all_records_log << endl 115 << "remaining_records_" << description << ": " 116 << remaining_records << endl 117 << "remaining_records_log_" << description << ": " 118 << remaining_records_log << endl 119 << "touched_by_" << description << ": " 120 << m_touched_vec << endl 121 << "touched_by_weighted_" << description << ": " 122 << m_touched_weighted_vec << endl 123 << endl; 124} 125 126AddressProfiler::AddressProfiler(int num_of_sequencers) 127{ 128 m_dataAccessTrace = new AddressMap; 129 m_macroBlockAccessTrace = new AddressMap; 130 m_programCounterAccessTrace = new AddressMap; 131 m_retryProfileMap = new AddressMap; 132 m_num_of_sequencers = num_of_sequencers; 133 clearStats(); 134} 135 136AddressProfiler::~AddressProfiler() 137{ 138 delete m_dataAccessTrace; 139 delete m_macroBlockAccessTrace; 140 delete m_programCounterAccessTrace; 141 delete m_retryProfileMap; 142} 143 144void 145AddressProfiler::setHotLines(bool hot_lines) 146{ 147 m_hot_lines = hot_lines; 148} 149 150void 151AddressProfiler::setAllInstructions(bool all_instructions) 152{ 153 m_all_instructions = all_instructions; 154} 155 156void 157AddressProfiler::printStats(ostream& out) const 158{ 159 if (m_hot_lines) { 160 out << endl; 161 out << "AddressProfiler Stats" << endl; 162 out << "---------------------" << endl; 163 164 out << endl; 165 out << "sharing_misses: " << m_sharing_miss_counter << endl; 166 out << "getx_sharing_histogram: " << m_getx_sharing_histogram << endl; 167 out << "gets_sharing_histogram: " << m_gets_sharing_histogram << endl; 168 169 out << endl; 170 out << "Hot Data Blocks" << endl; 171 out << "---------------" << endl; 172 out << endl; 173 printSorted(out, m_num_of_sequencers, m_dataAccessTrace, 174 "block_address"); 175 176 out << endl; 177 out << "Hot MacroData Blocks" << endl; 178 out << "--------------------" << endl; 179 out << endl; 180 printSorted(out, m_num_of_sequencers, m_macroBlockAccessTrace, 181 "macroblock_address"); 182 183 out << "Hot Instructions" << endl; 184 out << "----------------" << endl; 185 out << endl; 186 printSorted(out, m_num_of_sequencers, m_programCounterAccessTrace, 187 "pc_address"); 188 } 189 190 if (m_all_instructions) { 191 out << endl; 192 out << "All Instructions Profile:" << endl; 193 out << "-------------------------" << endl; 194 out << endl; 195 printSorted(out, m_num_of_sequencers, m_programCounterAccessTrace, 196 "pc_address"); 197 out << endl; 198 } 199 200 if (m_retryProfileHisto.size() > 0) { 201 out << "Retry Profile" << endl; 202 out << "-------------" << endl; 203 out << endl; 204 out << "retry_histogram_absolute: " << m_retryProfileHisto << endl; 205 out << "retry_histogram_write: " << m_retryProfileHistoWrite << endl; 206 out << "retry_histogram_read: " << m_retryProfileHistoRead << endl; 207 208 out << "retry_histogram_percent: "; 209 m_retryProfileHisto.printPercent(out); 210 out << endl; 211 212 printSorted(out, m_num_of_sequencers, m_retryProfileMap, 213 "block_address"); 214 out << endl; 215 } 216} 217 218void 219AddressProfiler::clearStats() 220{ 221 // Clear the maps 222 m_sharing_miss_counter = 0; 223 m_dataAccessTrace->clear(); 224 m_macroBlockAccessTrace->clear(); 225 m_programCounterAccessTrace->clear(); 226 m_retryProfileMap->clear(); 227 m_retryProfileHisto.clear(); 228 m_retryProfileHistoRead.clear(); 229 m_retryProfileHistoWrite.clear(); 230 m_getx_sharing_histogram.clear(); 231 m_gets_sharing_histogram.clear(); 232} 233 234void 235AddressProfiler::profileGetX(const Address& datablock, const Address& PC, 236 const Set& owner, const Set& sharers, 237 NodeID requestor) 238{ 239 Set indirection_set; 240 indirection_set.addSet(sharers); 241 indirection_set.addSet(owner); 242 indirection_set.remove(requestor); 243 int num_indirections = indirection_set.count(); 244 245 m_getx_sharing_histogram.add(num_indirections); 246 bool indirection_miss = (num_indirections > 0); 247 248 addTraceSample(datablock, PC, CacheRequestType_ST, AccessModeType(0), 249 requestor, indirection_miss); 250} 251 252void 253AddressProfiler::profileGetS(const Address& datablock, const Address& PC, 254 const Set& owner, const Set& sharers, 255 NodeID requestor) 256{ 257 Set indirection_set; 258 indirection_set.addSet(owner); 259 indirection_set.remove(requestor); 260 int num_indirections = indirection_set.count(); 261 262 m_gets_sharing_histogram.add(num_indirections); 263 bool indirection_miss = (num_indirections > 0); 264 265 addTraceSample(datablock, PC, CacheRequestType_LD, AccessModeType(0), 266 requestor, indirection_miss); 267} 268 269void 270AddressProfiler::addTraceSample(Address data_addr, Address pc_addr, 271 CacheRequestType type, 272 AccessModeType access_mode, NodeID id, 273 bool sharing_miss) 274{ 275 if (m_all_instructions) { 276 if (sharing_miss) { 277 m_sharing_miss_counter++; 278 } 279 280 // record data address trace info 281 data_addr.makeLineAddress(); 282 lookupTraceForAddress(data_addr, m_dataAccessTrace). 283 update(type, access_mode, id, sharing_miss); 284 285 // record macro data address trace info 286 287 // 6 for datablock, 4 to make it 16x more coarse 288 Address macro_addr(data_addr.maskLowOrderBits(10)); 289 lookupTraceForAddress(macro_addr, m_macroBlockAccessTrace). 290 update(type, access_mode, id, sharing_miss); 291 292 // record program counter address trace info 293 lookupTraceForAddress(pc_addr, m_programCounterAccessTrace). 294 update(type, access_mode, id, sharing_miss); 295 } 296 297 if (m_all_instructions) { 298 // This code is used if the address profiler is an 299 // all-instructions profiler record program counter address 300 // trace info 301 lookupTraceForAddress(pc_addr, m_programCounterAccessTrace). 302 update(type, access_mode, id, sharing_miss); 303 } 304} 305 306void 307AddressProfiler::profileRetry(const Address& data_addr, AccessType type, 308 int count) 309{ 310 m_retryProfileHisto.add(count); 311 if (type == AccessType_Read) { 312 m_retryProfileHistoRead.add(count); 313 } else { 314 m_retryProfileHistoWrite.add(count); 315 } 316 if (count > 1) { 317 lookupTraceForAddress(data_addr, m_retryProfileMap).addSample(count); 318 } 319}
| 89 for (int i = 0; i < m_touched_vec.size(); i++) { 90 m_touched_vec[i] = 0; 91 m_touched_weighted_vec[i] = 0; 92 } 93 94 int counter = 0; 95 while (heap.size() > 0 && counter < records_printed) { 96 AccessTraceForAddress* record = heap.extractMin(); 97 double percent = 100.0 * (record->getTotal() / double(misses)); 98 out << description << " | " << percent << " % " << *record << endl; 99 all_records.add(record->getTotal()); 100 all_records_log.add(record->getTotal()); 101 counter++; 102 m_touched_vec[record->getTouchedBy()]++; 103 m_touched_weighted_vec[record->getTouchedBy()] += record->getTotal(); 104 } 105 106 while (heap.size() > 0) { 107 AccessTraceForAddress* record = heap.extractMin(); 108 all_records.add(record->getTotal()); 109 remaining_records.add(record->getTotal()); 110 all_records_log.add(record->getTotal()); 111 remaining_records_log.add(record->getTotal()); 112 m_touched_vec[record->getTouchedBy()]++; 113 m_touched_weighted_vec[record->getTouchedBy()] += record->getTotal(); 114 } 115 out << endl; 116 out << "all_records_" << description << ": " 117 << all_records << endl 118 << "all_records_log_" << description << ": " 119 << all_records_log << endl 120 << "remaining_records_" << description << ": " 121 << remaining_records << endl 122 << "remaining_records_log_" << description << ": " 123 << remaining_records_log << endl 124 << "touched_by_" << description << ": " 125 << m_touched_vec << endl 126 << "touched_by_weighted_" << description << ": " 127 << m_touched_weighted_vec << endl 128 << endl; 129} 130 131AddressProfiler::AddressProfiler(int num_of_sequencers) 132{ 133 m_dataAccessTrace = new AddressMap; 134 m_macroBlockAccessTrace = new AddressMap; 135 m_programCounterAccessTrace = new AddressMap; 136 m_retryProfileMap = new AddressMap; 137 m_num_of_sequencers = num_of_sequencers; 138 clearStats(); 139} 140 141AddressProfiler::~AddressProfiler() 142{ 143 delete m_dataAccessTrace; 144 delete m_macroBlockAccessTrace; 145 delete m_programCounterAccessTrace; 146 delete m_retryProfileMap; 147} 148 149void 150AddressProfiler::setHotLines(bool hot_lines) 151{ 152 m_hot_lines = hot_lines; 153} 154 155void 156AddressProfiler::setAllInstructions(bool all_instructions) 157{ 158 m_all_instructions = all_instructions; 159} 160 161void 162AddressProfiler::printStats(ostream& out) const 163{ 164 if (m_hot_lines) { 165 out << endl; 166 out << "AddressProfiler Stats" << endl; 167 out << "---------------------" << endl; 168 169 out << endl; 170 out << "sharing_misses: " << m_sharing_miss_counter << endl; 171 out << "getx_sharing_histogram: " << m_getx_sharing_histogram << endl; 172 out << "gets_sharing_histogram: " << m_gets_sharing_histogram << endl; 173 174 out << endl; 175 out << "Hot Data Blocks" << endl; 176 out << "---------------" << endl; 177 out << endl; 178 printSorted(out, m_num_of_sequencers, m_dataAccessTrace, 179 "block_address"); 180 181 out << endl; 182 out << "Hot MacroData Blocks" << endl; 183 out << "--------------------" << endl; 184 out << endl; 185 printSorted(out, m_num_of_sequencers, m_macroBlockAccessTrace, 186 "macroblock_address"); 187 188 out << "Hot Instructions" << endl; 189 out << "----------------" << endl; 190 out << endl; 191 printSorted(out, m_num_of_sequencers, m_programCounterAccessTrace, 192 "pc_address"); 193 } 194 195 if (m_all_instructions) { 196 out << endl; 197 out << "All Instructions Profile:" << endl; 198 out << "-------------------------" << endl; 199 out << endl; 200 printSorted(out, m_num_of_sequencers, m_programCounterAccessTrace, 201 "pc_address"); 202 out << endl; 203 } 204 205 if (m_retryProfileHisto.size() > 0) { 206 out << "Retry Profile" << endl; 207 out << "-------------" << endl; 208 out << endl; 209 out << "retry_histogram_absolute: " << m_retryProfileHisto << endl; 210 out << "retry_histogram_write: " << m_retryProfileHistoWrite << endl; 211 out << "retry_histogram_read: " << m_retryProfileHistoRead << endl; 212 213 out << "retry_histogram_percent: "; 214 m_retryProfileHisto.printPercent(out); 215 out << endl; 216 217 printSorted(out, m_num_of_sequencers, m_retryProfileMap, 218 "block_address"); 219 out << endl; 220 } 221} 222 223void 224AddressProfiler::clearStats() 225{ 226 // Clear the maps 227 m_sharing_miss_counter = 0; 228 m_dataAccessTrace->clear(); 229 m_macroBlockAccessTrace->clear(); 230 m_programCounterAccessTrace->clear(); 231 m_retryProfileMap->clear(); 232 m_retryProfileHisto.clear(); 233 m_retryProfileHistoRead.clear(); 234 m_retryProfileHistoWrite.clear(); 235 m_getx_sharing_histogram.clear(); 236 m_gets_sharing_histogram.clear(); 237} 238 239void 240AddressProfiler::profileGetX(const Address& datablock, const Address& PC, 241 const Set& owner, const Set& sharers, 242 NodeID requestor) 243{ 244 Set indirection_set; 245 indirection_set.addSet(sharers); 246 indirection_set.addSet(owner); 247 indirection_set.remove(requestor); 248 int num_indirections = indirection_set.count(); 249 250 m_getx_sharing_histogram.add(num_indirections); 251 bool indirection_miss = (num_indirections > 0); 252 253 addTraceSample(datablock, PC, CacheRequestType_ST, AccessModeType(0), 254 requestor, indirection_miss); 255} 256 257void 258AddressProfiler::profileGetS(const Address& datablock, const Address& PC, 259 const Set& owner, const Set& sharers, 260 NodeID requestor) 261{ 262 Set indirection_set; 263 indirection_set.addSet(owner); 264 indirection_set.remove(requestor); 265 int num_indirections = indirection_set.count(); 266 267 m_gets_sharing_histogram.add(num_indirections); 268 bool indirection_miss = (num_indirections > 0); 269 270 addTraceSample(datablock, PC, CacheRequestType_LD, AccessModeType(0), 271 requestor, indirection_miss); 272} 273 274void 275AddressProfiler::addTraceSample(Address data_addr, Address pc_addr, 276 CacheRequestType type, 277 AccessModeType access_mode, NodeID id, 278 bool sharing_miss) 279{ 280 if (m_all_instructions) { 281 if (sharing_miss) { 282 m_sharing_miss_counter++; 283 } 284 285 // record data address trace info 286 data_addr.makeLineAddress(); 287 lookupTraceForAddress(data_addr, m_dataAccessTrace). 288 update(type, access_mode, id, sharing_miss); 289 290 // record macro data address trace info 291 292 // 6 for datablock, 4 to make it 16x more coarse 293 Address macro_addr(data_addr.maskLowOrderBits(10)); 294 lookupTraceForAddress(macro_addr, m_macroBlockAccessTrace). 295 update(type, access_mode, id, sharing_miss); 296 297 // record program counter address trace info 298 lookupTraceForAddress(pc_addr, m_programCounterAccessTrace). 299 update(type, access_mode, id, sharing_miss); 300 } 301 302 if (m_all_instructions) { 303 // This code is used if the address profiler is an 304 // all-instructions profiler record program counter address 305 // trace info 306 lookupTraceForAddress(pc_addr, m_programCounterAccessTrace). 307 update(type, access_mode, id, sharing_miss); 308 } 309} 310 311void 312AddressProfiler::profileRetry(const Address& data_addr, AccessType type, 313 int count) 314{ 315 m_retryProfileHisto.add(count); 316 if (type == AccessType_Read) { 317 m_retryProfileHistoRead.add(count); 318 } else { 319 m_retryProfileHistoWrite.add(count); 320 } 321 if (count > 1) { 322 lookupTraceForAddress(data_addr, m_retryProfileMap).addSample(count); 323 } 324}
|