ruby: avoid using g_system_ptr for event scheduling

This patch removes the use of g_system_ptr for event scheduling. Each consumer
object now needs to specify upfront an EventManager object it would use for
scheduling events. This makes the ruby memory system more amenable for a
multi-threaded simulation.
This commit is contained in:
Nilay Vaish 2012-09-18 22:46:34 -05:00
parent d2b57a7473
commit 86b1c0fd54
27 changed files with 37 additions and 42 deletions

View file

@ -33,23 +33,11 @@
void
Consumer::scheduleEvent(Time timeDelta)
{
scheduleEvent(g_system_ptr, timeDelta);
}
void
Consumer::scheduleEvent(EventManager *em, Time timeDelta)
{
scheduleEventAbsolute(em, timeDelta + g_system_ptr->getTime());
scheduleEventAbsolute(timeDelta + g_system_ptr->getTime());
}
void
Consumer::scheduleEventAbsolute(Time timeAbs)
{
scheduleEventAbsolute(g_system_ptr, timeAbs);
}
void
Consumer::scheduleEventAbsolute(EventManager *em, Time timeAbs)
{
Tick evt_time = g_system_ptr->clockPeriod() * timeAbs;
if (!alreadyScheduled(evt_time)) {

View file

@ -44,8 +44,8 @@
class Consumer
{
public:
Consumer()
: m_last_scheduled_wakeup(0), m_last_wakeup(0)
Consumer(EventManager *_em)
: m_last_scheduled_wakeup(0), m_last_wakeup(0), em(_em)
{
}
@ -88,8 +88,6 @@ class Consumer
m_scheduled_wakeups.erase(time);
}
void scheduleEvent(EventManager* em, Time timeDelta);
void scheduleEventAbsolute(EventManager* em, Time timeAbs);
void scheduleEvent(Time timeDelta);
void scheduleEventAbsolute(Time timeAbs);
@ -97,6 +95,7 @@ class Consumer
Tick m_last_scheduled_wakeup;
std::set<Tick> m_scheduled_wakeups;
Tick m_last_wakeup;
EventManager *em;
class ConsumerEvent : public Event
{

View file

@ -35,7 +35,7 @@
using namespace std;
using m5::stl_helpers::deletePointers;
InputUnit_d::InputUnit_d(int id, Router_d *router)
InputUnit_d::InputUnit_d(int id, Router_d *router) : Consumer(router)
{
m_id = id;
m_router = router;

View file

@ -44,6 +44,7 @@ using m5::stl_helpers::deletePointers;
NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks,
GarnetNetwork_d *network_ptr)
: Consumer(network_ptr)
{
m_id = id;
m_net_ptr = network_ptr;

View file

@ -32,7 +32,7 @@
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
NetworkLink_d::NetworkLink_d(const Params *p)
: SimObject(p)
: SimObject(p), Consumer(this)
{
m_latency = p->link_latency;
channel_width = p->channel_width;

View file

@ -36,6 +36,7 @@ using namespace std;
using m5::stl_helpers::deletePointers;
OutputUnit_d::OutputUnit_d(int id, Router_d *router)
: Consumer(router)
{
m_id = id;
m_router = router;

View file

@ -35,6 +35,7 @@
#include "mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.hh"
SWallocator_d::SWallocator_d(Router_d *router)
: Consumer(router)
{
m_router = router;
m_num_vcs = m_router->get_num_vcs();

View file

@ -37,6 +37,7 @@
using m5::stl_helpers::deletePointers;
Switch_d::Switch_d(Router_d *router)
: Consumer(router)
{
m_router = router;
m_num_vcs = m_router->get_num_vcs();

View file

@ -35,6 +35,7 @@
#include "mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh"
VCallocator_d::VCallocator_d(Router_d *router)
: Consumer(router)
{
m_router = router;
m_num_vcs = m_router->get_num_vcs();

View file

@ -38,6 +38,7 @@
class FlexibleConsumer : public Consumer
{
public:
FlexibleConsumer(EventManager *em) : Consumer(em) {}
virtual bool isBufferNotFull(int vc, int inport) { return true; }
virtual void grant_vc(int out_port, int vc, Time grant_time) {}
virtual void release_vc(int out_port, int vc, Time release_time) {}

View file

@ -44,6 +44,7 @@ using m5::stl_helpers::deletePointers;
NetworkInterface::NetworkInterface(int id, int virtual_networks,
GarnetNetwork *network_ptr)
: FlexibleConsumer(network_ptr)
{
m_id = id;
m_net_ptr = network_ptr;

View file

@ -32,7 +32,7 @@
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
NetworkLink::NetworkLink(const Params *p)
: SimObject(p)
: SimObject(p), FlexibleConsumer(this)
{
linkBuffer = new flitBuffer();
m_in_port = 0;
@ -140,7 +140,7 @@ NetworkLink::wakeup()
flit *t_flit = link_srcQueue->getTopFlit();
t_flit->set_time(g_system_ptr->getTime() + m_latency);
linkBuffer->insert(t_flit);
link_consumer->scheduleEvent(this, m_latency);
link_consumer->scheduleEvent(m_latency);
m_link_utilized++;
m_vc_load[t_flit->get_vc()]++;
}

View file

@ -41,7 +41,7 @@ using namespace std;
using m5::stl_helpers::deletePointers;
Router::Router(const Params *p)
: BasicRouter(p)
: BasicRouter(p), FlexibleConsumer(this)
{
m_id = p->router_id;
m_virtual_networks = p->virt_nets;

View file

@ -32,6 +32,7 @@
#include "mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh"
VCarbiter::VCarbiter(Router *router)
: Consumer(router)
{
m_router = router;
}

View file

@ -49,6 +49,7 @@ operator<(const LinkOrder& l1, const LinkOrder& l2)
}
PerfectSwitch::PerfectSwitch(SwitchID sid, SimpleNetwork* network_ptr)
: Consumer(network_ptr)
{
m_virtual_networks = network_ptr->getNumberOfVirtualNetworks();
m_switch_id = sid;

View file

@ -74,7 +74,8 @@ Switch::addOutPort(const vector<MessageBuffer*>& out,
// Create a throttle
throttle_ptr = new Throttle(m_switch_id, m_throttles.size(), link_latency,
bw_multiplier, net_ptr->getEndpointBandwidth());
bw_multiplier, net_ptr->getEndpointBandwidth(),
net_ptr);
m_throttles.push_back(throttle_ptr);
// Create one buffer per vnet (these are intermediaryQueues)
@ -214,4 +215,3 @@ Switch::print(std::ostream& out) const
// FIXME printing
out << "[Switch]";
}

View file

@ -42,8 +42,6 @@
#include <iostream>
#include <vector>
#include "mem/ruby/common/Global.hh"
class MessageBuffer;
class PerfectSwitch;
class NetDest;

View file

@ -49,14 +49,18 @@ const int PRIORITY_SWITCH_LIMIT = 128;
static int network_message_to_size(NetworkMessage* net_msg_ptr);
Throttle::Throttle(int sID, NodeID node, int link_latency,
int link_bandwidth_multiplier, int endpoint_bandwidth)
int link_bandwidth_multiplier, int endpoint_bandwidth,
EventManager *em)
: Consumer(em)
{
init(node, link_latency, link_bandwidth_multiplier, endpoint_bandwidth);
m_sID = sID;
}
Throttle::Throttle(NodeID node, int link_latency,
int link_bandwidth_multiplier, int endpoint_bandwidth)
int link_bandwidth_multiplier, int endpoint_bandwidth,
EventManager *em)
: Consumer(em)
{
init(node, link_latency, link_bandwidth_multiplier, endpoint_bandwidth);
m_sID = 0;

View file

@ -53,9 +53,10 @@ class Throttle : public Consumer
{
public:
Throttle(int sID, NodeID node, int link_latency,
int link_bandwidth_multiplier, int endpoint_bandwidth);
int link_bandwidth_multiplier, int endpoint_bandwidth,
EventManager *em);
Throttle(NodeID node, int link_latency, int link_bandwidth_multiplier,
int endpoint_bandwidth);
int endpoint_bandwidth, EventManager *em);
~Throttle() {}
std::string name()

View file

@ -29,7 +29,8 @@
#include "mem/ruby/slicc_interface/AbstractController.hh"
#include "mem/ruby/system/System.hh"
AbstractController::AbstractController(const Params *p) : SimObject(p)
AbstractController::AbstractController(const Params *p)
: SimObject(p), Consumer(this)
{
p->ruby_system->registerAbstractController(this);
}

View file

@ -35,7 +35,6 @@
class Consumer;
class MemoryNode;
class Message;
class AbstractMemOrCache
{

View file

@ -42,7 +42,8 @@
#include "mem/ruby/system/System.hh"
using namespace std;
MemoryControl::MemoryControl(const Params *p) : ClockedObject(p), m_event(this)
MemoryControl::MemoryControl(const Params *p)
: ClockedObject(p), Consumer(this), m_event(this)
{
g_system_ptr->registerMemController(this);
}

View file

@ -133,7 +133,6 @@ class RubySystem : public ClockedObject
void init();
static void printSystemConfig(std::ostream& out);
void readCompressedTrace(std::string filename,
uint8_t *&raw_data,
uint64& uncompressed_trace_size);

View file

@ -38,9 +38,6 @@
using namespace std;
class Consumer;
// Output operator definition
ostream&

View file

@ -37,7 +37,7 @@
#include <vector>
#include "mem/ruby/buffers/MessageBufferNode.hh"
#include "mem/ruby/common/Global.hh"
#include "mem/ruby/common/Consumer.hh"
#include "params/RubyWireBuffer.hh"
#include "sim/sim_object.hh"
@ -51,7 +51,6 @@
// separated by a network in real systems to simplify coherence.
/////////////////////////////////////////////////////////////////////////////
class Consumer;
class Message;
class WireBuffer : public SimObject

View file

@ -142,7 +142,7 @@ class FuncCallExprAST(ExprAST):
}
if (result == TransitionResult_ResourceStall) {
scheduleEvent(this, 1);
scheduleEvent(1);
// Cannot do anything with this transition, go check next doable transition (mostly likely of next port)
}
@ -173,7 +173,7 @@ class FuncCallExprAST(ExprAST):
}
if (result1 == TransitionResult_ResourceStall) {
scheduleEvent(this, 1);
scheduleEvent(1);
// Cannot do anything with this transition, go check next
// doable transition (mostly likely of next port)
}

View file

@ -1047,7 +1047,7 @@ ${ident}_Controller::wakeup()
g_system_ptr->getProfiler()->controllerBusy(m_machineID);
// Wakeup in another cycle and try again
scheduleEvent(this, 1);
scheduleEvent(1);
break;
}
''')