Deleted Added
sdiff udiff text old ( 10301:44839e8febbd ) new ( 10311:ad9c042dce54 )
full compact
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;

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

56 m_virtual_networks = virt_nets;
57}
58
59void
60PerfectSwitch::init(SimpleNetwork *network_ptr)
61{
62 m_network_ptr = network_ptr;
63
64 for(int i = 0;i < m_virtual_networks;++i) {
65 m_pending_message_count.push_back(0);
66 }
67}
68
69void
70PerfectSwitch::addInPort(const map<int, MessageBuffer*>& in)
71{
72 NodeID port = m_in.size();
73 m_in.push_back(in);
74
75 for (auto& it : in) {
76 it.second->setConsumer(this);
77
78 string desc = csprintf("[Queue from port %s %s %s to PerfectSwitch]",
79 to_string(m_switch_id), to_string(port), to_string(it.first));
80
81 it.second->setDescription(desc);
82 it.second->setIncomingLink(port);
83 it.second->setVnet(it.first);
84 }
85}
86
87void
88PerfectSwitch::addOutPort(const map<int, MessageBuffer*>& out,
89 const NetDest& routing_table_entry)
90{
91 // Setup link order
92 LinkOrder l;
93 l.m_value = 0;
94 l.m_link = m_out.size();
95 m_link_order.push_back(l);
96
97 // Add to routing table
98 m_out.push_back(out);

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

144 incoming = 0;
145 }
146
147 // temporary vectors to store the routing results
148 vector<LinkID> output_links;
149 vector<NetDest> output_link_destinations;
150
151 // Is there a message waiting?
152 auto it = m_in[incoming].find(vnet);
153 if (it == m_in[incoming].end())
154 continue;
155 MessageBuffer *buffer = (*it).second;
156
157 while (buffer->isReady()) {
158 DPRINTF(RubyNetwork, "incoming: %d\n", incoming);
159
160 // Peek at message
161 msg_ptr = buffer->peekMsgPtr();
162 net_msg_ptr = safe_cast<NetworkMessage*>(msg_ptr.get());
163 DPRINTF(RubyNetwork, "Message: %s\n", (*net_msg_ptr));
164
165 output_links.clear();
166 output_link_destinations.clear();
167 NetDest msg_dsts =
168 net_msg_ptr->getInternalDestination();
169

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

258 // enqueue func will modify the message
259
260 // This magic line creates a private copy of the
261 // message
262 unmodified_msg_ptr = msg_ptr->clone();
263 }
264
265 // Dequeue msg
266 buffer->dequeue();
267 m_pending_message_count[vnet]--;
268
269 // Enqueue it - for all outgoing queues
270 for (int i=0; i<output_links.size(); i++) {
271 int outgoing = output_links[i];
272
273 if (i > 0) {
274 // create a private copy of the unmodified

--- 45 unchanged lines hidden ---