gem5  v20.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 // NetDest specifies the network destination of a Message
39 class NetDest
40 {
41  public:
42  // Constructors
43  // creates and empty set
44  NetDest();
45  explicit NetDest(int bit_size);
46 
47  NetDest& operator=(const Set& obj);
48 
50  { }
51 
52  void add(MachineID newElement);
53  void addNetDest(const NetDest& netDest);
54  void setNetDest(MachineType machine, const Set& set);
55  void remove(MachineID oldElement);
56  void removeNetDest(const NetDest& netDest);
57  void clear();
58  void broadcast();
59  void broadcast(MachineType machine);
60  int count() const;
61  bool isEqual(const NetDest& netDest) const;
62 
63  // return the logical OR of this netDest and orNetDest
64  NetDest OR(const NetDest& orNetDest) const;
65 
66  // return the logical AND of this netDest and andNetDest
67  NetDest AND(const NetDest& andNetDest) const;
68 
69  // Returns true if the intersection of the two netDests is non-empty
70  bool intersectionIsNotEmpty(const NetDest& other_netDest) const;
71 
72  // Returns true if the intersection of the two netDests is empty
73  bool intersectionIsEmpty(const NetDest& other_netDest) const;
74 
75  bool isSuperset(const NetDest& test) const;
76  bool isSubset(const NetDest& test) const { return test.isSuperset(*this); }
77  bool isElement(MachineID element) const;
78  bool isBroadcast() const;
79  bool isEmpty() const;
80 
81  // For Princeton Network
83 
84  MachineID smallestElement() const;
85  MachineID smallestElement(MachineType machine) const;
86 
87  void resize();
88  int getSize() const { return m_bits.size(); }
89 
90  // get element for a index
92 
93  void print(std::ostream& out) const;
94 
95  private:
96  // returns a value >= MachineType_base_level("this machine")
97  // and < MachineType_base_level("next highest machine")
98  int
100  {
101  int vec_index = MachineType_base_level(m.type);
102  assert(vec_index < m_bits.size());
103  return vec_index;
104  }
105 
106  NodeID bitIndex(NodeID index) const { return index; }
107 
108  std::vector<Set> m_bits; // a vector of bit vectors - i.e. Sets
109 };
110 
111 inline std::ostream&
112 operator<<(std::ostream& out, const NetDest& obj)
113 {
114  obj.print(out);
115  out << std::flush;
116  return out;
117 }
118 
119 #endif // __MEM_RUBY_COMMON_NETDEST_HH__
MachineID.hh
NetDest::add
void add(MachineID newElement)
Definition: NetDest.cc:39
Set
Definition: Set.hh:42
MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:44
NetDest::count
int count() const
Definition: NetDest.cc:122
test
Definition: test.h:38
NetDest::getSize
int getSize() const
Definition: NetDest.hh:88
NetDest::remove
void remove(MachineID oldElement)
Definition: NetDest.cc:64
NetDest::elementAt
NodeID elementAt(MachineID index)
Definition: NetDest.cc:132
NetDest::isSubset
bool isSubset(const NetDest &test) const
Definition: NetDest.hh:76
NetDest::intersectionIsEmpty
bool intersectionIsEmpty(const NetDest &other_netDest) const
std::vector
STL vector class.
Definition: stl.hh:37
MachineID
Definition: MachineID.hh:38
NetDest::isElement
bool isElement(MachineID element) const
Definition: NetDest.cc:241
NetDest::resize
void resize()
Definition: NetDest.cc:247
NetDest::print
void print(std::ostream &out) const
Definition: NetDest.cc:258
NetDest::NetDest
NetDest()
Definition: NetDest.cc:33
NetDest::operator=
NetDest & operator=(const Set &obj)
NetDest::setNetDest
void setNetDest(MachineType machine, const Set &set)
Definition: NetDest.cc:55
NetDest::m_bits
std::vector< Set > m_bits
Definition: NetDest.hh:108
Set.hh
NetDest::smallestElement
MachineID smallestElement() const
Definition: NetDest.cc:138
NetDest::~NetDest
~NetDest()
Definition: NetDest.hh:49
NetDest::OR
NetDest OR(const NetDest &orNetDest) const
Definition: NetDest.cc:192
NetDest::bitIndex
NodeID bitIndex(NodeID index) const
Definition: NetDest.hh:106
NetDest::clear
void clear()
Definition: NetDest.cc:79
NetDest::broadcast
void broadcast()
Definition: NetDest.cc:87
NetDest::isSuperset
bool isSuperset(const NetDest &test) const
Definition: NetDest.cc:228
operator<<
std::ostream & operator<<(std::ostream &out, const NetDest &obj)
Definition: NetDest.hh:112
NetDest::vecIndex
int vecIndex(MachineID m) const
Definition: NetDest.hh:99
NetDest::addNetDest
void addNetDest(const NetDest &netDest)
Definition: NetDest.cc:46
NodeID
unsigned int NodeID
Definition: TypeDefines.hh:34
NetDest::intersectionIsNotEmpty
bool intersectionIsNotEmpty(const NetDest &other_netDest) const
Definition: NetDest.cc:216
NetDest::isEmpty
bool isEmpty() const
Definition: NetDest.cc:180
NetDest::isBroadcast
bool isBroadcast() const
Definition: NetDest.cc:168
NetDest::AND
NetDest AND(const NetDest &andNetDest) const
Definition: NetDest.cc:204
NetDest::isEqual
bool isEqual(const NetDest &netDest) const
Definition: NetDest.cc:272
NetDest::getAllDest
std::vector< NodeID > getAllDest()
Definition: NetDest.cc:106
NetDest
Definition: NetDest.hh:39
ArmISA::m
Bitfield< 0 > m
Definition: miscregs_types.hh:389
NetDest::removeNetDest
void removeNetDest(const NetDest &netDest)
Definition: NetDest.cc:70

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17