changeset e8a6637afa4c in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=e8a6637afa4c
description:
ruby: Expose MessageBuffers as SimObjects
Expose MessageBuffers from SLICC controllers as SimObjects that can be
manipulated in Python. This patch has numerous benefits:
1) First and foremost, it exposes MessageBuffers as SimObjects that can
be
manipulated in Python code. This allows parameters to be set and
checked in
Python code to avoid obfuscating parameters within protocol files.
Further, now
as SimObjects, MessageBuffer parameters are printed to config output
files as a
way to track parameters across simulations (e.g. buffer sizes)
2) Cleans up special-case code for responseFromMemory buffers, and
aligns their
instantiation and use with mandatoryQueue buffers. These two special
buffers
are the only MessageBuffers that are exposed to components outside of
SLICC
controllers, and they're both slave ends of these buffers. They should
be
exposed outside of SLICC in the same way, and this patch does it.
3) Distinguishes buffer-specific parameters from buffer-to-network
parameters.
Specifically, buffer size, randomization, ordering, recycle latency,
and ports
are all specific to a MessageBuffer, while the virtual network ID and
type are
intrinsics of how the buffer is connected to network ports. The former
are
specified in the Python object, while the latter are specified in the
controller *.sm files. Unlike buffer-specific parameters, which may
need to
change depending on the simulated system structure, buffer-to-network
parameters can be specified statically for most or all different
simulated
systems.
diffstat:
configs/ruby/Ruby.py | 5 +
src/mem/protocol/RubySlicc_Defines.sm | 1 -
src/mem/ruby/network/MessageBuffer.cc | 26 ++--
src/mem/ruby/network/MessageBuffer.hh | 44 +++-----
src/mem/ruby/network/MessageBuffer.py | 44 ++++++++
src/mem/ruby/network/SConscript | 1 +
src/mem/ruby/network/simple/PerfectSwitch.cc | 7 -
src/mem/ruby/network/simple/SimpleNetwork.cc | 25 ++--
src/mem/ruby/network/simple/SimpleNetwork.hh | 3 +-
src/mem/ruby/network/simple/SimpleNetwork.py | 40 ++++++++
src/mem/ruby/network/simple/Switch.cc | 23 ++--
src/mem/ruby/network/simple/Switch.hh | 3 +-
src/mem/ruby/network/simple/Throttle.cc | 1 -
src/mem/ruby/slicc_interface/AbstractController.cc | 19 +--
src/mem/ruby/slicc_interface/AbstractController.hh | 9 +-
src/mem/slicc/ast/ObjDeclAST.py | 16 ---
src/mem/slicc/symbols/StateMachine.py | 103 +++++++-------------
src/python/swig/pyobject.cc | 27 ++---
18 files changed, 201 insertions(+), 196 deletions(-)
diffs (truncated from 896 to 300 lines):
diff -r 882ce080c9f7 -r e8a6637afa4c configs/ruby/Ruby.py
--- a/configs/ruby/Ruby.py Fri Aug 14 00:19:39 2015 -0500
+++ b/configs/ruby/Ruby.py Fri Aug 14 00:19:44 2015 -0500
@@ -209,6 +209,11 @@
topology.makeTopology(options, network, IntLinkClass, ExtLinkClass,
RouterClass)
+ if options.garnet_network is None:
+ assert(NetworkClass == SimpleNetwork)
+ assert(RouterClass == Switch)
+ network.setup_buffers()
+
if InterfaceClass != None:
netifs = [InterfaceClass(id=i) for (i,n) in
enumerate(network.ext_links)]
network.netifs = netifs
diff -r 882ce080c9f7 -r e8a6637afa4c src/mem/protocol/RubySlicc_Defines.sm
--- a/src/mem/protocol/RubySlicc_Defines.sm Fri Aug 14 00:19:39 2015 -0500
+++ b/src/mem/protocol/RubySlicc_Defines.sm Fri Aug 14 00:19:44 2015 -0500
@@ -31,7 +31,6 @@
NodeID version;
MachineID machineID;
NodeID clusterID;
-MessageBuffer responseFromMemory, ordered="false";
// Functions implemented in the AbstractController class for
// making timing access to the memory maintained by the
diff -r 882ce080c9f7 -r e8a6637afa4c src/mem/ruby/network/MessageBuffer.cc
--- a/src/mem/ruby/network/MessageBuffer.cc Fri Aug 14 00:19:39 2015 -0500
+++ b/src/mem/ruby/network/MessageBuffer.cc Fri Aug 14 00:19:44 2015 -0500
@@ -39,25 +39,23 @@
using namespace std;
using m5::stl_helpers::operator<<;
-MessageBuffer::MessageBuffer(const string &name)
- : m_time_last_time_size_checked(0), m_time_last_time_enqueue(0),
- m_time_last_time_pop(0), m_last_arrival_time(0)
+MessageBuffer::MessageBuffer(const Params *p)
+ : SimObject(p), m_recycle_latency(p->recycle_latency),
+ m_max_size(p->buffer_size), m_time_last_time_size_checked(0),
+ m_time_last_time_enqueue(0), m_time_last_time_pop(0),
+ m_last_arrival_time(0), m_strict_fifo(p->ordered),
+ m_randomization(p->randomization)
{
m_msg_counter = 0;
m_consumer = NULL;
m_sender = NULL;
m_receiver = NULL;
- m_ordering_set = false;
- m_strict_fifo = true;
- m_max_size = 0;
- m_randomization = true;
m_size_last_time_size_checked = 0;
m_size_at_cycle_start = 0;
m_msgs_this_cycle = 0;
m_not_avail_count = 0;
m_priority_rank = 0;
- m_name = name;
m_stall_msg_map.clear();
m_input_link_id = 0;
@@ -144,8 +142,6 @@
void
MessageBuffer::enqueue(MsgPtr message, Cycles delta)
{
- assert(m_ordering_set);
-
// record current time incase we have a pop that also adjusts my size
if (m_time_last_time_enqueue < m_sender->curCycle()) {
m_msgs_this_cycle = 0; // first msg this cycle
@@ -184,7 +180,7 @@
if (arrival_time < m_last_arrival_time) {
panic("FIFO ordering violated: %s name: %s current time: %d "
"delta: %d arrival_time: %d last arrival_time: %d\n",
- *this, m_name, current_time,
+ *this, name(), current_time,
delta * m_sender->clockPeriod(),
arrival_time, m_last_arrival_time);
}
@@ -356,7 +352,7 @@
vector<MsgPtr> copy(m_prio_heap);
sort_heap(copy.begin(), copy.end(), greater<MsgPtr>());
- ccprintf(out, "%s] %s", copy, m_name);
+ ccprintf(out, "%s] %s", copy, name());
}
bool
@@ -424,3 +420,9 @@
return num_functional_writes;
}
+
+MessageBuffer *
+MessageBufferParams::create()
+{
+ return new MessageBuffer(this);
+}
diff -r 882ce080c9f7 -r e8a6637afa4c src/mem/ruby/network/MessageBuffer.hh
--- a/src/mem/ruby/network/MessageBuffer.hh Fri Aug 14 00:19:39 2015 -0500
+++ b/src/mem/ruby/network/MessageBuffer.hh Fri Aug 14 00:19:44 2015 -0500
@@ -41,20 +41,19 @@
#include <string>
#include <vector>
+#include "debug/RubyQueue.hh"
#include "mem/ruby/common/Address.hh"
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/slicc_interface/Message.hh"
#include "mem/packet.hh"
+#include "params/MessageBuffer.hh"
+#include "sim/sim_object.hh"
-class MessageBuffer
+class MessageBuffer : public SimObject
{
public:
- MessageBuffer(const std::string &name = "");
-
- std::string name() const { return m_name; }
-
- void setRecycleLatency(Cycles recycle_latency)
- { m_recycle_latency = recycle_latency; }
+ typedef MessageBufferParams Params;
+ MessageBuffer(const Params *p);
void reanalyzeMessages(const Address& addr);
void reanalyzeAllMessages();
@@ -78,6 +77,7 @@
void setPriority(int rank) { m_priority_rank = rank; }
void setConsumer(Consumer* consumer)
{
+ DPRINTF(RubyQueue, "Setting consumer: %s\n", *consumer);
if (m_consumer != NULL) {
fatal("Trying to connect %s to MessageBuffer %s. \
\n%s already connected. Check the cntrl_id's.\n",
@@ -88,20 +88,21 @@
void setSender(ClockedObject* obj)
{
+ DPRINTF(RubyQueue, "Setting sender: %s\n", obj->name());
assert(m_sender == NULL || m_sender == obj);
m_sender = obj;
}
void setReceiver(ClockedObject* obj)
{
+ DPRINTF(RubyQueue, "Setting receiver: %s\n", obj->name());
assert(m_receiver == NULL || m_receiver == obj);
m_receiver = obj;
}
- void setDescription(const std::string& name) { m_name = name; }
- std::string getDescription() { return m_name;}
+ Consumer* getConsumer() { return m_consumer; }
- Consumer* getConsumer() { return m_consumer; }
+ bool getOrdered() { return m_strict_fifo; }
//! Function for extracting the message at the head of the
//! message queue. The function assumes that the queue is nonempty.
@@ -126,16 +127,7 @@
bool isStallMapEmpty() { return m_stall_msg_map.size() == 0; }
unsigned int getStallMapSize() { return m_stall_msg_map.size(); }
- void
- setOrdering(bool order)
- {
- m_strict_fifo = order;
- m_ordering_set = true;
- }
-
- void resize(unsigned int size) { m_max_size = size; }
unsigned int getSize();
- void setRandomization(bool random_flag) { m_randomization = random_flag; }
void clear();
void print(std::ostream& out) const;
@@ -156,12 +148,12 @@
uint32_t functionalWrite(Packet *pkt);
private:
+ //added by SS
+ const Cycles m_recycle_latency;
+
void reanalyzeList(std::list<MsgPtr> &, Tick);
private:
- //added by SS
- Cycles m_recycle_latency;
-
// Data Members (m_ prefix)
//! The two ends of the buffer.
ClockedObject* m_sender;
@@ -176,9 +168,8 @@
typedef std::map< Address, std::list<MsgPtr> > StallMsgMapType;
StallMsgMapType m_stall_msg_map;
- std::string m_name;
- unsigned int m_max_size;
+ const unsigned int m_max_size;
Cycles m_time_last_time_size_checked;
unsigned int m_size_last_time_size_checked;
@@ -195,9 +186,8 @@
// slots available
uint64 m_msg_counter;
int m_priority_rank;
- bool m_strict_fifo;
- bool m_ordering_set;
- bool m_randomization;
+ const bool m_strict_fifo;
+ const bool m_randomization;
int m_input_link_id;
int m_vnet_id;
diff -r 882ce080c9f7 -r e8a6637afa4c src/mem/ruby/network/MessageBuffer.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mem/ruby/network/MessageBuffer.py Fri Aug 14 00:19:44 2015 -0500
@@ -0,0 +1,44 @@
+# Copyright (c) 2015 Mark D. Hill and David A. Wood.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer;
+# redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution;
+# neither the name of the copyright holders nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# Authors: Joel Hestness
+
+from m5.params import *
+from m5.proxy import *
+from m5.SimObject import SimObject
+
+class MessageBuffer(SimObject):
+ type = 'MessageBuffer'
+ cxx_class = 'MessageBuffer'
+ cxx_header = "mem/ruby/network/MessageBuffer.hh"
+ ordered = Param.Bool(False, "Whether the buffer is ordered")
+ buffer_size = Param.Unsigned(0, "Maximum number of entries to buffer \
+ (0 allows infinite entries)")
+ recycle_latency = Param.Cycles(Parent.recycle_latency, "")
+ randomization = Param.Bool(False, "")
+
+ master = MasterPort("Master port to MessageBuffer receiver")
+ slave = SlavePort("Slave port from MessageBuffer sender")
diff -r 882ce080c9f7 -r e8a6637afa4c src/mem/ruby/network/SConscript
--- a/src/mem/ruby/network/SConscript Fri Aug 14 00:19:39 2015 -0500
+++ b/src/mem/ruby/network/SConscript Fri Aug 14 00:19:44 2015 -0500
@@ -35,6 +35,7 @@
SimObject('BasicLink.py')
SimObject('BasicRouter.py')
+SimObject('MessageBuffer.py')
SimObject('Network.py')
Source('BasicLink.cc')
diff -r 882ce080c9f7 -r e8a6637afa4c
src/mem/ruby/network/simple/PerfectSwitch.cc
--- a/src/mem/ruby/network/simple/PerfectSwitch.cc Fri Aug 14 00:19:39
2015 -0500
+++ b/src/mem/ruby/network/simple/PerfectSwitch.cc Fri Aug 14 00:19:44
2015 -0500
@@ -76,13 +76,6 @@
for (int i = 0; i < in.size(); ++i) {
if (in[i] != nullptr) {
in[i]->setConsumer(this);
-
- string desc =
- csprintf("[Queue from port %s %s %s to PerfectSwitch]",
- to_string(m_switch_id), to_string(port),
- to_string(i));
-
- in[i]->setDescription(desc);
in[i]->setIncomingLink(port);
in[i]->setVnet(i);
}
diff -r 882ce080c9f7 -r e8a6637afa4c
src/mem/ruby/network/simple/SimpleNetwork.cc
--- a/src/mem/ruby/network/simple/SimpleNetwork.cc Fri Aug 14 00:19:39
2015 -0500
+++ b/src/mem/ruby/network/simple/SimpleNetwork.cc Fri Aug 14 00:19:44
2015 -0500
@@ -62,6 +62,9 @@
m_switches.push_back(s);
s->init_net_ptr(this);
}
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev