Switch.cc (9230:33eb3c8a98b9) | Switch.cc (9274:ba635023d4bb) |
---|---|
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; --- 27 unchanged lines hidden (view full) --- 36#include "mem/ruby/network/simple/SimpleNetwork.hh" 37#include "mem/ruby/network/simple/Switch.hh" 38#include "mem/ruby/network/simple/Throttle.hh" 39 40using namespace std; 41using m5::stl_helpers::deletePointers; 42using m5::stl_helpers::operator<<; 43 | 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; --- 27 unchanged lines hidden (view full) --- 36#include "mem/ruby/network/simple/SimpleNetwork.hh" 37#include "mem/ruby/network/simple/Switch.hh" 38#include "mem/ruby/network/simple/Throttle.hh" 39 40using namespace std; 41using m5::stl_helpers::deletePointers; 42using m5::stl_helpers::operator<<; 43 |
44Switch::Switch(SwitchID sid, SimpleNetwork* network_ptr) | 44Switch::Switch(const Params *p) : BasicRouter(p) |
45{ | 45{ |
46 m_perfect_switch_ptr = new PerfectSwitch(sid, network_ptr); 47 m_switch_id = sid; | 46 m_perfect_switch_ptr = new PerfectSwitch(m_id, this, p->virt_nets); |
48} 49 50Switch::~Switch() 51{ 52 delete m_perfect_switch_ptr; 53 54 // Delete throttles (one per output port) 55 deletePointers(m_throttles); 56 57 // Delete MessageBuffers 58 deletePointers(m_buffers_to_free); 59} 60 61void | 47} 48 49Switch::~Switch() 50{ 51 delete m_perfect_switch_ptr; 52 53 // Delete throttles (one per output port) 54 deletePointers(m_throttles); 55 56 // Delete MessageBuffers 57 deletePointers(m_buffers_to_free); 58} 59 60void |
61Switch::init() 62{ 63 BasicRouter::init(); 64 m_perfect_switch_ptr->init(m_network_ptr); 65} 66 67void |
|
62Switch::addInPort(const vector<MessageBuffer*>& in) 63{ 64 m_perfect_switch_ptr->addInPort(in); 65} 66 67void 68Switch::addOutPort(const vector<MessageBuffer*>& out, 69 const NetDest& routing_table_entry, int link_latency, int bw_multiplier) 70{ | 68Switch::addInPort(const vector<MessageBuffer*>& in) 69{ 70 m_perfect_switch_ptr->addInPort(in); 71} 72 73void 74Switch::addOutPort(const vector<MessageBuffer*>& out, 75 const NetDest& routing_table_entry, int link_latency, int bw_multiplier) 76{ |
71 Throttle* throttle_ptr = NULL; 72 SimpleNetwork* net_ptr = 73 safe_cast<SimpleNetwork*>(RubySystem::getNetwork()); 74 | |
75 // Create a throttle | 77 // Create a throttle |
76 throttle_ptr = new Throttle(m_switch_id, m_throttles.size(), link_latency, 77 bw_multiplier, net_ptr->getEndpointBandwidth(), 78 net_ptr); | 78 Throttle* throttle_ptr = new Throttle(m_id, m_throttles.size(), 79 link_latency, bw_multiplier, m_network_ptr->getEndpointBandwidth(), 80 this); |
79 m_throttles.push_back(throttle_ptr); 80 81 // Create one buffer per vnet (these are intermediaryQueues) 82 vector<MessageBuffer*> intermediateBuffers; 83 for (int i = 0; i < out.size(); i++) { 84 MessageBuffer* buffer_ptr = new MessageBuffer; 85 // Make these queues ordered 86 buffer_ptr->setOrdering(true); | 81 m_throttles.push_back(throttle_ptr); 82 83 // Create one buffer per vnet (these are intermediaryQueues) 84 vector<MessageBuffer*> intermediateBuffers; 85 for (int i = 0; i < out.size(); i++) { 86 MessageBuffer* buffer_ptr = new MessageBuffer; 87 // Make these queues ordered 88 buffer_ptr->setOrdering(true); |
87 if (net_ptr->getBufferSize() > 0) { 88 buffer_ptr->resize(net_ptr->getBufferSize()); | 89 if (m_network_ptr->getBufferSize() > 0) { 90 buffer_ptr->resize(m_network_ptr->getBufferSize()); |
89 } 90 intermediateBuffers.push_back(buffer_ptr); 91 m_buffers_to_free.push_back(buffer_ptr); | 91 } 92 intermediateBuffers.push_back(buffer_ptr); 93 m_buffers_to_free.push_back(buffer_ptr); |
92 } | 94 } |
93 94 // Hook the queues to the PerfectSwitch 95 m_perfect_switch_ptr->addOutPort(intermediateBuffers, routing_table_entry); 96 97 // Hook the queues to the Throttle 98 throttle_ptr->addLinks(intermediateBuffers, out); 99} 100 --- 31 unchanged lines hidden (view full) --- 132Switch::getThrottles() const 133{ 134 return &m_throttles; 135} 136 137void 138Switch::printStats(std::ostream& out) const 139{ | 95 96 // Hook the queues to the PerfectSwitch 97 m_perfect_switch_ptr->addOutPort(intermediateBuffers, routing_table_entry); 98 99 // Hook the queues to the Throttle 100 throttle_ptr->addLinks(intermediateBuffers, out); 101} 102 --- 31 unchanged lines hidden (view full) --- 134Switch::getThrottles() const 135{ 136 return &m_throttles; 137} 138 139void 140Switch::printStats(std::ostream& out) const 141{ |
140 ccprintf(out, "switch_%d_inlinks: %d\n", m_switch_id, | 142 ccprintf(out, "switch_%d_inlinks: %d\n", m_id, |
141 m_perfect_switch_ptr->getInLinks()); | 143 m_perfect_switch_ptr->getInLinks()); |
142 ccprintf(out, "switch_%d_outlinks: %d\n", m_switch_id, | 144 ccprintf(out, "switch_%d_outlinks: %d\n", m_id, |
143 m_perfect_switch_ptr->getOutLinks()); 144 145 // Average link utilizations 146 double average_utilization = 0.0; 147 int throttle_count = 0; 148 149 for (int i = 0; i < m_throttles.size(); i++) { 150 Throttle* throttle_ptr = m_throttles[i]; 151 if (throttle_ptr) { 152 average_utilization += throttle_ptr->getUtilization(); 153 throttle_count++; 154 } 155 } 156 average_utilization = 157 throttle_count == 0 ? 0 : average_utilization / throttle_count; 158 159 // Individual link utilizations | 145 m_perfect_switch_ptr->getOutLinks()); 146 147 // Average link utilizations 148 double average_utilization = 0.0; 149 int throttle_count = 0; 150 151 for (int i = 0; i < m_throttles.size(); i++) { 152 Throttle* throttle_ptr = m_throttles[i]; 153 if (throttle_ptr) { 154 average_utilization += throttle_ptr->getUtilization(); 155 throttle_count++; 156 } 157 } 158 average_utilization = 159 throttle_count == 0 ? 0 : average_utilization / throttle_count; 160 161 // Individual link utilizations |
160 out << "links_utilized_percent_switch_" << m_switch_id << ": " | 162 out << "links_utilized_percent_switch_" << m_id << ": " |
161 << average_utilization << endl; 162 163 for (int link = 0; link < m_throttles.size(); link++) { 164 Throttle* throttle_ptr = m_throttles[link]; 165 if (throttle_ptr != NULL) { | 163 << average_utilization << endl; 164 165 for (int link = 0; link < m_throttles.size(); link++) { 166 Throttle* throttle_ptr = m_throttles[link]; 167 if (throttle_ptr != NULL) { |
166 out << " links_utilized_percent_switch_" << m_switch_id | 168 out << " links_utilized_percent_switch_" << m_id |
167 << "_link_" << link << ": " 168 << throttle_ptr->getUtilization() << " bw: " 169 << throttle_ptr->getLinkBandwidth() 170 << " base_latency: " << throttle_ptr->getLatency() << endl; 171 } 172 } 173 out << endl; 174 --- 7 unchanged lines hidden (view full) --- 182 throttle_ptr->getCounters(); 183 for (int int_type = 0; int_type < MessageSizeType_NUM; int_type++) { 184 MessageSizeType type = MessageSizeType(int_type); 185 const vector<int> &mct = message_counts[type]; 186 int sum = accumulate(mct.begin(), mct.end(), 0); 187 if (sum == 0) 188 continue; 189 | 169 << "_link_" << link << ": " 170 << throttle_ptr->getUtilization() << " bw: " 171 << throttle_ptr->getLinkBandwidth() 172 << " base_latency: " << throttle_ptr->getLatency() << endl; 173 } 174 } 175 out << endl; 176 --- 7 unchanged lines hidden (view full) --- 184 throttle_ptr->getCounters(); 185 for (int int_type = 0; int_type < MessageSizeType_NUM; int_type++) { 186 MessageSizeType type = MessageSizeType(int_type); 187 const vector<int> &mct = message_counts[type]; 188 int sum = accumulate(mct.begin(), mct.end(), 0); 189 if (sum == 0) 190 continue; 191 |
190 out << " outgoing_messages_switch_" << m_switch_id | 192 out << " outgoing_messages_switch_" << m_id |
191 << "_link_" << link << "_" << type << ": " << sum << " " | 193 << "_link_" << link << "_" << type << ": " << sum << " " |
192 << sum * RubySystem::getNetwork()->MessageSizeType_to_int(type) | 194 << sum * m_network_ptr->MessageSizeType_to_int(type) |
193 << " "; 194 out << mct; 195 out << " base_latency: " 196 << throttle_ptr->getLatency() << endl; 197 } 198 } 199 out << endl; 200} --- 9 unchanged lines hidden (view full) --- 210} 211 212void 213Switch::print(std::ostream& out) const 214{ 215 // FIXME printing 216 out << "[Switch]"; 217} | 195 << " "; 196 out << mct; 197 out << " base_latency: " 198 << throttle_ptr->getLatency() << endl; 199 } 200 } 201 out << endl; 202} --- 9 unchanged lines hidden (view full) --- 212} 213 214void 215Switch::print(std::ostream& out) const 216{ 217 // FIXME printing 218 out << "[Switch]"; 219} |
220 221Switch * 222SwitchParams::create() 223{ 224 return new Switch(this); 225} |
|