ruby: Convered ruby tracing support usage of sequencer

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.
This commit is contained in:
Brad Beckmann 2010-01-29 20:29:20 -08:00
parent 2c9ca672df
commit 0f6535dba1
7 changed files with 69 additions and 24 deletions

View file

@ -48,9 +48,13 @@ CacheRecorder::~CacheRecorder()
delete m_records_ptr; 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) int CacheRecorder::dumpRecords(string filename)

View file

@ -47,6 +47,7 @@
template <class TYPE> class PrioHeap; template <class TYPE> class PrioHeap;
class Address; class Address;
class TraceRecord; class TraceRecord;
class Sequencer;
class CacheRecorder { class CacheRecorder {
public: public:
@ -57,7 +58,11 @@ public:
~CacheRecorder(); ~CacheRecorder();
// Public Methods // 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); int dumpRecords(string filename);
void print(ostream& out) const; void print(ostream& out) const;

View file

@ -36,10 +36,15 @@
#include "mem/ruby/system/Sequencer.hh" #include "mem/ruby/system/Sequencer.hh"
#include "mem/ruby/system/System.hh" #include "mem/ruby/system/System.hh"
#include "mem/protocol/CacheMsg.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_data_address = data_addr;
m_pc_address = pc_addr; m_pc_address = pc_addr;
m_time = time; m_time = time;
@ -63,7 +68,7 @@ TraceRecord::TraceRecord(const TraceRecord& obj)
TraceRecord& TraceRecord::operator=(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_time = obj.m_time;
m_data_address = obj.m_data_address; m_data_address = obj.m_data_address;
m_pc_address = obj.m_pc_address; m_pc_address = obj.m_pc_address;
@ -73,34 +78,38 @@ TraceRecord& TraceRecord::operator=(const TraceRecord& obj)
void TraceRecord::issueRequest() const void TraceRecord::issueRequest() const
{ {
// Lookup sequencer pointer from system assert(m_sequencer_ptr != NULL);
// 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);
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 // Clear out the sequencer
while (!sequencer_ptr->empty()) { while (!m_sequencer_ptr->empty()) {
g_eventQueue_ptr->triggerEvents(g_eventQueue_ptr->getTime() + 100); g_eventQueue_ptr->triggerEvents(g_eventQueue_ptr->getTime() + 100);
} }
sequencer_ptr->makeRequest(request); m_sequencer_ptr->makeRequest(request);
// Clear out the sequencer // Clear out the sequencer
while (!sequencer_ptr->empty()) { while (!m_sequencer_ptr->empty()) {
g_eventQueue_ptr->triggerEvents(g_eventQueue_ptr->getTime() + 100); g_eventQueue_ptr->triggerEvents(g_eventQueue_ptr->getTime() + 100);
} }
} }
void TraceRecord::print(ostream& out) const 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 void TraceRecord::output(ostream& out) const
{ {
out << m_sequencer_name << " "; out << m_sequencer_ptr->name() << " ";
m_data_address.output(out); m_data_address.output(out);
out << " "; out << " ";
m_pc_address.output(out); m_pc_address.output(out);
@ -111,7 +120,16 @@ void TraceRecord::output(ostream& out) const
bool TraceRecord::input(istream& in) 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_data_address.input(in);
m_pc_address.input(in); m_pc_address.input(in);
string type; string type;

View file

@ -49,8 +49,17 @@ class CacheMsg;
class TraceRecord { class TraceRecord {
public: public:
// Constructors // Constructors
TraceRecord(const string & sequencer_name, const Address& data_addr, const Address& pc_addr, RubyRequestType type, Time time); TraceRecord(Sequencer* _sequencer,
TraceRecord() { m_sequencer_name = ""; m_time = 0; m_type = RubyRequestType_NULL; } 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 // Destructor
// ~TraceRecord(); // ~TraceRecord();
@ -70,7 +79,7 @@ private:
// Private Methods // Private Methods
// Data Members (m_ prefix) // Data Members (m_ prefix)
string m_sequencer_name; Sequencer* m_sequencer_ptr;
Time m_time; Time m_time;
Address m_data_address; Address m_data_address;
Address m_pc_address; Address m_pc_address;

View 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); 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); tr.output(m_trace_file);
} }

View file

@ -52,6 +52,7 @@
template <class TYPE> class PrioHeap; template <class TYPE> class PrioHeap;
class Address; class Address;
class TraceRecord; class TraceRecord;
class Sequencer;
class Tracer : public SimObject { class Tracer : public SimObject {
public: public:
@ -67,7 +68,11 @@ public:
void startTrace(string filename); void startTrace(string filename);
void stopTrace(); void stopTrace();
bool traceEnabled() { return m_enabled; } 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; void print(ostream& out) const;

View file

@ -467,7 +467,7 @@ void Sequencer::issueRequest(const RubyRequest& request) {
} }
if (g_system_ptr->getTracer()->traceEnabled()) { 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()); request.type, g_eventQueue_ptr->getTime());
} }