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 9 * notice, this list of conditions and the following disclaimer; 10 * redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution; 13 * neither the name of the copyright holders nor the names of its 14 * contributors may be used to endorse or promote products derived from 15 * this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30/*
| 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; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/*
|
31 * $Id$ 32 * 33 * Description: The class to implement bandwidth and latency throttle. An 34 * instance of consumer class that can be woke up. It is only used 35 * to control bandwidth at output port of a switch. And the 36 * throttle is added *after* the output port, means the message is 37 * put in the output port of the PerfectSwitch (a 38 * intermediateBuffers) first, then go through the Throttle. 39 *
| 30 * The class to implement bandwidth and latency throttle. An instance 31 * of consumer class that can be woke up. It is only used to control 32 * bandwidth at output port of a switch. And the throttle is added 33 * *after* the output port, means the message is put in the output 34 * port of the PerfectSwitch (a intermediateBuffers) first, then go 35 * through the Throttle.
|
40 */ 41
| 36 */ 37
|
42#ifndef THROTTLE_H 43#define THROTTLE_H
| 38#ifndef __MEM_RUBY_NETWORK_SIMPLE_THROTTLE_HH__ 39#define __MEM_RUBY_NETWORK_SIMPLE_THROTTLE_HH__
|
44
| 40
|
45#include "mem/ruby/common/Global.hh"
| |
46#include "mem/gems_common/Vector.hh" 47#include "mem/ruby/common/Consumer.hh"
| 41#include "mem/gems_common/Vector.hh" 42#include "mem/ruby/common/Consumer.hh"
|
| 43#include "mem/ruby/common/Global.hh" 44#include "mem/ruby/network/Network.hh"
|
48#include "mem/ruby/system/NodeID.hh" 49#include "mem/ruby/system/System.hh"
| 45#include "mem/ruby/system/NodeID.hh" 46#include "mem/ruby/system/System.hh"
|
50#include "mem/ruby/network/Network.hh"
| |
51 52class MessageBuffer; 53
| 47 48class MessageBuffer; 49
|
54class Throttle : public Consumer { 55public: 56 // Constructors 57 Throttle(int sID, NodeID node, int link_latency, int link_bandwidth_multiplier); 58 Throttle(NodeID node, int link_latency, int link_bandwidth_multiplier);
| 50class Throttle : public Consumer 51{ 52 public: 53 Throttle(int sID, NodeID node, int link_latency, 54 int link_bandwidth_multiplier); 55 Throttle(NodeID node, int link_latency, int link_bandwidth_multiplier); 56 ~Throttle() {}
|
59
| 57
|
60 // Destructor 61 ~Throttle() {}
| 58 void addLinks(const Vector<MessageBuffer*>& in_vec, 59 const Vector<MessageBuffer*>& out_vec); 60 void wakeup();
|
62
| 61
|
63 // Public Methods 64 void addLinks(const Vector<MessageBuffer*>& in_vec, const Vector<MessageBuffer*>& out_vec); 65 void wakeup();
| 62 void printStats(ostream& out) const; 63 void clearStats(); 64 void printConfig(ostream& out) const; 65 // The average utilization (a percent) since last clearStats() 66 double getUtilization() const; 67 int 68 getLinkBandwidth() const 69 { 70 return RubySystem::getNetwork()->getEndpointBandwidth() * 71 m_link_bandwidth_multiplier; 72 } 73 int getLatency() const { return m_link_latency; }
|
66
| 74
|
67 void printStats(ostream& out) const; 68 void clearStats(); 69 void printConfig(ostream& out) const; 70 double getUtilization() const; // The average utilization (a percent) since last clearStats() 71 int getLinkBandwidth() const { return RubySystem::getNetwork()->getEndpointBandwidth() * m_link_bandwidth_multiplier; } 72 int getLatency() const { return m_link_latency; }
| 75 const Vector<Vector<int> >& 76 getCounters() const 77 { 78 return m_message_counters; 79 }
|
73
| 80
|
74 const Vector<Vector<int> >& getCounters() const { return m_message_counters; }
| 81 void clear();
|
75
| 82
|
76 void clear();
| 83 void print(ostream& out) const;
|
77
| 84
|
78 void print(ostream& out) const;
| 85 private: 86 void init(NodeID node, int link_latency, int link_bandwidth_multiplier); 87 void addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr); 88 void linkUtilized(double ratio) { m_links_utilized += ratio; }
|
79
| 89
|
80private: 81 // Private Methods 82 void init(NodeID node, int link_latency, int link_bandwidth_multiplier); 83 void addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr); 84 void linkUtilized(double ratio) { m_links_utilized += ratio; }
| 90 // Private copy constructor and assignment operator 91 Throttle(const Throttle& obj); 92 Throttle& operator=(const Throttle& obj);
|
85
| 93
|
86 // Private copy constructor and assignment operator 87 Throttle(const Throttle& obj); 88 Throttle& operator=(const Throttle& obj);
| 94 Vector<MessageBuffer*> m_in; 95 Vector<MessageBuffer*> m_out; 96 Vector<Vector<int> > m_message_counters; 97 int m_vnets; 98 Vector<int> m_units_remaining; 99 int m_sID; 100 NodeID m_node; 101 int m_link_bandwidth_multiplier; 102 int m_link_latency; 103 int m_wakeups_wo_switch;
|
89
| 104
|
90 // Data Members (m_ prefix) 91 Vector<MessageBuffer*> m_in; 92 Vector<MessageBuffer*> m_out; 93 Vector<Vector<int> > m_message_counters; 94 int m_vnets; 95 Vector<int> m_units_remaining; 96 int m_sID; 97 NodeID m_node; 98 int m_link_bandwidth_multiplier; 99 int m_link_latency; 100 int m_wakeups_wo_switch; 101 102 // For tracking utilization 103 Time m_ruby_start; 104 double m_links_utilized;
| 105 // For tracking utilization 106 Time m_ruby_start; 107 double m_links_utilized;
|
105}; 106
| 108}; 109
|
107// Output operator declaration 108ostream& operator<<(ostream& out, const Throttle& obj); 109 110// ******************* Definitions ******************* 111 112// Output operator definition 113extern inline 114ostream& operator<<(ostream& out, const Throttle& obj)
| 110inline ostream& 111operator<<(ostream& out, const Throttle& obj)
|
115{
| 112{
|
116 obj.print(out); 117 out << flush; 118 return out;
| 113 obj.print(out); 114 out << flush; 115 return out;
|
119} 120
| 116} 117
|
121#endif //THROTTLE_H
| 118#endif // __MEM_RUBY_NETWORK_SIMPLE_THROTTLE_HH__
|
| |