diff options
author | Nathan Binkert <nate@binkert.org> | 2010-06-10 23:17:07 -0700 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2010-06-10 23:17:07 -0700 |
commit | dd133c7b24aba128546d24e6042b0e0d46673aaf (patch) | |
tree | 60f82f2f2b708a0fdb6967a7bf1262b435b5e6e0 /src/mem/ruby/profiler | |
parent | 3df84fd8a0ce3959c0deb4c206d910fc0d050f47 (diff) | |
download | gem5-dd133c7b24aba128546d24e6042b0e0d46673aaf.tar.xz |
ruby: get rid of PrioHeap and use STL
One big difference is that PrioHeap puts the smallest element at the
top of the heap, whereas stl puts the largest element on top, so I
changed all comparisons so they did the right thing.
Some usage of PrioHeap was simply changed to a std::vector, using sort
at the right time, other usage had me just use the various heap functions
in the stl.
Diffstat (limited to 'src/mem/ruby/profiler')
-rw-r--r-- | src/mem/ruby/profiler/AccessTraceForAddress.hh | 14 | ||||
-rw-r--r-- | src/mem/ruby/profiler/AddressProfiler.cc | 15 | ||||
-rw-r--r-- | src/mem/ruby/profiler/CacheProfiler.cc | 1 | ||||
-rw-r--r-- | src/mem/ruby/profiler/Profiler.cc | 1 |
4 files changed, 15 insertions, 16 deletions
diff --git a/src/mem/ruby/profiler/AccessTraceForAddress.hh b/src/mem/ruby/profiler/AccessTraceForAddress.hh index a707cd4df..b950f2be2 100644 --- a/src/mem/ruby/profiler/AccessTraceForAddress.hh +++ b/src/mem/ruby/profiler/AccessTraceForAddress.hh @@ -60,6 +60,13 @@ class AccessTraceForAddress void print(std::ostream& out) const; + static inline bool + less_equal(const AccessTraceForAddress* n1, + const AccessTraceForAddress* n2) + { + return n1->getTotal() <= n2->getTotal(); + } + private: Address m_addr; uint64 m_loads; @@ -72,13 +79,6 @@ class AccessTraceForAddress Histogram* m_histogram_ptr; }; -inline bool -node_less_then_eq(const AccessTraceForAddress* n1, - const AccessTraceForAddress* n2) -{ - return n1->getTotal() > n2->getTotal(); -} - inline std::ostream& operator<<(std::ostream& out, const AccessTraceForAddress& obj) { diff --git a/src/mem/ruby/profiler/AddressProfiler.cc b/src/mem/ruby/profiler/AddressProfiler.cc index 4274569ad..5c1b7352c 100644 --- a/src/mem/ruby/profiler/AddressProfiler.cc +++ b/src/mem/ruby/profiler/AddressProfiler.cc @@ -29,7 +29,6 @@ #include <vector> #include "base/stl_helpers.hh" -#include "mem/gems_common/PrioHeap.hh" #include "mem/protocol/CacheMsg.hh" #include "mem/ruby/profiler/AddressProfiler.hh" #include "mem/ruby/profiler/Profiler.hh" @@ -70,15 +69,16 @@ printSorted(ostream& out, int num_of_sequencers, const AddressMap &record_map, const int records_printed = 100; uint64 misses = 0; - PrioHeap<const AccessTraceForAddress*> heap; + std::vector<const AccessTraceForAddress *> sorted; AddressMap::const_iterator i = record_map.begin(); AddressMap::const_iterator end = record_map.end(); for (; i != end; ++i) { const AccessTraceForAddress* record = &i->second; misses += record->getTotal(); - heap.insert(record); + sorted.push_back(record); } + sort(sorted.begin(), sorted.end(), AccessTraceForAddress::less_equal); out << "Total_entries_" << description << ": " << record_map.size() << endl; @@ -106,8 +106,9 @@ printSorted(ostream& out, int num_of_sequencers, const AddressMap &record_map, } int counter = 0; - while (heap.size() > 0 && counter < records_printed) { - const AccessTraceForAddress* record = heap.extractMin(); + int max = sorted.size(); + while (counter < max && counter < records_printed) { + const AccessTraceForAddress* record = sorted[counter]; double percent = 100.0 * (record->getTotal() / double(misses)); out << description << " | " << percent << " % " << *record << endl; all_records.add(record->getTotal()); @@ -117,8 +118,8 @@ printSorted(ostream& out, int num_of_sequencers, const AddressMap &record_map, m_touched_weighted_vec[record->getTouchedBy()] += record->getTotal(); } - while (heap.size() > 0) { - const AccessTraceForAddress* record = heap.extractMin(); + while (counter < max) { + const AccessTraceForAddress* record = sorted[counter]; all_records.add(record->getTotal()); remaining_records.add(record->getTotal()); all_records_log.add(record->getTotal()); diff --git a/src/mem/ruby/profiler/CacheProfiler.cc b/src/mem/ruby/profiler/CacheProfiler.cc index 8ba64add9..006617190 100644 --- a/src/mem/ruby/profiler/CacheProfiler.cc +++ b/src/mem/ruby/profiler/CacheProfiler.cc @@ -26,7 +26,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "mem/gems_common/PrioHeap.hh" #include "mem/ruby/profiler/CacheProfiler.hh" #include "mem/ruby/profiler/Profiler.hh" #include "mem/ruby/system/System.hh" diff --git a/src/mem/ruby/profiler/Profiler.cc b/src/mem/ruby/profiler/Profiler.cc index 33d490a85..2b844ef9d 100644 --- a/src/mem/ruby/profiler/Profiler.cc +++ b/src/mem/ruby/profiler/Profiler.cc @@ -50,7 +50,6 @@ #include "base/stl_helpers.hh" #include "base/str.hh" -#include "mem/gems_common/PrioHeap.hh" #include "mem/protocol/CacheMsg.hh" #include "mem/protocol/MachineType.hh" #include "mem/protocol/Protocol.hh" |