2009-05-11 19:38:43 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1999-2008 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.
|
|
|
|
*/
|
|
|
|
|
2011-01-10 20:11:20 +01:00
|
|
|
#include <cassert>
|
2010-08-20 20:46:12 +02:00
|
|
|
#include <numeric>
|
|
|
|
|
2012-01-01 01:44:51 +01:00
|
|
|
#include "base/cast.hh"
|
2010-06-11 08:17:07 +02:00
|
|
|
#include "base/stl_helpers.hh"
|
2010-04-01 01:56:45 +02:00
|
|
|
#include "mem/ruby/common/NetDest.hh"
|
2014-09-01 23:55:40 +02:00
|
|
|
#include "mem/ruby/network/MessageBuffer.hh"
|
2011-04-29 02:18:14 +02:00
|
|
|
#include "mem/ruby/network/simple/SimpleLink.hh"
|
2009-05-11 19:38:45 +02:00
|
|
|
#include "mem/ruby/network/simple/SimpleNetwork.hh"
|
|
|
|
#include "mem/ruby/network/simple/Switch.hh"
|
2010-08-20 20:46:12 +02:00
|
|
|
#include "mem/ruby/network/simple/Throttle.hh"
|
2010-04-01 01:56:45 +02:00
|
|
|
#include "mem/ruby/profiler/Profiler.hh"
|
2015-09-16 18:03:03 +02:00
|
|
|
#include "mem/ruby/system/RubySystem.hh"
|
2009-05-11 19:38:43 +02:00
|
|
|
|
2010-04-02 20:20:32 +02:00
|
|
|
using namespace std;
|
2010-06-11 08:17:07 +02:00
|
|
|
using m5::stl_helpers::deletePointers;
|
2010-04-02 20:20:32 +02:00
|
|
|
|
2010-01-30 05:29:17 +01:00
|
|
|
SimpleNetwork::SimpleNetwork(const Params *p)
|
2015-08-19 17:02:01 +02:00
|
|
|
: Network(p)
|
2009-07-07 00:49:47 +02:00
|
|
|
{
|
2015-08-19 17:02:01 +02:00
|
|
|
m_buffer_size = p->buffer_size;
|
|
|
|
m_endpoint_bandwidth = p->endpoint_bandwidth;
|
|
|
|
m_adaptive_routing = p->adaptive_routing;
|
|
|
|
|
|
|
|
// Note: the parent Network Object constructor is called before the
|
|
|
|
// SimpleNetwork child constructor. Therefore, the member variables
|
|
|
|
// used below should already be initialized.
|
|
|
|
m_endpoint_switches.resize(m_nodes);
|
|
|
|
|
2012-10-02 21:35:45 +02:00
|
|
|
// record the routers
|
2013-03-22 21:53:22 +01:00
|
|
|
for (vector<BasicRouter*>::const_iterator i = p->routers.begin();
|
|
|
|
i != p->routers.end(); ++i) {
|
2012-10-02 21:35:45 +02:00
|
|
|
Switch* s = safe_cast<Switch*>(*i);
|
2013-09-06 23:21:29 +02:00
|
|
|
m_switches.push_back(s);
|
2012-10-02 21:35:45 +02:00
|
|
|
s->init_net_ptr(this);
|
|
|
|
}
|
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.
2015-08-14 07:19:44 +02:00
|
|
|
|
|
|
|
m_int_link_buffers = p->int_link_buffers;
|
|
|
|
m_num_connected_buffers = 0;
|
2010-01-30 05:29:18 +01:00
|
|
|
}
|
|
|
|
|
2010-04-01 01:56:45 +02:00
|
|
|
void
|
|
|
|
SimpleNetwork::init()
|
2010-01-30 05:29:18 +01:00
|
|
|
{
|
2010-04-01 01:56:45 +02:00
|
|
|
Network::init();
|
|
|
|
|
|
|
|
// The topology pointer should have already been initialized in
|
|
|
|
// the parent class network constructor.
|
|
|
|
assert(m_topology_ptr != NULL);
|
2013-06-29 04:36:37 +02:00
|
|
|
m_topology_ptr->createLinks(this);
|
2009-07-07 00:49:47 +02:00
|
|
|
}
|
2009-05-11 19:38:43 +02:00
|
|
|
|
|
|
|
SimpleNetwork::~SimpleNetwork()
|
|
|
|
{
|
2013-09-06 23:21:29 +02:00
|
|
|
deletePointers(m_switches);
|
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.
2015-08-14 07:19:44 +02:00
|
|
|
deletePointers(m_int_link_buffers);
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// From a switch to an endpoint node
|
2010-04-01 01:56:45 +02:00
|
|
|
void
|
2015-07-10 23:05:23 +02:00
|
|
|
SimpleNetwork::makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
|
|
|
|
LinkDirection direction,
|
2013-06-29 04:36:37 +02:00
|
|
|
const NetDest& routing_table_entry)
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2010-04-01 01:56:45 +02:00
|
|
|
assert(dest < m_nodes);
|
2013-09-06 23:21:29 +02:00
|
|
|
assert(src < m_switches.size());
|
|
|
|
assert(m_switches[src] != NULL);
|
2010-04-01 01:56:45 +02:00
|
|
|
|
2011-04-29 02:18:14 +02:00
|
|
|
SimpleExtLink *simple_link = safe_cast<SimpleExtLink*>(link);
|
|
|
|
|
2014-09-01 23:55:47 +02:00
|
|
|
m_switches[src]->addOutPort(m_fromNetQueues[dest], routing_table_entry,
|
|
|
|
simple_link->m_latency,
|
|
|
|
simple_link->m_bw_multiplier);
|
2015-08-19 17:02:01 +02:00
|
|
|
|
|
|
|
m_endpoint_switches[dest] = m_switches[src];
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// From an endpoint node to a switch
|
2010-04-01 01:56:45 +02:00
|
|
|
void
|
2015-07-10 23:05:23 +02:00
|
|
|
SimpleNetwork::makeInLink(NodeID src, SwitchID dest, BasicLink* link,
|
|
|
|
LinkDirection direction,
|
2013-06-29 04:36:37 +02:00
|
|
|
const NetDest& routing_table_entry)
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2010-04-01 01:56:45 +02:00
|
|
|
assert(src < m_nodes);
|
2013-09-06 23:21:29 +02:00
|
|
|
m_switches[dest]->addInPort(m_toNetQueues[src]);
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// From a switch to a switch
|
2010-04-01 01:56:45 +02:00
|
|
|
void
|
2015-07-10 23:05:23 +02:00
|
|
|
SimpleNetwork::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
|
|
|
|
LinkDirection direction,
|
2013-06-29 04:36:37 +02:00
|
|
|
const NetDest& routing_table_entry)
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
|
|
|
// Create a set of new MessageBuffers
|
2014-09-15 23:19:38 +02:00
|
|
|
std::vector<MessageBuffer*> queues(m_virtual_networks);
|
|
|
|
|
2009-05-11 19:38:43 +02:00
|
|
|
for (int i = 0; i < m_virtual_networks; i++) {
|
2010-04-01 01:56:45 +02:00
|
|
|
// allocate a buffer
|
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.
2015-08-14 07:19:44 +02:00
|
|
|
assert(m_num_connected_buffers < m_int_link_buffers.size());
|
|
|
|
MessageBuffer* buffer_ptr = m_int_link_buffers[m_num_connected_buffers];
|
|
|
|
m_num_connected_buffers++;
|
2014-09-01 23:55:47 +02:00
|
|
|
queues[i] = buffer_ptr;
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
2014-09-01 23:55:47 +02:00
|
|
|
|
2009-05-11 19:38:43 +02:00
|
|
|
// Connect it to the two switches
|
2011-04-29 02:18:14 +02:00
|
|
|
SimpleIntLink *simple_link = safe_cast<SimpleIntLink*>(link);
|
|
|
|
|
2013-09-06 23:21:29 +02:00
|
|
|
m_switches[dest]->addInPort(queues);
|
|
|
|
m_switches[src]->addOutPort(queues, routing_table_entry,
|
2014-09-01 23:55:47 +02:00
|
|
|
simple_link->m_latency,
|
|
|
|
simple_link->m_bw_multiplier);
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2010-04-01 01:56:45 +02:00
|
|
|
void
|
2013-09-06 23:21:35 +02:00
|
|
|
SimpleNetwork::regStats()
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2013-09-06 23:21:35 +02:00
|
|
|
for (MessageSizeType type = MessageSizeType_FIRST;
|
|
|
|
type < MessageSizeType_NUM; ++type) {
|
|
|
|
m_msg_counts[(unsigned int) type]
|
|
|
|
.name(name() + ".msg_count." + MessageSizeType_to_string(type))
|
|
|
|
.flags(Stats::nozero)
|
|
|
|
;
|
|
|
|
m_msg_bytes[(unsigned int) type]
|
|
|
|
.name(name() + ".msg_byte." + MessageSizeType_to_string(type))
|
|
|
|
.flags(Stats::nozero)
|
|
|
|
;
|
|
|
|
|
|
|
|
// Now state what the formula is.
|
|
|
|
for (int i = 0; i < m_switches.size(); i++) {
|
|
|
|
m_msg_counts[(unsigned int) type] +=
|
|
|
|
sum(m_switches[i]->getMsgCount(type));
|
2010-08-20 20:46:12 +02:00
|
|
|
}
|
2013-09-06 23:21:35 +02:00
|
|
|
|
|
|
|
m_msg_bytes[(unsigned int) type] =
|
|
|
|
m_msg_counts[(unsigned int) type] * Stats::constant(
|
|
|
|
Network::MessageSizeType_to_int(type));
|
2010-04-01 01:56:45 +02:00
|
|
|
}
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2010-04-01 01:56:45 +02:00
|
|
|
void
|
2013-09-06 23:21:35 +02:00
|
|
|
SimpleNetwork::collateStats()
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2013-09-06 23:21:29 +02:00
|
|
|
for (int i = 0; i < m_switches.size(); i++) {
|
2013-09-06 23:21:35 +02:00
|
|
|
m_switches[i]->collateStats();
|
2010-04-01 01:56:45 +02:00
|
|
|
}
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2010-04-01 01:56:45 +02:00
|
|
|
void
|
|
|
|
SimpleNetwork::print(ostream& out) const
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2010-04-01 01:56:45 +02:00
|
|
|
out << "[SimpleNetwork]";
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
2010-01-30 05:29:17 +01:00
|
|
|
|
|
|
|
SimpleNetwork *
|
|
|
|
SimpleNetworkParams::create()
|
|
|
|
{
|
|
|
|
return new SimpleNetwork(this);
|
|
|
|
}
|
2012-10-16 00:51:57 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The simple network has an array of switches. These switches have buffers
|
|
|
|
* that need to be accessed for functional reads and writes. Also the links
|
|
|
|
* between different switches have buffers that need to be accessed.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
SimpleNetwork::functionalRead(Packet *pkt)
|
|
|
|
{
|
2013-09-06 23:21:29 +02:00
|
|
|
for (unsigned int i = 0; i < m_switches.size(); i++) {
|
|
|
|
if (m_switches[i]->functionalRead(pkt)) {
|
2012-10-16 00:51:57 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-19 17:02:01 +02:00
|
|
|
for (unsigned int i = 0; i < m_int_link_buffers.size(); ++i) {
|
|
|
|
if (m_int_link_buffers[i]->functionalRead(pkt)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-16 00:51:57 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SimpleNetwork::functionalWrite(Packet *pkt)
|
|
|
|
{
|
|
|
|
uint32_t num_functional_writes = 0;
|
|
|
|
|
2013-09-06 23:21:29 +02:00
|
|
|
for (unsigned int i = 0; i < m_switches.size(); i++) {
|
|
|
|
num_functional_writes += m_switches[i]->functionalWrite(pkt);
|
2012-10-16 00:51:57 +02:00
|
|
|
}
|
|
|
|
|
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.
2015-08-14 07:19:44 +02:00
|
|
|
for (unsigned int i = 0; i < m_int_link_buffers.size(); ++i) {
|
|
|
|
num_functional_writes += m_int_link_buffers[i]->functionalWrite(pkt);
|
2012-10-16 00:51:57 +02:00
|
|
|
}
|
|
|
|
return num_functional_writes;
|
|
|
|
}
|