PerfectSwitch.cc (10301:44839e8febbd) | PerfectSwitch.cc (10311:ad9c042dce54) |
---|---|
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 | 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 { | 64 for(int i = 0;i < m_virtual_networks;++i) { |
66 m_pending_message_count.push_back(0); 67 } 68} 69 70void | 65 m_pending_message_count.push_back(0); 66 } 67} 68 69void |
71PerfectSwitch::addInPort(const vector<MessageBuffer*>& in) | 70PerfectSwitch::addInPort(const map<int, MessageBuffer*>& in) |
72{ | 71{ |
73 assert(in.size() == m_virtual_networks); | |
74 NodeID port = m_in.size(); 75 m_in.push_back(in); 76 | 72 NodeID port = m_in.size(); 73 m_in.push_back(in); 74 |
77 for (int j = 0; j < m_virtual_networks; j++) { 78 m_in[port][j]->setConsumer(this); | 75 for (auto& it : in) { 76 it.second->setConsumer(this); |
79 80 string desc = csprintf("[Queue from port %s %s %s to PerfectSwitch]", | 77 78 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); | 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); |
85 } 86} 87 88void | 84 } 85} 86 87void |
89PerfectSwitch::addOutPort(const vector<MessageBuffer*>& out, | 88PerfectSwitch::addOutPort(const map<int, MessageBuffer*>& out, |
90 const NetDest& routing_table_entry) 91{ | 89 const NetDest& routing_table_entry) 90{ |
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? | 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? |
155 while (m_in[incoming][vnet]->isReady()) { | 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()) { |
156 DPRINTF(RubyNetwork, "incoming: %d\n", incoming); 157 158 // Peek at message | 158 DPRINTF(RubyNetwork, "incoming: %d\n", incoming); 159 160 // Peek at message |
159 msg_ptr = m_in[incoming][vnet]->peekMsgPtr(); | 161 msg_ptr = buffer->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 | 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 |
264 m_in[incoming][vnet]->dequeue(); | 266 buffer->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 --- | 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 --- |