projects
/
gem5.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ruby: drop NetworkMessage class
[gem5.git]
/
src
/
mem
/
ruby
/
common
/
NetDest.cc
diff --git
a/src/mem/ruby/common/NetDest.cc
b/src/mem/ruby/common/NetDest.cc
index 1edf6d1a6e382bbd67a2160ae28cc57e86bfddcf..0a89bda530d17b7c4297b4d4263790e18d6ab894 100644
(file)
--- a/
src/mem/ruby/common/NetDest.cc
+++ b/
src/mem/ruby/common/NetDest.cc
@@
-26,17
+26,19
@@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <algorithm>
+
#include "mem/ruby/common/NetDest.hh"
#include "mem/ruby/common/NetDest.hh"
-#include "mem/protocol/Protocol.hh"
NetDest::NetDest()
{
NetDest::NetDest()
{
-
setS
ize();
+
res
ize();
}
void
NetDest::add(MachineID newElement)
{
}
void
NetDest::add(MachineID newElement)
{
+ assert(bitIndex(newElement.num) < m_bits[vecIndex(newElement)].getSize());
m_bits[vecIndex(newElement)].add(bitIndex(newElement.num));
}
m_bits[vecIndex(newElement)].add(bitIndex(newElement.num));
}
@@
-49,13
+51,6
@@
NetDest::addNetDest(const NetDest& netDest)
}
}
}
}
-void
-NetDest::addRandom()
-{
- int i = random()%m_bits.size();
- m_bits[i].addRandom();
-}
-
void
NetDest::setNetDest(MachineType machine, const Set& set)
{
void
NetDest::setNetDest(MachineType machine, const Set& set)
{
@@
-100,23
+95,23
@@
NetDest::broadcast()
void
NetDest::broadcast(MachineType machineType)
{
void
NetDest::broadcast(MachineType machineType)
{
- for (
int
i = 0; i < MachineType_base_count(machineType); i++) {
+ for (
NodeID
i = 0; i < MachineType_base_count(machineType); i++) {
MachineID mach = {machineType, i};
add(mach);
}
}
//For Princeton Network
MachineID mach = {machineType, i};
add(mach);
}
}
//For Princeton Network
-
V
ector<NodeID>
+
std::v
ector<NodeID>
NetDest::getAllDest()
{
NetDest::getAllDest()
{
-
V
ector<NodeID> dest;
+
std::v
ector<NodeID> dest;
dest.clear();
for (int i = 0; i < m_bits.size(); i++) {
for (int j = 0; j < m_bits[i].getSize(); j++) {
if (m_bits[i].isElement(j)) {
int id = MachineType_base_number((MachineType)i) + j;
dest.clear();
for (int i = 0; i < m_bits.size(); i++) {
for (int j = 0; j < m_bits[i].getSize(); j++) {
if (m_bits[i].isElement(j)) {
int id = MachineType_base_number((MachineType)i) + j;
- dest.
insertAtBottom
((NodeID)id);
+ dest.
push_back
((NodeID)id);
}
}
}
}
}
}
@@
-144,28
+139,28
@@
NetDest::smallestElement() const
{
assert(count() > 0);
for (int i = 0; i < m_bits.size(); i++) {
{
assert(count() > 0);
for (int i = 0; i < m_bits.size(); i++) {
- for (
int
j = 0; j < m_bits[i].getSize(); j++) {
+ for (
NodeID
j = 0; j < m_bits[i].getSize(); j++) {
if (m_bits[i].isElement(j)) {
MachineID mach = {MachineType_from_base_level(i), j};
return mach;
}
}
}
if (m_bits[i].isElement(j)) {
MachineID mach = {MachineType_from_base_level(i), j};
return mach;
}
}
}
-
ERROR_MSG
("No smallest element of an empty set.");
+
panic
("No smallest element of an empty set.");
}
MachineID
NetDest::smallestElement(MachineType machine) const
{
int size = m_bits[MachineType_base_level(machine)].getSize();
}
MachineID
NetDest::smallestElement(MachineType machine) const
{
int size = m_bits[MachineType_base_level(machine)].getSize();
- for (
int
j = 0; j < size; j++) {
+ for (
NodeID
j = 0; j < size; j++) {
if (m_bits[MachineType_base_level(machine)].isElement(j)) {
MachineID mach = {machine, j};
return mach;
}
}
if (m_bits[MachineType_base_level(machine)].isElement(j)) {
MachineID mach = {machine, j};
return mach;
}
}
-
ERROR_MSG
("No smallest element of given MachineType.");
+
panic
("No smallest element of given MachineType.");
}
// Returns true iff all bits are set
}
// Returns true iff all bits are set
@@
-222,7
+217,7
@@
NetDest::intersectionIsNotEmpty(const NetDest& other_netDest) const
{
assert(m_bits.size() == other_netDest.getSize());
for (int i = 0; i < m_bits.size(); i++) {
{
assert(m_bits.size() == other_netDest.getSize());
for (int i = 0; i < m_bits.size(); i++) {
- if (
m_bits[i].intersectionIsNot
Empty(other_netDest.m_bits[i])) {
+ if (
!m_bits[i].intersectionIs
Empty(other_netDest.m_bits[i])) {
return true;
}
}
return true;
}
}
@@
-249,9
+244,9
@@
NetDest::isElement(MachineID element) const
}
void
}
void
-NetDest::
setS
ize()
+NetDest::
res
ize()
{
{
- m_bits.
setS
ize(MachineType_base_level(MachineType_NUM));
+ m_bits.
res
ize(MachineType_base_level(MachineType_NUM));
assert(m_bits.size() == MachineType_NUM);
for (int i = 0; i < m_bits.size(); i++) {
assert(m_bits.size() == MachineType_NUM);
for (int i = 0; i < m_bits.size(); i++) {
@@
-260,7
+255,7
@@
NetDest::setSize()
}
void
}
void
-NetDest::print(ostream& out) const
+NetDest::print(
std::
ostream& out) const
{
out << "[NetDest (" << m_bits.size() << ") ";
{
out << "[NetDest (" << m_bits.size() << ") ";
@@
-273,3
+268,13
@@
NetDest::print(ostream& out) const
out << "]";
}
out << "]";
}
+bool
+NetDest::isEqual(const NetDest& n) const
+{
+ assert(m_bits.size() == n.m_bits.size());
+ for (unsigned int i = 0; i < m_bits.size(); ++i) {
+ if (!m_bits[i].isEqual(n.m_bits[i]))
+ return false;
+ }
+ return true;
+}