Switch.cc (10301:44839e8febbd) | Switch.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; --- 50 unchanged lines hidden (view full) --- 59void 60Switch::init() 61{ 62 BasicRouter::init(); 63 m_perfect_switch->init(m_network_ptr); 64} 65 66void | 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; --- 50 unchanged lines hidden (view full) --- 59void 60Switch::init() 61{ 62 BasicRouter::init(); 63 m_perfect_switch->init(m_network_ptr); 64} 65 66void |
67Switch::addInPort(const vector<MessageBuffer*>& in) | 67Switch::addInPort(const map<int, MessageBuffer*>& in) |
68{ 69 m_perfect_switch->addInPort(in); 70 | 68{ 69 m_perfect_switch->addInPort(in); 70 |
71 for (int i = 0; i < in.size(); i++) { 72 in[i]->setReceiver(this); | 71 for (auto& it : in) { 72 it.second->setReceiver(this); |
73 } 74} 75 76void | 73 } 74} 75 76void |
77Switch::addOutPort(const vector<MessageBuffer*>& out, 78 const NetDest& routing_table_entry, Cycles link_latency, int bw_multiplier) | 77Switch::addOutPort(const map<int, MessageBuffer*>& out, 78 const NetDest& routing_table_entry, 79 Cycles link_latency, int bw_multiplier) |
79{ 80 // Create a throttle 81 Throttle* throttle_ptr = new Throttle(m_id, m_throttles.size(), | 80{ 81 // Create a throttle 82 Throttle* throttle_ptr = new Throttle(m_id, m_throttles.size(), |
82 link_latency, bw_multiplier, m_network_ptr->getEndpointBandwidth(), 83 this); | 83 link_latency, bw_multiplier, 84 m_network_ptr->getEndpointBandwidth(), 85 this); 86 |
84 m_throttles.push_back(throttle_ptr); 85 86 // Create one buffer per vnet (these are intermediaryQueues) | 87 m_throttles.push_back(throttle_ptr); 88 89 // Create one buffer per vnet (these are intermediaryQueues) |
87 vector<MessageBuffer*> intermediateBuffers; 88 for (int i = 0; i < out.size(); i++) { 89 out[i]->setSender(this); | 90 map<int, MessageBuffer*> intermediateBuffers; |
90 | 91 |
92 for (auto& it : out) { 93 it.second->setSender(this); 94 |
|
91 MessageBuffer* buffer_ptr = new MessageBuffer; 92 // Make these queues ordered 93 buffer_ptr->setOrdering(true); 94 if (m_network_ptr->getBufferSize() > 0) { 95 buffer_ptr->resize(m_network_ptr->getBufferSize()); 96 } 97 | 95 MessageBuffer* buffer_ptr = new MessageBuffer; 96 // Make these queues ordered 97 buffer_ptr->setOrdering(true); 98 if (m_network_ptr->getBufferSize() > 0) { 99 buffer_ptr->resize(m_network_ptr->getBufferSize()); 100 } 101 |
98 intermediateBuffers.push_back(buffer_ptr); | 102 intermediateBuffers[it.first] = buffer_ptr; |
99 m_buffers_to_free.push_back(buffer_ptr); 100 101 buffer_ptr->setSender(this); 102 buffer_ptr->setReceiver(this); 103 } 104 105 // Hook the queues to the PerfectSwitch 106 m_perfect_switch->addOutPort(intermediateBuffers, routing_table_entry); --- 99 unchanged lines hidden --- | 103 m_buffers_to_free.push_back(buffer_ptr); 104 105 buffer_ptr->setSender(this); 106 buffer_ptr->setReceiver(this); 107 } 108 109 // Hook the queues to the PerfectSwitch 110 m_perfect_switch->addOutPort(intermediateBuffers, routing_table_entry); --- 99 unchanged lines hidden --- |