gem5  v22.1.0.0
NetDest.hh
Go to the documentation of this file.
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 #ifndef __MEM_RUBY_COMMON_NETDEST_HH__
30 #define __MEM_RUBY_COMMON_NETDEST_HH__
31 
32 #include <iostream>
33 #include <vector>
34 
35 #include "mem/ruby/common/Set.hh"
37 
38 namespace gem5
39 {
40 
41 namespace ruby
42 {
43 
44 // NetDest specifies the network destination of a Message
45 class NetDest
46 {
47  public:
48  // Constructors
49  // creates and empty set
50  NetDest();
51  explicit NetDest(int bit_size);
52 
53  NetDest& operator=(const Set& obj);
54 
56  { }
57 
58  void add(MachineID newElement);
59  void addNetDest(const NetDest& netDest);
60  void setNetDest(MachineType machine, const Set& set);
61  void remove(MachineID oldElement);
62  void removeNetDest(const NetDest& netDest);
63  void clear();
64  void broadcast();
65  void broadcast(MachineType machine);
66  int count() const;
67  bool isEqual(const NetDest& netDest) const;
68 
69  // return the logical OR of this netDest and orNetDest
70  NetDest OR(const NetDest& orNetDest) const;
71 
72  // return the logical AND of this netDest and andNetDest
73  NetDest AND(const NetDest& andNetDest) const;
74 
75  // Returns true if the intersection of the two netDests is non-empty
76  bool intersectionIsNotEmpty(const NetDest& other_netDest) const;
77 
78  // Returns true if the intersection of the two netDests is empty
79  bool intersectionIsEmpty(const NetDest& other_netDest) const;
80 
81  bool isSuperset(const NetDest& test) const;
82  bool isSubset(const NetDest& test) const { return test.isSuperset(*this); }
83  bool isElement(MachineID element) const;
84  bool isBroadcast() const;
85  bool isEmpty() const;
86 
87  // For Princeton Network
89 
90  MachineID smallestElement() const;
91  MachineID smallestElement(MachineType machine) const;
92 
93  void resize();
94  int getSize() const { return m_bits.size(); }
95 
96  // get element for a index
98 
99  void print(std::ostream& out) const;
100 
101  private:
102  // returns a value >= MachineType_base_level("this machine")
103  // and < MachineType_base_level("next highest machine")
104  int
106  {
107  int vec_index = MachineType_base_level(m.type);
108  assert(vec_index < m_bits.size());
109  return vec_index;
110  }
111 
112  NodeID bitIndex(NodeID index) const { return index; }
113 
114  std::vector<Set> m_bits; // a vector of bit vectors - i.e. Sets
115 };
116 
117 inline std::ostream&
118 operator<<(std::ostream& out, const NetDest& obj)
119 {
120  obj.print(out);
121  out << std::flush;
122  return out;
123 }
124 
125 } // namespace ruby
126 } // namespace gem5
127 
128 #endif // __MEM_RUBY_COMMON_NETDEST_HH__
void add(MachineID newElement)
Definition: NetDest.cc:45
void remove(MachineID oldElement)
Definition: NetDest.cc:70
std::vector< NodeID > getAllDest()
Definition: NetDest.cc:112
NetDest AND(const NetDest &andNetDest) const
Definition: NetDest.cc:210
NetDest OR(const NetDest &orNetDest) const
Definition: NetDest.cc:198
bool isElement(MachineID element) const
Definition: NetDest.cc:247
bool isEqual(const NetDest &netDest) const
Definition: NetDest.cc:278
std::vector< Set > m_bits
Definition: NetDest.hh:114
void removeNetDest(const NetDest &netDest)
Definition: NetDest.cc:76
NodeID elementAt(MachineID index)
Definition: NetDest.cc:138
bool isSubset(const NetDest &test) const
Definition: NetDest.hh:82
NetDest(int bit_size)
int count() const
Definition: NetDest.cc:128
bool isBroadcast() const
Definition: NetDest.cc:174
void addNetDest(const NetDest &netDest)
Definition: NetDest.cc:52
NetDest & operator=(const Set &obj)
void setNetDest(MachineType machine, const Set &set)
Definition: NetDest.cc:61
MachineID smallestElement() const
Definition: NetDest.cc:144
bool isEmpty() const
Definition: NetDest.cc:186
bool intersectionIsNotEmpty(const NetDest &other_netDest) const
Definition: NetDest.cc:222
bool intersectionIsEmpty(const NetDest &other_netDest) const
int vecIndex(MachineID m) const
Definition: NetDest.hh:105
int getSize() const
Definition: NetDest.hh:94
bool isSuperset(const NetDest &test) const
Definition: NetDest.cc:234
void print(std::ostream &out) const
Definition: NetDest.cc:264
NodeID bitIndex(NodeID index) const
Definition: NetDest.hh:112
STL vector class.
Definition: stl.hh:37
Bitfield< 12, 11 > set
Definition: misc_types.hh:709
Bitfield< 30, 0 > index
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....
Definition: test.h:38

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