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; --- 55 unchanged lines hidden (view full) --- 64 m_sID = 0; 65} 66 67void 68Throttle::init(NodeID node, Cycles link_latency, 69 int link_bandwidth_multiplier, int endpoint_bandwidth) 70{ 71 m_node = node; |
72 m_vnets = 0; 73 |
74 assert(link_bandwidth_multiplier > 0); 75 m_link_bandwidth_multiplier = link_bandwidth_multiplier; 76 77 m_link_latency = link_latency; 78 m_endpoint_bandwidth = endpoint_bandwidth; 79 80 m_wakeups_wo_switch = 0; 81 m_link_utilization_proxy = 0; 82} 83 84void |
85Throttle::addLinks(const vector<MessageBuffer*>& in_vec, 86 const vector<MessageBuffer*>& out_vec) |
87{ 88 assert(in_vec.size() == out_vec.size()); 89 |
90 for (int vnet = 0; vnet < in_vec.size(); ++vnet) { 91 MessageBuffer *in_ptr = in_vec[vnet]; 92 MessageBuffer *out_ptr = out_vec[vnet]; |
93 |
94 m_vnets++; 95 m_units_remaining.push_back(0); 96 m_in.push_back(in_ptr); 97 m_out.push_back(out_ptr); |
98 |
99 // Set consumer and description 100 in_ptr->setConsumer(this); 101 string desc = "[Queue to Throttle " + to_string(m_sID) + " " + 102 to_string(m_node) + "]"; 103 in_ptr->setDescription(desc); 104 } 105} 106 107void 108Throttle::operateVnet(int vnet, int &bw_remaining, bool &schedule_wakeup, 109 MessageBuffer *in, MessageBuffer *out) 110{ |
111 if (out == nullptr || in == nullptr) { 112 return; 113 } |
114 assert(m_units_remaining[vnet] >= 0); 115 116 while (bw_remaining > 0 && (in->isReady() || m_units_remaining[vnet] > 0) && 117 out->areNSlotsAvailable(1)) { 118 119 // See if we are done transferring the previous message on 120 // this virtual network 121 if (m_units_remaining[vnet] == 0 && in->isReady()) { --- 50 unchanged lines hidden (view full) --- 172 173 // invert priorities to avoid starvation seen in the component network 174 if (m_wakeups_wo_switch > PRIORITY_SWITCH_LIMIT) { 175 m_wakeups_wo_switch = 0; 176 iteration_direction = true; 177 } 178 179 if (iteration_direction) { |
180 for (int vnet = 0; vnet < m_vnets; ++vnet) { |
181 operateVnet(vnet, bw_remaining, schedule_wakeup, |
182 m_in[vnet], m_out[vnet]); |
183 } 184 } else { |
185 for (int vnet = m_vnets-1; vnet >= 0; --vnet) { |
186 operateVnet(vnet, bw_remaining, schedule_wakeup, |
187 m_in[vnet], m_out[vnet]); |
188 } 189 } 190 191 // We should only wake up when we use the bandwidth 192 // This is only mostly true 193 // assert(bw_remaining != getLinkBandwidth()); 194 195 // Record that we used some or all of the link bandwidth this cycle --- 77 unchanged lines hidden --- |