ruby: fix message buffer init order
The recent changes to make MessageBuffers SimObjects required them to be initialized in a particular order, which could break some protocols. Fix this by calling initNetQueues on the external nodes of each external link in the constructor of Network. This patch also refactors the duplicated code for checking network allocation and setting net queues (which are called by initNetQueues) from the simple and garnet networks to be in Network.
This commit is contained in:
parent
c5058c0c00
commit
950e431d87
11 changed files with 62 additions and 116 deletions
|
@ -58,6 +58,7 @@ Network::Network(const Params *p)
|
||||||
m_fromNetQueues.resize(m_nodes);
|
m_fromNetQueues.resize(m_nodes);
|
||||||
|
|
||||||
m_ordered.resize(m_virtual_networks);
|
m_ordered.resize(m_virtual_networks);
|
||||||
|
m_vnet_type_names.resize(m_virtual_networks);
|
||||||
|
|
||||||
for (int i = 0; i < m_virtual_networks; i++) {
|
for (int i = 0; i < m_virtual_networks; i++) {
|
||||||
m_ordered[i] = false;
|
m_ordered[i] = false;
|
||||||
|
@ -75,6 +76,10 @@ Network::Network(const Params *p)
|
||||||
|
|
||||||
// Register a callback function for combining the statistics
|
// Register a callback function for combining the statistics
|
||||||
Stats::registerDumpCallback(new StatsCallback(this));
|
Stats::registerDumpCallback(new StatsCallback(this));
|
||||||
|
|
||||||
|
for (auto &it : dynamic_cast<Network *>(this)->params()->ext_links) {
|
||||||
|
it->params()->ext_node->initNetQueues();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Network::~Network()
|
Network::~Network()
|
||||||
|
@ -128,3 +133,41 @@ Network::MessageSizeType_to_int(MessageSizeType size_type)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Network::checkNetworkAllocation(NodeID id, bool ordered,
|
||||||
|
int network_num,
|
||||||
|
std::string vnet_type)
|
||||||
|
{
|
||||||
|
fatal_if(id >= m_nodes, "Node ID is out of range");
|
||||||
|
fatal_if(network_num >= m_virtual_networks, "Network id is out of range");
|
||||||
|
|
||||||
|
if (ordered) {
|
||||||
|
m_ordered[network_num] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_vnet_type_names[network_num] = vnet_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Network::setToNetQueue(NodeID id, bool ordered, int network_num,
|
||||||
|
std::string vnet_type, MessageBuffer *b)
|
||||||
|
{
|
||||||
|
checkNetworkAllocation(id, ordered, network_num, vnet_type);
|
||||||
|
while (m_toNetQueues[id].size() <= network_num) {
|
||||||
|
m_toNetQueues[id].push_back(nullptr);
|
||||||
|
}
|
||||||
|
m_toNetQueues[id][network_num] = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Network::setFromNetQueue(NodeID id, bool ordered, int network_num,
|
||||||
|
std::string vnet_type, MessageBuffer *b)
|
||||||
|
{
|
||||||
|
checkNetworkAllocation(id, ordered, network_num, vnet_type);
|
||||||
|
while (m_fromNetQueues[id].size() <= network_num) {
|
||||||
|
m_fromNetQueues[id].push_back(nullptr);
|
||||||
|
}
|
||||||
|
m_fromNetQueues[id][network_num] = b;
|
||||||
|
}
|
||||||
|
|
|
@ -72,10 +72,13 @@ class Network : public ClockedObject
|
||||||
static uint32_t MessageSizeType_to_int(MessageSizeType size_type);
|
static uint32_t MessageSizeType_to_int(MessageSizeType size_type);
|
||||||
|
|
||||||
// returns the queue requested for the given component
|
// returns the queue requested for the given component
|
||||||
virtual void setToNetQueue(NodeID id, bool ordered, int netNumber,
|
void setToNetQueue(NodeID id, bool ordered, int netNumber,
|
||||||
std::string vnet_type, MessageBuffer *b) = 0;
|
std::string vnet_type, MessageBuffer *b);
|
||||||
virtual void setFromNetQueue(NodeID id, bool ordered, int netNumber,
|
virtual void setFromNetQueue(NodeID id, bool ordered, int netNumber,
|
||||||
std::string vnet_type, MessageBuffer *b) = 0;
|
std::string vnet_type, MessageBuffer *b);
|
||||||
|
|
||||||
|
virtual void checkNetworkAllocation(NodeID id, bool ordered,
|
||||||
|
int network_num, std::string vnet_type);
|
||||||
|
|
||||||
virtual void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
|
virtual void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
|
||||||
LinkDirection direction,
|
LinkDirection direction,
|
||||||
|
@ -107,6 +110,7 @@ class Network : public ClockedObject
|
||||||
|
|
||||||
uint32_t m_nodes;
|
uint32_t m_nodes;
|
||||||
static uint32_t m_virtual_networks;
|
static uint32_t m_virtual_networks;
|
||||||
|
std::vector<std::string> m_vnet_type_names;
|
||||||
Topology* m_topology_ptr;
|
Topology* m_topology_ptr;
|
||||||
static uint32_t m_control_msg_size;
|
static uint32_t m_control_msg_size;
|
||||||
static uint32_t m_data_msg_size;
|
static uint32_t m_data_msg_size;
|
||||||
|
|
|
@ -66,28 +66,6 @@ BaseGarnetNetwork::init()
|
||||||
Network::init();
|
Network::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
BaseGarnetNetwork::setToNetQueue(NodeID id, bool ordered, int network_num,
|
|
||||||
string vnet_type, MessageBuffer *b)
|
|
||||||
{
|
|
||||||
checkNetworkAllocation(id, ordered, network_num, vnet_type);
|
|
||||||
while (m_toNetQueues[id].size() <= network_num) {
|
|
||||||
m_toNetQueues[id].push_back(nullptr);
|
|
||||||
}
|
|
||||||
m_toNetQueues[id][network_num] = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
BaseGarnetNetwork::setFromNetQueue(NodeID id, bool ordered, int network_num,
|
|
||||||
string vnet_type, MessageBuffer *b)
|
|
||||||
{
|
|
||||||
checkNetworkAllocation(id, ordered, network_num, vnet_type);
|
|
||||||
while (m_fromNetQueues[id].size() <= network_num) {
|
|
||||||
m_fromNetQueues[id].push_back(nullptr);
|
|
||||||
}
|
|
||||||
m_fromNetQueues[id][network_num] = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BaseGarnetNetwork::regStats()
|
BaseGarnetNetwork::regStats()
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,15 +68,7 @@ class BaseGarnetNetwork : public Network
|
||||||
m_queueing_latency[vnet] += latency;
|
m_queueing_latency[vnet] += latency;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the queue
|
|
||||||
void setToNetQueue(NodeID id, bool ordered, int network_num,
|
|
||||||
std::string vnet_type, MessageBuffer *b);
|
|
||||||
void setFromNetQueue(NodeID id, bool ordered, int network_num,
|
|
||||||
std::string vnet_type, MessageBuffer *b);
|
|
||||||
|
|
||||||
bool isVNetOrdered(int vnet) const { return m_ordered[vnet]; }
|
bool isVNetOrdered(int vnet) const { return m_ordered[vnet]; }
|
||||||
virtual void checkNetworkAllocation(NodeID id, bool ordered,
|
|
||||||
int network_num, std::string vnet_type) = 0;
|
|
||||||
|
|
||||||
virtual void regStats();
|
virtual void regStats();
|
||||||
virtual void collateStats() {}
|
virtual void collateStats() {}
|
||||||
|
|
|
@ -51,8 +51,13 @@ GarnetNetwork_d::GarnetNetwork_d(const Params *p)
|
||||||
m_buffers_per_ctrl_vc = p->buffers_per_ctrl_vc;
|
m_buffers_per_ctrl_vc = p->buffers_per_ctrl_vc;
|
||||||
|
|
||||||
m_vnet_type.resize(m_virtual_networks);
|
m_vnet_type.resize(m_virtual_networks);
|
||||||
for (int i = 0; i < m_vnet_type.size(); i++) {
|
|
||||||
m_vnet_type[i] = NULL_VNET_; // default
|
for(int i = 0 ; i < m_virtual_networks ; i++)
|
||||||
|
{
|
||||||
|
if (m_vnet_type_names[i] == "response")
|
||||||
|
m_vnet_type[i] = DATA_VNET_; // carries data (and ctrl) packets
|
||||||
|
else
|
||||||
|
m_vnet_type[i] = CTRL_VNET_; // carries only ctrl packets
|
||||||
}
|
}
|
||||||
|
|
||||||
// record the routers
|
// record the routers
|
||||||
|
@ -187,23 +192,6 @@ GarnetNetwork_d::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
|
||||||
link->m_weight, credit_link);
|
link->m_weight, credit_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
GarnetNetwork_d::checkNetworkAllocation(NodeID id, bool ordered,
|
|
||||||
int network_num, string vnet_type)
|
|
||||||
{
|
|
||||||
assert(id < m_nodes);
|
|
||||||
assert(network_num < m_virtual_networks);
|
|
||||||
|
|
||||||
if (ordered) {
|
|
||||||
m_ordered[network_num] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vnet_type == "response")
|
|
||||||
m_vnet_type[network_num] = DATA_VNET_; // carries data (and ctrl) packets
|
|
||||||
else
|
|
||||||
m_vnet_type[network_num] = CTRL_VNET_; // carries only ctrl packets
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GarnetNetwork_d::regStats()
|
GarnetNetwork_d::regStats()
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,9 +84,6 @@ class GarnetNetwork_d : public BaseGarnetNetwork
|
||||||
uint32_t functionalWrite(Packet *pkt);
|
uint32_t functionalWrite(Packet *pkt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkNetworkAllocation(NodeID id, bool ordered, int network_num,
|
|
||||||
std::string vnet_type);
|
|
||||||
|
|
||||||
GarnetNetwork_d(const GarnetNetwork_d& obj);
|
GarnetNetwork_d(const GarnetNetwork_d& obj);
|
||||||
GarnetNetwork_d& operator=(const GarnetNetwork_d& obj);
|
GarnetNetwork_d& operator=(const GarnetNetwork_d& obj);
|
||||||
|
|
||||||
|
|
|
@ -143,18 +143,6 @@ GarnetNetwork::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
|
||||||
link->m_weight);
|
link->m_weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
GarnetNetwork::checkNetworkAllocation(NodeID id, bool ordered,
|
|
||||||
int network_num, std::string vnet_type)
|
|
||||||
{
|
|
||||||
assert(id < m_nodes);
|
|
||||||
assert(network_num < m_virtual_networks);
|
|
||||||
|
|
||||||
if (ordered) {
|
|
||||||
m_ordered[network_num] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Go through all the routers, network interfaces and the interconnecting
|
* Go through all the routers, network interfaces and the interconnecting
|
||||||
* links for reading/writing all the messages.
|
* links for reading/writing all the messages.
|
||||||
|
|
|
@ -79,9 +79,6 @@ class GarnetNetwork : public BaseGarnetNetwork
|
||||||
uint32_t functionalWrite(Packet *pkt);
|
uint32_t functionalWrite(Packet *pkt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkNetworkAllocation(NodeID id, bool ordered, int network_num,
|
|
||||||
std::string vnet_type);
|
|
||||||
|
|
||||||
GarnetNetwork(const GarnetNetwork& obj);
|
GarnetNetwork(const GarnetNetwork& obj);
|
||||||
GarnetNetwork& operator=(const GarnetNetwork& obj);
|
GarnetNetwork& operator=(const GarnetNetwork& obj);
|
||||||
|
|
||||||
|
|
|
@ -139,39 +139,6 @@ SimpleNetwork::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
|
||||||
simple_link->m_bw_multiplier);
|
simple_link->m_bw_multiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
SimpleNetwork::checkNetworkAllocation(NodeID id, bool ordered, int network_num)
|
|
||||||
{
|
|
||||||
assert(id < m_nodes);
|
|
||||||
assert(network_num < m_virtual_networks);
|
|
||||||
|
|
||||||
if (ordered) {
|
|
||||||
m_ordered[network_num] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SimpleNetwork::setToNetQueue(NodeID id, bool ordered, int network_num,
|
|
||||||
std::string vnet_type, MessageBuffer *b)
|
|
||||||
{
|
|
||||||
checkNetworkAllocation(id, ordered, network_num);
|
|
||||||
while (m_toNetQueues[id].size() <= network_num) {
|
|
||||||
m_toNetQueues[id].push_back(nullptr);
|
|
||||||
}
|
|
||||||
m_toNetQueues[id][network_num] = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SimpleNetwork::setFromNetQueue(NodeID id, bool ordered, int network_num,
|
|
||||||
std::string vnet_type, MessageBuffer *b)
|
|
||||||
{
|
|
||||||
checkNetworkAllocation(id, ordered, network_num);
|
|
||||||
while (m_fromNetQueues[id].size() <= network_num) {
|
|
||||||
m_fromNetQueues[id].push_back(nullptr);
|
|
||||||
}
|
|
||||||
m_fromNetQueues[id][network_num] = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SimpleNetwork::regStats()
|
SimpleNetwork::regStats()
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,23 +56,17 @@ class SimpleNetwork : public Network
|
||||||
void collateStats();
|
void collateStats();
|
||||||
void regStats();
|
void regStats();
|
||||||
|
|
||||||
// sets the queue requested
|
|
||||||
void setToNetQueue(NodeID id, bool ordered, int network_num,
|
|
||||||
std::string vnet_type, MessageBuffer *b);
|
|
||||||
void setFromNetQueue(NodeID id, bool ordered, int network_num,
|
|
||||||
std::string vnet_type, MessageBuffer *b);
|
|
||||||
|
|
||||||
bool isVNetOrdered(int vnet) const { return m_ordered[vnet]; }
|
bool isVNetOrdered(int vnet) const { return m_ordered[vnet]; }
|
||||||
|
|
||||||
// Methods used by Topology to setup the network
|
// Methods used by Topology to setup the network
|
||||||
void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
|
void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
|
||||||
LinkDirection direction,
|
LinkDirection direction,
|
||||||
const NetDest& routing_table_entry);
|
const NetDest& routing_table_entry);
|
||||||
void makeInLink(NodeID src, SwitchID dest, BasicLink* link,
|
void makeInLink(NodeID src, SwitchID dest, BasicLink* link,
|
||||||
LinkDirection direction,
|
LinkDirection direction,
|
||||||
const NetDest& routing_table_entry);
|
const NetDest& routing_table_entry);
|
||||||
void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
|
void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
|
||||||
LinkDirection direction,
|
LinkDirection direction,
|
||||||
const NetDest& routing_table_entry);
|
const NetDest& routing_table_entry);
|
||||||
|
|
||||||
void print(std::ostream& out) const;
|
void print(std::ostream& out) const;
|
||||||
|
@ -81,7 +75,6 @@ class SimpleNetwork : public Network
|
||||||
uint32_t functionalWrite(Packet *pkt);
|
uint32_t functionalWrite(Packet *pkt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkNetworkAllocation(NodeID id, bool ordered, int network_num);
|
|
||||||
void addLink(SwitchID src, SwitchID dest, int link_latency);
|
void addLink(SwitchID src, SwitchID dest, int link_latency);
|
||||||
void makeLink(SwitchID src, SwitchID dest,
|
void makeLink(SwitchID src, SwitchID dest,
|
||||||
const NetDest& routing_table_entry, int link_latency);
|
const NetDest& routing_table_entry, int link_latency);
|
||||||
|
@ -98,7 +91,7 @@ class SimpleNetwork : public Network
|
||||||
|
|
||||||
int m_buffer_size;
|
int m_buffer_size;
|
||||||
int m_endpoint_bandwidth;
|
int m_endpoint_bandwidth;
|
||||||
bool m_adaptive_routing;
|
bool m_adaptive_routing;
|
||||||
|
|
||||||
//Statistical variables
|
//Statistical variables
|
||||||
Stats::Formula m_msg_counts[MessageSizeType_NUM];
|
Stats::Formula m_msg_counts[MessageSizeType_NUM];
|
||||||
|
|
|
@ -592,7 +592,6 @@ void
|
||||||
$c_ident::init()
|
$c_ident::init()
|
||||||
{
|
{
|
||||||
// initialize objects
|
// initialize objects
|
||||||
initNetQueues();
|
|
||||||
''')
|
''')
|
||||||
|
|
||||||
code.indent()
|
code.indent()
|
||||||
|
|
Loading…
Reference in a new issue