NetDest.hh (6797:7bf0a839c237) NetDest.hh (7039:bc0b6ea676b5)
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;

--- 12 unchanged lines hidden (view full) ---

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
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;

--- 12 unchanged lines hidden (view full) ---

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
30/*
31 * Set.hh
32 *
33 * Description:
34 *
35 * $Id$
36 *
37 */
38
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
43
29// NetDest specifies the network destination of a NetworkMessage
30// This is backward compatible with the Set class that was previously
31// used to specify network destinations.
32// NetDest supports both node networks and component networks
33
44#ifndef NETDEST_H
45#define NETDEST_H
34#ifndef __MEM_RUBY_COMMON_NETDEST_HH__
35#define __MEM_RUBY_COMMON_NETDEST_HH__
46
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"
53
36
37#include "mem/ruby/common/Global.hh"
38#include "mem/gems_common/Vector.hh"
39#include "mem/ruby/system/NodeID.hh"
40#include "mem/ruby/system/MachineID.hh"
41#include "mem/ruby/common/Set.hh"
42#include "mem/protocol/MachineType.hh"
43
54class Set;
44class NetDest
45{
46 public:
47 // Constructors
48 // creates and empty set
49 NetDest();
50 explicit NetDest(int bit_size);
55
51
56class NetDest {
57public:
58 // Constructors
59 // creates and empty set
60 NetDest();
61 explicit NetDest(int bit_size);
52 NetDest& operator=(const Set& obj);
62
53
63 NetDest& operator=(const Set& obj);
54 ~NetDest()
55 {
56 DEBUG_MSG(MEMORY_COMP, LowPrio, "NetDest Destructor");
57 }
64
58
65 // Destructor
66 ~NetDest() { DEBUG_MSG(MEMORY_COMP, LowPrio, "NetDest Destructor"); }
59 void add(MachineID newElement);
60 void addNetDest(const NetDest& netDest);
61 void addRandom();
62 void setNetDest(MachineType machine, const Set& set);
63 void remove(MachineID oldElement);
64 void removeNetDest(const NetDest& netDest);
65 void clear();
66 void broadcast();
67 void broadcast(MachineType machine);
68 int count() const;
69 bool isEqual(const NetDest& netDest);
67
70
68 // Public Methods
69 void add(MachineID newElement);
70 void addNetDest(const NetDest& netDest);
71 void addRandom();
72 void setNetDest(MachineType machine, const Set& set);
73 void remove(MachineID oldElement);
74 void removeNetDest(const NetDest& netDest);
75 void clear();
76 void broadcast();
77 void broadcast(MachineType machine);
78 int count() const;
79 bool isEqual(const NetDest& netDest);
71 // return the logical OR of this netDest and orNetDest
72 NetDest OR(const NetDest& orNetDest) const;
80
73
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
74 // return the logical AND of this netDest and andNetDest
75 NetDest AND(const NetDest& andNetDest) const;
83
76
84 // Returns true if the intersection of the two netDests is non-empty
85 bool intersectionIsNotEmpty(const NetDest& other_netDest) const;
77 // Returns true if the intersection of the two netDests is non-empty
78 bool intersectionIsNotEmpty(const NetDest& other_netDest) const;
86
79
87 // Returns true if the intersection of the two netDests is empty
88 bool intersectionIsEmpty(const NetDest& other_netDest) const;
80 // Returns true if the intersection of the two netDests is empty
81 bool intersectionIsEmpty(const NetDest& other_netDest) const;
89
82
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;
94 bool isEmpty() const;
83 bool isSuperset(const NetDest& test) const;
84 bool isSubset(const NetDest& test) const { return test.isSuperset(*this); }
85 bool isElement(MachineID element) const;
86 bool isBroadcast() const;
87 bool isEmpty() const;
95
88
96 //For Princeton Network
97 Vector getAllDest();
89 // For Princeton Network
90 Vector<NodeID> getAllDest();
98
91
99 MachineID smallestElement() const;
100 MachineID smallestElement(MachineType machine) const;
92 MachineID smallestElement() const;
93 MachineID smallestElement(MachineType machine) const;
101
94
102 void setSize();
103 int getSize() const { return m_bits.size(); }
95 void setSize();
96 int getSize() const { return m_bits.size(); }
104
97
105 // get element for a index
106 NodeID elementAt(MachineID index);
98 // get element for a index
99 NodeID elementAt(MachineID index);
107
100
108 void print(ostream& out) const;
101 void print(ostream& out) const;
109
102
110private:
103 private:
104 // returns a value >= MachineType_base_level("this machine")
105 // and < MachineType_base_level("next highest machine")
106 int
107 vecIndex(MachineID m) const
108 {
109 int vec_index = MachineType_base_level(m.type);
110 assert(vec_index < m_bits.size());
111 return vec_index;
112 }
111
113
112 // Private Methods
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());
117 return vec_index;
118 }
114 NodeID
115 bitIndex(NodeID index) const
116 {
117 return index;
118 }
119
119
120 NodeID bitIndex(NodeID index) const {
121 return index;
122 }
123
124 // Data Members (m_ prefix)
125 Vector < Set > m_bits; // a Vector of bit vectors - i.e. Sets
126
120 Vector <Set> m_bits; // a Vector of bit vectors - i.e. Sets
127};
128
121};
122
129// Output operator declaration
130ostream& operator<<(ostream& out, const NetDest& obj);
131
132// ******************* Definitions *******************
133
134// Output operator definition
135extern inline
136ostream& operator<<(ostream& out, const NetDest& obj)
123inline ostream&
124operator<<(ostream& out, const NetDest& obj)
137{
125{
138 obj.print(out);
139 out << flush;
140 return out;
126 obj.print(out);
127 out << flush;
128 return out;
141}
142
129}
130
143#endif //NETDEST_H
131#endif // __MEM_RUBY_COMMON_NETDEST_HH__
144
132