From 5ab13e2deb8f904ef2a233749193fa09ea7013c4 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Mon, 22 Mar 2010 18:43:53 -0700 Subject: ruby: style pass --- src/mem/ruby/common/Address.cc | 48 ++--- src/mem/ruby/common/Address.hh | 310 ++++++++++++++------------- src/mem/ruby/common/Consumer.hh | 138 ++++++------ src/mem/ruby/common/DataBlock.cc | 20 +- src/mem/ruby/common/DataBlock.hh | 191 ++++++++--------- src/mem/ruby/common/Debug.cc | 405 ++++++++++++++++------------------- src/mem/ruby/common/Debug.hh | 450 ++++++++++++++++++--------------------- src/mem/ruby/common/Driver.cc | 40 +++- src/mem/ruby/common/Driver.hh | 81 +++---- src/mem/ruby/common/Global.cc | 1 - src/mem/ruby/common/Global.hh | 46 +--- src/mem/ruby/common/Histogram.cc | 224 +++++++++---------- src/mem/ruby/common/Histogram.hh | 98 ++++----- src/mem/ruby/common/Message.cc | 34 --- src/mem/ruby/common/NetDest.cc | 294 +++++++++++++------------ src/mem/ruby/common/NetDest.hh | 182 ++++++++-------- src/mem/ruby/common/SConscript | 1 - src/mem/ruby/common/SubBlock.cc | 51 +++-- src/mem/ruby/common/SubBlock.hh | 87 ++++---- 19 files changed, 1274 insertions(+), 1427 deletions(-) delete mode 100644 src/mem/ruby/common/Message.cc (limited to 'src/mem/ruby/common') 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 #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
- { - size_t operator()(const Address &s) const { return (size_t) s.getAddress(); } - }; -} -namespace std { - template <> struct equal_to
- { - bool operator()(const Address& s1, const Address& s2) const { return s1 == s2; } - }; -} +template <> struct hash
+{ + size_t + operator()(const Address &s) const + { + return (size_t)s.getAddress(); + } +}; +/* namespace __hash_namespace */ } -#endif //ADDRESS_H +namespace std { +template <> struct equal_to
+{ + 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 #include @@ -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