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:
parent
d2b57a7473
commit
86b1c0fd54
27 changed files with 37 additions and 42 deletions
|
@ -33,23 +33,11 @@
|
||||||
void
|
void
|
||||||
Consumer::scheduleEvent(Time timeDelta)
|
Consumer::scheduleEvent(Time timeDelta)
|
||||||
{
|
{
|
||||||
scheduleEvent(g_system_ptr, timeDelta);
|
scheduleEventAbsolute(timeDelta + g_system_ptr->getTime());
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Consumer::scheduleEvent(EventManager *em, Time timeDelta)
|
|
||||||
{
|
|
||||||
scheduleEventAbsolute(em, timeDelta + g_system_ptr->getTime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Consumer::scheduleEventAbsolute(Time timeAbs)
|
Consumer::scheduleEventAbsolute(Time timeAbs)
|
||||||
{
|
|
||||||
scheduleEventAbsolute(g_system_ptr, timeAbs);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Consumer::scheduleEventAbsolute(EventManager *em, Time timeAbs)
|
|
||||||
{
|
{
|
||||||
Tick evt_time = g_system_ptr->clockPeriod() * timeAbs;
|
Tick evt_time = g_system_ptr->clockPeriod() * timeAbs;
|
||||||
if (!alreadyScheduled(evt_time)) {
|
if (!alreadyScheduled(evt_time)) {
|
||||||
|
|
|
@ -44,8 +44,8 @@
|
||||||
class Consumer
|
class Consumer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Consumer()
|
Consumer(EventManager *_em)
|
||||||
: m_last_scheduled_wakeup(0), m_last_wakeup(0)
|
: m_last_scheduled_wakeup(0), m_last_wakeup(0), em(_em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,8 +88,6 @@ class Consumer
|
||||||
m_scheduled_wakeups.erase(time);
|
m_scheduled_wakeups.erase(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scheduleEvent(EventManager* em, Time timeDelta);
|
|
||||||
void scheduleEventAbsolute(EventManager* em, Time timeAbs);
|
|
||||||
void scheduleEvent(Time timeDelta);
|
void scheduleEvent(Time timeDelta);
|
||||||
void scheduleEventAbsolute(Time timeAbs);
|
void scheduleEventAbsolute(Time timeAbs);
|
||||||
|
|
||||||
|
@ -97,6 +95,7 @@ class Consumer
|
||||||
Tick m_last_scheduled_wakeup;
|
Tick m_last_scheduled_wakeup;
|
||||||
std::set<Tick> m_scheduled_wakeups;
|
std::set<Tick> m_scheduled_wakeups;
|
||||||
Tick m_last_wakeup;
|
Tick m_last_wakeup;
|
||||||
|
EventManager *em;
|
||||||
|
|
||||||
class ConsumerEvent : public Event
|
class ConsumerEvent : public Event
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using m5::stl_helpers::deletePointers;
|
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_id = id;
|
||||||
m_router = router;
|
m_router = router;
|
||||||
|
|
|
@ -44,6 +44,7 @@ using m5::stl_helpers::deletePointers;
|
||||||
|
|
||||||
NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks,
|
NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks,
|
||||||
GarnetNetwork_d *network_ptr)
|
GarnetNetwork_d *network_ptr)
|
||||||
|
: Consumer(network_ptr)
|
||||||
{
|
{
|
||||||
m_id = id;
|
m_id = id;
|
||||||
m_net_ptr = network_ptr;
|
m_net_ptr = network_ptr;
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
|
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
|
||||||
|
|
||||||
NetworkLink_d::NetworkLink_d(const Params *p)
|
NetworkLink_d::NetworkLink_d(const Params *p)
|
||||||
: SimObject(p)
|
: SimObject(p), Consumer(this)
|
||||||
{
|
{
|
||||||
m_latency = p->link_latency;
|
m_latency = p->link_latency;
|
||||||
channel_width = p->channel_width;
|
channel_width = p->channel_width;
|
||||||
|
|
|
@ -36,6 +36,7 @@ using namespace std;
|
||||||
using m5::stl_helpers::deletePointers;
|
using m5::stl_helpers::deletePointers;
|
||||||
|
|
||||||
OutputUnit_d::OutputUnit_d(int id, Router_d *router)
|
OutputUnit_d::OutputUnit_d(int id, Router_d *router)
|
||||||
|
: Consumer(router)
|
||||||
{
|
{
|
||||||
m_id = id;
|
m_id = id;
|
||||||
m_router = router;
|
m_router = router;
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.hh"
|
#include "mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.hh"
|
||||||
|
|
||||||
SWallocator_d::SWallocator_d(Router_d *router)
|
SWallocator_d::SWallocator_d(Router_d *router)
|
||||||
|
: Consumer(router)
|
||||||
{
|
{
|
||||||
m_router = router;
|
m_router = router;
|
||||||
m_num_vcs = m_router->get_num_vcs();
|
m_num_vcs = m_router->get_num_vcs();
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
using m5::stl_helpers::deletePointers;
|
using m5::stl_helpers::deletePointers;
|
||||||
|
|
||||||
Switch_d::Switch_d(Router_d *router)
|
Switch_d::Switch_d(Router_d *router)
|
||||||
|
: Consumer(router)
|
||||||
{
|
{
|
||||||
m_router = router;
|
m_router = router;
|
||||||
m_num_vcs = m_router->get_num_vcs();
|
m_num_vcs = m_router->get_num_vcs();
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh"
|
#include "mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh"
|
||||||
|
|
||||||
VCallocator_d::VCallocator_d(Router_d *router)
|
VCallocator_d::VCallocator_d(Router_d *router)
|
||||||
|
: Consumer(router)
|
||||||
{
|
{
|
||||||
m_router = router;
|
m_router = router;
|
||||||
m_num_vcs = m_router->get_num_vcs();
|
m_num_vcs = m_router->get_num_vcs();
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
class FlexibleConsumer : public Consumer
|
class FlexibleConsumer : public Consumer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
FlexibleConsumer(EventManager *em) : Consumer(em) {}
|
||||||
virtual bool isBufferNotFull(int vc, int inport) { return true; }
|
virtual bool isBufferNotFull(int vc, int inport) { return true; }
|
||||||
virtual void grant_vc(int out_port, int vc, Time grant_time) {}
|
virtual void grant_vc(int out_port, int vc, Time grant_time) {}
|
||||||
virtual void release_vc(int out_port, int vc, Time release_time) {}
|
virtual void release_vc(int out_port, int vc, Time release_time) {}
|
||||||
|
|
|
@ -44,6 +44,7 @@ using m5::stl_helpers::deletePointers;
|
||||||
|
|
||||||
NetworkInterface::NetworkInterface(int id, int virtual_networks,
|
NetworkInterface::NetworkInterface(int id, int virtual_networks,
|
||||||
GarnetNetwork *network_ptr)
|
GarnetNetwork *network_ptr)
|
||||||
|
: FlexibleConsumer(network_ptr)
|
||||||
{
|
{
|
||||||
m_id = id;
|
m_id = id;
|
||||||
m_net_ptr = network_ptr;
|
m_net_ptr = network_ptr;
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
|
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
|
||||||
|
|
||||||
NetworkLink::NetworkLink(const Params *p)
|
NetworkLink::NetworkLink(const Params *p)
|
||||||
: SimObject(p)
|
: SimObject(p), FlexibleConsumer(this)
|
||||||
{
|
{
|
||||||
linkBuffer = new flitBuffer();
|
linkBuffer = new flitBuffer();
|
||||||
m_in_port = 0;
|
m_in_port = 0;
|
||||||
|
@ -140,7 +140,7 @@ NetworkLink::wakeup()
|
||||||
flit *t_flit = link_srcQueue->getTopFlit();
|
flit *t_flit = link_srcQueue->getTopFlit();
|
||||||
t_flit->set_time(g_system_ptr->getTime() + m_latency);
|
t_flit->set_time(g_system_ptr->getTime() + m_latency);
|
||||||
linkBuffer->insert(t_flit);
|
linkBuffer->insert(t_flit);
|
||||||
link_consumer->scheduleEvent(this, m_latency);
|
link_consumer->scheduleEvent(m_latency);
|
||||||
m_link_utilized++;
|
m_link_utilized++;
|
||||||
m_vc_load[t_flit->get_vc()]++;
|
m_vc_load[t_flit->get_vc()]++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ using namespace std;
|
||||||
using m5::stl_helpers::deletePointers;
|
using m5::stl_helpers::deletePointers;
|
||||||
|
|
||||||
Router::Router(const Params *p)
|
Router::Router(const Params *p)
|
||||||
: BasicRouter(p)
|
: BasicRouter(p), FlexibleConsumer(this)
|
||||||
{
|
{
|
||||||
m_id = p->router_id;
|
m_id = p->router_id;
|
||||||
m_virtual_networks = p->virt_nets;
|
m_virtual_networks = p->virt_nets;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh"
|
#include "mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh"
|
||||||
|
|
||||||
VCarbiter::VCarbiter(Router *router)
|
VCarbiter::VCarbiter(Router *router)
|
||||||
|
: Consumer(router)
|
||||||
{
|
{
|
||||||
m_router = router;
|
m_router = router;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ operator<(const LinkOrder& l1, const LinkOrder& l2)
|
||||||
}
|
}
|
||||||
|
|
||||||
PerfectSwitch::PerfectSwitch(SwitchID sid, SimpleNetwork* network_ptr)
|
PerfectSwitch::PerfectSwitch(SwitchID sid, SimpleNetwork* network_ptr)
|
||||||
|
: Consumer(network_ptr)
|
||||||
{
|
{
|
||||||
m_virtual_networks = network_ptr->getNumberOfVirtualNetworks();
|
m_virtual_networks = network_ptr->getNumberOfVirtualNetworks();
|
||||||
m_switch_id = sid;
|
m_switch_id = sid;
|
||||||
|
|
|
@ -74,7 +74,8 @@ Switch::addOutPort(const vector<MessageBuffer*>& out,
|
||||||
|
|
||||||
// Create a throttle
|
// Create a throttle
|
||||||
throttle_ptr = new Throttle(m_switch_id, m_throttles.size(), link_latency,
|
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);
|
m_throttles.push_back(throttle_ptr);
|
||||||
|
|
||||||
// Create one buffer per vnet (these are intermediaryQueues)
|
// Create one buffer per vnet (these are intermediaryQueues)
|
||||||
|
@ -214,4 +215,3 @@ Switch::print(std::ostream& out) const
|
||||||
// FIXME printing
|
// FIXME printing
|
||||||
out << "[Switch]";
|
out << "[Switch]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "mem/ruby/common/Global.hh"
|
|
||||||
|
|
||||||
class MessageBuffer;
|
class MessageBuffer;
|
||||||
class PerfectSwitch;
|
class PerfectSwitch;
|
||||||
class NetDest;
|
class NetDest;
|
||||||
|
|
|
@ -49,14 +49,18 @@ const int PRIORITY_SWITCH_LIMIT = 128;
|
||||||
static int network_message_to_size(NetworkMessage* net_msg_ptr);
|
static int network_message_to_size(NetworkMessage* net_msg_ptr);
|
||||||
|
|
||||||
Throttle::Throttle(int sID, NodeID node, int link_latency,
|
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);
|
init(node, link_latency, link_bandwidth_multiplier, endpoint_bandwidth);
|
||||||
m_sID = sID;
|
m_sID = sID;
|
||||||
}
|
}
|
||||||
|
|
||||||
Throttle::Throttle(NodeID node, int link_latency,
|
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);
|
init(node, link_latency, link_bandwidth_multiplier, endpoint_bandwidth);
|
||||||
m_sID = 0;
|
m_sID = 0;
|
||||||
|
|
|
@ -53,9 +53,10 @@ class Throttle : public Consumer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Throttle(int sID, NodeID node, int link_latency,
|
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,
|
Throttle(NodeID node, int link_latency, int link_bandwidth_multiplier,
|
||||||
int endpoint_bandwidth);
|
int endpoint_bandwidth, EventManager *em);
|
||||||
~Throttle() {}
|
~Throttle() {}
|
||||||
|
|
||||||
std::string name()
|
std::string name()
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
#include "mem/ruby/slicc_interface/AbstractController.hh"
|
#include "mem/ruby/slicc_interface/AbstractController.hh"
|
||||||
#include "mem/ruby/system/System.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);
|
p->ruby_system->registerAbstractController(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
|
|
||||||
class Consumer;
|
class Consumer;
|
||||||
class MemoryNode;
|
class MemoryNode;
|
||||||
class Message;
|
|
||||||
|
|
||||||
class AbstractMemOrCache
|
class AbstractMemOrCache
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,8 @@
|
||||||
#include "mem/ruby/system/System.hh"
|
#include "mem/ruby/system/System.hh"
|
||||||
|
|
||||||
using namespace std;
|
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);
|
g_system_ptr->registerMemController(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,6 @@ class RubySystem : public ClockedObject
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
static void printSystemConfig(std::ostream& out);
|
|
||||||
void readCompressedTrace(std::string filename,
|
void readCompressedTrace(std::string filename,
|
||||||
uint8_t *&raw_data,
|
uint8_t *&raw_data,
|
||||||
uint64& uncompressed_trace_size);
|
uint64& uncompressed_trace_size);
|
||||||
|
|
|
@ -38,9 +38,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class Consumer;
|
|
||||||
|
|
||||||
|
|
||||||
// Output operator definition
|
// Output operator definition
|
||||||
|
|
||||||
ostream&
|
ostream&
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "mem/ruby/buffers/MessageBufferNode.hh"
|
#include "mem/ruby/buffers/MessageBufferNode.hh"
|
||||||
#include "mem/ruby/common/Global.hh"
|
#include "mem/ruby/common/Consumer.hh"
|
||||||
#include "params/RubyWireBuffer.hh"
|
#include "params/RubyWireBuffer.hh"
|
||||||
#include "sim/sim_object.hh"
|
#include "sim/sim_object.hh"
|
||||||
|
|
||||||
|
@ -51,7 +51,6 @@
|
||||||
// separated by a network in real systems to simplify coherence.
|
// separated by a network in real systems to simplify coherence.
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class Consumer;
|
|
||||||
class Message;
|
class Message;
|
||||||
|
|
||||||
class WireBuffer : public SimObject
|
class WireBuffer : public SimObject
|
||||||
|
|
|
@ -142,7 +142,7 @@ class FuncCallExprAST(ExprAST):
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == TransitionResult_ResourceStall) {
|
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)
|
// 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) {
|
if (result1 == TransitionResult_ResourceStall) {
|
||||||
scheduleEvent(this, 1);
|
scheduleEvent(1);
|
||||||
// Cannot do anything with this transition, go check next
|
// Cannot do anything with this transition, go check next
|
||||||
// doable transition (mostly likely of next port)
|
// doable transition (mostly likely of next port)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1047,7 +1047,7 @@ ${ident}_Controller::wakeup()
|
||||||
g_system_ptr->getProfiler()->controllerBusy(m_machineID);
|
g_system_ptr->getProfiler()->controllerBusy(m_machineID);
|
||||||
|
|
||||||
// Wakeup in another cycle and try again
|
// Wakeup in another cycle and try again
|
||||||
scheduleEvent(this, 1);
|
scheduleEvent(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
|
|
Loading…
Reference in a new issue