Network.cc (11108:6342ddf6d733) Network.cc (11113:5a2e1b1b5c43)
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 44 unchanged lines hidden (view full) ---

53 // Allocate to and from queues
54 // Queues that are getting messages from protocol
55 m_toNetQueues.resize(m_nodes);
56
57 // Queues that are feeding the protocol
58 m_fromNetQueues.resize(m_nodes);
59
60 m_ordered.resize(m_virtual_networks);
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 44 unchanged lines hidden (view full) ---

53 // Allocate to and from queues
54 // Queues that are getting messages from protocol
55 m_toNetQueues.resize(m_nodes);
56
57 // Queues that are feeding the protocol
58 m_fromNetQueues.resize(m_nodes);
59
60 m_ordered.resize(m_virtual_networks);
61 m_vnet_type_names.resize(m_virtual_networks);
61
62 for (int i = 0; i < m_virtual_networks; i++) {
63 m_ordered[i] = false;
64 }
65
66 params()->ruby_system->registerNetwork(this);
67
68 // Initialize the controller's network pointers
69 for (std::vector<BasicExtLink*>::const_iterator i = p->ext_links.begin();
70 i != p->ext_links.end(); ++i) {
71 BasicExtLink *ext_link = (*i);
72 AbstractController *abs_cntrl = ext_link->params()->ext_node;
73 abs_cntrl->initNetworkPtr(this);
74 }
75
76 // Register a callback function for combining the statistics
77 Stats::registerDumpCallback(new StatsCallback(this));
62
63 for (int i = 0; i < m_virtual_networks; i++) {
64 m_ordered[i] = false;
65 }
66
67 params()->ruby_system->registerNetwork(this);
68
69 // Initialize the controller's network pointers
70 for (std::vector<BasicExtLink*>::const_iterator i = p->ext_links.begin();
71 i != p->ext_links.end(); ++i) {
72 BasicExtLink *ext_link = (*i);
73 AbstractController *abs_cntrl = ext_link->params()->ext_node;
74 abs_cntrl->initNetworkPtr(this);
75 }
76
77 // Register a callback function for combining the statistics
78 Stats::registerDumpCallback(new StatsCallback(this));
79
80 for (auto &it : dynamic_cast<Network *>(this)->params()->ext_links) {
81 it->params()->ext_node->initNetQueues();
82 }
78}
79
80Network::~Network()
81{
82 for (int node = 0; node < m_nodes; node++) {
83
84 // Delete the Message Buffers
85 for (auto& it : m_toNetQueues[node]) {

--- 37 unchanged lines hidden (view full) ---

123 case MessageSizeType_ResponseL2hit_Data:
124 case MessageSizeType_Writeback_Data:
125 return m_data_msg_size;
126 default:
127 panic("Invalid range for type MessageSizeType");
128 break;
129 }
130}
83}
84
85Network::~Network()
86{
87 for (int node = 0; node < m_nodes; node++) {
88
89 // Delete the Message Buffers
90 for (auto& it : m_toNetQueues[node]) {

--- 37 unchanged lines hidden (view full) ---

128 case MessageSizeType_ResponseL2hit_Data:
129 case MessageSizeType_Writeback_Data:
130 return m_data_msg_size;
131 default:
132 panic("Invalid range for type MessageSizeType");
133 break;
134 }
135}
136
137void
138Network::checkNetworkAllocation(NodeID id, bool ordered,
139 int network_num,
140 std::string vnet_type)
141{
142 fatal_if(id >= m_nodes, "Node ID is out of range");
143 fatal_if(network_num >= m_virtual_networks, "Network id is out of range");
144
145 if (ordered) {
146 m_ordered[network_num] = true;
147 }
148
149 m_vnet_type_names[network_num] = vnet_type;
150}
151
152
153void
154Network::setToNetQueue(NodeID id, bool ordered, int network_num,
155 std::string vnet_type, MessageBuffer *b)
156{
157 checkNetworkAllocation(id, ordered, network_num, vnet_type);
158 while (m_toNetQueues[id].size() <= network_num) {
159 m_toNetQueues[id].push_back(nullptr);
160 }
161 m_toNetQueues[id][network_num] = b;
162}
163
164void
165Network::setFromNetQueue(NodeID id, bool ordered, int network_num,
166 std::string vnet_type, MessageBuffer *b)
167{
168 checkNetworkAllocation(id, ordered, network_num, vnet_type);
169 while (m_fromNetQueues[id].size() <= network_num) {
170 m_fromNetQueues[id].push_back(nullptr);
171 }
172 m_fromNetQueues[id][network_num] = b;
173}