AddressProfiler.cc (6433:0f0f0fbef977) AddressProfiler.cc (6896:649e40aad897)
1
2/*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

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

40#include "mem/protocol/CacheMsg.hh"
41#include "mem/ruby/profiler/AccessTraceForAddress.hh"
42#include "mem/gems_common/PrioHeap.hh"
43#include "mem/gems_common/Map.hh"
44#include "mem/ruby/system/System.hh"
45#include "mem/ruby/profiler/Profiler.hh"
46
47// Helper functions
1
2/*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

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

40#include "mem/protocol/CacheMsg.hh"
41#include "mem/ruby/profiler/AccessTraceForAddress.hh"
42#include "mem/gems_common/PrioHeap.hh"
43#include "mem/gems_common/Map.hh"
44#include "mem/ruby/system/System.hh"
45#include "mem/ruby/profiler/Profiler.hh"
46
47// Helper functions
48static AccessTraceForAddress& lookupTraceForAddress(const Address& addr, Map<Address, AccessTraceForAddress>* record_map);
49static void printSorted(ostream& out, const Map<Address, AccessTraceForAddress>* record_map, string description);
48static AccessTraceForAddress& lookupTraceForAddress(const Address& addr,
49 Map<Address,
50 AccessTraceForAddress>* record_map);
50
51
51AddressProfiler::AddressProfiler()
52static void printSorted(ostream& out,
53 int num_of_sequencers,
54 const Map<Address, AccessTraceForAddress>* record_map,
55 string description);
56
57AddressProfiler::AddressProfiler(int num_of_sequencers)
52{
53 m_dataAccessTrace = new Map<Address, AccessTraceForAddress>;
54 m_macroBlockAccessTrace = new Map<Address, AccessTraceForAddress>;
55 m_programCounterAccessTrace = new Map<Address, AccessTraceForAddress>;
56 m_retryProfileMap = new Map<Address, AccessTraceForAddress>;
58{
59 m_dataAccessTrace = new Map<Address, AccessTraceForAddress>;
60 m_macroBlockAccessTrace = new Map<Address, AccessTraceForAddress>;
61 m_programCounterAccessTrace = new Map<Address, AccessTraceForAddress>;
62 m_retryProfileMap = new Map<Address, AccessTraceForAddress>;
63 m_num_of_sequencers = num_of_sequencers;
57 clearStats();
58}
59
60AddressProfiler::~AddressProfiler()
61{
62 delete m_dataAccessTrace;
63 delete m_macroBlockAccessTrace;
64 delete m_programCounterAccessTrace;

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

83 out << "sharing_misses: " << m_sharing_miss_counter << endl;
84 out << "getx_sharing_histogram: " << m_getx_sharing_histogram << endl;
85 out << "gets_sharing_histogram: " << m_gets_sharing_histogram << endl;
86
87 out << endl;
88 out << "Hot Data Blocks" << endl;
89 out << "---------------" << endl;
90 out << endl;
64 clearStats();
65}
66
67AddressProfiler::~AddressProfiler()
68{
69 delete m_dataAccessTrace;
70 delete m_macroBlockAccessTrace;
71 delete m_programCounterAccessTrace;

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

90 out << "sharing_misses: " << m_sharing_miss_counter << endl;
91 out << "getx_sharing_histogram: " << m_getx_sharing_histogram << endl;
92 out << "gets_sharing_histogram: " << m_gets_sharing_histogram << endl;
93
94 out << endl;
95 out << "Hot Data Blocks" << endl;
96 out << "---------------" << endl;
97 out << endl;
91 printSorted(out, m_dataAccessTrace, "block_address");
98 printSorted(out, m_num_of_sequencers, m_dataAccessTrace, "block_address");
92
93 out << endl;
94 out << "Hot MacroData Blocks" << endl;
95 out << "--------------------" << endl;
96 out << endl;
99
100 out << endl;
101 out << "Hot MacroData Blocks" << endl;
102 out << "--------------------" << endl;
103 out << endl;
97 printSorted(out, m_macroBlockAccessTrace, "macroblock_address");
104 printSorted(out, m_num_of_sequencers, m_macroBlockAccessTrace, "macroblock_address");
98
99 out << "Hot Instructions" << endl;
100 out << "----------------" << endl;
101 out << endl;
105
106 out << "Hot Instructions" << endl;
107 out << "----------------" << endl;
108 out << endl;
102 printSorted(out, m_programCounterAccessTrace, "pc_address");
109 printSorted(out, m_num_of_sequencers, m_programCounterAccessTrace, "pc_address");
103 }
104
105 if (m_all_instructions){
106 out << endl;
107 out << "All Instructions Profile:" << endl;
108 out << "-------------------------" << endl;
109 out << endl;
110 }
111
112 if (m_all_instructions){
113 out << endl;
114 out << "All Instructions Profile:" << endl;
115 out << "-------------------------" << endl;
116 out << endl;
110 printSorted(out, m_programCounterAccessTrace, "pc_address");
117 printSorted(out, m_num_of_sequencers, m_programCounterAccessTrace, "pc_address");
111 out << endl;
112 }
113
114 if (m_retryProfileHisto.size() > 0) {
115 out << "Retry Profile" << endl;
116 out << "-------------" << endl;
117 out << endl;
118 out << "retry_histogram_absolute: " << m_retryProfileHisto << endl;
119 out << "retry_histogram_write: " << m_retryProfileHistoWrite << endl;
120 out << "retry_histogram_read: " << m_retryProfileHistoRead << endl;
121
122 out << "retry_histogram_percent: ";
123 m_retryProfileHisto.printPercent(out);
124 out << endl;
125
118 out << endl;
119 }
120
121 if (m_retryProfileHisto.size() > 0) {
122 out << "Retry Profile" << endl;
123 out << "-------------" << endl;
124 out << endl;
125 out << "retry_histogram_absolute: " << m_retryProfileHisto << endl;
126 out << "retry_histogram_write: " << m_retryProfileHistoWrite << endl;
127 out << "retry_histogram_read: " << m_retryProfileHistoRead << endl;
128
129 out << "retry_histogram_percent: ";
130 m_retryProfileHisto.printPercent(out);
131 out << endl;
132
126 printSorted(out, m_retryProfileMap, "block_address");
133 printSorted(out, m_num_of_sequencers, m_retryProfileMap, "block_address");
127 out << endl;
128 }
129
130}
131
132void AddressProfiler::clearStats()
133{
134 // Clear the maps

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

207 }
208 if (count > 1) {
209 lookupTraceForAddress(data_addr, m_retryProfileMap).addSample(count);
210 }
211}
212
213// ***** Normal Functions ******
214
134 out << endl;
135 }
136
137}
138
139void AddressProfiler::clearStats()
140{
141 // Clear the maps

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

214 }
215 if (count > 1) {
216 lookupTraceForAddress(data_addr, m_retryProfileMap).addSample(count);
217 }
218}
219
220// ***** Normal Functions ******
221
215static void printSorted(ostream& out, const Map<Address, AccessTraceForAddress>* record_map, string description)
222static void printSorted(ostream& out,
223 int num_of_sequencers,
224 const Map<Address, AccessTraceForAddress>* record_map,
225 string description)
216{
217 const int records_printed = 100;
218
219 uint64 misses = 0;
220 PrioHeap<AccessTraceForAddress*> heap;
221 Vector<Address> keys = record_map->keys();
222 for(int i=0; i<keys.size(); i++){
223 AccessTraceForAddress* record = &(record_map->lookup(keys[i]));

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

236 Histogram remaining_records(1, 100);
237 Histogram all_records(1, 100);
238 Histogram remaining_records_log(-1);
239 Histogram all_records_log(-1);
240
241 // Allows us to track how many lines where touched by n processors
242 Vector<int64> m_touched_vec;
243 Vector<int64> m_touched_weighted_vec;
226{
227 const int records_printed = 100;
228
229 uint64 misses = 0;
230 PrioHeap<AccessTraceForAddress*> heap;
231 Vector<Address> keys = record_map->keys();
232 for(int i=0; i<keys.size(); i++){
233 AccessTraceForAddress* record = &(record_map->lookup(keys[i]));

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

246 Histogram remaining_records(1, 100);
247 Histogram all_records(1, 100);
248 Histogram remaining_records_log(-1);
249 Histogram all_records_log(-1);
250
251 // Allows us to track how many lines where touched by n processors
252 Vector<int64> m_touched_vec;
253 Vector<int64> m_touched_weighted_vec;
244 m_touched_vec.setSize(RubySystem::getNumberOfSequencers()+1);
245 m_touched_weighted_vec.setSize(RubySystem::getNumberOfSequencers()+1);
254 m_touched_vec.setSize(num_of_sequencers+1);
255 m_touched_weighted_vec.setSize(num_of_sequencers+1);
246 for (int i=0; i<m_touched_vec.size(); i++) {
247 m_touched_vec[i] = 0;
248 m_touched_weighted_vec[i] = 0;
249 }
250
251 int counter = 0;
252 while((heap.size() > 0) && (counter < records_printed)) {
253 AccessTraceForAddress* record = heap.extractMin();

--- 35 unchanged lines hidden ---
256 for (int i=0; i<m_touched_vec.size(); i++) {
257 m_touched_vec[i] = 0;
258 m_touched_weighted_vec[i] = 0;
259 }
260
261 int counter = 0;
262 while((heap.size() > 0) && (counter < records_printed)) {
263 AccessTraceForAddress* record = heap.extractMin();

--- 35 unchanged lines hidden ---