gem5  v22.1.0.0
Throttle.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 /*
42  * The class to implement bandwidth and latency throttle. An instance
43  * of consumer class that can be woke up. It is only used to control
44  * bandwidth at output port of a switch. And the throttle is added
45  * *after* the output port, means the message is put in the output
46  * port of the PerfectSwitch (a intermediateBuffers) first, then go
47  * through the Throttle.
48  */
49 
50 #ifndef __MEM_RUBY_NETWORK_SIMPLE_THROTTLE_HH__
51 #define __MEM_RUBY_NETWORK_SIMPLE_THROTTLE_HH__
52 
53 #include <iostream>
54 #include <string>
55 #include <vector>
56 
60 
61 namespace gem5
62 {
63 
64 namespace ruby
65 {
66 
67 class MessageBuffer;
68 class Switch;
69 
70 class Throttle : public Consumer
71 {
72  private:
73  Throttle(int sID, RubySystem *rs, NodeID node, Cycles link_latency,
74  int endpoint_bandwidth, Switch *em);
75  public:
76  Throttle(int sID, RubySystem *rs, NodeID node, Cycles link_latency,
77  int link_bandwidth_multiplier, int endpoint_bandwidth,
78  Switch *em);
79  Throttle(int sID, RubySystem *rs, NodeID node, Cycles link_latency,
80  const std::vector<int> &vnet_channels,
81  const std::vector<int> &vnet_bandwidth_multiplier,
82  int endpoint_bandwidth, Switch *em);
83  ~Throttle() {}
84 
85  std::string name()
86  { return csprintf("Throttle-%i", m_switch_id); }
87 
88  void addLinks(const std::vector<MessageBuffer*>& in_vec,
89  const std::vector<MessageBuffer*>& out_vec);
90  void wakeup();
91 
92  // The average utilization (a fraction) since last clearStats()
95  const statistics::Vector & getMsgCount(unsigned int type) const
96  { return *(throttleStats.msg_counts[type]); }
97 
98  int getLinkBandwidth(int vnet) const;
99 
100  int getTotalLinkBandwidth() const;
101 
102  int getChannelCnt(int vnet) const;
103 
104  Cycles getLatency() const { return m_link_latency; }
105 
106  void print(std::ostream& out) const;
107 
108  private:
109  void init(NodeID node, Cycles link_latency, int link_bandwidth_multiplier,
110  int endpoint_bandwidth);
111  void operateVnet(int vnet, int channel, int &total_bw_remaining,
112  bool &bw_saturated, bool &output_blocked,
113  MessageBuffer *in, MessageBuffer *out);
114 
115  // Private copy constructor and assignment operator
116  Throttle(const Throttle& obj);
118 
121  unsigned int m_vnets;
123 
124  const int m_switch_id;
127 
135 
137  {
138  ThrottleStats(Switch *parent, const NodeID &nodeID);
139 
140  // Statistical variables
143  statistics::Vector* msg_counts[MessageSizeType_NUM];
144  statistics::Formula* msg_bytes[MessageSizeType_NUM];
145 
156 };
157 
158 inline std::ostream&
159 operator<<(std::ostream& out, const Throttle& obj)
160 {
161  obj.print(out);
162  out << std::flush;
163  return out;
164 }
165 
166 } // namespace ruby
167 } // namespace gem5
168 
169 #endif // __MEM_RUBY_NETWORK_SIMPLE_THROTTLE_HH__
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
ClockedObject * em
Definition: Consumer.hh:93
std::vector< int > m_vnet_channels
Definition: Throttle.hh:130
std::vector< MessageBuffer * > m_in
Definition: Throttle.hh:119
unsigned int m_vnets
Definition: Throttle.hh:121
Throttle(const Throttle &obj)
void operateVnet(int vnet, int channel, int &total_bw_remaining, bool &bw_saturated, bool &output_blocked, MessageBuffer *in, MessageBuffer *out)
Definition: Throttle.cc:165
std::vector< std::vector< int > > m_units_remaining
Definition: Throttle.hh:122
void print(std::ostream &out) const
Definition: Throttle.cc:304
const int m_switch_id
Definition: Throttle.hh:124
int getTotalLinkBandwidth() const
Definition: Throttle.cc:148
Throttle & operator=(const Throttle &obj)
Cycles getLatency() const
Definition: Throttle.hh:104
RubySystem * m_ruby_system
Definition: Throttle.hh:134
gem5::ruby::Throttle::ThrottleStats throttleStats
const statistics::Vector & getMsgCount(unsigned int type) const
Definition: Throttle.hh:95
std::string name()
Definition: Throttle.hh:85
Throttle(int sID, RubySystem *rs, NodeID node, Cycles link_latency, int endpoint_bandwidth, Switch *em)
Definition: Throttle.cc:68
std::vector< MessageBuffer * > m_out
Definition: Throttle.hh:120
int getLinkBandwidth(int vnet) const
Definition: Throttle.cc:138
void addLinks(const std::vector< MessageBuffer * > &in_vec, const std::vector< MessageBuffer * > &out_vec)
Definition: Throttle.cc:111
const statistics::Formula & getUtilization() const
Definition: Throttle.hh:93
std::vector< int > m_link_bandwidth_multiplier
Definition: Throttle.hh:129
void init(NodeID node, Cycles link_latency, int link_bandwidth_multiplier, int endpoint_bandwidth)
int getChannelCnt(int vnet) const
Definition: Throttle.cc:159
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2540
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
A vector of scalar stats.
Definition: statistics.hh:2007
Bitfield< 9, 8 > rs
Definition: misc_types.hh:383
unsigned int NodeID
Definition: TypeDefines.hh:42
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition: BoolVec.cc:49
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:161
statistics::Scalar total_msg_bytes
Definition: Throttle.hh:147
statistics::Formula avg_msg_wait_time
Definition: Throttle.hh:152
statistics::Formula link_utilization
Definition: Throttle.hh:142
statistics::Formula * msg_bytes[MessageSizeType_NUM]
Definition: Throttle.hh:144
statistics::Scalar total_msg_wait_time
Definition: Throttle.hh:149
statistics::Scalar total_data_msg_bytes
Definition: Throttle.hh:148
statistics::Scalar acc_link_utilization
Definition: Throttle.hh:141
ThrottleStats(Switch *parent, const NodeID &nodeID)
Definition: Throttle.cc:332
statistics::Formula avg_useful_bandwidth
Definition: Throttle.hh:154
statistics::Scalar total_msg_count
Definition: Throttle.hh:146
statistics::Formula avg_bandwidth
Definition: Throttle.hh:153
statistics::Vector * msg_counts[MessageSizeType_NUM]
Definition: Throttle.hh:143
statistics::Scalar total_stall_cy
Definition: Throttle.hh:150
statistics::Scalar total_bw_sat_cy
Definition: Throttle.hh:151

Generated on Wed Dec 21 2022 10:22:38 for gem5 by doxygen 1.9.1