changeset a9e7d19871b5 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=a9e7d19871b5
description:
        ruby: Fix RubyMemory to work with the newer ruby.

diffstat:

15 files changed, 231 insertions(+), 94 deletions(-)
src/mem/RubyMemory.py                   |    5 
src/mem/ruby/SConsopts                  |    7 -
src/mem/ruby/storebuffer/storebuffer.cc |   20 +--
src/mem/ruby/storebuffer/storebuffer.hh |    8 -
src/mem/rubymem.cc                      |  157 ++++++++++++++++++++++---------
src/mem/rubymem.hh                      |   54 +++++++---
tests/configs/memtest-ruby.py           |    5 
tests/configs/o3-timing-mp-ruby.py      |    6 -
tests/configs/o3-timing-ruby.py         |    5 
tests/configs/ruby_config.py            |   20 +++
tests/configs/simple-atomic-mp-ruby.py  |    6 -
tests/configs/simple-atomic-ruby.py     |    5 
tests/configs/simple-timing-mp-ruby.py  |    6 -
tests/configs/simple-timing-ruby.py     |    5 
tests/run.py                            |   16 +--

diffs (truncated from 711 to 300 lines):

diff -r 083a6806dd96 -r a9e7d19871b5 src/mem/RubyMemory.py
--- a/src/mem/RubyMemory.py     Mon Jul 06 15:49:47 2009 -0700
+++ b/src/mem/RubyMemory.py     Mon Jul 06 15:49:47 2009 -0700
@@ -35,12 +35,11 @@
     type = 'RubyMemory'
     clock = Param.Clock('1t', "ruby clock speed")
     phase = Param.Latency('0ns', "ruby clock phase")
-    config_file = Param.String("", "path to the Ruby config file")
-    config_options = Param.String("", "extra Ruby options (one per line)")
+    config_file = Param.String("path to the Ruby config file")
     stats_file = Param.String("ruby.stats",
         "file to which ruby dumps its stats")
     num_cpus = Param.Int(1, "Number of CPUs connected to the Ruby memory")
     debug = Param.Bool(False, "Use ruby debug")
-    debug_file = Param.String("",
+    debug_file = Param.String("ruby.debug",
         "path to the Ruby debug output file (stdout if blank)")
 
diff -r 083a6806dd96 -r a9e7d19871b5 src/mem/ruby/SConsopts
--- a/src/mem/ruby/SConsopts    Mon Jul 06 15:49:47 2009 -0700
+++ b/src/mem/ruby/SConsopts    Mon Jul 06 15:49:47 2009 -0700
@@ -36,7 +36,10 @@
 sticky_vars.AddVariables(
     BoolVariable('NO_VECTOR_BOUNDS_CHECKS', "Don't do bounds checks", True),
     BoolVariable('RUBY_DEBUG', "Add debugging stuff to Ruby", False),
-    ('GEMS_ROOT', "Add debugging stuff to Ruby", Dir('..').srcnode().abspath))
+    ('GEMS_ROOT', "Add debugging stuff to Ruby", Dir('..').srcnode().abspath),
+    BoolVariable('RUBY_TSO_CHECKER', "Use the Ruby TSO Checker", False)
+    )
 
-export_vars += [ 'NO_VECTOR_BOUNDS_CHECKS', 'RUBY_DEBUG', 'GEMS_ROOT' ]
+export_vars += [ 'NO_VECTOR_BOUNDS_CHECKS', 'RUBY_DEBUG', 'GEMS_ROOT',
+                 'RUBY_TSO_CHECKER' ]
 
diff -r 083a6806dd96 -r a9e7d19871b5 src/mem/ruby/storebuffer/storebuffer.cc
--- a/src/mem/ruby/storebuffer/storebuffer.cc   Mon Jul 06 15:49:47 2009 -0700
+++ b/src/mem/ruby/storebuffer/storebuffer.cc   Mon Jul 06 15:49:47 2009 -0700
@@ -36,7 +36,7 @@
 #include "mem/ruby/storebuffer/storebuffer.hh"
 #include "mem/ruby/common/Global.hh"
 
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
 #include "TsoChecker.hh"
 #endif
 
@@ -46,7 +46,7 @@
 // global map of request id_s to map them back to storebuffer pointers
 map <uint64_t, StoreBuffer *> request_map;
 
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
 Tso::TsoChecker * g_tsoChecker;
 #endif
 
@@ -65,7 +65,7 @@
 
 
//*****************************************************************************************
 StoreBuffer::StoreBuffer(uint32 id, uint32 block_bits, int storebuffer_size) {
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
   if (id == 0) {
     g_tsoChecker = new Tso::TsoChecker();
     g_tsoChecker->init(64);
@@ -99,7 +99,7 @@
 
 
//******************************************************************************************
 StoreBuffer::~StoreBuffer(){
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
   if (m_id == 0) {
     delete g_tsoChecker;
   }
@@ -272,7 +272,7 @@
     ASSERT(checkForLoadHit(request) != NO_MATCH);
     physical_address_t lineaddr = physical_address & m_block_mask;
     bool found = false;
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
     Tso::TsoCheckerCmd * cmd;
 #endif
     deque<struct SBEntry>::iterator satisfying_store;
@@ -280,7 +280,7 @@
       if ((it->m_request.paddr & m_block_mask) == lineaddr) {
         if (!found) {
           found = true;
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
           satisfying_store = it;
           cmd = new Tso::TsoCheckerCmd(m_id, // this thread id
                             iseq, // instruction sequence
@@ -313,7 +313,7 @@
       }
     }
 
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
     uint64_t tso_data = 0;
     memcpy(&tso_data, request.data, request.len);
     cmd->setData(tso_data);
@@ -400,7 +400,7 @@
         m_buffer_size--;
         ASSERT(m_buffer_size >= 0);
 
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
         int len = outstanding_requests.find(id)->second.len;
         uint64_t data = 0;
         memcpy(&data, from_buffer.m_request.data, 4);
@@ -462,7 +462,7 @@
 #endif
     } // end if (type == ST)
     else if (type == RubyRequestType_LD) {
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
       RubyRequest request = outstanding_requests.find(id)->second;
       uint64_t data = 0;
       memcpy(&data, request.data, request.len);
@@ -511,7 +511,7 @@
   }
 }
 
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
 void StoreBuffer::insertTsoLL(Tso::TsoCheckerCmd * cmd) {
   uint64_t count = cmd->getIseq();
   Tso::TsoCheckerCmd * current = NULL;
diff -r 083a6806dd96 -r a9e7d19871b5 src/mem/ruby/storebuffer/storebuffer.hh
--- a/src/mem/ruby/storebuffer/storebuffer.hh   Mon Jul 06 15:49:47 2009 -0700
+++ b/src/mem/ruby/storebuffer/storebuffer.hh   Mon Jul 06 15:49:47 2009 -0700
@@ -36,7 +36,7 @@
 #include "mem/ruby/storebuffer/hfa.hh"
 #include "mem/ruby/libruby.hh"
 
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
 #include "TsoCheckerCmd.hh"
 #endif
 
@@ -53,13 +53,13 @@
 
 struct SBEntry {
   struct RubyRequest m_request;
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
   Tso::TsoCheckerCmd * m_next_ptr;
 #endif
   SBEntry(struct RubyRequest request, void * ptr)
       : m_request(request)
     {
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
         m_next_ptr = (Tso::TsoCheckerCmd*) ptr;
 #endif
     }
@@ -101,7 +101,7 @@
   /// prints out the contents of the Write Buffer
   void print();
 
-#ifdef RUBY_TSO_CHECKER
+#if RUBY_TSO_CHECKER
   /// if load completes before store, insert correctly to be issued to 
TSOChecker
   void insertTsoLL(Tso::TsoCheckerCmd * cmd);
 #endif
diff -r 083a6806dd96 -r a9e7d19871b5 src/mem/rubymem.cc
--- a/src/mem/rubymem.cc        Mon Jul 06 15:49:47 2009 -0700
+++ b/src/mem/rubymem.cc        Mon Jul 06 15:49:47 2009 -0700
@@ -33,9 +33,11 @@
 
 #include "arch/isa_traits.hh"
 #include "base/output.hh"
+#include "base/str.hh"
 #include "base/types.hh"
 #include "mem/ruby/common/Debug.hh"
-#include "mem/ruby/init.hh"
+#include "mem/ruby/libruby.hh"
+#include "mem/ruby/system/RubyPort.hh"
 #include "mem/ruby/system/Sequencer.hh"
 #include "mem/ruby/system/System.hh"
 #include "mem/rubymem.hh"
@@ -45,33 +47,54 @@
 using namespace std;
 using namespace TheISA;
 
+map<int64_t, PacketPtr> RubyMemory::pending_requests;
+
 RubyMemory::RubyMemory(const Params *p)
   : PhysicalMemory(p)
 {
-    config_file = p->config_file;
-    config_options = p->config_options;
-    stats_file = p->stats_file;
-    num_cpus = p->num_cpus;
     ruby_clock = p->clock;
     ruby_phase = p->phase;
 
-    debug = p->debug;
-    debug_file = p->debug_file;
+    ifstream config(p->config_file.c_str());
+
+    vector<RubyObjConf> sys_conf;
+    while (!config.eof()) {
+        char buffer[4096];
+        config.getline(buffer, sizeof(buffer));
+        string line = buffer;
+        if (line.empty())
+            continue;
+        vector<string> tokens;
+        tokenize(tokens, line, ' ');
+        assert(tokens.size() >= 2);
+        vector<string> argv;
+        for (size_t i=2; i<tokens.size(); i++) {
+            std::replace(tokens[i].begin(), tokens[i].end(), '%', ' ');
+            std::replace(tokens[i].begin(), tokens[i].end(), '#', '\n');
+            argv.push_back(tokens[i]);
+        }
+        sys_conf.push_back(RubyObjConf(tokens[0], tokens[1], argv));
+        tokens.clear();
+        argv.clear();
+    }
+
+    RubySystem::create(sys_conf);
+
+    for (int i = 0; i < params()->num_cpus; i++) {
+        RubyPort *p = RubySystem::getPort(csprintf("Sequencer_%d", i),
+                                          ruby_hit_callback);
+        ruby_ports.push_back(p);
+    }
 }
 
 void
 RubyMemory::init()
 {
-    init_variables();
-    g_NUM_PROCESSORS = num_cpus;
-
-    init_simulator(this);
-
-    if (debug) {
+    if (params()->debug) {
         g_debug_ptr->setVerbosityString("high");
         g_debug_ptr->setDebugTime(1);
-        if (debug_file != "") {
-             g_debug_ptr->setDebugOutputFile("ruby.debug");
+        if (!params()->debug_file.empty()) {
+            g_debug_ptr->setDebugOutputFile(params()->debug_file.c_str());
         }
     }
 
@@ -104,23 +127,21 @@
 }
 
 //called by rubyTickEvent
-void RubyMemory::tick() {
-    g_eventQueue_ptr->triggerEvents(g_eventQueue_ptr->getTime() + 1);
-    schedule(rubyTickEvent, curTick + ruby_clock); //dsm: clock_phase was 
added here. This is wrong, the phase is only added on the first tick
+void
+RubyMemory::tick()
+{
+    RubyEventQueue *eq = RubySystem::getEventQueue();
+    eq->triggerEvents(eq->getTime() + 1);
+    schedule(rubyTickEvent, curTick + ruby_clock);
 }
 
-
-RubyMemory::~RubyMemory() {
-    delete g_system_ptr;
+RubyMemory::~RubyMemory()
+{
 }
 
 void
-RubyMemory::hitCallback(Packet* pkt)
+RubyMemory::hitCallback(PacketPtr pkt, Port *port)
 {
-    RubyMemoryPort* port = m_packet_to_port_map[pkt];
-    assert(port != NULL);
-    m_packet_to_port_map.erase(pkt);
-
     DPRINTF(MemoryAccess, "Hit callback\n");
 
     bool needsResponse = pkt->needsResponse();
@@ -146,7 +167,7 @@
     // with places where this function is called from C++.  I'd prefer
     // to move all these into Python someday.
     if (if_name == "functional") {
-        return new RubyMemoryPort(csprintf("%s-functional", name()), this);
+        return new Port(csprintf("%s-functional", name()), this);
     }
 
     if (if_name != "port") {
@@ -161,22 +182,20 @@
         panic("RubyMemory::getPort: port %d already assigned", idx);
     }
 
-    RubyMemoryPort *port =
-        new RubyMemoryPort(csprintf("%s-port%d", name(), idx), this);
+    Port *port = new Port(csprintf("%s-port%d", name(), idx), this);
 
     ports[idx] = port;
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to