Throttle.cc (9499:b03b556a8fbb) Throttle.cc (9508:dde110931867)
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;

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

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,
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;

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

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, ClockedObject *em)
96 const std::vector& out_vec)
97{
98 assert(in_vec.size() == out_vec.size());
99 for (int i=0; i<in_vec.size(); i++) {
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], em);
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
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 ClockedObject *em)
113Throttle::addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr)
115{
116 m_units_remaining.push_back(0);
117 m_in.push_back(in_ptr);
118 m_out.push_back(out_ptr);
119
120 // Set consumer and description
121 m_in[m_vnets]->setConsumer(this);
114{
115 m_units_remaining.push_back(0);
116 m_in.push_back(in_ptr);
117 m_out.push_back(out_ptr);
118
119 // Set consumer and description
120 m_in[m_vnets]->setConsumer(this);
122 m_in[m_vnets]->setClockObj(em);
123
124 string desc = "[Queue to Throttle " + to_string(m_sID) + " " +
125 to_string(m_node) + "]";
126 m_in[m_vnets]->setDescription(desc);
127 m_vnets++;
128}
129
130void

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

169 NetworkMessage* net_msg_ptr =
170 safe_cast<NetworkMessage*>(msg_ptr.get());
171 m_units_remaining[vnet] +=
172 network_message_to_size(net_msg_ptr);
173
174 DPRINTF(RubyNetwork, "throttle: %d my bw %d bw spent "
175 "enqueueing net msg %d time: %lld.\n",
176 m_node, getLinkBandwidth(), m_units_remaining[vnet],
121
122 string desc = "[Queue to Throttle " + to_string(m_sID) + " " +
123 to_string(m_node) + "]";
124 m_in[m_vnets]->setDescription(desc);
125 m_vnets++;
126}
127
128void

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

167 NetworkMessage* net_msg_ptr =
168 safe_cast<NetworkMessage*>(msg_ptr.get());
169 m_units_remaining[vnet] +=
170 network_message_to_size(net_msg_ptr);
171
172 DPRINTF(RubyNetwork, "throttle: %d my bw %d bw spent "
173 "enqueueing net msg %d time: %lld.\n",
174 m_node, getLinkBandwidth(), m_units_remaining[vnet],
177 g_system_ptr->getTime());
175 g_system_ptr->curCycle());
178
179 // Move the message
180 m_out[vnet]->enqueue(m_in[vnet]->peekMsgPtr(), m_link_latency);
181 m_in[vnet]->pop();
182
183 // Count the message
184 m_message_counters[net_msg_ptr->getMessageSize()][vnet]++;
185

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

230Throttle::printStats(ostream& out) const
231{
232 out << "utilized_percent: " << getUtilization() << endl;
233}
234
235void
236Throttle::clearStats()
237{
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

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

228Throttle::printStats(ostream& out) const
229{
230 out << "utilized_percent: " << getUtilization() << endl;
231}
232
233void
234Throttle::clearStats()
235{
238 m_ruby_start = g_system_ptr->getTime();
236 m_ruby_start = g_system_ptr->curCycle();
239 m_links_utilized = 0.0;
240
241 for (int i = 0; i < m_message_counters.size(); i++) {
242 for (int j = 0; j < m_message_counters[i].size(); j++) {
243 m_message_counters[i][j] = 0;
244 }
245 }
246}
247
248double
249Throttle::getUtilization() const
250{
251 return 100.0 * double(m_links_utilized) /
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) /
252 double(g_system_ptr->getTime()-m_ruby_start);
250 double(g_system_ptr->curCycle()-m_ruby_start);
253}
254
255void
256Throttle::print(ostream& out) const
257{
258 ccprintf(out, "[%i bw: %i]", m_node, getLinkBandwidth());
259}
260

--- 14 unchanged lines hidden ---
251}
252
253void
254Throttle::print(ostream& out) const
255{
256 ccprintf(out, "[%i bw: %i]", m_node, getLinkBandwidth());
257}
258

--- 14 unchanged lines hidden ---