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

--- 99 unchanged lines hidden ---