gem5 v24.1.0.1
Loading...
Searching...
No Matches
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
37
38namespace gem5
39{
40
41namespace ruby
42{
43
44class RubySystem;
45
46// NetDest specifies the network destination of a Message
48{
49 public:
50 // Constructors
51 // creates and empty set
52 NetDest();
53 NetDest(RubySystem *ruby_system);
54 explicit NetDest(int bit_size);
55
56 NetDest& operator=(const Set& obj);
57
59 { }
60
61 void add(MachineID newElement);
62 void addNetDest(const NetDest& netDest);
63 void setNetDest(MachineType machine, const Set& set);
64 void remove(MachineID oldElement);
65 void removeNetDest(const NetDest& netDest);
66 void clear();
67 void broadcast();
68 void broadcast(MachineType machine);
69 int count() const;
70 bool isEqual(const NetDest& netDest) const;
71
72 // return the logical OR of this netDest and orNetDest
73 NetDest OR(const NetDest& orNetDest) const;
74
75 // return the logical AND of this netDest and andNetDest
76 NetDest AND(const NetDest& andNetDest) const;
77
78 // Returns true if the intersection of the two netDests is non-empty
79 bool intersectionIsNotEmpty(const NetDest& other_netDest) const;
80
81 // Returns true if the intersection of the two netDests is empty
82 bool intersectionIsEmpty(const NetDest& other_netDest) const;
83
84 bool isSuperset(const NetDest& test) const;
85 bool isSubset(const NetDest& test) const { return test.isSuperset(*this); }
86 bool isElement(MachineID element) const;
87 bool isBroadcast() const;
88 bool isEmpty() const;
89
90 // For Princeton Network
92
94 MachineID smallestElement(MachineType machine) const;
95
96 void resize();
97 int getSize() const { return m_bits.size(); }
98
99 // get element for a index
101
102 void print(std::ostream& out) const;
103
105
106 private:
107 // returns a value >= MachineType_base_level("this machine")
108 // and < MachineType_base_level("next highest machine")
109 int
111 {
112 int vec_index = MachineType_base_level(m.type);
113 assert(vec_index < m_bits.size());
114 return vec_index;
115 }
116
117 NodeID bitIndex(NodeID index) const { return index; }
118
119 std::vector<Set> m_bits; // a vector of bit vectors - i.e. Sets
120
121 // Needed to call MacheinType_base_count/level
123
124 int MachineType_base_count(const MachineType& obj);
125 int MachineType_base_number(const MachineType& obj);
126};
127
128inline std::ostream&
129operator<<(std::ostream& out, const NetDest& obj)
130{
131 obj.print(out);
132 out << std::flush;
133 return out;
134}
135
136} // namespace ruby
137} // namespace gem5
138
139#endif // __MEM_RUBY_COMMON_NETDEST_HH__
void add(MachineID newElement)
Definition NetDest.cc:52
void remove(MachineID oldElement)
Definition NetDest.cc:81
std::vector< NodeID > getAllDest()
Definition NetDest.cc:128
NetDest AND(const NetDest &andNetDest) const
Definition NetDest.cc:239
RubySystem * m_ruby_system
Definition NetDest.hh:122
NetDest OR(const NetDest &orNetDest) const
Definition NetDest.cc:226
int MachineType_base_count(const MachineType &obj)
Definition NetDest.cc:326
bool isElement(MachineID element) const
Definition NetDest.cc:279
bool isEqual(const NetDest &netDest) const
Definition NetDest.cc:314
std::vector< Set > m_bits
Definition NetDest.hh:119
void removeNetDest(const NetDest &netDest)
Definition NetDest.cc:88
NodeID elementAt(MachineID index)
Definition NetDest.cc:159
bool isSubset(const NetDest &test) const
Definition NetDest.hh:85
NetDest(int bit_size)
int count() const
Definition NetDest.cc:147
bool isBroadcast() const
Definition NetDest.cc:200
void addNetDest(const NetDest &netDest)
Definition NetDest.cc:60
void setNetDest(MachineType machine, const Set &set)
Definition NetDest.cc:70
MachineID smallestElement() const
Definition NetDest.cc:166
bool isEmpty() const
Definition NetDest.cc:213
bool intersectionIsNotEmpty(const NetDest &other_netDest) const
Definition NetDest.cc:252
bool intersectionIsEmpty(const NetDest &other_netDest) const
int vecIndex(MachineID m) const
Definition NetDest.hh:110
int getSize() const
Definition NetDest.hh:97
bool isSuperset(const NetDest &test) const
Definition NetDest.cc:265
void setRubySystem(RubySystem *rs)
Definition NetDest.hh:104
int MachineType_base_number(const MachineType &obj)
Definition NetDest.cc:333
NetDest & operator=(const Set &obj)
void print(std::ostream &out) const
Definition NetDest.cc:299
NodeID bitIndex(NodeID index) const
Definition NetDest.hh:117
STL vector class.
Definition stl.hh:37
Bitfield< 9, 8 > rs
Bitfield< 12, 11 > set
Bitfield< 0 > m
Bitfield< 30, 0 > index
unsigned int NodeID
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
std::ostream & operator<<(std::ostream &os, const BaseSemihosting::InPlaceArg &ipa)
Definition test.h:38

Generated on Mon Jan 13 2025 04:28:40 for gem5 by doxygen 1.9.8