ruby: Convered ruby tracing support usage of sequencer
authorBrad Beckmann <Brad.Beckmann@amd.com>
Sat, 30 Jan 2010 04:29:20 +0000 (20:29 -0800)
committerBrad Beckmann <Brad.Beckmann@amd.com>
Sat, 30 Jan 2010 04:29:20 +0000 (20:29 -0800)
Modified ruby's tracing support to no longer rely on the RubySystem map
to convert a sequencer string name to a sequencer pointer.  As a
temporary solution, the code uses the sim_object find function.
Eventually, we should develop a better fix.

src/mem/ruby/recorder/CacheRecorder.cc
src/mem/ruby/recorder/CacheRecorder.hh
src/mem/ruby/recorder/TraceRecord.cc
src/mem/ruby/recorder/TraceRecord.hh
src/mem/ruby/recorder/Tracer.cc
src/mem/ruby/recorder/Tracer.hh
src/mem/ruby/system/Sequencer.cc

index 672c175e319a2f5f3c5fe6857f917b5b62d74a65..09c4e0597b0976636dc127209e91ddd4ded9014d 100644 (file)
@@ -48,9 +48,13 @@ CacheRecorder::~CacheRecorder()
   delete m_records_ptr;
 }
 
-void CacheRecorder::addRecord(const string & sequencer_name, const Address& data_addr, const Address& pc_addr, RubyRequestType type, Time time)
+void CacheRecorder::addRecord(Sequencer* sequencer, 
+                              const Address& data_addr, 
+                              const Address& pc_addr, 
+                              RubyRequestType type, 
+                              Time time)
 {
-  m_records_ptr->insert(TraceRecord(sequencer_name, data_addr, pc_addr, type, time));
+  m_records_ptr->insert(TraceRecord(sequencer, data_addr, pc_addr, type, time));
 }
 
 int CacheRecorder::dumpRecords(string filename)
index 144e841b392636735b2b1bb1ea284692a262b13e..88cc5eaca037471ffdd8d804706e18eccc7fce0b 100644 (file)
@@ -47,6 +47,7 @@
 template <class TYPE> class PrioHeap;
 class Address;
 class TraceRecord;
+class Sequencer;
 
 class CacheRecorder {
 public:
@@ -57,7 +58,11 @@ public:
   ~CacheRecorder();
 
   // Public Methods
-  void addRecord(const string & sequencer_name, const Address& data_addr, const Address& pc_addr, RubyRequestType type, Time time);
+  void addRecord(Sequencer* sequencer, 
+                 const Address& data_addr, 
+                 const Address& pc_addr, 
+                 RubyRequestType type, 
+                 Time time);
   int dumpRecords(string filename);
 
   void print(ostream& out) const;
index 8f426d6902d4b47a7707a734ccee28051f1c73eb..e700687d651e388521d712b0aae67129686ec5f6 100644 (file)
 #include "mem/ruby/system/Sequencer.hh"
 #include "mem/ruby/system/System.hh"
 #include "mem/protocol/CacheMsg.hh"
+#include "sim/sim_object.hh"
 
-TraceRecord::TraceRecord(const string & sequencer_name, const Address& data_addr, const Address& pc_addr, RubyRequestType type, Time time)
+TraceRecord::TraceRecord(Sequencer* _sequencer, 
+                         const Address& data_addr, 
+                         const Address& pc_addr, 
+                         RubyRequestType type, 
+                         Time time)
 {
-  m_sequencer_name = sequencer_name;
+  m_sequencer_ptr = _sequencer;
   m_data_address = data_addr;
   m_pc_address = pc_addr;
   m_time = time;
@@ -63,7 +68,7 @@ TraceRecord::TraceRecord(const TraceRecord& obj)
 
 TraceRecord& TraceRecord::operator=(const TraceRecord& obj)
 {
-  m_sequencer_name = obj.m_sequencer_name;
+  m_sequencer_ptr = obj.m_sequencer_ptr;
   m_time = obj.m_time;
   m_data_address = obj.m_data_address;
   m_pc_address = obj.m_pc_address;
@@ -73,34 +78,38 @@ TraceRecord& TraceRecord::operator=(const TraceRecord& obj)
 
 void TraceRecord::issueRequest() const
 {
-  // Lookup sequencer pointer from system
-  // Note that the chip index also needs to take into account SMT configurations
-  Sequencer* sequencer_ptr = RubySystem::getSequencer(m_sequencer_name);
-  assert(sequencer_ptr != NULL);
+  assert(m_sequencer_ptr != NULL);
 
-  RubyRequest request(m_data_address.getAddress(), NULL, RubySystem::getBlockSizeBytes(), m_pc_address.getAddress(), m_type, RubyAccessMode_User);
+  RubyRequest request(m_data_address.getAddress(), 
+                      NULL, 
+                      RubySystem::getBlockSizeBytes(), 
+                      m_pc_address.getAddress(), 
+                      m_type, 
+                      RubyAccessMode_User);
 
   // Clear out the sequencer
-  while (!sequencer_ptr->empty()) {
+  while (!m_sequencer_ptr->empty()) {
     g_eventQueue_ptr->triggerEvents(g_eventQueue_ptr->getTime() + 100);
   }
 
-  sequencer_ptr->makeRequest(request);
+  m_sequencer_ptr->makeRequest(request);
 
   // Clear out the sequencer
-  while (!sequencer_ptr->empty()) {
+  while (!m_sequencer_ptr->empty()) {
     g_eventQueue_ptr->triggerEvents(g_eventQueue_ptr->getTime() + 100);
   }
 }
 
 void TraceRecord::print(ostream& out) const
 {
-  out << "[TraceRecord: Node, " << m_sequencer_name << ", " << m_data_address << ", " << m_pc_address << ", " << m_type << ", Time: " << m_time << "]";
+  out << "[TraceRecord: Node, " << m_sequencer_ptr->name() << ", " 
+      << m_data_address << ", " << m_pc_address << ", " 
+      << m_type << ", Time: " << m_time << "]";
 }
 
 void TraceRecord::output(ostream& out) const
 {
-  out << m_sequencer_name << " ";
+  out << m_sequencer_ptr->name() << " ";
   m_data_address.output(out);
   out << " ";
   m_pc_address.output(out);
@@ -111,7 +120,16 @@ void TraceRecord::output(ostream& out) const
 
 bool TraceRecord::input(istream& in)
 {
-  in >> m_sequencer_name;
+  string sequencer_name;
+  in >> sequencer_name;
+  
+  //
+  // The SimObject find function is slow and iterates through the 
+  // simObjectList to find the sequencer pointer.  Therefore, expect trace
+  // playback to be slow.
+  //
+  m_sequencer_ptr = (Sequencer*)SimObject::find(sequencer_name.c_str());
+
   m_data_address.input(in);
   m_pc_address.input(in);
   string type;
index 081d392e59f423206f8a68b8e00a528f6624f29d..beb66d9b3a600f090cffccc9b1c7d5e4fbd993e5 100644 (file)
@@ -49,8 +49,17 @@ class CacheMsg;
 class TraceRecord {
 public:
   // Constructors
-  TraceRecord(const string & sequencer_name, const Address& data_addr, const Address& pc_addr, RubyRequestType type, Time time);
-  TraceRecord() { m_sequencer_name = ""; m_time = 0; m_type = RubyRequestType_NULL; }
+  TraceRecord(Sequencer* _sequencer, 
+              const Address& data_addr, 
+              const Address& pc_addr, 
+              RubyRequestType type, 
+              Time time);
+
+  TraceRecord() { 
+    m_sequencer_ptr = NULL; 
+    m_time = 0; 
+    m_type = RubyRequestType_NULL; 
+  }
 
   // Destructor
   //  ~TraceRecord();
@@ -70,7 +79,7 @@ private:
   // Private Methods
 
   // Data Members (m_ prefix)
-  string m_sequencer_name;
+  Sequencer* m_sequencer_ptr;
   Time m_time;
   Address m_data_address;
   Address m_pc_address;
index 55b5efe3993f41aa4b886ceea06ab01d49f242d2..b58fa1eb694bf79320dc8dba6ca1153216934a3d 100644 (file)
@@ -89,10 +89,14 @@ void Tracer::stopTrace()
   }
 }
 
-void Tracer::traceRequest(const string & sequencer_name, const Address& data_addr, const Address& pc_addr, RubyRequestType type, Time time)
+void Tracer::traceRequest(Sequencer* sequencer, 
+                          const Address& data_addr, 
+                          const Address& pc_addr, 
+                          RubyRequestType type, 
+                          Time time)
 {
   assert(m_enabled == true);
-  TraceRecord tr(sequencer_name, data_addr, pc_addr, type, time);
+  TraceRecord tr(sequencer, data_addr, pc_addr, type, time);
   tr.output(m_trace_file);
 }
 
index b806b7081546624836d55075e7c8e424b60d78a1..16432f5fce637d5d5cc2754cb6013fca12e7842d 100644 (file)
@@ -52,6 +52,7 @@
 template <class TYPE> class PrioHeap;
 class Address;
 class TraceRecord;
+class Sequencer;
 
 class Tracer : public SimObject {
 public:
@@ -67,7 +68,11 @@ public:
   void startTrace(string filename);
   void stopTrace();
   bool traceEnabled() { return m_enabled; }
-  void traceRequest(const string & sequencer_name, const Address& data_addr, const Address& pc_addr, RubyRequestType type, Time time);
+  void traceRequest(Sequencer* sequencer, 
+                    const Address& data_addr, 
+                    const Address& pc_addr, 
+                    RubyRequestType type, 
+                    Time time);
 
   void print(ostream& out) const;
 
index a5a6e3260e062599858c026aa17a7371c112c2bf..23a6b44e2fa5f95f2ae405a17de4e60f5918b06f 100644 (file)
@@ -467,7 +467,7 @@ void Sequencer::issueRequest(const RubyRequest& request) {
   }
 
   if (g_system_ptr->getTracer()->traceEnabled()) {
-    g_system_ptr->getTracer()->traceRequest(m_name, line_addr, Address(request.pc),
+    g_system_ptr->getTracer()->traceRequest(this, line_addr, Address(request.pc),
                                             request.type, g_eventQueue_ptr->getTime());
   }