gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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__
void broadcast()
Definition: NetDest.cc:87
Bitfield< 30, 0 > index
void addNetDest(const NetDest &netDest)
Definition: NetDest.cc:46
int vecIndex(MachineID m) const
Definition: NetDest.hh:99
NetDest & operator=(const Set &obj)
Bitfield< 0 > m
Definition: miscregs.hh:1577
void clear()
Definition: NetDest.cc:79
bool intersectionIsNotEmpty(const NetDest &other_netDest) const
Definition: NetDest.cc:216
bool isBroadcast() const
Definition: NetDest.cc:168
bool isEqual(const NetDest &netDest) const
Definition: NetDest.cc:272
NetDest()
Definition: NetDest.cc:33
void add(MachineID newElement)
Definition: NetDest.cc:39
bool isElement(MachineID element) const
Definition: NetDest.cc:241
NetDest OR(const NetDest &orNetDest) const
Definition: NetDest.cc:192
int count() const
Definition: NetDest.cc:122
STL vector class.
Definition: stl.hh:40
MachineType type
Definition: MachineID.hh:44
void resize()
Definition: NetDest.cc:247
unsigned int NodeID
Definition: TypeDefines.hh:34
void print(std::ostream &out) const
Definition: NetDest.cc:258
bool intersectionIsEmpty(const NetDest &other_netDest) const
int getSize() const
Definition: NetDest.hh:88
NodeID bitIndex(NodeID index) const
Definition: NetDest.hh:106
void removeNetDest(const NetDest &netDest)
Definition: NetDest.cc:70
NetDest AND(const NetDest &andNetDest) const
Definition: NetDest.cc:204
bool isSubset(const NetDest &test) const
Definition: NetDest.hh:76
~NetDest()
Definition: NetDest.hh:49
MachineID smallestElement() const
Definition: NetDest.cc:138
NodeID elementAt(MachineID index)
Definition: NetDest.cc:132
bool isSuperset(const NetDest &test) const
Definition: NetDest.cc:228
void setNetDest(MachineType machine, const Set &set)
Definition: NetDest.cc:55
bool isEmpty() const
Definition: NetDest.cc:180
std::vector< NodeID > getAllDest()
Definition: NetDest.cc:106
std::ostream & operator<<(std::ostream &out, const NetDest &obj)
Definition: NetDest.hh:112
Definition: Set.hh:45
std::vector< Set > m_bits
Definition: NetDest.hh:108

Generated on Fri Jun 9 2017 13:03:49 for gem5 by doxygen 1.8.6