summaryrefslogtreecommitdiff
path: root/src/mem/ruby/network
diff options
context:
space:
mode:
authorBrandon Potter <brandon.potter@amd.com>2015-07-10 16:05:23 -0500
committerBrandon Potter <brandon.potter@amd.com>2015-07-10 16:05:23 -0500
commitc38f5098b152ea1e1dde96220d3f9e50d3411780 (patch)
tree921765f6aac17f76f5801deb2e14ea16f5ed8963 /src/mem/ruby/network
parent9eda4bdc5a947883a2d55ab860d37c5cd80c3370 (diff)
downloadgem5-c38f5098b152ea1e1dde96220d3f9e50d3411780.tar.xz
ruby: replace g_ruby_start with per-RubySystem m_start_cycle
This patch begins the process of removing global variables from the Ruby source with the goal of eventually allowing users to create multiple Ruby instances in a single simulation. Currently, users cannot do so because several global variables and static members are referenced by the RubySystem object in a way that assumes that there will only ever be a single RubySystem. These need to be replaced with per-RubySystem equivalents. This specific patch replaces the global var g_ruby_start, which is used to calculate throughput statistics for Throttles in simple networks and links in Garnet networks, with a RubySystem instance var m_start_cycle.
Diffstat (limited to 'src/mem/ruby/network')
-rw-r--r--src/mem/ruby/network/Network.cc2
-rw-r--r--src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc10
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc7
-rw-r--r--src/mem/ruby/network/simple/Switch.cc3
-rw-r--r--src/mem/ruby/network/simple/Throttle.cc14
-rw-r--r--src/mem/ruby/network/simple/Throttle.hh8
6 files changed, 27 insertions, 17 deletions
diff --git a/src/mem/ruby/network/Network.cc b/src/mem/ruby/network/Network.cc
index 5f1fff195..2d611cd7e 100644
--- a/src/mem/ruby/network/Network.cc
+++ b/src/mem/ruby/network/Network.cc
@@ -65,7 +65,7 @@ Network::Network(const Params *p)
m_ordered[i] = false;
}
- p->ruby_system->registerNetwork(this);
+ params()->ruby_system->registerNetwork(this);
// Initialize the controller's network pointers
for (std::vector<BasicExtLink*>::const_iterator i = p->ext_links.begin();
diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc
index 35732edad..d16db76ca 100644
--- a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc
+++ b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc
@@ -40,6 +40,7 @@
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
+#include "mem/ruby/system/System.hh"
using namespace std;
using m5::stl_helpers::deletePointers;
@@ -223,15 +224,16 @@ GarnetNetwork_d::regStats()
void
GarnetNetwork_d::collateStats()
{
+ RubySystem *rs = params()->ruby_system;
+ double time_delta = double(curCycle() - rs->getStartCycle());
+
for (int i = 0; i < m_links.size(); i++) {
m_average_link_utilization +=
- (double(m_links[i]->getLinkUtilization())) /
- (double(curCycle() - g_ruby_start));
+ (double(m_links[i]->getLinkUtilization())) / time_delta;
vector<unsigned int> vc_load = m_links[i]->getVcLoad();
for (int j = 0; j < vc_load.size(); j++) {
- m_average_vc_load[j] +=
- ((double)vc_load[j] / (double)(curCycle() - g_ruby_start));
+ m_average_vc_load[j] += ((double)vc_load[j] / time_delta);
}
}
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc
index 8951f7513..091a0077d 100644
--- a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc
@@ -40,6 +40,7 @@
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/Router.hh"
+#include "mem/ruby/system/System.hh"
using namespace std;
using m5::stl_helpers::deletePointers;
@@ -227,10 +228,12 @@ GarnetNetwork::regStats()
void
GarnetNetwork::collateStats()
{
+ RubySystem *rs = params()->ruby_system;
+ double time_delta = double(curCycle() - rs->getStartCycle());
+
for (int i = 0; i < m_links.size(); i++) {
m_average_link_utilization +=
- (double(m_links[i]->getLinkUtilization())) /
- (double(curCycle() - g_ruby_start));
+ (double(m_links[i]->getLinkUtilization())) / time_delta;
vector<unsigned int> vc_load = m_links[i]->getVcLoad();
for (int j = 0; j < vc_load.size(); j++) {
diff --git a/src/mem/ruby/network/simple/Switch.cc b/src/mem/ruby/network/simple/Switch.cc
index 416a222bb..431a7b28f 100644
--- a/src/mem/ruby/network/simple/Switch.cc
+++ b/src/mem/ruby/network/simple/Switch.cc
@@ -81,7 +81,8 @@ Switch::addOutPort(const vector<MessageBuffer*>& out,
Cycles link_latency, int bw_multiplier)
{
// Create a throttle
- Throttle* throttle_ptr = new Throttle(m_id, m_throttles.size(),
+ RubySystem *rs = m_network_ptr->params()->ruby_system;
+ Throttle* throttle_ptr = new Throttle(m_id, rs, m_throttles.size(),
link_latency, bw_multiplier,
m_network_ptr->getEndpointBandwidth(),
this);
diff --git a/src/mem/ruby/network/simple/Throttle.cc b/src/mem/ruby/network/simple/Throttle.cc
index d722c91ea..f0cd6bd16 100644
--- a/src/mem/ruby/network/simple/Throttle.cc
+++ b/src/mem/ruby/network/simple/Throttle.cc
@@ -46,19 +46,19 @@ const int PRIORITY_SWITCH_LIMIT = 128;
static int network_message_to_size(Message* net_msg_ptr);
-Throttle::Throttle(int sID, NodeID node, Cycles link_latency,
+Throttle::Throttle(int sID, RubySystem *rs, NodeID node, Cycles link_latency,
int link_bandwidth_multiplier, int endpoint_bandwidth,
ClockedObject *em)
- : Consumer(em)
+ : Consumer(em), m_ruby_system(rs)
{
init(node, link_latency, link_bandwidth_multiplier, endpoint_bandwidth);
m_sID = sID;
}
-Throttle::Throttle(NodeID node, Cycles link_latency,
+Throttle::Throttle(RubySystem *rs, NodeID node, Cycles link_latency,
int link_bandwidth_multiplier, int endpoint_bandwidth,
ClockedObject *em)
- : Consumer(em)
+ : Consumer(em), m_ruby_system(rs)
{
init(node, link_latency, link_bandwidth_multiplier, endpoint_bandwidth);
m_sID = 0;
@@ -245,8 +245,10 @@ Throttle::clearStats()
void
Throttle::collateStats()
{
- m_link_utilization = 100.0 * m_link_utilization_proxy
- / (double(g_system_ptr->curCycle() - g_ruby_start));
+ double time_delta = double(m_ruby_system->curCycle() -
+ m_ruby_system->getStartCycle());
+
+ m_link_utilization = 100.0 * m_link_utilization_proxy / time_delta;
}
void
diff --git a/src/mem/ruby/network/simple/Throttle.hh b/src/mem/ruby/network/simple/Throttle.hh
index 797511702..19b0fcd35 100644
--- a/src/mem/ruby/network/simple/Throttle.hh
+++ b/src/mem/ruby/network/simple/Throttle.hh
@@ -52,11 +52,12 @@ class MessageBuffer;
class Throttle : public Consumer
{
public:
- Throttle(int sID, NodeID node, Cycles link_latency,
+ Throttle(int sID, RubySystem *rs, NodeID node, Cycles link_latency,
+ int link_bandwidth_multiplier, int endpoint_bandwidth,
+ ClockedObject *em);
+ Throttle(RubySystem *rs, NodeID node, Cycles link_latency,
int link_bandwidth_multiplier, int endpoint_bandwidth,
ClockedObject *em);
- Throttle(NodeID node, Cycles link_latency, int link_bandwidth_multiplier,
- int endpoint_bandwidth, ClockedObject *em);
~Throttle() {}
std::string name()
@@ -103,6 +104,7 @@ class Throttle : public Consumer
Cycles m_link_latency;
int m_wakeups_wo_switch;
int m_endpoint_bandwidth;
+ RubySystem *m_ruby_system;
// Statistical variables
Stats::Scalar m_link_utilization;