Throttle.cc (6891:77451885bb00) Throttle.cc (7024:30883414ad10)
1
2/*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

--- 59 unchanged lines hidden (view full) ---

68{
69 m_node = node;
70 m_vnets = 0;
71
72 ASSERT(link_bandwidth_multiplier > 0);
73 m_link_bandwidth_multiplier = link_bandwidth_multiplier;
74 m_link_latency = link_latency;
75
1
2/*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

--- 59 unchanged lines hidden (view full) ---

68{
69 m_node = node;
70 m_vnets = 0;
71
72 ASSERT(link_bandwidth_multiplier > 0);
73 m_link_bandwidth_multiplier = link_bandwidth_multiplier;
74 m_link_latency = link_latency;
75
76 m_bash_counter = HIGH_RANGE;
77 m_bandwidth_since_sample = 0;
78 m_last_bandwidth_sample = 0;
79 m_wakeups_wo_switch = 0;
80 clearStats();
81}
82
83void Throttle::clear()
84{
85 for (int counter = 0; counter < m_vnets; counter++) {
86 m_in[counter]->clear();

--- 99 unchanged lines hidden (view full) ---

186 // We should only wake up when we use the bandwidth
187 // assert(bw_remaining != getLinkBandwidth()); // This is only mostly true
188
189 // Record that we used some or all of the link bandwidth this cycle
190 double ratio = 1.0-(double(bw_remaining)/double(getLinkBandwidth()));
191 // If ratio = 0, we used no bandwidth, if ratio = 1, we used all
192 linkUtilized(ratio);
193
76 m_wakeups_wo_switch = 0;
77 clearStats();
78}
79
80void Throttle::clear()
81{
82 for (int counter = 0; counter < m_vnets; counter++) {
83 m_in[counter]->clear();

--- 99 unchanged lines hidden (view full) ---

183 // We should only wake up when we use the bandwidth
184 // assert(bw_remaining != getLinkBandwidth()); // This is only mostly true
185
186 // Record that we used some or all of the link bandwidth this cycle
187 double ratio = 1.0-(double(bw_remaining)/double(getLinkBandwidth()));
188 // If ratio = 0, we used no bandwidth, if ratio = 1, we used all
189 linkUtilized(ratio);
190
194 // Sample the link bandwidth utilization over a number of cycles
195 int bw_used = getLinkBandwidth()-bw_remaining;
196 m_bandwidth_since_sample += bw_used;
197
198 // FIXME - comment out the bash specific code for faster performance
199 // Start Bash code
200 // Update the predictor
201 Time current_time = g_eventQueue_ptr->getTime();
202 while ((current_time - m_last_bandwidth_sample) > ADJUST_INTERVAL) {
203 // Used less bandwidth
204 m_bash_counter--;
205
206 // Make sure we don't overflow
207 m_bash_counter = min(HIGH_RANGE, m_bash_counter);
208 m_bash_counter = max(0, m_bash_counter);
209
210 // Reset samples
211 m_last_bandwidth_sample += ADJUST_INTERVAL;
212 m_bandwidth_since_sample = 0;
213 }
214 // End Bash code
215
216 if ((bw_remaining > 0) && !schedule_wakeup) {
217 // We have extra bandwidth and our output buffer was available, so we must not have anything else to do until another message arrives.
218 DEBUG_MSG(NETWORK_COMP,LowPrio,*this);
219 DEBUG_MSG(NETWORK_COMP,LowPrio,"not scheduled again");
220 } else {
221 DEBUG_MSG(NETWORK_COMP,LowPrio,*this);
222 DEBUG_MSG(NETWORK_COMP,LowPrio,"scheduled again");
223 // We are out of bandwidth for this cycle, so wakeup next cycle and continue
224 g_eventQueue_ptr->scheduleEvent(this, 1);
225 }
226}
227
191 if ((bw_remaining > 0) && !schedule_wakeup) {
192 // We have extra bandwidth and our output buffer was available, so we must not have anything else to do until another message arrives.
193 DEBUG_MSG(NETWORK_COMP,LowPrio,*this);
194 DEBUG_MSG(NETWORK_COMP,LowPrio,"not scheduled again");
195 } else {
196 DEBUG_MSG(NETWORK_COMP,LowPrio,*this);
197 DEBUG_MSG(NETWORK_COMP,LowPrio,"scheduled again");
198 // We are out of bandwidth for this cycle, so wakeup next cycle and continue
199 g_eventQueue_ptr->scheduleEvent(this, 1);
200 }
201}
202
228bool Throttle::broadcastBandwidthAvailable(int rand) const
229{
230 bool result = !(m_bash_counter > ((HIGH_RANGE/4) + (rand % (HIGH_RANGE/2))));
231 return result;
232}
233
234void Throttle::printStats(ostream& out) const
235{
236 out << "utilized_percent: " << getUtilization() << endl;
237}
238
239void Throttle::clearStats()
240{
241 m_ruby_start = g_eventQueue_ptr->getTime();

--- 39 unchanged lines hidden ---
203void Throttle::printStats(ostream& out) const
204{
205 out << "utilized_percent: " << getUtilization() << endl;
206}
207
208void Throttle::clearStats()
209{
210 m_ruby_start = g_eventQueue_ptr->getTime();

--- 39 unchanged lines hidden ---