summaryrefslogtreecommitdiff
path: root/src/mem/ruby/recorder/CacheRecorder.cc
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2010-06-10 23:17:07 -0700
committerNathan Binkert <nate@binkert.org>2010-06-10 23:17:07 -0700
commitdd133c7b24aba128546d24e6042b0e0d46673aaf (patch)
tree60f82f2f2b708a0fdb6967a7bf1262b435b5e6e0 /src/mem/ruby/recorder/CacheRecorder.cc
parent3df84fd8a0ce3959c0deb4c206d910fc0d050f47 (diff)
downloadgem5-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/recorder/CacheRecorder.cc')
-rw-r--r--src/mem/ruby/recorder/CacheRecorder.cc34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/mem/ruby/recorder/CacheRecorder.cc b/src/mem/ruby/recorder/CacheRecorder.cc
index 32db211b6..1d08eef12 100644
--- a/src/mem/ruby/recorder/CacheRecorder.cc
+++ b/src/mem/ruby/recorder/CacheRecorder.cc
@@ -26,31 +26,21 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <algorithm>
+
#include "gzstream.hh"
-#include "mem/gems_common/PrioHeap.hh"
#include "mem/ruby/eventqueue/RubyEventQueue.hh"
#include "mem/ruby/recorder/CacheRecorder.hh"
-#include "mem/ruby/recorder/TraceRecord.hh"
using namespace std;
-CacheRecorder::CacheRecorder()
-{
- m_records_ptr = new PrioHeap<TraceRecord>;
-}
-
-CacheRecorder::~CacheRecorder()
-{
- delete m_records_ptr;
-}
-
void
CacheRecorder::addRecord(Sequencer* sequencer, const Address& data_addr,
const Address& pc_addr, RubyRequestType type, Time time)
{
- m_records_ptr->
- insert(TraceRecord(sequencer, data_addr, pc_addr, type, time));
+ TraceRecord rec(sequencer, data_addr, pc_addr, type, time);
+ m_records.push_back(rec);
}
int
@@ -62,13 +52,15 @@ CacheRecorder::dumpRecords(string filename)
return 0;
}
- int counter = 0;
- while (m_records_ptr->size() != 0) {
- TraceRecord record = m_records_ptr->extractMin();
- record.output(out);
- counter++;
- }
- return counter;
+ std::sort(m_records.begin(), m_records.end(), greater<TraceRecord>());
+
+ int size = m_records.size();
+ for (int i = 0; i < size; ++i)
+ m_records[i].output(out);
+
+ m_records.clear();
+
+ return size;
}
void