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; --- 65 unchanged lines hidden (view full) --- 74 m_vnets = 0; 75 76 assert(link_bandwidth_multiplier > 0); 77 m_link_bandwidth_multiplier = link_bandwidth_multiplier; 78 m_link_latency = link_latency; 79 m_endpoint_bandwidth = endpoint_bandwidth; 80 81 m_wakeups_wo_switch = 0; |
82 |
83 m_msg_counts.resize(MessageSizeType_NUM); 84 m_msg_bytes.resize(MessageSizeType_NUM); 85 86 m_link_utilization_proxy = 0; |
87} 88 89void 90Throttle::addLinks(const std::vector<MessageBuffer*>& in_vec, 91 const std::vector<MessageBuffer*>& out_vec) 92{ 93 assert(in_vec.size() == out_vec.size()); 94 for (int i=0; i<in_vec.size(); i++) { 95 addVirtualNetwork(in_vec[i], out_vec[i]); 96 } |
97} 98 99void 100Throttle::addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr) 101{ 102 m_units_remaining.push_back(0); 103 m_in.push_back(in_ptr); 104 m_out.push_back(out_ptr); --- 56 unchanged lines hidden (view full) --- 161 m_node, getLinkBandwidth(), m_units_remaining[vnet], 162 g_system_ptr->curCycle()); 163 164 // Move the message 165 m_out[vnet]->enqueue(m_in[vnet]->peekMsgPtr(), m_link_latency); 166 m_in[vnet]->pop(); 167 168 // Count the message |
169 m_msg_counts[net_msg_ptr->getMessageSize()][vnet]++; |
170 171 DPRINTF(RubyNetwork, "%s\n", *m_out[vnet]); 172 } 173 174 // Calculate the amount of bandwidth we spent on this message 175 int diff = m_units_remaining[vnet] - bw_remaining; 176 m_units_remaining[vnet] = max(0, diff); 177 bw_remaining = max(0, -diff); --- 12 unchanged lines hidden (view full) --- 190 // We should only wake up when we use the bandwidth 191 // This is only mostly true 192 // assert(bw_remaining != getLinkBandwidth()); 193 194 // Record that we used some or all of the link bandwidth this cycle 195 double ratio = 1.0 - (double(bw_remaining) / double(getLinkBandwidth())); 196 197 // If ratio = 0, we used no bandwidth, if ratio = 1, we used all |
198 m_link_utilization_proxy += ratio; |
199 200 if (bw_remaining > 0 && !schedule_wakeup) { 201 // We have extra bandwidth and our output buffer was 202 // available, so we must not have anything else to do until 203 // another message arrives. 204 DPRINTF(RubyNetwork, "%s not scheduled again\n", *this); 205 } else { 206 DPRINTF(RubyNetwork, "%s scheduled again\n", *this); 207 208 // We are out of bandwidth for this cycle, so wakeup next 209 // cycle and continue 210 scheduleEvent(Cycles(1)); 211 } 212} 213 214void |
215Throttle::regStats(string parent) |
216{ |
217 m_link_utilization 218 .name(parent + csprintf(".throttle%i", m_node) + ".link_utilization"); 219 220 for (MessageSizeType type = MessageSizeType_FIRST; 221 type < MessageSizeType_NUM; ++type) { 222 m_msg_counts[(unsigned int)type] 223 .init(m_vnets) 224 .name(parent + csprintf(".throttle%i", m_node) + ".msg_count." + 225 MessageSizeType_to_string(type)) 226 .flags(Stats::nozero) 227 ; 228 m_msg_bytes[(unsigned int) type] 229 .name(parent + csprintf(".throttle%i", m_node) + ".msg_bytes." + 230 MessageSizeType_to_string(type)) 231 .flags(Stats::nozero) 232 ; 233 234 m_msg_bytes[(unsigned int) type] = m_msg_counts[type] * Stats::constant( 235 Network::MessageSizeType_to_int(type)); 236 } |
237} 238 239void 240Throttle::clearStats() 241{ |
242 m_link_utilization_proxy = 0; |
243} 244 |
245void 246Throttle::collateStats() |
247{ |
248 m_link_utilization = 100.0 * m_link_utilization_proxy 249 / (double(g_system_ptr->curCycle() - g_ruby_start)); |
250} 251 252void 253Throttle::print(ostream& out) const 254{ 255 ccprintf(out, "[%i bw: %i]", m_node, getLinkBandwidth()); 256} 257 --- 14 unchanged lines hidden --- |