3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
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.
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.
39 // NetDest specifies the network destination of a NetworkMessage
40 // This is backward compatible with the Set class that was previously
41 // used to specify network destinations.
42 // NetDest supports both node networks and component networks
47 #include "mem/ruby/common/Global.hh"
48 #include "mem/gems_common/Vector.hh"
49 #include "mem/ruby/system/NodeID.hh"
50 #include "mem/ruby/system/MachineID.hh"
51 #include "mem/ruby/common/Set.hh"
52 #include "mem/protocol/MachineType.hh"
59 // creates and empty set
61 explicit NetDest(int bit_size);
63 NetDest& operator=(const Set& obj);
66 ~NetDest() { DEBUG_MSG(MEMORY_COMP, LowPrio, "NetDest Destructor"); }
69 void add(MachineID newElement);
70 void addNetDest(const NetDest& netDest);
72 void setNetDest(MachineType machine, const Set& set);
73 void remove(MachineID oldElement);
74 void removeNetDest(const NetDest& netDest);
77 void broadcast(MachineType machine);
79 bool isEqual(const NetDest& netDest);
81 NetDest OR(const NetDest& orNetDest) const; // return the logical OR of this netDest and orNetDest
82 NetDest AND(const NetDest& andNetDest) const; // return the logical AND of this netDest and andNetDest
84 // Returns true if the intersection of the two netDests is non-empty
85 bool intersectionIsNotEmpty(const NetDest& other_netDest) const;
87 // Returns true if the intersection of the two netDests is empty
88 bool intersectionIsEmpty(const NetDest& other_netDest) const;
90 bool isSuperset(const NetDest& test) const;
91 bool isSubset(const NetDest& test) const { return test.isSuperset(*this); }
92 bool isElement(MachineID element) const;
93 bool isBroadcast() const;
96 //For Princeton Network
97 Vector<NodeID> getAllDest();
99 NodeID smallestElement() const;
100 MachineID smallestElement(MachineType machine) const;
103 int getSize() const { return m_bits.size(); }
105 // get element for a index
106 NodeID elementAt(MachineID index);
108 void print(ostream& out) const;
113 // returns a value >= MachineType_base_level("this machine") and < MachineType_base_level("next highest machine")
114 int vecIndex(MachineID m) const {
115 int vec_index = MachineType_base_level(m.type);
116 assert(vec_index < m_bits.size());
120 NodeID bitIndex(NodeID index) const {
124 // Data Members (m_ prefix)
125 Vector < Set > m_bits; // a Vector of bit vectors - i.e. Sets
129 // Output operator declaration
130 ostream& operator<<(ostream& out, const NetDest& obj);
132 // ******************* Definitions *******************
134 // Output operator definition
136 ostream& operator<<(ostream& out, const NetDest& obj)