AddressProfiler.cc (7454:3a3e8e8cce1b) | AddressProfiler.cc (7455:586f99bf0dc4) |
---|---|
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; --- 15 unchanged lines hidden (view full) --- 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 29#include <vector> 30 31#include "base/stl_helpers.hh" | 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; --- 15 unchanged lines hidden (view full) --- 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 29#include <vector> 30 31#include "base/stl_helpers.hh" |
32#include "mem/gems_common/Map.hh" | |
33#include "mem/gems_common/PrioHeap.hh" 34#include "mem/protocol/CacheMsg.hh" | 32#include "mem/gems_common/PrioHeap.hh" 33#include "mem/protocol/CacheMsg.hh" |
35#include "mem/ruby/profiler/AccessTraceForAddress.hh" | |
36#include "mem/ruby/profiler/AddressProfiler.hh" 37#include "mem/ruby/profiler/Profiler.hh" 38#include "mem/ruby/system/System.hh" 39 40using namespace std; 41typedef AddressProfiler::AddressMap AddressMap; 42 43using m5::stl_helpers::operator<<; 44 45// Helper functions 46AccessTraceForAddress& | 34#include "mem/ruby/profiler/AddressProfiler.hh" 35#include "mem/ruby/profiler/Profiler.hh" 36#include "mem/ruby/system/System.hh" 37 38using namespace std; 39typedef AddressProfiler::AddressMap AddressMap; 40 41using m5::stl_helpers::operator<<; 42 43// Helper functions 44AccessTraceForAddress& |
47lookupTraceForAddress(const Address& addr, AddressMap* record_map) | 45lookupTraceForAddress(const Address& addr, AddressMap& record_map) |
48{ | 46{ |
49 if (!record_map->exist(addr)) { 50 record_map->add(addr, AccessTraceForAddress(addr)); | 47 // we create a static default object here that is used to insert 48 // since the insertion will create a copy of the object in the 49 // process. Perhaps this is optimizing early, but it doesn't seem 50 // like it could hurt. 51 static const AccessTraceForAddress dflt; 52 53 pair<AddressMap::iterator, bool> r = 54 record_map.insert(make_pair(addr, dflt)); 55 AddressMap::iterator i = r.first; 56 AccessTraceForAddress &access_trace = i->second; 57 if (r.second) { 58 // there was nothing there and the insert succeed, so we need 59 // to actually set the address. 60 access_trace.setAddress(addr); |
51 } | 61 } |
52 return record_map->lookup(addr); | 62 63 return access_trace; |
53} 54 55void | 64} 65 66void |
56printSorted(ostream& out, int num_of_sequencers, const AddressMap* record_map, | 67printSorted(ostream& out, int num_of_sequencers, const AddressMap &record_map, |
57 string description) 58{ 59 const int records_printed = 100; 60 61 uint64 misses = 0; | 68 string description) 69{ 70 const int records_printed = 100; 71 72 uint64 misses = 0; |
62 PrioHeap 63 std::vector<Address> keys = record_map->keys(); 64 for (int i = 0; i < keys.size(); i++) { 65 AccessTraceForAddress* record = &(record_map->lookup(keys[i])); | 73 PrioHeap<const AccessTraceForAddress*> heap; 74 75 AddressMap::const_iterator i = record_map.begin(); 76 AddressMap::const_iterator end = record_map.end(); 77 for (; i != end; ++i) { 78 const AccessTraceForAddress* record = &i->second; |
66 misses += record->getTotal(); 67 heap.insert(record); 68 } 69 | 79 misses += record->getTotal(); 80 heap.insert(record); 81 } 82 |
70 out << "Total_entries_" << description << ": " << keys.size() << endl; | 83 out << "Total_entries_" << description << ": " << record_map.size() 84 << endl; |
71 if (g_system_ptr->getProfiler()->getAllInstructions()) 72 out << "Total_Instructions_" << description << ": " << misses << endl; 73 else 74 out << "Total_data_misses_" << description << ": " << misses << endl; 75 76 out << "total | load store atomic | user supervisor | sharing | touched-by" 77 << endl; 78 --- 9 unchanged lines hidden (view full) --- 88 m_touched_weighted_vec.resize(num_of_sequencers+1); 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) { | 85 if (g_system_ptr->getProfiler()->getAllInstructions()) 86 out << "Total_Instructions_" << description << ": " << misses << endl; 87 else 88 out << "Total_data_misses_" << description << ": " << misses << endl; 89 90 out << "total | load store atomic | user supervisor | sharing | touched-by" 91 << endl; 92 --- 9 unchanged lines hidden (view full) --- 102 m_touched_weighted_vec.resize(num_of_sequencers+1); 103 for (int i = 0; i < m_touched_vec.size(); i++) { 104 m_touched_vec[i] = 0; 105 m_touched_weighted_vec[i] = 0; 106 } 107 108 int counter = 0; 109 while (heap.size() > 0 && counter < records_printed) { |
96 AccessTraceForAddress* record = heap.extractMin(); | 110 const 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) { | 111 double percent = 100.0 * (record->getTotal() / double(misses)); 112 out << description << " | " << percent << " % " << *record << endl; 113 all_records.add(record->getTotal()); 114 all_records_log.add(record->getTotal()); 115 counter++; 116 m_touched_vec[record->getTouchedBy()]++; 117 m_touched_weighted_vec[record->getTouchedBy()] += record->getTotal(); 118 } 119 120 while (heap.size() > 0) { |
107 AccessTraceForAddress* record = heap.extractMin(); | 121 const 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; --- 9 unchanged lines hidden (view full) --- 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{ | 122 all_records.add(record->getTotal()); 123 remaining_records.add(record->getTotal()); 124 all_records_log.add(record->getTotal()); 125 remaining_records_log.add(record->getTotal()); 126 m_touched_vec[record->getTouchedBy()]++; 127 m_touched_weighted_vec[record->getTouchedBy()] += record->getTotal(); 128 } 129 out << endl; --- 9 unchanged lines hidden (view full) --- 139 << m_touched_vec << endl 140 << "touched_by_weighted_" << description << ": " 141 << m_touched_weighted_vec << endl 142 << endl; 143} 144 145AddressProfiler::AddressProfiler(int num_of_sequencers) 146{ |
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{ | 147 m_num_of_sequencers = num_of_sequencers; 148 clearStats(); 149} 150 151AddressProfiler::~AddressProfiler() 152{ |
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 --- 65 unchanged lines hidden (view full) --- 220 } 221} 222 223void 224AddressProfiler::clearStats() 225{ 226 // Clear the maps 227 m_sharing_miss_counter = 0; | 153} 154 155void 156AddressProfiler::setHotLines(bool hot_lines) 157{ 158 m_hot_lines = hot_lines; 159} 160 --- 65 unchanged lines hidden (view full) --- 226 } 227} 228 229void 230AddressProfiler::clearStats() 231{ 232 // Clear the maps 233 m_sharing_miss_counter = 0; |
228 m_dataAccessTrace->clear(); 229 m_macroBlockAccessTrace->clear(); 230 m_programCounterAccessTrace->clear(); 231 m_retryProfileMap->clear(); | 234 m_dataAccessTrace.clear(); 235 m_macroBlockAccessTrace.clear(); 236 m_programCounterAccessTrace.clear(); 237 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 --- 85 unchanged lines hidden --- | 238 m_retryProfileHisto.clear(); 239 m_retryProfileHistoRead.clear(); 240 m_retryProfileHistoWrite.clear(); 241 m_getx_sharing_histogram.clear(); 242 m_gets_sharing_histogram.clear(); 243} 244 245void --- 85 unchanged lines hidden --- |