Deleted Added
sdiff udiff text old ( 9508:dde110931867 ) new ( 9863:9483739f83ee )
full compact
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 clearStats();
83}
84
85void
86Throttle::clear()
87{
88 for (int counter = 0; counter < m_vnets; counter++) {
89 m_in[counter]->clear();
90 m_out[counter]->clear();
91 }
92}
93
94void
95Throttle::addLinks(const std::vector<MessageBuffer*>& in_vec,
96 const std::vector<MessageBuffer*>& out_vec)
97{
98 assert(in_vec.size() == out_vec.size());
99 for (int i=0; i<in_vec.size(); i++) {
100 addVirtualNetwork(in_vec[i], out_vec[i]);
101 }
102
103 m_message_counters.resize(MessageSizeType_NUM);
104 for (int i = 0; i < MessageSizeType_NUM; i++) {
105 m_message_counters[i].resize(in_vec.size());
106 for (int j = 0; j<m_message_counters[i].size(); j++) {
107 m_message_counters[i][j] = 0;
108 }
109 }
110}
111
112void
113Throttle::addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr)
114{
115 m_units_remaining.push_back(0);
116 m_in.push_back(in_ptr);
117 m_out.push_back(out_ptr);

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

174 m_node, getLinkBandwidth(), m_units_remaining[vnet],
175 g_system_ptr->curCycle());
176
177 // Move the message
178 m_out[vnet]->enqueue(m_in[vnet]->peekMsgPtr(), m_link_latency);
179 m_in[vnet]->pop();
180
181 // Count the message
182 m_message_counters[net_msg_ptr->getMessageSize()][vnet]++;
183
184 DPRINTF(RubyNetwork, "%s\n", *m_out[vnet]);
185 }
186
187 // Calculate the amount of bandwidth we spent on this message
188 int diff = m_units_remaining[vnet] - bw_remaining;
189 m_units_remaining[vnet] = max(0, diff);
190 bw_remaining = max(0, -diff);

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

203 // We should only wake up when we use the bandwidth
204 // This is only mostly true
205 // assert(bw_remaining != getLinkBandwidth());
206
207 // Record that we used some or all of the link bandwidth this cycle
208 double ratio = 1.0 - (double(bw_remaining) / double(getLinkBandwidth()));
209
210 // If ratio = 0, we used no bandwidth, if ratio = 1, we used all
211 linkUtilized(ratio);
212
213 if (bw_remaining > 0 && !schedule_wakeup) {
214 // We have extra bandwidth and our output buffer was
215 // available, so we must not have anything else to do until
216 // another message arrives.
217 DPRINTF(RubyNetwork, "%s not scheduled again\n", *this);
218 } else {
219 DPRINTF(RubyNetwork, "%s scheduled again\n", *this);
220
221 // We are out of bandwidth for this cycle, so wakeup next
222 // cycle and continue
223 scheduleEvent(Cycles(1));
224 }
225}
226
227void
228Throttle::printStats(ostream& out) const
229{
230 out << "utilized_percent: " << getUtilization() << endl;
231}
232
233void
234Throttle::clearStats()
235{
236 m_ruby_start = g_system_ptr->curCycle();
237 m_links_utilized = 0.0;
238
239 for (int i = 0; i < m_message_counters.size(); i++) {
240 for (int j = 0; j < m_message_counters[i].size(); j++) {
241 m_message_counters[i][j] = 0;
242 }
243 }
244}
245
246double
247Throttle::getUtilization() const
248{
249 return 100.0 * double(m_links_utilized) /
250 double(g_system_ptr->curCycle()-m_ruby_start);
251}
252
253void
254Throttle::print(ostream& out) const
255{
256 ccprintf(out, "[%i bw: %i]", m_node, getLinkBandwidth());
257}
258

--- 14 unchanged lines hidden ---