AddressProfiler.cc (7455:586f99bf0dc4) AddressProfiler.cc (7456:8b9be6e12c9b)
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/PrioHeap.hh"
33#include "mem/protocol/CacheMsg.hh"
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

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

65
66void
67printSorted(ostream& out, int num_of_sequencers, const AddressMap &record_map,
68 string description)
69{
70 const int records_printed = 100;
71
72 uint64 misses = 0;
32#include "mem/protocol/CacheMsg.hh"
33#include "mem/ruby/profiler/AddressProfiler.hh"
34#include "mem/ruby/profiler/Profiler.hh"
35#include "mem/ruby/system/System.hh"
36
37using namespace std;
38typedef AddressProfiler::AddressMap AddressMap;
39

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

64
65void
66printSorted(ostream& out, int num_of_sequencers, const AddressMap &record_map,
67 string description)
68{
69 const int records_printed = 100;
70
71 uint64 misses = 0;
73 PrioHeap<const AccessTraceForAddress*> heap;
72 std::vector<const AccessTraceForAddress *> sorted;
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;
79 misses += record->getTotal();
73
74 AddressMap::const_iterator i = record_map.begin();
75 AddressMap::const_iterator end = record_map.end();
76 for (; i != end; ++i) {
77 const AccessTraceForAddress* record = &i->second;
78 misses += record->getTotal();
80 heap.insert(record);
79 sorted.push_back(record);
81 }
80 }
81 sort(sorted.begin(), sorted.end(), AccessTraceForAddress::less_equal);
82
83 out << "Total_entries_" << description << ": " << record_map.size()
84 << endl;
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

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

101 m_touched_vec.resize(num_of_sequencers+1);
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;
82
83 out << "Total_entries_" << description << ": " << record_map.size()
84 << endl;
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

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

101 m_touched_vec.resize(num_of_sequencers+1);
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) {
110 const AccessTraceForAddress* record = heap.extractMin();
109 int max = sorted.size();
110 while (counter < max && counter < records_printed) {
111 const AccessTraceForAddress* record = sorted[counter];
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
112 double percent = 100.0 * (record->getTotal() / double(misses));
113 out << description << " | " << percent << " % " << *record << endl;
114 all_records.add(record->getTotal());
115 all_records_log.add(record->getTotal());
116 counter++;
117 m_touched_vec[record->getTouchedBy()]++;
118 m_touched_weighted_vec[record->getTouchedBy()] += record->getTotal();
119 }
120
120 while (heap.size() > 0) {
121 const AccessTraceForAddress* record = heap.extractMin();
121 while (counter < max) {
122 const AccessTraceForAddress* record = sorted[counter];
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;

--- 201 unchanged lines hidden ---
123 all_records.add(record->getTotal());
124 remaining_records.add(record->getTotal());
125 all_records_log.add(record->getTotal());
126 remaining_records_log.add(record->getTotal());
127 m_touched_vec[record->getTouchedBy()]++;
128 m_touched_weighted_vec[record->getTouchedBy()] += record->getTotal();
129 }
130 out << endl;

--- 201 unchanged lines hidden ---