Deleted Added
sdiff udiff text old ( 9499:b03b556a8fbb ) new ( 9508:dde110931867 )
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;

--- 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& 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);
118
119 // Set consumer and description
120 m_in[m_vnets]->setConsumer(this);
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],
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

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

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