summaryrefslogtreecommitdiff
path: root/src/mem/ruby/common
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2010-03-22 18:43:53 -0700
committerNathan Binkert <nate@binkert.org>2010-03-22 18:43:53 -0700
commit5ab13e2deb8f904ef2a233749193fa09ea7013c4 (patch)
tree07f5f02902f9e719fe58d1a9419b5a1d51f7a2ce /src/mem/ruby/common
parent2620e08722b38660658d46cdb76c337db18e877c (diff)
downloadgem5-5ab13e2deb8f904ef2a233749193fa09ea7013c4.tar.xz
ruby: style pass
Diffstat (limited to 'src/mem/ruby/common')
-rw-r--r--src/mem/ruby/common/Address.cc48
-rw-r--r--src/mem/ruby/common/Address.hh310
-rw-r--r--src/mem/ruby/common/Consumer.hh138
-rw-r--r--src/mem/ruby/common/DataBlock.cc20
-rw-r--r--src/mem/ruby/common/DataBlock.hh191
-rw-r--r--src/mem/ruby/common/Debug.cc405
-rw-r--r--src/mem/ruby/common/Debug.hh450
-rw-r--r--src/mem/ruby/common/Driver.cc40
-rw-r--r--src/mem/ruby/common/Driver.hh81
-rw-r--r--src/mem/ruby/common/Global.cc1
-rw-r--r--src/mem/ruby/common/Global.hh46
-rw-r--r--src/mem/ruby/common/Histogram.cc224
-rw-r--r--src/mem/ruby/common/Histogram.hh98
-rw-r--r--src/mem/ruby/common/Message.cc34
-rw-r--r--src/mem/ruby/common/NetDest.cc294
-rw-r--r--src/mem/ruby/common/NetDest.hh182
-rw-r--r--src/mem/ruby/common/SConscript1
-rw-r--r--src/mem/ruby/common/SubBlock.cc51
-rw-r--r--src/mem/ruby/common/SubBlock.hh87
19 files changed, 1274 insertions, 1427 deletions
diff --git a/src/mem/ruby/common/Address.cc b/src/mem/ruby/common/Address.cc
index b4ad39294..e74bdb47b 100644
--- a/src/mem/ruby/common/Address.cc
+++ b/src/mem/ruby/common/Address.cc
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,42 +26,41 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * $Id$
- */
-
#include "mem/ruby/common/Address.hh"
-void Address::output(ostream& out) const
+void
+Address::output(ostream& out) const
{
- // Note: this outputs addresses in the form "ffff", not "0xffff".
- // This code should always be able to write out addresses in a
- // format that can be read in by the below input() method. Please
- // don't change this without talking to Milo first.
- out << hex << m_address << dec;
+ // Note: this outputs addresses in the form "ffff", not "0xffff".
+ // This code should always be able to write out addresses in a
+ // format that can be read in by the below input() method. Please
+ // don't change this without talking to Milo first.
+ out << hex << m_address << dec;
}
-void Address::input(istream& in)
+void
+Address::input(istream& in)
{
- // Note: this only works with addresses in the form "ffff", not
- // "0xffff". This code should always be able to read in addresses
- // written out by the above output() method. Please don't change
- // this without talking to Milo first.
- in >> hex >> m_address >> dec;
+ // Note: this only works with addresses in the form "ffff", not
+ // "0xffff". This code should always be able to read in addresses
+ // written out by the above output() method. Please don't change
+ // this without talking to Milo first.
+ in >> hex >> m_address >> dec;
}
Address::Address(const Address& obj)
{
- m_address = obj.m_address;
+ m_address = obj.m_address;
}
-Address& Address::operator=(const Address& obj)
+Address&
+Address::operator=(const Address& obj)
{
- if (this == &obj) {
- // assert(false);
- } else {
- m_address = obj.m_address;
- }
- return *this;
+ if (this == &obj) {
+ // assert(false);
+ } else {
+ m_address = obj.m_address;
+ }
+ return *this;
}
diff --git a/src/mem/ruby/common/Address.hh b/src/mem/ruby/common/Address.hh
index 7da5ed0fe..73327e617 100644
--- a/src/mem/ruby/common/Address.hh
+++ b/src/mem/ruby/common/Address.hh
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,20 +26,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * $Id$
- */
-
-#ifndef ADDRESS_H
-#define ADDRESS_H
+#ifndef __MEM_RUBY_COMMON_ADDRESS_HH__
+#define __MEM_RUBY_COMMON_ADDRESS_HH__
#include <iomanip>
#include "base/hashmap.hh"
#include "mem/ruby/common/Global.hh"
-#include "mem/ruby/system/System.hh"
-#include "mem/ruby/system/NodeID.hh"
#include "mem/ruby/system/MachineID.hh"
+#include "mem/ruby/system/NodeID.hh"
+#include "mem/ruby/system/System.hh"
const int ADDRESS_WIDTH = 64; // address width in bytes
@@ -48,124 +43,131 @@ class Address;
typedef Address PhysAddress;
typedef Address VirtAddress;
-class Address {
-public:
- // Constructors
- Address() { m_address = 0; }
- explicit Address(physical_address_t address) { m_address = address; }
-
- Address(const Address& obj);
- Address& operator=(const Address& obj);
-
- // Destructor
- // ~Address();
-
- // Public Methods
-
- void setAddress(physical_address_t address) { m_address = address; }
- physical_address_t getAddress() const {return m_address;}
- // selects bits inclusive
- physical_address_t bitSelect(int small, int big) const;
- physical_address_t bitRemove(int small, int big) const;
- physical_address_t maskLowOrderBits(int number) const;
- physical_address_t maskHighOrderBits(int number) const;
- physical_address_t shiftLowOrderBits(int number) const;
- physical_address_t getLineAddress() const
- { return bitSelect(RubySystem::getBlockSizeBits(), ADDRESS_WIDTH); }
- physical_address_t getOffset() const
- { return bitSelect(0, RubySystem::getBlockSizeBits()-1); }
-
- void makeLineAddress() { m_address = maskLowOrderBits(RubySystem::getBlockSizeBits()); }
- // returns the next stride address based on line address
- void makeNextStrideAddress( int stride) {
- m_address = maskLowOrderBits(RubySystem::getBlockSizeBits())
- + RubySystem::getBlockSizeBytes()*stride;
- }
- int getBankSetNum() const;
- int getBankSetDist() const;
+class Address
+{
+ public:
+ Address()
+ : m_address(0)
+ { }
+
+ explicit
+ Address(physical_address_t address)
+ : m_address(address)
+ { }
+
+ Address(const Address& obj);
+ Address& operator=(const Address& obj);
+
+ void setAddress(physical_address_t address) { m_address = address; }
+ physical_address_t getAddress() const {return m_address;}
+ // selects bits inclusive
+ physical_address_t bitSelect(int small, int big) const;
+ physical_address_t bitRemove(int small, int big) const;
+ physical_address_t maskLowOrderBits(int number) const;
+ physical_address_t maskHighOrderBits(int number) const;
+ physical_address_t shiftLowOrderBits(int number) const;
+
+ physical_address_t
+ getLineAddress() const
+ {
+ return bitSelect(RubySystem::getBlockSizeBits(), ADDRESS_WIDTH);
+ }
- Index memoryModuleIndex() const;
+ physical_address_t
+ getOffset() const
+ {
+ return bitSelect(0, RubySystem::getBlockSizeBits() - 1);
+ }
- void print(ostream& out) const;
- void output(ostream& out) const;
- void input(istream& in);
+ void
+ makeLineAddress()
+ {
+ m_address = maskLowOrderBits(RubySystem::getBlockSizeBits());
+ }
- void setOffset( int offset ){
- // first, zero out the offset bits
- makeLineAddress();
- m_address |= (physical_address_t) offset;
- }
+ // returns the next stride address based on line address
+ void
+ makeNextStrideAddress(int stride)
+ {
+ m_address = maskLowOrderBits(RubySystem::getBlockSizeBits())
+ + RubySystem::getBlockSizeBytes()*stride;
+ }
-private:
- // Private Methods
+ int getBankSetNum() const;
+ int getBankSetDist() const;
- // Private copy constructor and assignment operator
- // Address(const Address& obj);
- // Address& operator=(const Address& obj);
+ Index memoryModuleIndex() const;
- // Data Members (m_ prefix)
- physical_address_t m_address;
-};
+ void print(ostream& out) const;
+ void output(ostream& out) const;
+ void input(istream& in);
-inline
-Address line_address(const Address& addr) { Address temp(addr); temp.makeLineAddress(); return temp; }
+ void
+ setOffset(int offset)
+ {
+ // first, zero out the offset bits
+ makeLineAddress();
+ m_address |= (physical_address_t) offset;
+ }
-// Output operator declaration
-ostream& operator<<(ostream& out, const Address& obj);
-// comparison operator declaration
-bool operator==(const Address& obj1, const Address& obj2);
-bool operator!=(const Address& obj1, const Address& obj2);
-bool operator<(const Address& obj1, const Address& obj2);
-/* Address& operator=(const physical_address_t address); */
+ private:
+ physical_address_t m_address;
+};
-inline
-bool operator<(const Address& obj1, const Address& obj2)
+inline Address
+line_address(const Address& addr)
{
- return obj1.getAddress() < obj2.getAddress();
+ Address temp(addr);
+ temp.makeLineAddress();
+ return temp;
}
-// ******************* Definitions *******************
+inline bool
+operator<(const Address& obj1, const Address& obj2)
+{
+ return obj1.getAddress() < obj2.getAddress();
+}
-// Output operator definition
-inline
-ostream& operator<<(ostream& out, const Address& obj)
+inline ostream&
+operator<<(ostream& out, const Address& obj)
{
- obj.print(out);
- out << flush;
- return out;
+ obj.print(out);
+ out << flush;
+ return out;
}
-inline
-bool operator==(const Address& obj1, const Address& obj2)
+inline bool
+operator==(const Address& obj1, const Address& obj2)
{
- return (obj1.getAddress() == obj2.getAddress());
+ return (obj1.getAddress() == obj2.getAddress());
}
-inline
-bool operator!=(const Address& obj1, const Address& obj2)
+inline bool
+operator!=(const Address& obj1, const Address& obj2)
{
- return (obj1.getAddress() != obj2.getAddress());
+ return (obj1.getAddress() != obj2.getAddress());
}
-inline
-physical_address_t Address::bitSelect(int small, int big) const // rips bits inclusive
+// rips bits inclusive
+inline physical_address_t
+Address::bitSelect(int small, int big) const
{
- physical_address_t mask;
- assert((unsigned)big >= (unsigned)small);
+ physical_address_t mask;
+ assert((unsigned)big >= (unsigned)small);
- if (big >= ADDRESS_WIDTH - 1) {
- return (m_address >> small);
- } else {
- mask = ~((physical_address_t)~0 << (big + 1));
- // FIXME - this is slow to manipulate a 64-bit number using 32-bits
- physical_address_t partial = (m_address & mask);
- return (partial >> small);
- }
+ if (big >= ADDRESS_WIDTH - 1) {
+ return (m_address >> small);
+ } else {
+ mask = ~((physical_address_t)~0 << (big + 1));
+ // FIXME - this is slow to manipulate a 64-bit number using 32-bits
+ physical_address_t partial = (m_address & mask);
+ return (partial >> small);
+ }
}
// removes bits inclusive
-inline
-physical_address_t Address::bitRemove(int small, int big) const
+inline physical_address_t
+Address::bitRemove(int small, int big) const
{
physical_address_t mask;
assert((unsigned)big >= (unsigned)small);
@@ -184,60 +186,64 @@ physical_address_t Address::bitRemove(int small, int big) const
mask = (physical_address_t)~0 << (big + 1);
physical_address_t higher_bits = m_address & mask;
- //
// Shift the valid high bits over the removed section
- //
higher_bits = higher_bits >> (big - small);
return (higher_bits | lower_bits);
}
}
-inline
-physical_address_t Address::maskLowOrderBits(int number) const
+inline physical_address_t
+Address::maskLowOrderBits(int number) const
{
physical_address_t mask;
if (number >= ADDRESS_WIDTH - 1) {
- mask = ~0;
+ mask = ~0;
} else {
- mask = (physical_address_t)~0 << number;
+ mask = (physical_address_t)~0 << number;
}
return (m_address & mask);
}
-inline
-physical_address_t Address::maskHighOrderBits(int number) const
+inline physical_address_t
+Address::maskHighOrderBits(int number) const
{
- physical_address_t mask;
+ physical_address_t mask;
- if (number >= ADDRESS_WIDTH - 1) {
- mask = ~0;
- } else {
- mask = (physical_address_t)~0 >> number;
- }
- return (m_address & mask);
+ if (number >= ADDRESS_WIDTH - 1) {
+ mask = ~0;
+ } else {
+ mask = (physical_address_t)~0 >> number;
+ }
+ return (m_address & mask);
}
-inline
-physical_address_t Address::shiftLowOrderBits(int number) const
+inline physical_address_t
+Address::shiftLowOrderBits(int number) const
{
- return (m_address >> number);
+ return (m_address >> number);
}
-inline
-integer_t Address::memoryModuleIndex() const
+inline integer_t
+Address::memoryModuleIndex() const
{
- integer_t index = bitSelect(RubySystem::getBlockSizeBits()+RubySystem::getMemorySizeBits(), ADDRESS_WIDTH);
- assert (index >= 0);
- return index;
-
- // Index indexHighPortion = address.bitSelect(MEMORY_SIZE_BITS-1, PAGE_SIZE_BITS+NUMBER_OF_MEMORY_MODULE_BITS);
- // Index indexLowPortion = address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS-1);
-
- //Index index = indexLowPortion | (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS));
-
- /*
- Round-robin mapping of addresses, at page size granularity
+ integer_t index =
+ bitSelect(RubySystem::getBlockSizeBits() +
+ RubySystem::getMemorySizeBits(), ADDRESS_WIDTH);
+ assert (index >= 0);
+ return index;
+
+ // Index indexHighPortion =
+ // address.bitSelect(MEMORY_SIZE_BITS - 1,
+ // PAGE_SIZE_BITS + NUMBER_OF_MEMORY_MODULE_BITS);
+ // Index indexLowPortion =
+ // address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS - 1);
+ //
+ // Index index = indexLowPortion |
+ // (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS));
+
+ /*
+ Round-robin mapping of addresses, at page size granularity
ADDRESS_WIDTH MEMORY_SIZE_BITS PAGE_SIZE_BITS DATA_BLOCK_BITS
| | | |
@@ -249,29 +255,39 @@ ADDRESS_WIDTH MEMORY_SIZE_BITS PAGE_SIZE_BITS DATA_BLOCK_BITS
indexHighPortion indexLowPortion
<------->
NUMBER_OF_MEMORY_MODULE_BITS
- */
+ */
}
-inline
-void Address::print(ostream& out) const
+inline void
+Address::print(ostream& out) const
{
using namespace std;
- out << "[" << hex << "0x" << m_address << "," << " line 0x" << maskLowOrderBits(RubySystem::getBlockSizeBits()) << dec << "]" << flush;
+ out << "[" << hex << "0x" << m_address << "," << " line 0x"
+ << maskLowOrderBits(RubySystem::getBlockSizeBits()) << dec << "]"
+ << flush;
}
class Address;
namespace __hash_namespace {
- template <> struct hash<Address>
- {
- size_t operator()(const Address &s) const { return (size_t) s.getAddress(); }
- };
-}
-namespace std {
- template <> struct equal_to<Address>
- {
- bool operator()(const Address& s1, const Address& s2) const { return s1 == s2; }
- };
-}
+template <> struct hash<Address>
+{
+ size_t
+ operator()(const Address &s) const
+ {
+ return (size_t)s.getAddress();
+ }
+};
+/* namespace __hash_namespace */ }
-#endif //ADDRESS_H
+namespace std {
+template <> struct equal_to<Address>
+{
+ bool
+ operator()(const Address& s1, const Address& s2) const
+ {
+ return s1 == s2;
+ }
+};
+/* namespace std */ }
+#endif // __MEM_RUBY_COMMON_ADDRESS_HH__
diff --git a/src/mem/ruby/common/Consumer.hh b/src/mem/ruby/common/Consumer.hh
index e541ef615..c1f8bc42e 100644
--- a/src/mem/ruby/common/Consumer.hh
+++ b/src/mem/ruby/common/Consumer.hh
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -28,16 +27,13 @@
*/
/*
- * $Id$
- *
- * Description: This is the virtual base class of all classes that can
- * be the targets of wakeup events. There is only two methods,
- * wakeup() and print() and no data members.
- *
+ * This is the virtual base class of all classes that can be the
+ * targets of wakeup events. There is only two methods, wakeup() and
+ * print() and no data members.
*/
-#ifndef CONSUMER_H
-#define CONSUMER_H
+#ifndef __MEM_RUBY_COMMON_CONSUMER_HH__
+#define __MEM_RUBY_COMMON_CONSUMER_HH__
#include <iostream>
#include <set>
@@ -47,68 +43,74 @@
class MessageBuffer;
-class Consumer {
-public:
- // Constructors
- Consumer() { m_last_scheduled_wakeup = 0; m_last_wakeup = 0; }
-
- // Destructor
- virtual ~Consumer() { }
-
- // Public Methods - pure virtual methods
- void triggerWakeup(RubyEventQueue * eventQueue)
- {
- Time time = eventQueue->getTime();
- if (m_last_wakeup != time) {
- wakeup(); m_last_wakeup = time;
- }
- }
- virtual void wakeup() = 0;
- virtual void print(std::ostream& out) const = 0;
- const Time& getLastScheduledWakeup() const
- {
- return m_last_scheduled_wakeup;
- }
- void setLastScheduledWakeup(const Time& time)
- {
- m_last_scheduled_wakeup = time;
- }
- bool alreadyScheduled(Time time)
- {
- return (m_scheduled_wakeups.find(time) != m_scheduled_wakeups.end());
- }
- void insertScheduledWakeupTime(Time time)
- {
- m_scheduled_wakeups.insert(time);
- }
- void removeScheduledWakeupTime(Time time)
- {
- assert(alreadyScheduled(time));
- m_scheduled_wakeups.erase(time);
- }
-
-private:
- // Private Methods
-
- // Data Members (m_ prefix)
- Time m_last_scheduled_wakeup;
- std::set<Time> m_scheduled_wakeups;
- Time m_last_wakeup;
-};
+class Consumer
+{
+ public:
+ Consumer()
+ : m_last_scheduled_wakeup(0), m_last_wakeup(0)
+ {
+ }
+
+ virtual
+ ~Consumer()
+ { }
+
+ void
+ triggerWakeup(RubyEventQueue *eventQueue)
+ {
+ Time time = eventQueue->getTime();
+ if (m_last_wakeup != time) {
+ wakeup();
+ m_last_wakeup = time;
+ }
+ }
-// Output operator declaration
-inline extern
-std::ostream& operator<<(std::ostream& out, const Consumer& obj);
+ virtual void wakeup() = 0;
+ virtual void print(std::ostream& out) const = 0;
-// ******************* Definitions *******************
+ const Time&
+ getLastScheduledWakeup() const
+ {
+ return m_last_scheduled_wakeup;
+ }
+
+ void
+ setLastScheduledWakeup(const Time& time)
+ {
+ m_last_scheduled_wakeup = time;
+ }
+
+ bool
+ alreadyScheduled(Time time)
+ {
+ return m_scheduled_wakeups.find(time) != m_scheduled_wakeups.end();
+ }
+
+ void
+ insertScheduledWakeupTime(Time time)
+ {
+ m_scheduled_wakeups.insert(time);
+ }
+
+ void
+ removeScheduledWakeupTime(Time time)
+ {
+ assert(alreadyScheduled(time));
+ m_scheduled_wakeups.erase(time);
+ }
+
+ private:
+ Time m_last_scheduled_wakeup;
+ std::set<Time> m_scheduled_wakeups;
+ Time m_last_wakeup;
+};
-// Output operator definition
-inline extern
-std::ostream& operator<<(std::ostream& out, const Consumer& obj)
+inline std::ostream&
+operator<<(std::ostream& out, const Consumer& obj)
{
- obj.print(out);
- out << std::flush;
- return out;
+ obj.print(out);
+ out << std::flush;
+ return out;
}
-#endif //CONSUMER_H
+#endif // __MEM_RUBY_COMMON_CONSUMER_HH__
diff --git a/src/mem/ruby/common/DataBlock.cc b/src/mem/ruby/common/DataBlock.cc
index 75ede7f4f..8d3c81242 100644
--- a/src/mem/ruby/common/DataBlock.cc
+++ b/src/mem/ruby/common/DataBlock.cc
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -32,13 +31,14 @@
DataBlock &
DataBlock::operator=(const DataBlock & obj)
{
- if (this == &obj) {
- // assert(false);
- } else {
- if (!m_alloc)
- m_data = new uint8[RubySystem::getBlockSizeBytes()];
- memcpy(m_data, obj.m_data, RubySystem::getBlockSizeBytes());
- m_alloc = true;
- }
- return *this;
+ if (this == &obj) {
+ // assert(false);
+ } else {
+ if (!m_alloc)
+ m_data = new uint8[RubySystem::getBlockSizeBytes()];
+ memcpy(m_data, obj.m_data, RubySystem::getBlockSizeBytes());
+ m_alloc = true;
+ }
+
+ return *this;
}
diff --git a/src/mem/ruby/common/DataBlock.hh b/src/mem/ruby/common/DataBlock.hh
index 5407033bf..edf774166 100644
--- a/src/mem/ruby/common/DataBlock.hh
+++ b/src/mem/ruby/common/DataBlock.hh
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,152 +26,144 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef DATABLOCK_H
-#define DATABLOCK_H
+#ifndef __MEM_RUBY_COMMON_DATABLOCK_HH__
+#define __MEM_RUBY_COMMON_DATABLOCK_HH__
#include <iomanip>
#include <iostream>
+#include "mem/gems_common/Vector.hh"
#include "mem/ruby/common/Global.hh"
#include "mem/ruby/system/System.hh"
-#include "mem/gems_common/Vector.hh"
-class DataBlock {
- public:
- // Constructors
- DataBlock() {alloc();}
- DataBlock(const DataBlock & cp) {
- m_data = new uint8[RubySystem::getBlockSizeBytes()];
- memcpy(m_data, cp.m_data, RubySystem::getBlockSizeBytes());
- m_alloc = true;
- }
+class DataBlock
+{
+ public:
+ DataBlock()
+ {
+ alloc();
+ }
- // Destructor
- ~DataBlock() {
- if(m_alloc) {
- delete [] m_data;
+ DataBlock(const DataBlock &cp)
+ {
+ m_data = new uint8[RubySystem::getBlockSizeBytes()];
+ memcpy(m_data, cp.m_data, RubySystem::getBlockSizeBytes());
+ m_alloc = true;
}
- }
-
- DataBlock& operator=(const DataBlock& obj);
-
- // Public Methods
- void assign(uint8* data);
-
- void clear();
- uint8 getByte(int whichByte) const;
- const uint8* getData(int offset, int len) const;
- void setByte(int whichByte, uint8 data);
- void setData(uint8* data, int offset, int len);
- void copyPartial(const DataBlock & dblk, int offset, int len);
- bool equal(const DataBlock& obj) const;
- void print(std::ostream& out) const;
-
-private:
- void alloc();
- // Data Members (m_ prefix)
- uint8* m_data;
- bool m_alloc;
-};
-// Output operator declaration
-std::ostream& operator<<(std::ostream& out, const DataBlock& obj);
+ ~DataBlock()
+ {
+ if (m_alloc)
+ delete [] m_data;
+ }
+
+ DataBlock& operator=(const DataBlock& obj);
+
+ void assign(uint8* data);
-bool operator==(const DataBlock& obj1, const DataBlock& obj2);
+ void clear();
+ uint8 getByte(int whichByte) const;
+ const uint8* getData(int offset, int len) const;
+ void setByte(int whichByte, uint8 data);
+ void setData(uint8* data, int offset, int len);
+ void copyPartial(const DataBlock & dblk, int offset, int len);
+ bool equal(const DataBlock& obj) const;
+ void print(std::ostream& out) const;
-// inline functions for speed
+ private:
+ void alloc();
+ uint8* m_data;
+ bool m_alloc;
+};
-inline
-void DataBlock::assign(uint8* data)
+inline void
+DataBlock::assign(uint8* data)
{
- if (m_alloc) {
- delete [] m_data;
- }
- m_data = data;
- m_alloc = false;
+ if (m_alloc) {
+ delete [] m_data;
+ }
+ m_data = data;
+ m_alloc = false;
}
-inline
-void DataBlock::alloc()
+inline void
+DataBlock::alloc()
{
- m_data = new uint8[RubySystem::getBlockSizeBytes()];
- m_alloc = true;
- clear();
+ m_data = new uint8[RubySystem::getBlockSizeBytes()];
+ m_alloc = true;
+ clear();
}
-inline
-void DataBlock::clear()
+inline void
+DataBlock::clear()
{
- memset(m_data, 0, RubySystem::getBlockSizeBytes());
+ memset(m_data, 0, RubySystem::getBlockSizeBytes());
}
-inline
-bool DataBlock::equal(const DataBlock& obj) const
+inline bool
+DataBlock::equal(const DataBlock& obj) const
{
- return !memcmp(m_data, obj.m_data, RubySystem::getBlockSizeBytes());
+ return !memcmp(m_data, obj.m_data, RubySystem::getBlockSizeBytes());
}
-inline
-void DataBlock::print(std::ostream& out) const
+inline void
+DataBlock::print(std::ostream& out) const
{
- using namespace std;
-
- int size = RubySystem::getBlockSizeBytes();
- out << "[ ";
- for (int i = 0; i < size; i++) {
- out << setw(2) << setfill('0') << hex << "0x" << (int)m_data[i] << " ";
- out << setfill(' ');
- }
- out << dec << "]" << flush;
+ using namespace std;
+
+ int size = RubySystem::getBlockSizeBytes();
+ out << "[ ";
+ for (int i = 0; i < size; i++) {
+ out << setw(2) << setfill('0') << hex << "0x" << (int)m_data[i] << " ";
+ out << setfill(' ');
+ }
+ out << dec << "]" << flush;
}
-inline
-uint8 DataBlock::getByte(int whichByte) const
+inline uint8
+DataBlock::getByte(int whichByte) const
{
- return m_data[whichByte];
+ return m_data[whichByte];
}
-inline
-const uint8* DataBlock::getData(int offset, int len) const
+inline const uint8*
+DataBlock::getData(int offset, int len) const
{
- assert(offset + len <= RubySystem::getBlockSizeBytes());
- return &m_data[offset];
+ assert(offset + len <= RubySystem::getBlockSizeBytes());
+ return &m_data[offset];
}
-inline
-void DataBlock::setByte(int whichByte, uint8 data)
+inline void
+DataBlock::setByte(int whichByte, uint8 data)
{
m_data[whichByte] = data;
}
-inline
-void DataBlock::setData(uint8* data, int offset, int len)
+inline void
+DataBlock::setData(uint8* data, int offset, int len)
{
- assert(offset + len <= RubySystem::getBlockSizeBytes());
- memcpy(&m_data[offset], data, len);
+ assert(offset + len <= RubySystem::getBlockSizeBytes());
+ memcpy(&m_data[offset], data, len);
}
-inline
-void DataBlock::copyPartial(const DataBlock & dblk, int offset, int len)
+inline void
+DataBlock::copyPartial(const DataBlock & dblk, int offset, int len)
{
- setData(&dblk.m_data[offset], offset, len);
+ setData(&dblk.m_data[offset], offset, len);
}
-// ******************* Definitions *******************
-
-// Output operator definition
-extern inline
-std::ostream& operator<<(std::ostream& out, const DataBlock& obj)
+inline std::ostream&
+operator<<(std::ostream& out, const DataBlock& obj)
{
- obj.print(out);
- out << std::flush;
- return out;
+ obj.print(out);
+ out << std::flush;
+ return out;
}
-extern inline
-bool operator==(const DataBlock& obj1,const DataBlock& obj2)
+inline bool
+operator==(const DataBlock& obj1,const DataBlock& obj2)
{
- return (obj1.equal(obj2));
+ return obj1.equal(obj2);
}
-#endif //DATABLOCK_H
+#endif // __MEM_RUBY_COMMON_DATABLOCK_HH__
diff --git a/src/mem/ruby/common/Debug.cc b/src/mem/ruby/common/Debug.cc
index e67dc68ba..2c1acc4ff 100644
--- a/src/mem/ruby/common/Debug.cc
+++ b/src/mem/ruby/common/Debug.cc
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,19 +26,14 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * $Id$
- *
- */
-
#include <fstream>
#include <stdarg.h>
-#include "mem/ruby/common/Global.hh"
+#include "base/misc.hh"
+#include "mem/gems_common/util.hh"
#include "mem/ruby/common/Debug.hh"
+#include "mem/ruby/common/Global.hh"
#include "mem/ruby/eventqueue/RubyEventQueue.hh"
-#include "mem/gems_common/util.hh"
-#include "base/misc.hh"
using namespace std;
@@ -79,313 +73,272 @@ DebugComponentData debugComponents[] =
extern "C" void changeDebugVerbosity(VerbosityLevel vb);
extern "C" void changeDebugFilter(int filter);
-void changeDebugVerbosity(VerbosityLevel vb)
+void
+changeDebugVerbosity(VerbosityLevel vb)
{
- g_debug_ptr->setVerbosity(vb);
+ g_debug_ptr->setVerbosity(vb);
}
-void changeDebugFilter(int filter)
+void
+changeDebugFilter(int filter)
{
- g_debug_ptr->setFilter(filter);
+ g_debug_ptr->setFilter(filter);
}
Debug::Debug(const Params *p)
: SimObject(p)
{
- clearFilter();
- debug_cout_ptr = &cout;
-
- setFilterString(p->filter_string.c_str());
- setVerbosityString(p->verbosity_string.c_str());
- setDebugOutputFile(p->output_filename.c_str());
- m_starting_cycle = p->start_time;
- m_protocol_trace = p->protocol_trace;
- g_debug_ptr = this;
-}
-
+ clearFilter();
+ debug_cout_ptr = &cout;
-Debug::~Debug()
-{
+ setFilterString(p->filter_string.c_str());
+ setVerbosityString(p->verbosity_string.c_str());
+ setDebugOutputFile(p->output_filename.c_str());
+ m_starting_cycle = p->start_time;
+ m_protocol_trace = p->protocol_trace;
+ g_debug_ptr = this;
}
-void Debug::printVerbosity(ostream& out) const
+Debug::~Debug()
{
- switch (getVerbosity()) {
- case No_Verb:
- out << "verbosity = No_Verb" << endl;
- break;
- case Low_Verb:
- out << "verbosity = Low_Verb" << endl;
- break;
- case Med_Verb:
- out << "verbosity = Med_Verb" << endl;
- break;
- case High_Verb:
- out << "verbosity = High_Verb" << endl;
- break;
- default:
- out << "verbosity = unknown" << endl;
- }
}
-bool Debug::validDebug(int module, PriorityLevel priority)
+void
+Debug::printVerbosity(ostream& out) const
{
- int local_module = (1 << module);
- if(m_filter & local_module) {
- if (g_eventQueue_ptr == NULL ||
- g_eventQueue_ptr->getTime() >= m_starting_cycle) {
- switch(m_verbosityLevel) {
+ switch (getVerbosity()) {
case No_Verb:
- return false;
+ out << "verbosity = No_Verb" << endl;
break;
case Low_Verb:
- if(priority == HighPrio) {
- return true;
- }else{
- return false;
- }
+ out << "verbosity = Low_Verb" << endl;
break;
case Med_Verb:
- if(priority == HighPrio || priority == MedPrio ) {
- return true;
- }else{
- return false;
- }
+ out << "verbosity = Med_Verb" << endl;
break;
case High_Verb:
- return true;
+ out << "verbosity = High_Verb" << endl;
break;
- }
+ default:
+ out << "verbosity = unknown" << endl;
}
- }
- return false;
}
-void Debug::setDebugTime(Time t)
+bool
+Debug::validDebug(int module, PriorityLevel priority)
{
- m_starting_cycle = t;
+ int local_module = (1 << module);
+ if (m_filter & local_module) {
+ if (g_eventQueue_ptr == NULL ||
+ g_eventQueue_ptr->getTime() >= m_starting_cycle) {
+ switch (m_verbosityLevel) {
+ case No_Verb:
+ return false;
+ case Low_Verb:
+ return (priority == HighPrio);
+ case Med_Verb:
+ return (priority == HighPrio || priority == MedPrio);
+ case High_Verb:
+ return true;
+ }
+ }
+ }
+ return false;
}
-void Debug::setVerbosity(VerbosityLevel vb)
+void
+Debug::setDebugTime(Time t)
{
- m_verbosityLevel = vb;
+ m_starting_cycle = t;
}
-void Debug::setFilter(int filter)
+void
+Debug::setVerbosity(VerbosityLevel vb)
{
- m_filter = filter;
+ m_verbosityLevel = vb;
}
-bool Debug::checkVerbosityString(const char *verb_str)
+void
+Debug::setFilter(int filter)
{
- if (verb_str == NULL) {
- cerr << "Error: unrecognized verbosity (use none, low, med, high): NULL" << endl;
- return true; // error
- } else if ( (string(verb_str) == "none") ||
- (string(verb_str) == "low") ||
- (string(verb_str) == "med") ||
- (string(verb_str) == "high") ) {
- return false;
- }
- cerr << "Error: unrecognized verbosity (use none, low, med, high): NULL" << endl;
- return true; // error
+ m_filter = filter;
}
-bool Debug::setVerbosityString(const char *verb_str)
+bool
+Debug::setVerbosityString(const char *verb_str)
{
- bool check_fails = checkVerbosityString(verb_str);
- if (check_fails) {
- return true; // error
- }
- if (string(verb_str) == "none") {
- setVerbosity(No_Verb);
- } else if (string(verb_str) == "low") {
- setVerbosity(Low_Verb);
- } else if (string(verb_str) == "med") {
- setVerbosity(Med_Verb);
- } else if (string(verb_str) == "high") {
- setVerbosity(High_Verb);
- } else {
- cerr << "Error: unrecognized verbosity (use none, low, med, high): " << verb_str << endl;
- return true; // error
- }
- return false; // no error
+ string verb = verb_str ? verb_str : "";
+ if (verb == "none") {
+ setVerbosity(No_Verb);
+ } else if (verb == "low") {
+ setVerbosity(Low_Verb);
+ } else if (verb == "med") {
+ setVerbosity(Med_Verb);
+ } else if (verb == "high") {
+ setVerbosity(High_Verb);
+ } else {
+ cerr << "Error: unrecognized verbosity (use none, low, med, high): "
+ << verb << endl;
+ return true; // error
+ }
+ return false; // no error
}
-bool Debug::checkFilter(char ch)
+bool
+Debug::checkFilter(char ch)
{
- for (int i=0; i<NUMBER_OF_COMPS; i++) {
- // Look at all components to find a character match
- if (debugComponents[i].ch == ch) {
- // We found a match - return no error
- return false; // no error
+ for (int i = 0; i < NUMBER_OF_COMPS; i++) {
+ // Look at all components to find a character match
+ if (debugComponents[i].ch == ch) {
+ // We found a match - return no error
+ return false; // no error
+ }
}
- }
- return true; // error
+ return true; // error
}
-bool Debug::checkFilterString(const char *filter_str)
+bool
+Debug::checkFilterString(const char *filter_str)
{
- if (filter_str == NULL) {
- cerr << "Error: unrecognized component filter: NULL" << endl;
- return true; // error
- }
+ if (filter_str == NULL) {
+ cerr << "Error: unrecognized component filter: NULL" << endl;
+ return true; // error
+ }
- // check for default filter ("none") before reporting RUBY_DEBUG error
- if ( (string(filter_str) == "none") ) {
- return false; // no error
- }
+ // check for default filter ("none") before reporting RUBY_DEBUG error
+ if (string(filter_str) == "none") {
+ return false; // no error
+ }
- if (RUBY_DEBUG == false) {
- cerr << "Error: User specified set of debug components, but the RUBY_DEBUG compile-time flag is false." << endl;
- cerr << "Solution: Re-compile with RUBY_DEBUG set to true." << endl;
- return true; // error
- }
+ if (RUBY_DEBUG == false) {
+ cerr << "Error: User specified set of debug components, but the "
+ << "RUBY_DEBUG compile-time flag is false." << endl
+ << "Solution: Re-compile with RUBY_DEBUG set to true." << endl;
+ return true; // error
+ }
- if ( (string(filter_str) == "all") ) {
- return false; // no error
- }
+ if (string(filter_str) == "all") {
+ return false; // no error
+ }
- // scan string checking each character
- for (unsigned int i = 0; i < strlen(filter_str); i++) {
- bool unrecognized = checkFilter( filter_str[i] );
- if (unrecognized == true) {
- return true; // error
+ // scan string checking each character
+ for (unsigned int i = 0; i < strlen(filter_str); i++) {
+ bool unrecognized = checkFilter(filter_str[i]);
+ if (unrecognized == true) {
+ return true; // error
+ }
}
- }
- return false; // no error
+ return false; // no error
}
-bool Debug::setFilterString(const char *filter_str)
+bool
+Debug::setFilterString(const char *filter_str)
{
- if (checkFilterString(filter_str)) {
- return true; // error
- }
-
- if (string(filter_str) == "all" ) {
- allFilter();
- } else if (string(filter_str) == "none") {
- clearFilter();
- } else {
- // scan string adding to bit mask for each component which is present
- for (unsigned int i = 0; i < strlen(filter_str); i++) {
- bool error = addFilter( filter_str[i] );
- if (error) {
+ if (checkFilterString(filter_str)) {
return true; // error
- }
}
- }
- return false; // no error
+
+ if (string(filter_str) == "all" ) {
+ allFilter();
+ } else if (string(filter_str) == "none") {
+ clearFilter();
+ } else {
+ // scan string adding to bit mask for each component which is present
+ for (unsigned int i = 0; i < strlen(filter_str); i++) {
+ bool error = addFilter( filter_str[i] );
+ if (error) {
+ return true; // error
+ }
+ }
+ }
+ return false; // no error
}
-bool Debug::addFilter(char ch)
+bool
+Debug::addFilter(char ch)
{
- for (int i=0; i<NUMBER_OF_COMPS; i++) {
- // Look at all components to find a character match
- if (debugComponents[i].ch == ch) {
- // We found a match - update the filter bit mask
- cout << " Debug: Adding to filter: '" << ch << "' (" << debugComponents[i].desc << ")" << endl;
- m_filter |= (1 << i);
- return false; // no error
+ for (int i = 0; i < NUMBER_OF_COMPS; i++) {
+ // Look at all components to find a character match
+ if (debugComponents[i].ch == ch) {
+ // We found a match - update the filter bit mask
+ cout << " Debug: Adding to filter: '" << ch << "' ("
+ << debugComponents[i].desc << ")" << endl;
+ m_filter |= (1 << i);
+ return false; // no error
+ }
}
- }
- // We didn't find the character
- cerr << "Error: unrecognized component filter: " << ch << endl;
- usageInstructions();
- return true; // error
+ // We didn't find the character
+ cerr << "Error: unrecognized component filter: " << ch << endl;
+ usageInstructions();
+ return true; // error
}
-void Debug::clearFilter()
+void
+Debug::clearFilter()
{
- m_filter = 0;
+ m_filter = 0;
}
void Debug::allFilter()
{
- m_filter = ~0;
+ m_filter = ~0;
}
-void Debug::usageInstructions(void)
+void
+Debug::usageInstructions(void)
{
- cerr << "Debug components: " << endl;
- for (int i=0; i<NUMBER_OF_COMPS; i++) {
- cerr << " " << debugComponents[i].ch << ": " << debugComponents[i].desc << endl;
- }
+ cerr << "Debug components: " << endl;
+ for (int i = 0; i < NUMBER_OF_COMPS; i++) {
+ cerr << " " << debugComponents[i].ch << ": "
+ << debugComponents[i].desc << endl;
+ }
}
-void Debug::print(ostream& out) const
+void
+Debug::print(ostream& out) const
{
- out << "[Debug]" << endl;
+ out << "[Debug]" << endl;
}
-void Debug::setDebugOutputFile (const char * filename)
+void
+Debug::setDebugOutputFile (const char *filename)
{
- if ( (filename == NULL) ||
- (!strcmp(filename, "none")) ) {
- debug_cout_ptr = &cout;
- return;
- }
-
- if (m_fout.is_open() ) {
- m_fout.close ();
- }
- m_fout.open (filename, ios::out);
- if (! m_fout.is_open() ) {
- cerr << "setDebugOutputFile: can't open file " << filename << endl;
- }
- else {
- debug_cout_ptr = &m_fout;
- }
-}
+ if (filename == NULL || !strcmp(filename, "none")) {
+ debug_cout_ptr = &cout;
+ return;
+ }
-void Debug::closeDebugOutputFile ()
-{
- if (m_fout.is_open() ) {
- m_fout.close ();
- debug_cout_ptr = &cout;
- }
+ if (m_fout.is_open()) {
+ m_fout.close();
+ }
+ m_fout.open(filename, ios::out);
+ if (!m_fout.is_open()) {
+ cerr << "setDebugOutputFile: can't open file " << filename << endl;
+ } else {
+ debug_cout_ptr = &m_fout;
+ }
}
-void Debug::debugMsg( const char *fmt, ... )
+void
+Debug::closeDebugOutputFile ()
{
- va_list args;
-
- // you could check validDebug() here before printing the message
- va_start(args, fmt);
- vfprintf(stdout, fmt, args);
- va_end(args);
+ if (m_fout.is_open()) {
+ m_fout.close ();
+ debug_cout_ptr = &cout;
+ }
}
-/*
-void DEBUG_OUT( const char* fmt, ...) {
- if (RUBY_DEBUG) {
- cout << "Debug: in fn "
- << __PRETTY_FUNCTION__
- << " in " << __FILE__ << ":"
- << __LINE__ << ": ";
+void
+Debug::debugMsg( const char *fmt, ...)
+{
va_list args;
- va_start(args, fmt);
- vfprintf(stdout, fmt, args);
- va_end(args);
- }
-}
-void ERROR_OUT( const char* fmt, ... ) {
- if (ERROR_MESSAGE_FLAG) {
- cout << "error: in fn "
- << __PRETTY_FUNCTION__ << " in "
- << __FILE__ << ":"
- << __LINE__ << ": ";
- va_list args;
+ // you could check validDebug() here before printing the message
va_start(args, fmt);
vfprintf(stdout, fmt, args);
va_end(args);
- }
- assert(0);
}
-*/
-
Debug *
RubyDebugParams::create()
diff --git a/src/mem/ruby/common/Debug.hh b/src/mem/ruby/common/Debug.hh
index a7b1a15d1..a2344e82d 100644
--- a/src/mem/ruby/common/Debug.hh
+++ b/src/mem/ruby/common/Debug.hh
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,12 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * $Id$
- */
-
-#ifndef __MEM_RUBY_DEBUG_HH__
-#define __MEM_RUBY_DEBUG_HH__
+#ifndef __MEM_RUBY_COMMON_DEBUG_HH__
+#define __MEM_RUBY_COMMON_DEBUG_HH__
#include <unistd.h>
@@ -75,68 +70,55 @@ enum DebugComponents
enum PriorityLevel {HighPrio, MedPrio, LowPrio};
enum VerbosityLevel {No_Verb, Low_Verb, Med_Verb, High_Verb};
-class Debug : public SimObject {
-public:
- // Constructors
+class Debug : public SimObject
+{
+ public:
typedef RubyDebugParams Params;
- Debug(const Params *p);
-
- // Destructor
- ~Debug();
-
- // Public Methods
- static bool getProtocolTrace() { return m_protocol_trace; }
- bool validDebug(int module, PriorityLevel priority);
- void printVerbosity(std::ostream& out) const;
- void setVerbosity(VerbosityLevel vb);
- static bool checkVerbosityString(const char *verb_str);
- bool setVerbosityString(const char *);
- VerbosityLevel getVerbosity() const { return m_verbosityLevel; }
- void setFilter(int);
- static bool checkFilter( char);
- static bool checkFilterString(const char *);
- bool setFilterString(const char *);
- void setDebugTime(Time);
- Time getDebugTime() const { return m_starting_cycle; }
- bool addFilter(char);
- void clearFilter();
- void allFilter();
- void print(std::ostream& out) const;
- /* old school debugging "vararg": sends messages to screen and log */
- void debugMsg( const char *fmt, ... );
-
- void setDebugOutputFile (const char * filename);
- void closeDebugOutputFile ();
- static void usageInstructions(void);
-
-private:
- // Private Methods
-
- // Private copy constructor and assignment operator
- Debug(const Debug& obj);
- Debug& operator=(const Debug& obj);
-
- // Data Members (m_ prefix)
- static bool m_protocol_trace;
- VerbosityLevel m_verbosityLevel;
- int m_filter;
- Time m_starting_cycle;
-
- std::fstream m_fout;
+ Debug(const Params *p);
+ ~Debug();
+
+ static bool getProtocolTrace() { return m_protocol_trace; }
+ bool validDebug(int module, PriorityLevel priority);
+ void printVerbosity(std::ostream& out) const;
+ void setVerbosity(VerbosityLevel vb);
+ bool setVerbosityString(const char *);
+ VerbosityLevel getVerbosity() const { return m_verbosityLevel; }
+ void setFilter(int);
+ static bool checkFilter( char);
+ static bool checkFilterString(const char *);
+ bool setFilterString(const char *);
+ void setDebugTime(Time);
+ Time getDebugTime() const { return m_starting_cycle; }
+ bool addFilter(char);
+ void clearFilter();
+ void allFilter();
+ void print(std::ostream& out) const;
+ /* old school debugging "vararg": sends messages to screen and log */
+ void debugMsg(const char *fmt, ...);
+
+ void setDebugOutputFile (const char * filename);
+ void closeDebugOutputFile ();
+ static void usageInstructions(void);
+
+ private:
+ // Private copy constructor and assignment operator
+ Debug(const Debug& obj);
+ Debug& operator=(const Debug& obj);
+
+ static bool m_protocol_trace;
+ VerbosityLevel m_verbosityLevel;
+ int m_filter;
+ Time m_starting_cycle;
+
+ std::fstream m_fout;
};
-// Output operator declaration
-std::ostream& operator<<(std::ostream& out, const Debug& obj);
-
-// ******************* Definitions *******************
-
-// Output operator definition
-extern inline
-std::ostream& operator<<(std::ostream& out, const Debug& obj)
+inline std::ostream&
+operator<<(std::ostream& out, const Debug& obj)
{
- obj.print(out);
- out << std::flush;
- return out;
+ obj.print(out);
+ out << std::flush;
+ return out;
}
const bool ERROR_MESSAGE_FLAG = true;
@@ -151,178 +133,168 @@ const bool ASSERT_FLAG = true;
#undef assert
#define assert(EXPR) ASSERT(EXPR)
#undef ASSERT
-#define ASSERT(EXPR)\
-{\
- using namespace std;\
- if (ASSERT_FLAG) {\
- if (!(EXPR)) {\
- cerr << "failed assertion '"\
- << #EXPR << "' at fn "\
- << __PRETTY_FUNCTION__ << " in "\
- << __FILE__ << ":"\
- << __LINE__ << endl << flush;\
- (* debug_cout_ptr) << "failed assertion '"\
- << #EXPR << "' at fn "\
- << __PRETTY_FUNCTION__ << " in "\
- << __FILE__ << ":"\
- << __LINE__ << endl << flush;\
- if(isatty(STDIN_FILENO)) {\
- cerr << "At this point you might want to attach a debug to ";\
- cerr << "the running and get to the" << endl;\
- cerr << "crash site; otherwise press enter to continue" << endl;\
- cerr << "PID: " << getpid();\
- cerr << endl << flush; \
- char c; \
- cin.get(c); \
- }\
- abort();\
- }\
- }\
-}
-
-#define BREAK(X)\
-{\
- using namespace std;\
- cerr << "breakpoint '"\
- << #X << "' reached at fn "\
- << __PRETTY_FUNCTION__ << " in "\
- << __FILE__ << ":"\
- << __LINE__ << endl << flush;\
- if(isatty(STDIN_FILENO)) {\
- cerr << "press enter to continue" << endl;\
- cerr << "PID: " << getpid();\
- cerr << endl << flush; \
- char c; \
- cin.get(c); \
- }\
-}
-
-#define ERROR_MSG(MESSAGE)\
-{\
- using namespace std;\
- if (ERROR_MESSAGE_FLAG) {\
- cerr << "Fatal Error: in fn "\
- << __PRETTY_FUNCTION__ << " in "\
- << __FILE__ << ":"\
- << __LINE__ << ": "\
- << (MESSAGE) << endl << flush;\
- (* debug_cout_ptr) << "Fatal Error: in fn "\
- << __PRETTY_FUNCTION__ << " in "\
- << __FILE__ << ":"\
- << __LINE__ << ": "\
- << (MESSAGE) << endl << flush;\
- abort();\
- }\
-}
-
-#define WARN_MSG(MESSAGE)\
-{\
- using namespace std;\
- if (WARNING_MESSAGE_FLAG) {\
- cerr << "Warning: in fn "\
- << __PRETTY_FUNCTION__ << " in "\
- << __FILE__ << ":"\
- << __LINE__ << ": "\
- << (MESSAGE) << endl << flush;\
- (* debug_cout_ptr) << "Warning: in fn "\
- << __PRETTY_FUNCTION__ << " in "\
- << __FILE__ << ":"\
- << __LINE__ << ": "\
- << (MESSAGE) << endl << flush;\
- }\
-}
-
-#define WARN_EXPR(EXPR)\
-{\
- using namespace std;\
- if (WARNING_MESSAGE_FLAG) {\
- cerr << "Warning: in fn "\
- << __PRETTY_FUNCTION__ << " in "\
- << __FILE__ << ":"\
- << __LINE__ << ": "\
- << #EXPR << " is "\
- << (EXPR) << endl << flush;\
- (* debug_cout_ptr) << "Warning: in fn "\
- << __PRETTY_FUNCTION__ << " in "\
- << __FILE__ << ":"\
- << __LINE__ << ": "\
- << #EXPR << " is "\
- << (EXPR) << endl << flush;\
- }\
-}
-
-#define DEBUG_MSG(module, priority, MESSAGE)\
-{\
- using namespace std;\
- if (RUBY_DEBUG) {\
- if (g_debug_ptr->validDebug(module, priority)) {\
- (* debug_cout_ptr) << "Debug: in fn "\
- << __PRETTY_FUNCTION__\
- << " in " << __FILE__ << ":"\
- << __LINE__ << ": "\
- << (MESSAGE) << endl << flush;\
- }\
- }\
-}
-
-#define DEBUG_EXPR(module, priority, EXPR)\
-{\
- using namespace std;\
- if (RUBY_DEBUG) {\
- if (g_debug_ptr->validDebug(module, priority)) {\
- (* debug_cout_ptr) << "Debug: in fn "\
- << __PRETTY_FUNCTION__\
- << " in " << __FILE__ << ":"\
- << __LINE__ << ": "\
- << #EXPR << " is "\
- << (EXPR) << endl << flush;\
- }\
- }\
-}
-
-#define DEBUG_NEWLINE(module, priority)\
-{\
- using namespace std;\
- if (RUBY_DEBUG) {\
- if (g_debug_ptr->validDebug(module, priority)) {\
- (* debug_cout_ptr) << endl << flush;\
- }\
- }\
-}
-
-#define DEBUG_SLICC(priority, LINE, MESSAGE)\
-{\
- using namespace std;\
- if (RUBY_DEBUG) {\
- if (g_debug_ptr->validDebug(SLICC_COMP, priority)) {\
- (* debug_cout_ptr) << (LINE) << (MESSAGE) << endl << flush;\
- }\
- }\
-}
-
-#define DEBUG_OUT( rest... ) \
-{\
- using namespace std;\
- if (RUBY_DEBUG) {\
- cout << "Debug: in fn "\
- << __PRETTY_FUNCTION__\
- << " in " << __FILE__ << ":"\
- << __LINE__ << ": "; \
- g_debug_ptr->debugMsg(rest); \
- }\
-}
-
-#define ERROR_OUT( rest... ) \
-{\
- using namespace std;\
- if (ERROR_MESSAGE_FLAG) {\
- cout << "error: in fn "\
- << __PRETTY_FUNCTION__ << " in "\
- << __FILE__ << ":"\
- << __LINE__ << ": ";\
- g_debug_ptr->debugMsg(rest); \
- }\
-}
-
-#endif //DEBUG_H
+#define ASSERT(EXPR) do { \
+ using namespace std; \
+ if (ASSERT_FLAG) { \
+ if (!(EXPR)) { \
+ cerr << "failed assertion '" \
+ << #EXPR << "' at fn " \
+ << __PRETTY_FUNCTION__ << " in " \
+ << __FILE__ << ":" \
+ << __LINE__ << endl << flush; \
+ (*debug_cout_ptr) << "failed assertion '" \
+ << #EXPR << "' at fn " \
+ << __PRETTY_FUNCTION__ << " in " \
+ << __FILE__ << ":" \
+ << __LINE__ << endl << flush; \
+ if (isatty(STDIN_FILENO)) { \
+ cerr << "At this point you might want to attach a debug to " \
+ << "the running and get to the" << endl \
+ << "crash site; otherwise press enter to continue" \
+ << endl \
+ << "PID: " << getpid() \
+ << endl << flush; \
+ char c; \
+ cin.get(c); \
+ } \
+ abort(); \
+ } \
+ } \
+} while (0)
+
+#define BREAK(X) do { \
+ using namespace std; \
+ cerr << "breakpoint '" \
+ << #X << "' reached at fn " \
+ << __PRETTY_FUNCTION__ << " in " \
+ << __FILE__ << ":" \
+ << __LINE__ << endl << flush; \
+ if(isatty(STDIN_FILENO)) { \
+ cerr << "press enter to continue" << endl; \
+ cerr << "PID: " << getpid(); \
+ cerr << endl << flush; \
+ char c; \
+ cin.get(c); \
+ } \
+} while (0)
+
+#define ERROR_MSG(MESSAGE) do { \
+ using namespace std; \
+ if (ERROR_MESSAGE_FLAG) { \
+ cerr << "Fatal Error: in fn " \
+ << __PRETTY_FUNCTION__ << " in " \
+ << __FILE__ << ":" \
+ << __LINE__ << ": " \
+ << (MESSAGE) << endl << flush; \
+ (* debug_cout_ptr) << "Fatal Error: in fn " \
+ << __PRETTY_FUNCTION__ << " in " \
+ << __FILE__ << ":" \
+ << __LINE__ << ": " \
+ << (MESSAGE) << endl << flush; \
+ abort(); \
+ } \
+} while(0)
+
+#define WARN_MSG(MESSAGE) do { \
+ using namespace std; \
+ if (WARNING_MESSAGE_FLAG) { \
+ cerr << "Warning: in fn " \
+ << __PRETTY_FUNCTION__ << " in " \
+ << __FILE__ << ":" \
+ << __LINE__ << ": " \
+ << (MESSAGE) << endl << flush; \
+ (* debug_cout_ptr) << "Warning: in fn " \
+ << __PRETTY_FUNCTION__ << " in " \
+ << __FILE__ << ":" \
+ << __LINE__ << ": " \
+ << (MESSAGE) << endl << flush; \
+ } \
+} while (0)
+
+#define WARN_EXPR(EXPR) do { \
+ using namespace std; \
+ if (WARNING_MESSAGE_FLAG) { \
+ cerr << "Warning: in fn " \
+ << __PRETTY_FUNCTION__ << " in " \
+ << __FILE__ << ":" \
+ << __LINE__ << ": " \
+ << #EXPR << " is " \
+ << (EXPR) << endl << flush; \
+ (* debug_cout_ptr) << "Warning: in fn " \
+ << __PRETTY_FUNCTION__ << " in " \
+ << __FILE__ << ":" \
+ << __LINE__ << ": " \
+ << #EXPR << " is " \
+ << (EXPR) << endl << flush; \
+ } \
+} while (0)
+
+#define DEBUG_MSG(module, priority, MESSAGE) do { \
+ using namespace std; \
+ if (RUBY_DEBUG) { \
+ if (g_debug_ptr->validDebug(module, priority)) { \
+ (* debug_cout_ptr) << "Debug: in fn " \
+ << __PRETTY_FUNCTION__ \
+ << " in " << __FILE__ << ":" \
+ << __LINE__ << ": " \
+ << (MESSAGE) << endl << flush; \
+ } \
+ } \
+} while (0)
+
+#define DEBUG_EXPR(module, priority, EXPR) do { \
+ using namespace std; \
+ if (RUBY_DEBUG) { \
+ if (g_debug_ptr->validDebug(module, priority)) { \
+ (* debug_cout_ptr) << "Debug: in fn " \
+ << __PRETTY_FUNCTION__ \
+ << " in " << __FILE__ << ":" \
+ << __LINE__ << ": " \
+ << #EXPR << " is " \
+ << (EXPR) << endl << flush; \
+ } \
+ } \
+} while (0)
+
+#define DEBUG_NEWLINE(module, priority) do { \
+ using namespace std; \
+ if (RUBY_DEBUG) { \
+ if (g_debug_ptr->validDebug(module, priority)) { \
+ (* debug_cout_ptr) << endl << flush; \
+ } \
+ } \
+} while (0)
+
+#define DEBUG_SLICC(priority, LINE, MESSAGE) do { \
+ using namespace std; \
+ if (RUBY_DEBUG) { \
+ if (g_debug_ptr->validDebug(SLICC_COMP, priority)) { \
+ (* debug_cout_ptr) << (LINE) << (MESSAGE) << endl << flush; \
+ } \
+ } \
+} while (0)
+
+#define DEBUG_OUT(rest... ) do { \
+ using namespace std; \
+ if (RUBY_DEBUG) { \
+ cout << "Debug: in fn " \
+ << __PRETTY_FUNCTION__ \
+ << " in " << __FILE__ << ":" \
+ << __LINE__ << ": "; \
+ g_debug_ptr->debugMsg(rest); \
+ } \
+} while (0)
+
+#define ERROR_OUT( rest... ) do { \
+ using namespace std; \
+ if (ERROR_MESSAGE_FLAG) { \
+ cout << "error: in fn " \
+ << __PRETTY_FUNCTION__ << " in " \
+ << __FILE__ << ":" \
+ << __LINE__ << ": "; \
+ g_debug_ptr->debugMsg(rest); \
+ } \
+} while (0)
+
+#endif // __MEM_RUBY_COMMON_DEBUG_HH__
diff --git a/src/mem/ruby/common/Driver.cc b/src/mem/ruby/common/Driver.cc
index 2d6034b02..085044c7d 100644
--- a/src/mem/ruby/common/Driver.cc
+++ b/src/mem/ruby/common/Driver.cc
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,6 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <cassert>
+
#include "mem/ruby/common/Driver.hh"
Driver::Driver()
@@ -37,3 +38,40 @@ Driver::Driver()
Driver::~Driver()
{
}
+
+integer_t
+Driver::getInstructionCount(int procID) const
+{
+ return 1;
+}
+
+integer_t
+Driver::getCycleCount(int procID) const
+{
+ return 1;
+}
+
+void
+Driver::addThreadDependency(int procID, int requestor_thread,
+ int conflict_thread) const
+{
+ assert(0);
+}
+
+void
+Driver::printDebug()
+{}
+
+integer_t
+Driver::readPhysicalMemory(int procID, physical_address_t address, int len)
+{
+ assert(0);
+ return 0;
+}
+
+void
+Driver::writePhysicalMemory(int procID, physical_address_t address,
+ integer_t value, int len)
+{
+ assert(0);
+}
diff --git a/src/mem/ruby/common/Driver.hh b/src/mem/ruby/common/Driver.hh
index 9d17fcadb..f5f2f9c58 100644
--- a/src/mem/ruby/common/Driver.hh
+++ b/src/mem/ruby/common/Driver.hh
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,58 +26,40 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * $Id$
- *
- * Description:
- *
- */
-
-#ifndef DRIVER_H
-#define DRIVER_H
+#ifndef __MEM_RUBY_COMMON_DRIVER_HH__
+#define __MEM_RUBY_COMMON_DRIVER_HH__
-#include "mem/ruby/common/Global.hh"
+#include "mem/ruby/common/Address.hh"
#include "mem/ruby/common/Consumer.hh"
+#include "mem/ruby/common/Global.hh"
#include "mem/ruby/system/NodeID.hh"
-#include "mem/ruby/common/Address.hh"
-
-
-class Driver {
-public:
- // Constructors
- Driver();
-
- // Destructor
- virtual ~Driver() = 0;
-
- // Public Methods
- virtual void get_network_config() {}
- virtual void dmaHitCallback() {};
- virtual void hitCallback(int64_t id) = 0; // Called by sequencer
- virtual void go() = 0;
- virtual integer_t getInstructionCount(int procID) const { return 1; }
- virtual integer_t getCycleCount(int procID) const { return 1; }
- virtual void addThreadDependency(int procID, int requestor_thread, int conflict_thread) const { assert(0);}
- virtual void printDebug(){} //called by Sequencer
-
- virtual void printStats(ostream& out) const = 0;
- virtual void clearStats() = 0;
-
- virtual void printConfig(ostream& out) const = 0;
-
-
- virtual integer_t readPhysicalMemory(int procID, physical_address_t address,
- int len ){ ASSERT(0); return 0; }
-
- virtual void writePhysicalMemory( int procID, physical_address_t address,
- integer_t value, int len ){ ASSERT(0); }
-
-protected:
- // accessible by subclasses
-
-private:
- // inaccessible by subclasses
+class Driver
+{
+ public:
+ Driver();
+ virtual ~Driver() = 0;
+
+ // Public Methods
+ virtual void get_network_config() {}
+ virtual void dmaHitCallback() {};
+ virtual void hitCallback(int64_t id) = 0; // Called by sequencer
+ virtual void go() = 0;
+ virtual integer_t getInstructionCount(int procID) const;
+ virtual integer_t getCycleCount(int procID) const;
+ virtual void addThreadDependency(int procID, int requestor_thread,
+ int conflict_thread) const;
+ virtual void printDebug(); //called by Sequencer
+
+ virtual void printStats(ostream& out) const = 0;
+ virtual void clearStats() = 0;
+
+ virtual void printConfig(ostream& out) const = 0;
+
+ virtual integer_t readPhysicalMemory(int procID, physical_address_t addr,
+ int len);
+ virtual void writePhysicalMemory(int procID, physical_address_t addr,
+ integer_t value, int len);
};
-#endif //DRIVER_H
+#endif //__MEM_RUBY_COMMON_DRIVER_HH__
diff --git a/src/mem/ruby/common/Global.cc b/src/mem/ruby/common/Global.cc
index 7c7cab1e8..f780707e2 100644
--- a/src/mem/ruby/common/Global.cc
+++ b/src/mem/ruby/common/Global.cc
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
diff --git a/src/mem/ruby/common/Global.hh b/src/mem/ruby/common/Global.hh
index 16465656d..de96c5a6b 100644
--- a/src/mem/ruby/common/Global.hh
+++ b/src/mem/ruby/common/Global.hh
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,42 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * $Id$
- *
- * */
-
-#ifndef GLOBAL_H
-#define GLOBAL_H
-
-/*
-#ifdef SINGLE_LEVEL_CACHE
-const bool TWO_LEVEL_CACHE = false;
-#define L1I_CACHE_MEMBER_VARIABLE m_L1Cache_cacheMemory_vec[m_version] // currently all protocols require L1s == nodes
-#define L1D_CACHE_MEMBER_VARIABLE m_L1Cache_cacheMemory_vec[m_version] // "
-#define L2_CACHE_MEMBER_VARIABLE m_L1Cache_cacheMemory_vec[m_version] // "
-#define L2_CACHE_VARIABLE m_L1Cache_cacheMemory_vec
-#else
-const bool TWO_LEVEL_CACHE = true;
-#ifdef IS_CMP
-#define L1I_CACHE_MEMBER_VARIABLE m_L1Cache_L1IcacheMemory_vec[m_version]
-#define L1D_CACHE_MEMBER_VARIABLE m_L1Cache_L1DcacheMemory_vec[m_version]
-#define L2_CACHE_MEMBER_VARIABLE m_L2Cache_L2cacheMemory_vec[m_version]
-#define L2_CACHE_VARIABLE m_L2Cache_L2cacheMemory_vec
-#else // not IS_CMP
-#define L1I_CACHE_MEMBER_VARIABLE m_L1Cache_L1IcacheMemory_vec[m_version] // currently all protocols require L1s == nodes
-#define L1D_CACHE_MEMBER_VARIABLE m_L1Cache_L1DcacheMemory_vec[m_version] // "
-// #define L2_CACHE_MEMBER_VARIABLE m_L1Cache_L2cacheMemory_vec[m_version] // old exclusive caches don't support L2s != nodes
-#define L2_CACHE_MEMBER_VARIABLE m_L1Cache_cacheMemory_vec[m_version] // old exclusive caches don't support L2s != nodes
-#define L2_CACHE_VARIABLE m_L1Cache_L2cacheMemory_vec
-#endif // IS_CMP
-#endif //SINGLE_LEVEL_CACHE
-
-#define DIRECTORY_MEMBER_VARIABLE m_Directory_directory_vec[m_version]
-#define TBE_TABLE_MEMBER_VARIABLE m_L1Cache_TBEs_vec[m_version]
-
-*/
-
+#ifndef __MEM_RUBY_COMMON_GLOBAL_HH__
+#define __MEM_RUBY_COMMON_GLOBAL_HH__
// external includes for all classes
#include "mem/ruby/common/TypeDefines.hh"
@@ -85,13 +50,12 @@ extern RubySystem* g_system_ptr;
class Debug;
extern Debug* g_debug_ptr;
-// FIXME: this is required by the contructor of Directory_Entry.hh. It can't go
-// into slicc_util.hh because it opens a can of ugly worms
+// FIXME: this is required by the contructor of Directory_Entry.hh.
+// It can't go into slicc_util.hh because it opens a can of ugly worms
extern inline int max_tokens()
{
return 1024;
}
-
-#endif //GLOBAL_H
+#endif // __MEM_RUBY_COMMON_GLOBAL_HH__
diff --git a/src/mem/ruby/common/Histogram.cc b/src/mem/ruby/common/Histogram.cc
index 2a25cfeb1..c57b55997 100644
--- a/src/mem/ruby/common/Histogram.cc
+++ b/src/mem/ruby/common/Histogram.cc
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,164 +26,169 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * $Id$
- *
- */
-
#include <cmath>
#include <iomanip>
+#include "base/intmath.hh"
#include "mem/ruby/common/Histogram.hh"
using namespace std;
Histogram::Histogram(int binsize, int bins)
{
- m_binsize = binsize;
- m_bins = bins;
- clear();
+ m_binsize = binsize;
+ m_bins = bins;
+ clear();
}
Histogram::~Histogram()
{
}
-void Histogram::clear(int binsize, int bins)
+void
+Histogram::clear(int binsize, int bins)
{
- m_binsize = binsize;
- clear(bins);
+ m_binsize = binsize;
+ clear(bins);
}
-void Histogram::clear(int bins)
+void
+Histogram::clear(int bins)
{
- m_bins = bins;
- m_largest_bin = 0;
- m_max = 0;
- m_data.setSize(m_bins);
- for (int i = 0; i < m_bins; i++) {
- m_data[i] = 0;
- }
- m_count = 0;
- m_max = 0;
-
- m_sumSamples = 0;
- m_sumSquaredSamples = 0;
+ m_bins = bins;
+ m_largest_bin = 0;
+ m_max = 0;
+ m_data.setSize(m_bins);
+ for (int i = 0; i < m_bins; i++) {
+ m_data[i] = 0;
+ }
+ m_count = 0;
+ m_max = 0;
+
+ m_sumSamples = 0;
+ m_sumSquaredSamples = 0;
}
-void Histogram::add(int64 value)
+void
+Histogram::add(int64 value)
{
- assert(value >= 0);
- m_max = max(m_max, value);
- m_count++;
-
- m_sumSamples += value;
- m_sumSquaredSamples += (value*value);
-
- int index;
- if (m_binsize == -1) {
- // This is a log base 2 histogram
- if (value == 0) {
- index = 0;
+ assert(value >= 0);
+ m_max = max(m_max, value);
+ m_count++;
+
+ m_sumSamples += value;
+ m_sumSquaredSamples += (value*value);
+
+ int index;
+ if (m_binsize == -1) {
+ // This is a log base 2 histogram
+ if (value == 0) {
+ index = 0;
+ } else {
+ index = floorLog2(value) + 1;
+ if (index >= m_data.size()) {
+ index = m_data.size() - 1;
+ }
+ }
} else {
- index = int(log(double(value))/log(2.0))+1;
- if (index >= m_data.size()) {
- index = m_data.size()-1;
- }
- }
- } else {
- // This is a linear histogram
- while (m_max >= (m_bins * m_binsize)) {
- for (int i = 0; i < m_bins/2; i++) {
- m_data[i] = m_data[i*2] + m_data[i*2 + 1];
- }
- for (int i = m_bins/2; i < m_bins; i++) {
- m_data[i] = 0;
- }
- m_binsize *= 2;
+ // This is a linear histogram
+ while (m_max >= (m_bins * m_binsize)) {
+ for (int i = 0; i < m_bins/2; i++) {
+ m_data[i] = m_data[i*2] + m_data[i*2 + 1];
+ }
+ for (int i = m_bins/2; i < m_bins; i++) {
+ m_data[i] = 0;
+ }
+ m_binsize *= 2;
+ }
+ index = value/m_binsize;
}
- index = value/m_binsize;
- }
- assert(index >= 0);
- m_data[index]++;
- m_largest_bin = max(m_largest_bin, index);
+ assert(index >= 0);
+ m_data[index]++;
+ m_largest_bin = max(m_largest_bin, index);
}
-void Histogram::add(const Histogram& hist)
+void
+Histogram::add(const Histogram& hist)
{
- assert(hist.getBins() == m_bins);
- assert(hist.getBinSize() == -1); // assume log histogram
- assert(m_binsize == -1);
-
- for (int j = 0; j < hist.getData(0); j++) {
- add(0);
- }
+ assert(hist.getBins() == m_bins);
+ assert(hist.getBinSize() == -1); // assume log histogram
+ assert(m_binsize == -1);
- for (int i = 1; i < m_bins; i++) {
- for (int j = 0; j < hist.getData(i); j++) {
- add(1<<(i-1)); // account for the + 1 index
+ for (int j = 0; j < hist.getData(0); j++) {
+ add(0);
}
- }
+ for (int i = 1; i < m_bins; i++) {
+ for (int j = 0; j < hist.getData(i); j++) {
+ add(1<<(i-1)); // account for the + 1 index
+ }
+ }
}
// Computation of standard deviation of samples a1, a2, ... aN
// variance = [SUM {ai^2} - (SUM {ai})^2/N]/(N-1)
// std deviation equals square root of variance
-double Histogram::getStandardDeviation() const
+double
+Histogram::getStandardDeviation() const
{
- double variance;
- if(m_count > 1){
- variance = (double)(m_sumSquaredSamples - m_sumSamples*m_sumSamples/m_count)/(m_count - 1);
- } else {
- return 0;
- }
- return sqrt(variance);
+ if (m_count <= 1)
+ return 0.0;
+
+ double variance =
+ (double)(m_sumSquaredSamples - m_sumSamples * m_sumSamples / m_count)
+ / (m_count - 1);
+ return sqrt(variance);
}
-void Histogram::print(ostream& out) const
+void
+Histogram::print(ostream& out) const
{
- printWithMultiplier(out, 1.0);
+ printWithMultiplier(out, 1.0);
}
-void Histogram::printPercent(ostream& out) const
+void
+Histogram::printPercent(ostream& out) const
{
- if (m_count == 0) {
- printWithMultiplier(out, 0.0);
- } else {
- printWithMultiplier(out, 100.0/double(m_count));
- }
+ if (m_count == 0) {
+ printWithMultiplier(out, 0.0);
+ } else {
+ printWithMultiplier(out, 100.0 / double(m_count));
+ }
}
-void Histogram::printWithMultiplier(ostream& out, double multiplier) const
+void
+Histogram::printWithMultiplier(ostream& out, double multiplier) const
{
- if (m_binsize == -1) {
- out << "[binsize: log2 ";
- } else {
- out << "[binsize: " << m_binsize << " ";
- }
- out << "max: " << m_max << " ";
- out << "count: " << m_count << " ";
- // out << "total: " << m_sumSamples << " ";
- if (m_count == 0) {
- out << "average: NaN |";
- out << "standard deviation: NaN |";
- } else {
- out << "average: " << setw(5) << ((double) m_sumSamples)/m_count << " | ";
- out << "standard deviation: " << getStandardDeviation() << " |";
- }
- for (int i = 0; i < m_bins && i <= m_largest_bin; i++) {
- if (multiplier == 1.0) {
- out << " " << m_data[i];
+ if (m_binsize == -1) {
+ out << "[binsize: log2 ";
+ } else {
+ out << "[binsize: " << m_binsize << " ";
+ }
+ out << "max: " << m_max << " ";
+ out << "count: " << m_count << " ";
+ // out << "total: " << m_sumSamples << " ";
+ if (m_count == 0) {
+ out << "average: NaN |";
+ out << "standard deviation: NaN |";
} else {
- out << " " << double(m_data[i]) * multiplier;
+ out << "average: " << setw(5) << ((double) m_sumSamples)/m_count
+ << " | ";
+ out << "standard deviation: " << getStandardDeviation() << " |";
+ }
+ for (int i = 0; i < m_bins && i <= m_largest_bin; i++) {
+ if (multiplier == 1.0) {
+ out << " " << m_data[i];
+ } else {
+ out << " " << double(m_data[i]) * multiplier;
+ }
}
- }
- out << " ]";
+ out << " ]";
}
-bool node_less_then_eq(const Histogram* n1, const Histogram* n2)
+bool
+node_less_then_eq(const Histogram* n1, const Histogram* n2)
{
- return (n1->size() > n2->size());
+ return (n1->size() > n2->size());
}
diff --git a/src/mem/ruby/common/Histogram.hh b/src/mem/ruby/common/Histogram.hh
index 64247d64a..e5cd211d6 100644
--- a/src/mem/ruby/common/Histogram.hh
+++ b/src/mem/ruby/common/Histogram.hh
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,80 +26,57 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * $Id$
- *
- * Description: The histogram class implements a simple histogram
- *
- */
-
-#ifndef HISTOGRAM_H
-#define HISTOGRAM_H
+#ifndef __MEM_RUBY_COMMON_HISTOGRAM_HH__
+#define __MEM_RUBY_COMMON_HISTOGRAM_HH__
#include <iostream>
#include "mem/ruby/common/Global.hh"
#include "mem/gems_common/Vector.hh"
-class Histogram {
-public:
- // Constructors
- Histogram(int binsize = 1, int bins = 50);
-
- // Destructor
- ~Histogram();
-
- // Public Methods
-
- void add(int64 value);
- void add(const Histogram& hist);
- void clear() { clear(m_bins); }
- void clear(int bins);
- void clear(int binsize, int bins);
- int64 size() const { return m_count; }
- int getBins() const { return m_bins; }
- int getBinSize() const { return m_binsize; }
- int64 getTotal() const { return m_sumSamples; }
- int64 getData(int index) const { return m_data[index]; }
+class Histogram
+{
+ public:
+ Histogram(int binsize = 1, int bins = 50);
+ ~Histogram();
+
+ void add(int64 value);
+ void add(const Histogram& hist);
+ void clear() { clear(m_bins); }
+ void clear(int bins);
+ void clear(int binsize, int bins);
+ int64 size() const { return m_count; }
+ int getBins() const { return m_bins; }
+ int getBinSize() const { return m_binsize; }
+ int64 getTotal() const { return m_sumSamples; }
+ int64 getData(int index) const { return m_data[index]; }
+
+ void printWithMultiplier(std::ostream& out, double multiplier) const;
+ void printPercent(std::ostream& out) const;
+ void print(std::ostream& out) const;
- void printWithMultiplier(std::ostream& out, double multiplier) const;
- void printPercent(std::ostream& out) const;
- void print(std::ostream& out) const;
private:
- // Private Methods
-
- // Private copy constructor and assignment operator
- // Histogram(const Histogram& obj);
- // Histogram& operator=(const Histogram& obj);
+ Vector<int64> m_data;
+ int64 m_max; // the maximum value seen so far
+ int64 m_count; // the number of elements added
+ int m_binsize; // the size of each bucket
+ int m_bins; // the number of buckets
+ int m_largest_bin; // the largest bin used
- // Data Members (m_ prefix)
- Vector<int64> m_data;
- int64 m_max; // the maximum value seen so far
- int64 m_count; // the number of elements added
- int m_binsize; // the size of each bucket
- int m_bins; // the number of buckets
- int m_largest_bin; // the largest bin used
+ int64 m_sumSamples; // the sum of all samples
+ int64 m_sumSquaredSamples; // the sum of the square of all samples
- int64 m_sumSamples; // the sum of all samples
- int64 m_sumSquaredSamples; // the sum of the square of all samples
-
- double getStandardDeviation() const;
+ double getStandardDeviation() const;
};
bool node_less_then_eq(const Histogram* n1, const Histogram* n2);
-// Output operator declaration
-std::ostream& operator<<(std::ostream& out, const Histogram& obj);
-
-// ******************* Definitions *******************
-
-// Output operator definition
-extern inline
-std::ostream& operator<<(std::ostream& out, const Histogram& obj)
+inline std::ostream&
+operator<<(std::ostream& out, const Histogram& obj)
{
- obj.print(out);
- out << std::flush;
- return out;
+ obj.print(out);
+ out << std::flush;
+ return out;
}
-#endif //HISTOGRAM_H
+#endif // __MEM_RUBY_COMMON_HISTOGRAM_HH__
diff --git a/src/mem/ruby/common/Message.cc b/src/mem/ruby/common/Message.cc
deleted file mode 100644
index bf3307687..000000000
--- a/src/mem/ruby/common/Message.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-
-/*
- * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * $Id$
- */
-
-#include "mem/ruby/slicc_interface/Message.hh"
diff --git a/src/mem/ruby/common/NetDest.cc b/src/mem/ruby/common/NetDest.cc
index 35bb4ec43..1edf6d1a6 100644
--- a/src/mem/ruby/common/NetDest.cc
+++ b/src/mem/ruby/common/NetDest.cc
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,15 +26,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * NetDest.C
- *
- * Description: See NetDest.hh
- *
- * $Id$
- *
- */
-
#include "mem/ruby/common/NetDest.hh"
#include "mem/protocol/Protocol.hh"
@@ -44,216 +34,242 @@ NetDest::NetDest()
setSize();
}
-void NetDest::add(MachineID newElement)
+void
+NetDest::add(MachineID newElement)
{
- m_bits[vecIndex(newElement)].add(bitIndex(newElement.num));
+ m_bits[vecIndex(newElement)].add(bitIndex(newElement.num));
}
-void NetDest::addNetDest(const NetDest& netDest)
+void
+NetDest::addNetDest(const NetDest& netDest)
{
- assert(m_bits.size() == netDest.getSize());
- for (int i = 0; i < m_bits.size(); i++) {
- m_bits[i].addSet(netDest.m_bits[i]);
- }
+ assert(m_bits.size() == netDest.getSize());
+ for (int i = 0; i < m_bits.size(); i++) {
+ m_bits[i].addSet(netDest.m_bits[i]);
+ }
}
-void NetDest::addRandom()
+void
+NetDest::addRandom()
{
- int i = random()%m_bits.size();
- m_bits[i].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)
{
- // assure that there is only one set of destinations for this machine
- assert(MachineType_base_level((MachineType)(machine+1)) - MachineType_base_level(machine) == 1);
- m_bits[MachineType_base_level(machine)] = set;
+ // assure that there is only one set of destinations for this machine
+ assert(MachineType_base_level((MachineType)(machine + 1)) -
+ MachineType_base_level(machine) == 1);
+ m_bits[MachineType_base_level(machine)] = set;
}
-void NetDest::remove(MachineID oldElement)
+void
+NetDest::remove(MachineID oldElement)
{
- m_bits[vecIndex(oldElement)].remove(bitIndex(oldElement.num));
+ m_bits[vecIndex(oldElement)].remove(bitIndex(oldElement.num));
}
-void NetDest::removeNetDest(const NetDest& netDest)
+void
+NetDest::removeNetDest(const NetDest& netDest)
{
- assert(m_bits.size() == netDest.getSize());
- for (int i = 0; i < m_bits.size(); i++) {
- m_bits[i].removeSet(netDest.m_bits[i]);
-
- }
+ assert(m_bits.size() == netDest.getSize());
+ for (int i = 0; i < m_bits.size(); i++) {
+ m_bits[i].removeSet(netDest.m_bits[i]);
+ }
}
-void NetDest::clear()
+void
+NetDest::clear()
{
- for (int i = 0; i < m_bits.size(); i++) {
- m_bits[i].clear();
- }
+ for (int i = 0; i < m_bits.size(); i++) {
+ m_bits[i].clear();
+ }
}
-void NetDest::broadcast()
+void
+NetDest::broadcast()
{
- for (MachineType machine = MachineType_FIRST; machine < MachineType_NUM; ++machine) {
- broadcast(machine);
- }
+ for (MachineType machine = MachineType_FIRST;
+ machine < MachineType_NUM; ++machine) {
+ broadcast(machine);
+ }
}
-void NetDest::broadcast(MachineType machineType) {
-
- for (int i = 0; i < MachineType_base_count(machineType); i++) {
- MachineID mach = {machineType, i};
- add(mach);
- }
+void
+NetDest::broadcast(MachineType machineType)
+{
+ for (int i = 0; i < MachineType_base_count(machineType); i++) {
+ MachineID mach = {machineType, i};
+ add(mach);
+ }
}
//For Princeton Network
-Vector<NodeID> NetDest::getAllDest() {
- Vector<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)) {
- dest.insertAtBottom((NodeID) (MachineType_base_number((MachineType) i) + j));
- }
- }
+Vector<NodeID>
+NetDest::getAllDest()
+{
+ Vector<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.insertAtBottom((NodeID)id);
+ }
}
- return dest;
+ }
+ return dest;
}
-int NetDest::count() const
+int
+NetDest::count() const
{
- int counter = 0;
- for (int i=0; i<m_bits.size(); i++) {
- counter += m_bits[i].count();
- }
- return counter;
+ int counter = 0;
+ for (int i = 0; i < m_bits.size(); i++) {
+ counter += m_bits[i].count();
+ }
+ return counter;
}
-NodeID NetDest::elementAt(MachineID index) {
- return m_bits[vecIndex(index)].elementAt(bitIndex(index.num));
+NodeID
+NetDest::elementAt(MachineID index)
+{
+ return m_bits[vecIndex(index)].elementAt(bitIndex(index.num));
}
-MachineID NetDest::smallestElement() const
+MachineID
+NetDest::smallestElement() const
{
- assert(count() > 0);
- 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)) {
- MachineID mach = {MachineType_from_base_level(i), j};
- return mach;
- }
+ assert(count() > 0);
+ 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)) {
+ MachineID mach = {MachineType_from_base_level(i), j};
+ return mach;
+ }
+ }
}
- }
- ERROR_MSG("No smallest element of an empty set.");
+ ERROR_MSG("No smallest element of an empty set.");
}
-MachineID NetDest::smallestElement(MachineType machine) const
+MachineID
+NetDest::smallestElement(MachineType machine) const
{
- for (int j = 0; j < m_bits[MachineType_base_level(machine)].getSize(); j++) {
- if (m_bits[MachineType_base_level(machine)].isElement(j)) {
- MachineID mach = {machine, j};
- return mach;
+ int size = m_bits[MachineType_base_level(machine)].getSize();
+ for (int j = 0; j < size; j++) {
+ if (m_bits[MachineType_base_level(machine)].isElement(j)) {
+ MachineID mach = {machine, j};
+ return mach;
+ }
}
- }
- ERROR_MSG("No smallest element of given MachineType.");
+ ERROR_MSG("No smallest element of given MachineType.");
}
-
// Returns true iff all bits are set
-bool NetDest::isBroadcast() const
+bool
+NetDest::isBroadcast() const
{
- for (int i=0; i<m_bits.size(); i++) {
- if (!m_bits[i].isBroadcast()) {
- return false;
+ for (int i = 0; i < m_bits.size(); i++) {
+ if (!m_bits[i].isBroadcast()) {
+ return false;
+ }
}
- }
- return true;
+ return true;
}
// Returns true iff no bits are set
-bool NetDest::isEmpty() const
+bool
+NetDest::isEmpty() const
{
- for (int i=0; i<m_bits.size(); i++) {
- if (!m_bits[i].isEmpty()) {
- return false;
+ for (int i = 0; i < m_bits.size(); i++) {
+ if (!m_bits[i].isEmpty()) {
+ return false;
+ }
}
- }
- return true;
+ return true;
}
// returns the logical OR of "this" set and orNetDest
-NetDest NetDest::OR(const NetDest& orNetDest) const
+NetDest
+NetDest::OR(const NetDest& orNetDest) const
{
- assert(m_bits.size() == orNetDest.getSize());
- NetDest result;
- for (int i=0; i<m_bits.size(); i++) {
- result.m_bits[i] = m_bits[i].OR(orNetDest.m_bits[i]);
- }
- return result;
+ assert(m_bits.size() == orNetDest.getSize());
+ NetDest result;
+ for (int i = 0; i < m_bits.size(); i++) {
+ result.m_bits[i] = m_bits[i].OR(orNetDest.m_bits[i]);
+ }
+ return result;
}
-
// returns the logical AND of "this" set and andNetDest
-NetDest NetDest::AND(const NetDest& andNetDest) const
+NetDest
+NetDest::AND(const NetDest& andNetDest) const
{
- assert(m_bits.size() == andNetDest.getSize());
- NetDest result;
- for (int i=0; i<m_bits.size(); i++) {
- result.m_bits[i] = m_bits[i].AND(andNetDest.m_bits[i]);
- }
- return result;
+ assert(m_bits.size() == andNetDest.getSize());
+ NetDest result;
+ for (int i = 0; i < m_bits.size(); i++) {
+ result.m_bits[i] = m_bits[i].AND(andNetDest.m_bits[i]);
+ }
+ return result;
}
// Returns true if the intersection of the two sets is non-empty
-bool NetDest::intersectionIsNotEmpty(const NetDest& other_netDest) const
+bool
+NetDest::intersectionIsNotEmpty(const NetDest& other_netDest) const
{
- assert(m_bits.size() == other_netDest.getSize());
- for (int i=0; i<m_bits.size(); i++) {
- if (m_bits[i].intersectionIsNotEmpty(other_netDest.m_bits[i])) {
- return true;
+ assert(m_bits.size() == other_netDest.getSize());
+ for (int i = 0; i < m_bits.size(); i++) {
+ if (m_bits[i].intersectionIsNotEmpty(other_netDest.m_bits[i])) {
+ return true;
+ }
}
- }
- return false;
+ return false;
}
-bool NetDest::isSuperset(const NetDest& test) const
+bool
+NetDest::isSuperset(const NetDest& test) const
{
- assert(m_bits.size() == test.getSize());
+ assert(m_bits.size() == test.getSize());
- for (int i=0; i<m_bits.size(); i++) {
- if (!m_bits[i].isSuperset(test.m_bits[i])) {
- return false;
+ for (int i = 0; i < m_bits.size(); i++) {
+ if (!m_bits[i].isSuperset(test.m_bits[i])) {
+ return false;
+ }
}
- }
- return true;
+ return true;
}
-bool NetDest::isElement(MachineID element) const
+bool
+NetDest::isElement(MachineID element) const
{
- return ((m_bits[vecIndex(element)])).isElement(bitIndex(element.num));
+ return ((m_bits[vecIndex(element)])).isElement(bitIndex(element.num));
}
-void NetDest::setSize()
+void
+NetDest::setSize()
{
- m_bits.setSize(MachineType_base_level(MachineType_NUM));
- assert(m_bits.size() == MachineType_NUM);
+ m_bits.setSize(MachineType_base_level(MachineType_NUM));
+ assert(m_bits.size() == MachineType_NUM);
- for (int i = 0; i < m_bits.size(); i++) {
- m_bits[i].setSize(MachineType_base_count((MachineType)i));
- }
+ for (int i = 0; i < m_bits.size(); i++) {
+ m_bits[i].setSize(MachineType_base_count((MachineType)i));
+ }
}
-void NetDest::print(ostream& out) const
+void
+NetDest::print(ostream& out) const
{
- out << "[NetDest (" << m_bits.size() << ") ";
+ out << "[NetDest (" << m_bits.size() << ") ";
- for (int i=0; i<m_bits.size(); i++) {
- for (int j=0; j<m_bits[i].getSize(); j++) {
- out << (bool) m_bits[i].isElement(j) << " ";
+ for (int i = 0; i < m_bits.size(); i++) {
+ for (int j = 0; j < m_bits[i].getSize(); j++) {
+ out << (bool) m_bits[i].isElement(j) << " ";
+ }
+ out << " - ";
}
- out << " - ";
- }
- out << "]";
+ out << "]";
}
diff --git a/src/mem/ruby/common/NetDest.hh b/src/mem/ruby/common/NetDest.hh
index 071106623..7592ad9b5 100644
--- a/src/mem/ruby/common/NetDest.hh
+++ b/src/mem/ruby/common/NetDest.hh
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,22 +26,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * Set.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
// NetDest specifies the network destination of a NetworkMessage
// This is backward compatible with the Set class that was previously
// used to specify network destinations.
// NetDest supports both node networks and component networks
-#ifndef NETDEST_H
-#define NETDEST_H
+#ifndef __MEM_RUBY_COMMON_NETDEST_HH__
+#define __MEM_RUBY_COMMON_NETDEST_HH__
#include "mem/ruby/common/Global.hh"
#include "mem/gems_common/Vector.hh"
@@ -51,94 +41,92 @@
#include "mem/ruby/common/Set.hh"
#include "mem/protocol/MachineType.hh"
-class Set;
-
-class NetDest {
-public:
- // Constructors
- // creates and empty set
- NetDest();
- explicit NetDest(int bit_size);
-
- NetDest& operator=(const Set& obj);
-
- // Destructor
- ~NetDest() { DEBUG_MSG(MEMORY_COMP, LowPrio, "NetDest Destructor"); }
-
- // Public Methods
- void add(MachineID newElement);
- void addNetDest(const NetDest& netDest);
- void addRandom();
- void setNetDest(MachineType machine, const Set& set);
- void remove(MachineID oldElement);
- void removeNetDest(const NetDest& netDest);
- void clear();
- void broadcast();
- void broadcast(MachineType machine);
- int count() const;
- bool isEqual(const NetDest& netDest);
-
- NetDest OR(const NetDest& orNetDest) const; // return the logical OR of this netDest and orNetDest
- NetDest AND(const NetDest& andNetDest) const; // return the logical AND of this netDest and andNetDest
-
- // Returns true if the intersection of the two netDests is non-empty
- bool intersectionIsNotEmpty(const NetDest& other_netDest) const;
-
- // Returns true if the intersection of the two netDests is empty
- bool intersectionIsEmpty(const NetDest& other_netDest) const;
-
- bool isSuperset(const NetDest& test) const;
- bool isSubset(const NetDest& test) const { return test.isSuperset(*this); }
- bool isElement(MachineID element) const;
- bool isBroadcast() const;
- bool isEmpty() const;
-
- //For Princeton Network
- Vector<NodeID> getAllDest();
-
- MachineID smallestElement() const;
- MachineID smallestElement(MachineType machine) const;
-
- void setSize();
- int getSize() const { return m_bits.size(); }
-
- // get element for a index
- NodeID elementAt(MachineID index);
-
- void print(ostream& out) const;
-
-private:
-
- // Private Methods
- // returns a value >= MachineType_base_level("this machine") and < MachineType_base_level("next highest machine")
- int vecIndex(MachineID m) const {
- int vec_index = MachineType_base_level(m.type);
- assert(vec_index < m_bits.size());
- return vec_index;
- }
-
- NodeID bitIndex(NodeID index) const {
- return index;
- }
-
- // Data Members (m_ prefix)
- Vector < Set > m_bits; // a Vector of bit vectors - i.e. Sets
-
+class NetDest
+{
+ public:
+ // Constructors
+ // creates and empty set
+ NetDest();
+ explicit NetDest(int bit_size);
+
+ NetDest& operator=(const Set& obj);
+
+ ~NetDest()
+ {
+ DEBUG_MSG(MEMORY_COMP, LowPrio, "NetDest Destructor");
+ }
+
+ void add(MachineID newElement);
+ void addNetDest(const NetDest& netDest);
+ void addRandom();
+ void setNetDest(MachineType machine, const Set& set);
+ void remove(MachineID oldElement);
+ void removeNetDest(const NetDest& netDest);
+ void clear();
+ void broadcast();
+ void broadcast(MachineType machine);
+ int count() const;
+ bool isEqual(const NetDest& netDest);
+
+ // return the logical OR of this netDest and orNetDest
+ NetDest OR(const NetDest& orNetDest) const;
+
+ // return the logical AND of this netDest and andNetDest
+ NetDest AND(const NetDest& andNetDest) const;
+
+ // Returns true if the intersection of the two netDests is non-empty
+ bool intersectionIsNotEmpty(const NetDest& other_netDest) const;
+
+ // Returns true if the intersection of the two netDests is empty
+ bool intersectionIsEmpty(const NetDest& other_netDest) const;
+
+ bool isSuperset(const NetDest& test) const;
+ bool isSubset(const NetDest& test) const { return test.isSuperset(*this); }
+ bool isElement(MachineID element) const;
+ bool isBroadcast() const;
+ bool isEmpty() const;
+
+ // For Princeton Network
+ Vector<NodeID> getAllDest();
+
+ MachineID smallestElement() const;
+ MachineID smallestElement(MachineType machine) const;
+
+ void setSize();
+ int getSize() const { return m_bits.size(); }
+
+ // get element for a index
+ NodeID elementAt(MachineID index);
+
+ void print(ostream& out) const;
+
+ private:
+ // returns a value >= MachineType_base_level("this machine")
+ // and < MachineType_base_level("next highest machine")
+ int
+ vecIndex(MachineID m) const
+ {
+ int vec_index = MachineType_base_level(m.type);
+ assert(vec_index < m_bits.size());
+ return vec_index;
+ }
+
+ NodeID
+ bitIndex(NodeID index) const
+ {
+ return index;
+ }
+
+ Vector <Set> m_bits; // a Vector of bit vectors - i.e. Sets
};
-// Output operator declaration
-ostream& operator<<(ostream& out, const NetDest& obj);
-
-// ******************* Definitions *******************
-
-// Output operator definition
-extern inline
-ostream& operator<<(ostream& out, const NetDest& obj)
+inline ostream&
+operator<<(ostream& out, const NetDest& obj)
{
- obj.print(out);
- out << flush;
- return out;
+ obj.print(out);
+ out << flush;
+ return out;
}
-#endif //NETDEST_H
+#endif // __MEM_RUBY_COMMON_NETDEST_HH__
diff --git a/src/mem/ruby/common/SConscript b/src/mem/ruby/common/SConscript
index 56f5d7556..2197faae8 100644
--- a/src/mem/ruby/common/SConscript
+++ b/src/mem/ruby/common/SConscript
@@ -41,7 +41,6 @@ Source('Debug.cc')
Source('Driver.cc')
Source('Global.cc')
Source('Histogram.cc')
-Source('Message.cc')
Source('NetDest.cc')
Source('Set.cc', Werror=False)
Source('SubBlock.cc')
diff --git a/src/mem/ruby/common/SubBlock.cc b/src/mem/ruby/common/SubBlock.cc
index de40e3f7d..533aefbe7 100644
--- a/src/mem/ruby/common/SubBlock.cc
+++ b/src/mem/ruby/common/SubBlock.cc
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,44 +26,44 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * $Id$
- */
-
#include "mem/ruby/common/SubBlock.hh"
SubBlock::SubBlock(const Address& addr, int size)
{
- m_address = addr;
- setSize(size);
- for(int i=0; i<size; i++) {
- setByte(i, 0);
- }
+ m_address = addr;
+ setSize(size);
+ for (int i = 0; i < size; i++) {
+ setByte(i, 0);
+ }
}
-void SubBlock::internalMergeFrom(const DataBlock& data)
+void
+SubBlock::internalMergeFrom(const DataBlock& data)
{
- int size = getSize();
- assert(size > 0);
- int offset = m_address.getOffset();
- for(int i=0; i<size; i++) {
- this->setByte(i, data.getByte(offset+i));
- }
+ int size = getSize();
+ assert(size > 0);
+ int offset = m_address.getOffset();
+ for (int i = 0; i < size; i++) {
+ this->setByte(i, data.getByte(offset + i));
+ }
}
-void SubBlock::internalMergeTo(DataBlock& data) const
+void
+SubBlock::internalMergeTo(DataBlock& data) const
{
- int size = getSize();
- assert(size > 0);
- int offset = m_address.getOffset();
- for(int i=0; i<size; i++) {
- data.setByte(offset+i, this->getByte(i)); // This will detect crossing a cache line boundary
- }
+ int size = getSize();
+ assert(size > 0);
+ int offset = m_address.getOffset();
+ for (int i = 0; i < size; i++) {
+ // This will detect crossing a cache line boundary
+ data.setByte(offset + i, this->getByte(i));
+ }
}
-void SubBlock::print(ostream& out) const
+void
+SubBlock::print(ostream& out) const
{
- out << "[" << m_address << ", " << getSize() << ", " << m_data << "]";
+ out << "[" << m_address << ", " << getSize() << ", " << m_data << "]";
}
diff --git a/src/mem/ruby/common/SubBlock.hh b/src/mem/ruby/common/SubBlock.hh
index 8acdd9f4d..ab286dd0e 100644
--- a/src/mem/ruby/common/SubBlock.hh
+++ b/src/mem/ruby/common/SubBlock.hh
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
* All rights reserved.
@@ -27,69 +26,55 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * $Id$
- *
- */
+#ifndef __MEM_RUBY_COMMON_SUBBLOCK_HH__
+#define __MEM_RUBY_COMMON_SUBBLOCK_HH__
-#ifndef SubBlock_H
-#define SubBlock_H
-
-#include "mem/ruby/common/Global.hh"
+#include "mem/gems_common/Vector.hh"
#include "mem/ruby/common/Address.hh"
#include "mem/ruby/common/DataBlock.hh"
-#include "mem/gems_common/Vector.hh"
-
-class SubBlock {
-public:
- // Constructors
- SubBlock() { }
- SubBlock(const Address& addr, int size);
+#include "mem/ruby/common/Global.hh"
- // Destructor
- ~SubBlock() { }
+class SubBlock
+{
+ public:
+ SubBlock() { }
+ SubBlock(const Address& addr, int size);
+ ~SubBlock() { }
- // Public Methods
- const Address& getAddress() const { return m_address; }
- void setAddress(const Address& addr) { m_address = addr; }
+ const Address& getAddress() const { return m_address; }
+ void setAddress(const Address& addr) { m_address = addr; }
- int getSize() const { return m_data.size(); }
- void setSize(int size) { m_data.setSize(size); }
- uint8 getByte(int offset) const { return m_data[offset]; }
- void setByte(int offset, uint8 data) { m_data[offset] = data; }
+ int getSize() const { return m_data.size(); }
+ void setSize(int size) { m_data.setSize(size); }
+ uint8 getByte(int offset) const { return m_data[offset]; }
+ void setByte(int offset, uint8 data) { m_data[offset] = data; }
- // Shorthands
- uint8 readByte() const { return getByte(0); }
- void writeByte(uint8 data) { setByte(0, data); }
+ // Shorthands
+ uint8 readByte() const { return getByte(0); }
+ void writeByte(uint8 data) { setByte(0, data); }
- // Merging to and from DataBlocks - We only need to worry about
- // updates when we are using DataBlocks
- void mergeTo(DataBlock& data) const { internalMergeTo(data); }
- void mergeFrom(const DataBlock& data) { internalMergeFrom(data); }
+ // Merging to and from DataBlocks - We only need to worry about
+ // updates when we are using DataBlocks
+ void mergeTo(DataBlock& data) const { internalMergeTo(data); }
+ void mergeFrom(const DataBlock& data) { internalMergeFrom(data); }
- void print(ostream& out) const;
-private:
+ void print(ostream& out) const;
- void internalMergeTo(DataBlock& data) const;
- void internalMergeFrom(const DataBlock& data);
+ private:
+ void internalMergeTo(DataBlock& data) const;
+ void internalMergeFrom(const DataBlock& data);
- // Data Members (m_ prefix)
- Address m_address;
- Vector<uint8_t> m_data;
+ // Data Members (m_ prefix)
+ Address m_address;
+ Vector<uint8_t> m_data;
};
-// Output operator declaration
-ostream& operator<<(ostream& out, const SubBlock& obj);
-
-// ******************* Definitions *******************
-
-// Output operator definition
-extern inline
-ostream& operator<<(ostream& out, const SubBlock& obj)
+inline ostream&
+operator<<(ostream& out, const SubBlock& obj)
{
- obj.print(out);
- out << flush;
- return out;
+ obj.print(out);
+ out << flush;
+ return out;
}
-#endif //SubBlock_H
+#endif // __MEM_RUBY_COMMON_SUBBLOCK_HH__