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 {
66 m_pending_message_count.push_back(0);
67 }
68}
69
70void
71PerfectSwitch::addInPort(const vector<MessageBuffer*>& in)
72{
73 assert(in.size() == m_virtual_networks);
74 NodeID port = m_in.size();
75 m_in.push_back(in);
76
77 for (int j = 0; j < m_virtual_networks; j++) {
78 m_in[port][j]->setConsumer(this);
79
80 string desc = csprintf("[Queue from port %s %s %s to PerfectSwitch]",
81 to_string(m_switch_id), to_string(port), to_string(j));
82 m_in[port][j]->setDescription(desc);
83 m_in[port][j]->setIncomingLink(port);
84 m_in[port][j]->setVnet(j);
85 }
86}
87
88void
89PerfectSwitch::addOutPort(const vector<MessageBuffer*>& out,
90 const NetDest& routing_table_entry)
91{
92 assert(out.size() == m_virtual_networks);
93
94 // Setup link order
95 LinkOrder l;
96 l.m_value = 0;
97 l.m_link = m_out.size();
98 m_link_order.push_back(l);
99
100 // Add to routing table
101 m_out.push_back(out);

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

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

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

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

--- 45 unchanged lines hidden ---