From 2f30950143cc70bc42a3c8a4111d7cf8198ec881 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Mon, 11 May 2009 10:38:43 -0700 Subject: ruby: Import ruby and slicc from GEMS We eventually plan to replace the m5 cache hierarchy with the GEMS hierarchy, but for now we will make both live alongside eachother. --- src/mem/ruby/common/Address.cc | 68 +++++ src/mem/ruby/common/Address.hh | 255 +++++++++++++++++ src/mem/ruby/common/BigSet.cc | 249 +++++++++++++++++ src/mem/ruby/common/BigSet.hh | 125 +++++++++ src/mem/ruby/common/Consumer.hh | 89 ++++++ src/mem/ruby/common/DataBlock.cc | 91 +++++++ src/mem/ruby/common/DataBlock.hh | 82 ++++++ src/mem/ruby/common/Debug.cc | 369 +++++++++++++++++++++++++ src/mem/ruby/common/Debug.def | 17 ++ src/mem/ruby/common/Debug.hh | 291 ++++++++++++++++++++ src/mem/ruby/common/Driver.cc | 39 +++ src/mem/ruby/common/Driver.hh | 98 +++++++ src/mem/ruby/common/Global.cc | 35 +++ src/mem/ruby/common/Global.hh | 110 ++++++++ src/mem/ruby/common/Histogram.cc | 185 +++++++++++++ src/mem/ruby/common/Histogram.hh | 104 +++++++ src/mem/ruby/common/Message.cc | 34 +++ src/mem/ruby/common/NetDest.cc | 259 ++++++++++++++++++ src/mem/ruby/common/NetDest.hh | 145 ++++++++++ src/mem/ruby/common/OptBigSet.cc | 576 +++++++++++++++++++++++++++++++++++++++ src/mem/ruby/common/OptBigSet.hh | 202 ++++++++++++++ src/mem/ruby/common/Set.cc | 231 ++++++++++++++++ src/mem/ruby/common/Set.hh | 149 ++++++++++ src/mem/ruby/common/SubBlock.cc | 81 ++++++ src/mem/ruby/common/SubBlock.hh | 105 +++++++ 25 files changed, 3989 insertions(+) create mode 100644 src/mem/ruby/common/Address.cc create mode 100644 src/mem/ruby/common/Address.hh create mode 100644 src/mem/ruby/common/BigSet.cc create mode 100644 src/mem/ruby/common/BigSet.hh create mode 100644 src/mem/ruby/common/Consumer.hh create mode 100644 src/mem/ruby/common/DataBlock.cc create mode 100644 src/mem/ruby/common/DataBlock.hh create mode 100644 src/mem/ruby/common/Debug.cc create mode 100644 src/mem/ruby/common/Debug.def create mode 100644 src/mem/ruby/common/Debug.hh create mode 100644 src/mem/ruby/common/Driver.cc create mode 100644 src/mem/ruby/common/Driver.hh create mode 100644 src/mem/ruby/common/Global.cc create mode 100644 src/mem/ruby/common/Global.hh create mode 100644 src/mem/ruby/common/Histogram.cc create mode 100644 src/mem/ruby/common/Histogram.hh create mode 100644 src/mem/ruby/common/Message.cc create mode 100644 src/mem/ruby/common/NetDest.cc create mode 100644 src/mem/ruby/common/NetDest.hh create mode 100644 src/mem/ruby/common/OptBigSet.cc create mode 100644 src/mem/ruby/common/OptBigSet.hh create mode 100644 src/mem/ruby/common/Set.cc create mode 100644 src/mem/ruby/common/Set.hh create mode 100644 src/mem/ruby/common/SubBlock.cc create mode 100644 src/mem/ruby/common/SubBlock.hh (limited to 'src/mem/ruby/common') diff --git a/src/mem/ruby/common/Address.cc b/src/mem/ruby/common/Address.cc new file mode 100644 index 000000000..5d38faae0 --- /dev/null +++ b/src/mem/ruby/common/Address.cc @@ -0,0 +1,68 @@ + +/* + * 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 "Address.hh" + +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; +} + +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; +} + +Address::Address(const Address& obj) +{ + m_address = obj.m_address; +} + +Address& Address::operator=(const Address& obj) +{ + 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 new file mode 100644 index 000000000..3c3c5ad30 --- /dev/null +++ b/src/mem/ruby/common/Address.hh @@ -0,0 +1,255 @@ + +/* + * Copyright (c) 1999 by Mark Hill and David Wood for the Wisconsin + * Multifacet Project. ALL RIGHTS RESERVED. + * + * ##HEADER## + * + * This software is furnished under a license and may be used and + * copied only in accordance with the terms of such license and the + * inclusion of the above copyright notice. This software or any + * other copies thereof or any derivative works may not be provided or + * otherwise made available to any other persons. Title to and + * ownership of the software is retained by Mark Hill and David Wood. + * Any use of this software must include the above copyright notice. + * + * THIS SOFTWARE IS PROVIDED "AS IS". THE LICENSOR MAKES NO + * WARRANTIES ABOUT ITS CORRECTNESS OR PERFORMANCE. + * */ + +/* + * $Id$ + */ + +#ifndef ADDRESS_H +#define ADDRESS_H + +#include +#include "Global.hh" +#include "RubyConfig.hh" +#include "NodeID.hh" +#include "MachineID.hh" + +const int ADDRESS_WIDTH = 64; // address width in bytes + +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 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(RubyConfig::dataBlockBits(), ADDRESS_WIDTH); } + physical_address_t getOffset() const + { return bitSelect(0, RubyConfig::dataBlockBits()-1); } + + void makeLineAddress() { m_address = maskLowOrderBits(RubyConfig::dataBlockBits()); } + // returns the next stride address based on line address + void makeNextStrideAddress( int stride) { + m_address = maskLowOrderBits(RubyConfig::dataBlockBits()) + + RubyConfig::dataBlockBytes()*stride; + } + void makePageAddress() { m_address = maskLowOrderBits(RubyConfig::pageSizeBits()); } + int getBankSetNum() const; + int getBankSetDist() const; + + Index memoryModuleIndex() const; + + void print(ostream& out) const; + void output(ostream& out) const; + void input(istream& in); + + void setOffset( int offset ){ + // first, zero out the offset bits + makeLineAddress(); + m_address |= (physical_address_t) offset; + } + +private: + // Private Methods + + // Private copy constructor and assignment operator + // Address(const Address& obj); + // Address& operator=(const Address& obj); + + // Data Members (m_ prefix) + physical_address_t m_address; +}; + +inline +Address line_address(const Address& addr) { Address temp(addr); temp.makeLineAddress(); return temp; } + +inline +Address next_stride_address(const Address& addr, int stride) { + Address temp = addr; + temp.makeNextStrideAddress(stride); + temp.setAddress(temp.maskHighOrderBits(ADDRESS_WIDTH-RubyConfig::memorySizeBits())); // surpress wrap-around problem + return temp; +} + +inline +Address page_address(const Address& addr) { Address temp(addr); temp.makePageAddress(); return temp; } + +// 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); */ + +inline +bool operator<(const Address& obj1, const Address& obj2) +{ + return obj1.getAddress() < obj2.getAddress(); +} + +// ******************* Definitions ******************* + +// Output operator definition +inline +ostream& operator<<(ostream& out, const Address& obj) +{ + obj.print(out); + out << flush; + return out; +} + +inline +bool operator==(const Address& obj1, const Address& obj2) +{ + return (obj1.getAddress() == obj2.getAddress()); +} + +inline +bool operator!=(const Address& obj1, const Address& obj2) +{ + return (obj1.getAddress() != obj2.getAddress()); +} + +inline +physical_address_t Address::bitSelect(int small, int big) const // rips bits inclusive +{ + physical_address_t mask; + assert(big >= 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); + } +} + +inline +physical_address_t Address::maskLowOrderBits(int number) const +{ + physical_address_t mask; + + if (number >= ADDRESS_WIDTH - 1) { + mask = ~0; + } else { + mask = (physical_address_t)~0 << number; + } + return (m_address & mask); +} + +inline +physical_address_t Address::maskHighOrderBits(int number) const +{ + physical_address_t 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 +{ + return (m_address >> number); +} + +inline +integer_t Address::memoryModuleIndex() const +{ + integer_t index = bitSelect(RubyConfig::dataBlockBits()+RubyConfig::memoryBits(), ADDRESS_WIDTH); + assert (index >= 0); + if (index >= RubyConfig::memoryModuleBlocks()) { + cerr << " memoryBits: " << RubyConfig::memoryBits() << " memorySizeBits: " << RubyConfig::memorySizeBits() + << " Address: " << "[" << hex << "0x" << m_address << "," << " line 0x" << maskLowOrderBits(RubyConfig::dataBlockBits()) << dec << "]" << flush + << "error: limit exceeded. " << + " dataBlockBits: " << RubyConfig::dataBlockBits() << + " memoryModuleBlocks: " << RubyConfig::memoryModuleBlocks() << + " index: " << index << endl; + } + assert (index < RubyConfig::memoryModuleBlocks()); + 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 + | | | | + \ / \ / \ / \ / 0 + ----------------------------------------------------------------------- + | unused |xxxxxxxxxxxxxxx| |xxxxxxxxxxxxxxx| | + | |xxxxxxxxxxxxxxx| |xxxxxxxxxxxxxxx| | + ----------------------------------------------------------------------- + indexHighPortion indexLowPortion + <-------> + NUMBER_OF_MEMORY_MODULE_BITS + */ +} + +inline +void Address::print(ostream& out) const +{ + out << "[" << hex << "0x" << m_address << "," << " line 0x" << maskLowOrderBits(RubyConfig::dataBlockBits()) << dec << "]" << flush; +} + +class Address; +namespace __gnu_cxx { + 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; } + }; +} + +#endif //ADDRESS_H + diff --git a/src/mem/ruby/common/BigSet.cc b/src/mem/ruby/common/BigSet.cc new file mode 100644 index 000000000..e16284f15 --- /dev/null +++ b/src/mem/ruby/common/BigSet.cc @@ -0,0 +1,249 @@ + +/* + * 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. + */ + +#include "Set.hh" +#include "RubyConfig.hh" + +Set::Set() +{ + setSize(RubyConfig::numberOfProcessors()); +} + +Set::Set(int size) +{ + setSize(size); +} + +void Set::add(NodeID index) +{ + m_bits[index] = Present; +} + +void Set::addSet(const Set& set) +{ + assert(m_bits.size() == set.getSize()); + for (int i=0; i> 1); // Shift the random number to look at the next bit + } +} + +void Set::remove(NodeID index) +{ + m_bits[index] = NotPresent; +} + +void Set::removeSet(const Set& set) +{ + assert(m_bits.size() == set.getSize()); + for (int i=0; i 0); + for (int i=0; i m_bits; // This is an vector of uint8 to reduce the size of the set +}; + +// Output operator declaration +ostream& operator<<(ostream& out, const Set& obj); + +// ******************* Definitions ******************* + +// Output operator definition +extern inline +ostream& operator<<(ostream& out, const Set& obj) +{ + obj.print(out); + out << flush; + return out; +} + +#endif //SET_H + diff --git a/src/mem/ruby/common/Consumer.hh b/src/mem/ruby/common/Consumer.hh new file mode 100644 index 000000000..bd51af7ba --- /dev/null +++ b/src/mem/ruby/common/Consumer.hh @@ -0,0 +1,89 @@ + +/* + * 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$ + * + * 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. + * + */ + +#ifndef CONSUMER_H +#define CONSUMER_H + +#include "Global.hh" +#include "EventQueue.hh" + +class MessageBuffer; + +class Consumer { +public: + // Constructors + Consumer() { m_last_scheduled_wakeup = 0; m_last_wakeup = 0; m_out_link_vec.setSize(0); } + + // Destructor + virtual ~Consumer() { } + + // Public Methods - pure virtual methods + void triggerWakeup() { Time time = g_eventQueue_ptr->getTime(); if (m_last_wakeup != time) { wakeup(); m_last_wakeup = time; }} + virtual void wakeup() = 0; + virtual void print(ostream& out) const = 0; + const Time& getLastScheduledWakeup() const { return m_last_scheduled_wakeup; } + void setLastScheduledWakeup(const Time& time) { m_last_scheduled_wakeup = time; } + Vector< Vector > getOutBuffers() { return m_out_link_vec; } + +protected: + Vector< Vector > m_out_link_vec; + +private: + // Private Methods + + // Data Members (m_ prefix) + Time m_last_scheduled_wakeup; + Time m_last_wakeup; +}; + +// Output operator declaration +inline extern +ostream& operator<<(ostream& out, const Consumer& obj); + +// ******************* Definitions ******************* + +// Output operator definition +inline extern +ostream& operator<<(ostream& out, const Consumer& obj) +{ + obj.print(out); + out << flush; + return out; +} + +#endif //CONSUMER_H diff --git a/src/mem/ruby/common/DataBlock.cc b/src/mem/ruby/common/DataBlock.cc new file mode 100644 index 000000000..c4d6d7a33 --- /dev/null +++ b/src/mem/ruby/common/DataBlock.cc @@ -0,0 +1,91 @@ + +/* + * 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 "DataBlock.hh" + +DataBlock::DataBlock() +{ + if (DATA_BLOCK || XACT_MEMORY) { + m_data.setSize(RubyConfig::dataBlockBytes()); + } + clear(); +} + +DataBlock::~DataBlock() +{ + +} + +void DataBlock::clear() +{ + int size = m_data.size(); + for (int i = 0; i < size; i++) { + m_data[i] = 0; + } +} + +bool DataBlock::equal(const DataBlock& obj) const +{ + bool value = true; + int size = m_data.size(); + for (int i = 0; i < size; i++) { + value = value && (m_data[i] == obj.m_data[i]); + } + return value; +} + +void DataBlock::print(ostream& out) const +{ + int size = m_data.size(); + for (int i = 0; i < size; i+=4) { + out << hex << *((uint32*)(&(m_data[i]))) << " "; + } + out << dec << "]" << flush; +} + +uint8 DataBlock::getByte(int whichByte) const +{ + if (DATA_BLOCK || XACT_MEMORY) { + return m_data[whichByte]; + } else { + return 0; + } +} + +void DataBlock::setByte(int whichByte, uint8 data) +{ + if (DATA_BLOCK || XACT_MEMORY) { + m_data[whichByte] = data; + } +} + diff --git a/src/mem/ruby/common/DataBlock.hh b/src/mem/ruby/common/DataBlock.hh new file mode 100644 index 000000000..aae364078 --- /dev/null +++ b/src/mem/ruby/common/DataBlock.hh @@ -0,0 +1,82 @@ + +/* + * 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. + */ + +#ifndef DATABLOCK_H +#define DATABLOCK_H + +#include "Global.hh" +#include "RubyConfig.hh" +#include "Vector.hh" + +class DataBlock { +public: + // Constructors + DataBlock(); + + // Destructor + ~DataBlock(); + + // Public Methods + void clear(); + uint8 getByte(int whichByte) const; + void setByte(int whichByte, uint8 data); + bool equal(const DataBlock& obj) const; + void print(ostream& out) const; + +private: + // Private Methods + + // Data Members (m_ prefix) + Vector m_data; +}; + +// Output operator declaration +ostream& operator<<(ostream& out, const DataBlock& obj); + +bool operator==(const DataBlock& obj1, const DataBlock& obj2); + + +// ******************* Definitions ******************* + +// Output operator definition +extern inline +ostream& operator<<(ostream& out, const DataBlock& obj) +{ + obj.print(out); + out << flush; + return out; +} + +extern inline +bool operator==(const DataBlock& obj1,const DataBlock& obj2) +{ + return (obj1.equal(obj2)); +} + +#endif //DATABLOCK_H diff --git a/src/mem/ruby/common/Debug.cc b/src/mem/ruby/common/Debug.cc new file mode 100644 index 000000000..f0319ceb8 --- /dev/null +++ b/src/mem/ruby/common/Debug.cc @@ -0,0 +1,369 @@ + +/* + * 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 +#include + +#include "Global.hh" +#include "Debug.hh" +#include "EventQueue.hh" + +class Debug; +extern Debug* g_debug_ptr; +std::ostream * debug_cout_ptr; + +// component character list +const char DEFINE_COMP_CHAR[] = +{ +#undef DEFINE_COMP +#define DEFINE_COMP(component, character, description) character, +#include "Debug.def" +}; + +// component description list +const char* DEFINE_COMP_DESCRIPTION[] = +{ +#undef DEFINE_COMP +#define DEFINE_COMP(component, character, description) description, +#include "Debug.def" +}; + +extern "C" void changeDebugVerbosity(VerbosityLevel vb); +extern "C" void changeDebugFilter(int filter); + +void changeDebugVerbosity(VerbosityLevel vb) +{ + g_debug_ptr->setVerbosity(vb); +} + +void changeDebugFilter(int filter) +{ + g_debug_ptr->setFilter(filter); +} + +Debug::Debug( const char *filterString, const char *verboseString, + Time filterStartTime, const char *filename ) +{ + m_verbosityLevel = No_Verb; + clearFilter(); + debug_cout_ptr = &cout; + + m_starting_cycle = filterStartTime; + setFilterString( filterString ); + setVerbosityString( verboseString ); + setDebugOutputFile( filename ); +} + +Debug::~Debug() +{ +} + +void Debug::printVerbosity(ostream& out) const +{ + 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) +{ + 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; + break; + case Low_Verb: + if(priority == HighPrio) { + return true; + }else{ + return false; + } + break; + case Med_Verb: + if(priority == HighPrio || priority == MedPrio ) { + return true; + }else{ + return false; + } + break; + case High_Verb: + return true; + break; + } + } + } + return false; +} + +void Debug::setDebugTime(Time t) +{ + m_starting_cycle = t; +} + +void Debug::setVerbosity(VerbosityLevel vb) +{ + m_verbosityLevel = vb; +} + +void Debug::setFilter(int filter) +{ + m_filter = filter; +} + +bool Debug::checkVerbosityString(const char *verb_str) +{ + 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 +} + +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 +} + +bool Debug::checkFilter(char ch) +{ + for (int i=0; i +#include + +extern std::ostream * debug_cout_ptr; + +// component enumeration +enum DebugComponents +{ +#undef DEFINE_COMP +#define DEFINE_COMP(component, character, description) component, +#include "Debug.def" + NUMBER_OF_COMPS +}; + +enum PriorityLevel {HighPrio, MedPrio, LowPrio}; +enum VerbosityLevel {No_Verb, Low_Verb, Med_Verb, High_Verb}; + +class Debug { +public: + // Constructors + Debug( const char *filterString, const char *verboseString, + Time filterStartTime, const char *filename ); + + // Destructor + ~Debug(); + + // Public Methods + bool validDebug(int module, PriorityLevel priority); + void printVerbosity(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(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) + VerbosityLevel m_verbosityLevel; + int m_filter; + Time m_starting_cycle; + + std::fstream m_fout; +}; + +// Output operator declaration +ostream& operator<<(ostream& out, const Debug& obj); + +// ******************* Definitions ******************* + +// Output operator definition +extern inline +ostream& operator<<(ostream& out, const Debug& obj) +{ + obj.print(out); + out << flush; + return out; +} + +const bool ERROR_MESSAGE_FLAG = true; +const bool WARNING_MESSAGE_FLAG = true; + +#ifdef RUBY_NO_ASSERT +const bool ASSERT_FLAG = false; +#else +const bool ASSERT_FLAG = true; +#endif + +#undef assert +#define assert(EXPR) ASSERT(EXPR) +#undef ASSERT +#define ASSERT(EXPR)\ +{\ + 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)\ +{\ + 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)\ +{\ + 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)\ +{\ + 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)\ +{\ + 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)\ +{\ + 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)\ +{\ + 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)\ +{\ + if (RUBY_DEBUG) {\ + if (g_debug_ptr->validDebug(module, priority)) {\ + (* debug_cout_ptr) << endl << flush;\ + }\ + }\ +} + +#define DEBUG_SLICC(priority, LINE, MESSAGE)\ +{\ + if (RUBY_DEBUG) {\ + if (g_debug_ptr->validDebug(SLICC_COMP, priority)) {\ + (* debug_cout_ptr) << (LINE) << (MESSAGE) << endl << flush;\ + }\ + }\ +} + +#define DEBUG_OUT( rest... ) \ +{\ + if (RUBY_DEBUG) {\ + cout << "Debug: in fn "\ + << __PRETTY_FUNCTION__\ + << " in " << __FILE__ << ":"\ + << __LINE__ << ": "; \ + g_debug_ptr->debugMsg(rest); \ + }\ +} + +#define ERROR_OUT( rest... ) \ +{\ + if (ERROR_MESSAGE_FLAG) {\ + cout << "error: in fn "\ + << __PRETTY_FUNCTION__ << " in "\ + << __FILE__ << ":"\ + << __LINE__ << ": ";\ + g_debug_ptr->debugMsg(rest); \ + }\ +} + +#endif //DEBUG_H + diff --git a/src/mem/ruby/common/Driver.cc b/src/mem/ruby/common/Driver.cc new file mode 100644 index 000000000..019ac6403 --- /dev/null +++ b/src/mem/ruby/common/Driver.cc @@ -0,0 +1,39 @@ + +/* + * 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. + */ + +#include "Driver.hh" + +Driver::Driver() +{ +} + +// still need to be defined for subclasses +Driver::~Driver() +{ +} diff --git a/src/mem/ruby/common/Driver.hh b/src/mem/ruby/common/Driver.hh new file mode 100644 index 000000000..911cb742b --- /dev/null +++ b/src/mem/ruby/common/Driver.hh @@ -0,0 +1,98 @@ + +/* + * 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. + */ + +#ifndef DRIVER_H +#define DRIVER_H + +#include "Global.hh" +#include "Consumer.hh" +#include "NodeID.hh" +#include "CacheRequestType.hh" + +class System; +class SubBlock; +class Address; +class MachineID; +class SimicsHypervisor; + +class Driver { +public: + // Constructors + Driver(); + + // Destructor + virtual ~Driver() = 0; + + // Public Methods + virtual void get_network_config() {} + virtual void hitCallback(NodeID proc, SubBlock& data, CacheRequestType type, int thread) = 0; // Called by sequencer + virtual void conflictCallback(NodeID proc, SubBlock& data, CacheRequestType type, int thread) { assert(0); } // Called by sequencer + virtual integer_t getInstructionCount(int procID) const { return 1; } + virtual integer_t getCycleCount(int procID) const { return 1; } + virtual SimicsHypervisor * getHypervisor() { return NULL; } + virtual void notifySendNack( int procID, const Address & addr, uint64 remote_timestamp, const MachineID & remote_id) { assert(0); }; //Called by Sequencer + virtual void notifyReceiveNack( int procID, const Address & addr, uint64 remote_timestamp, const MachineID & remote_id) { assert(0); }; //Called by Sequencer + virtual void notifyReceiveNackFinal( int procID, const Address & addr) { assert(0); }; // Called by Sequencer + virtual void notifyTrapStart( int procID, const Address & handlerPC, int threadID, int smtThread ) { assert(0); } //called by Sequencer + virtual void notifyTrapComplete( int procID, const Address & newPC, int smtThread ) {assert(0); } // called by Sequencer + virtual int getOpalTransactionLevel(int procID, int thread) const { + cout << "Driver.hh getOpalTransactionLevel() " << endl; + return 0; } //called by Sequencer + virtual void addThreadDependency(int procID, int requestor_thread, int conflict_thread) const { assert(0);} + virtual uint64 getOpalTime(int procID) const{ return 0; } //called by Sequencer + virtual uint64 getOpalTimestamp(int procID, int thread) const{ + cout << "Driver.hh getOpalTimestamp " << endl; + return 0; } // called by Sequencer + virtual int inTransaction(int procID, int thread ) const{ + cout << "Driver.hh inTransaction " << endl; +return false; } //called by Sequencer + 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 void abortCallback(NodeID proc){} + + 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 + +}; + +#endif //DRIVER_H diff --git a/src/mem/ruby/common/Global.cc b/src/mem/ruby/common/Global.cc new file mode 100644 index 000000000..e60cd4fd3 --- /dev/null +++ b/src/mem/ruby/common/Global.cc @@ -0,0 +1,35 @@ + +/* + * 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. + */ + +#include "Global.hh" + +EventQueue* g_eventQueue_ptr = NULL; +System* g_system_ptr = NULL; +Debug* g_debug_ptr = NULL; + diff --git a/src/mem/ruby/common/Global.hh b/src/mem/ruby/common/Global.hh new file mode 100644 index 000000000..eaec05d46 --- /dev/null +++ b/src/mem/ruby/common/Global.hh @@ -0,0 +1,110 @@ + +/* + * 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$ + * + * */ + +#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] + +typedef unsigned char uint8; +typedef unsigned int uint32; +typedef unsigned long long uint64; + +typedef signed char int8; +typedef int int32; +typedef long long int64; + +typedef long long integer_t; +typedef unsigned long long uinteger_t; + +typedef int64 Time; +typedef uint64 physical_address_t; +typedef uint64 la_t; +typedef uint64 pa_t; +typedef integer_t simtime_t; + +// external includes for all classes +#include "std-includes.hh" +#include "Debug.hh" + +// simple type declarations +typedef Time LogicalTime; +typedef int64 Index; // what the address bit ripper returns +typedef int word; // one word of a cache line +typedef unsigned int uint; +typedef int SwitchID; +typedef int LinkID; + +class EventQueue; +extern EventQueue* g_eventQueue_ptr; + +class System; +extern System* g_system_ptr; + +class Debug; +extern Debug* g_debug_ptr; + +// FIXME: this is required by the contructor of Directory_Entry.h. It can't go +// into slicc_util.h because it opens a can of ugly worms +extern inline int max_tokens() +{ + return 1024; +} + + +#endif //GLOBAL_H + diff --git a/src/mem/ruby/common/Histogram.cc b/src/mem/ruby/common/Histogram.cc new file mode 100644 index 000000000..9c5e8e623 --- /dev/null +++ b/src/mem/ruby/common/Histogram.cc @@ -0,0 +1,185 @@ + +/* + * 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 "Histogram.hh" + +Histogram::Histogram(int binsize, int bins) +{ + m_binsize = binsize; + m_bins = bins; + clear(); +} + +Histogram::~Histogram() +{ +} + +void Histogram::clear(int binsize, int bins) +{ + m_binsize = binsize; + clear(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; +} + + +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; + } 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; + } + index = value/m_binsize; + } + assert(index >= 0); + m_data[index]++; + m_largest_bin = max(m_largest_bin, index); +} + +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); + } + + 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 variance; + if(m_count > 1){ + variance = (double)(m_sumSquaredSamples - m_sumSamples*m_sumSamples/m_count)/(m_count - 1); + } else { + return 0; + } + return sqrt(variance); +} + +void Histogram::print(ostream& out) const +{ + printWithMultiplier(out, 1.0); +} + +void Histogram::printPercent(ostream& out) const +{ + if (m_count == 0) { + printWithMultiplier(out, 0.0); + } else { + printWithMultiplier(out, 100.0/double(m_count)); + } +} + +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]; + } else { + out << " " << double(m_data[i]) * multiplier; + } + } + out << " ]"; +} + +bool node_less_then_eq(const Histogram* n1, const Histogram* n2) +{ + return (n1->size() > n2->size()); +} diff --git a/src/mem/ruby/common/Histogram.hh b/src/mem/ruby/common/Histogram.hh new file mode 100644 index 000000000..e48efc35f --- /dev/null +++ b/src/mem/ruby/common/Histogram.hh @@ -0,0 +1,104 @@ + +/* + * 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$ + * + * Description: The histogram class implements a simple histogram + * + */ + +#ifndef HISTOGRAM_H +#define HISTOGRAM_H + +#include "Global.hh" +#include "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]; } + + void printWithMultiplier(ostream& out, double multiplier) const; + void printPercent(ostream& out) const; + void print(ostream& out) const; +private: + // Private Methods + + // Private copy constructor and assignment operator + // Histogram(const Histogram& obj); + // Histogram& operator=(const Histogram& obj); + + // Data Members (m_ prefix) + Vector 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 + + double getStandardDeviation() const; +}; + +bool node_less_then_eq(const Histogram* n1, const Histogram* n2); + +// Output operator declaration +ostream& operator<<(ostream& out, const Histogram& obj); + +// ******************* Definitions ******************* + +// Output operator definition +extern inline +ostream& operator<<(ostream& out, const Histogram& obj) +{ + obj.print(out); + out << flush; + return out; +} + +#endif //HISTOGRAM_H diff --git a/src/mem/ruby/common/Message.cc b/src/mem/ruby/common/Message.cc new file mode 100644 index 000000000..baad8ac9b --- /dev/null +++ b/src/mem/ruby/common/Message.cc @@ -0,0 +1,34 @@ + +/* + * 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 "Message.hh" diff --git a/src/mem/ruby/common/NetDest.cc b/src/mem/ruby/common/NetDest.cc new file mode 100644 index 000000000..79a6078e9 --- /dev/null +++ b/src/mem/ruby/common/NetDest.cc @@ -0,0 +1,259 @@ + +/* + * 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. + */ + +/* + * NetDest.C + * + * Description: See NetDest.h + * + * $Id$ + * + */ + +#include "NetDest.hh" +#include "RubyConfig.hh" +#include "Protocol.hh" + +NetDest::NetDest() +{ + setSize(); +} + +void NetDest::add(MachineID newElement) +{ + m_bits[vecIndex(newElement)].add(bitIndex(newElement.num)); +} + +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]); + } +} + +void NetDest::addRandom() +{ + int i = random()%m_bits.size(); + m_bits[i].addRandom(); +} + +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; +} + +void NetDest::remove(MachineID oldElement) +{ + m_bits[vecIndex(oldElement)].remove(bitIndex(oldElement.num)); +} + +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]); + + } +} + +void NetDest::clear() +{ + for (int i = 0; i < m_bits.size(); i++) { + m_bits[i].clear(); + } +} + +void NetDest::broadcast() +{ + 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); + } +} + +//For Princeton Network +Vector NetDest::getAllDest() { + Vector dest; + dest.clear(); + for (int i=0; i 0); + for (int i=0; i getAllDest(); + + NodeID 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 + +}; + +// Output operator declaration +ostream& operator<<(ostream& out, const NetDest& obj); + +// ******************* Definitions ******************* + +// Output operator definition +extern inline +ostream& operator<<(ostream& out, const NetDest& obj) +{ + obj.print(out); + out << flush; + return out; +} + +#endif //NETDEST_H + diff --git a/src/mem/ruby/common/OptBigSet.cc b/src/mem/ruby/common/OptBigSet.cc new file mode 100644 index 000000000..51214e936 --- /dev/null +++ b/src/mem/ruby/common/OptBigSet.cc @@ -0,0 +1,576 @@ + +/* + * 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. + */ + +/* + * Set.C + * + * Description: See Set.h + * + * $Id: BigSet.C 1.9 05/01/19 13:12:25-06:00 mikem@maya.cs.wisc.edu $ + * + */ + +// modified (rewritten) 05/20/05 by Dan Gibson to accomimdate FASTER >32 bit +// set sizes + +#include "Set.hh" +#include "RubyConfig.hh" + +#if __amd64__ || __LP64__ +#define __64BITS__ +#else +#define __32BITS__ +#endif + +Set::Set() +{ + m_p_nArray = NULL; + setSize(RubyConfig::numberOfProcessors()); +} + +// copy constructor +Set::Set(const Set& obj) { + m_p_nArray = NULL; + setSize(obj.m_nSize); + + // copy from the host to this array + for(int i=0; i0); + setSize(size); +} + +Set::~Set() { + if( (m_p_nArray != (&m_p_nArray_Static[0])) && (m_p_nArray != NULL)) + delete [] m_p_nArray; + m_p_nArray = NULL; +} + + +// /* +// * This function should set the bit corresponding to index +// * to 1. +// */ + +// void Set::add(NodeID index) +// { +// assert(index= 0); + +// #ifdef __32BITS__ +// m_p_nArray[index>>5] |= (1 << (index & 0x01F)); +// #else +// m_p_nArray[index>>6] |= (((unsigned long) 1) << (index & 0x03F)); +// #endif // __32BITS__ + +// } + +/* + * This function should set all the bits in the current set + * that are already set in the parameter set + */ +void Set::addSet(const Set& set) +{ + assert(getSize()==set.getSize()); + for(int i=0; i> 1; + } + } +#else + long mask = 0x7FFFFFFFFFFFFFFF; + + // the number of populated spaces in the higest-order array slot is: + // m_nSize % 64, so the uppermost 64 - m_nSize%64 bits should be + // cleared + + if((m_nSize % 64) != 0) { + for(int j=0; j<64-(m_nSize&0x03F); j++) { + m_p_nArray[m_nArrayLen-1] &= mask; + mask = mask >> 1; + } + } +#endif // __32BITS__ + +} + +// /* +// * This function unsets the bit associated with index +// */ +// void Set::remove(NodeID index) +// { +// assert(index=0); + +// #ifdef __32BITS__ +// m_p_nArray[index>>5] &= ~(0x00000001 << (index & 0x01F)); +// #else +// m_p_nArray[index>>6] &= ~(((unsigned long) 0x0000000000000001) << (index & 0x03F)); +// #endif // __32BITS__ + +// } + + +/* + * This function clears bits that are =1 in the parameter set + */ +void Set::removeSet(const Set& set) +{ + + assert(m_nSize==set.m_nSize); + for(int i=0; i> 1; + } + } +#else + long mask = 0x7FFFFFFFFFFFFFFF; + + // the number of populated spaces in the higest-order array slot is: + // m_nSize % 64, so the uppermost 64 - m_nSize%64 bits should be + // cleared + + if((m_nSize % 64) != 0) { + for(int j=0; j<64-(m_nSize&0x03F); j++) { + m_p_nArray[m_nArrayLen-1] &= mask; + mask = mask >> 1; + } + } +#endif // __32BITS__ + +} + +/* + * This function returns the population count of 1's in the set + */ +int Set::count() const +{ + int counter = 0; + long mask; + for( int i=0; i 0); + long x; + for( int i=0; i> 1; + } +#else + for( int j=0; j<64; j++) { + if(x & 0x0000000000000001) { + return 64*i+j; + } + + x = x >> 1; + } +#endif // __32BITS__ + + ERROR_MSG("No smallest element of an empty set."); + } + } + + ERROR_MSG("No smallest element of an empty set."); + + return 0; +} + +/* + * this function returns true iff all bits are set + */ +bool Set::isBroadcast() const +{ + // check the fully-loaded words by equal to 0xffffffff + // only the last word may not be fully loaded, it is not + // fully loaded iff m_nSize % 32 or 64 !=0 => fully loaded iff + // m_nSize % 32 or 64 == 0 + +#ifdef __32BITS__ + for(int i=0; i< (((m_nSize % 32)==0) ? m_nArrayLen : m_nArrayLen-1); i++) { + if(m_p_nArray[i]!=-1) { + return false; + } + } + + // now check the last word, which may not be fully loaded + long mask = 1; + for(int j=0; j< (m_nSize % 32); j++) { + if((mask & m_p_nArray[m_nArrayLen-1])==0) { + return false; + } + mask = mask << 1; + } +#else + for(int i=0; i< (((m_nSize % 64)==0) ? m_nArrayLen : m_nArrayLen-1); i++) { + if(m_p_nArray[i]!=-1) { + return false; + } + } + + // now check the last word, which may not be fully loaded + long mask = 1; + for(int j=0; j< (m_nSize % 64); j++) { + if((mask & m_p_nArray[m_nArrayLen-1])==0) { + return false; + } + mask = mask << 1; + } + +#endif // __32BITS__ + + return true; +} + +/* + * this function returns true iff no bits are set + */ +bool Set::isEmpty() const +{ + + // here we can simply check if all = 0, since we ensure + // that "extra slots" are all zero + for(int i=0; i< m_nArrayLen ; i++) { + if(m_p_nArray[i]!=0) { + return false; + } + } + + return true; +} + +// returns the logical OR of "this" set and orSet +Set Set::OR(const Set& orSet) const +{ + Set result(m_nSize); + assert(m_nSize == orSet.m_nSize); + for(int i=0; i< m_nArrayLen; i++) { + result.m_p_nArray[i] = m_p_nArray[i] | orSet.m_p_nArray[i]; + } + + return result; + +} + +// returns the logical AND of "this" set and andSet +Set Set::AND(const Set& andSet) const +{ + Set result(m_nSize); + assert(m_nSize == andSet.m_nSize); + + for(int i=0; i< m_nArrayLen; i++) { + result.m_p_nArray[i] = m_p_nArray[i] & andSet.m_p_nArray[i]; + } + + return result; +} + +// // Returns true if the intersection of the two sets is non-empty +// bool Set::intersectionIsNotEmpty(const Set& other_set) const +// { +// assert(m_nSize == other_set.m_nSize); +// for(int i=0; i< m_nArrayLen; i++) { +// if(m_p_nArray[i] & other_set.m_p_nArray[i]) { +// return true; +// } +// } + +// return false; + +// } + +// // Returns true if the intersection of the two sets is empty +// bool Set::intersectionIsEmpty(const Set& other_set) const +// { +// assert(m_nSize == other_set.m_nSize); +// for(int i=0; i< m_nArrayLen; i++) { +// if(m_p_nArray[i] & other_set.m_p_nArray[i]) { +// return false; +// } +// } + +// return true; + +// } + +/* + * Returns false if a bit is set in the parameter set that is + * NOT set in this set + */ +bool Set::isSuperset(const Set& test) const +{ + assert(m_nSize == test.m_nSize); + + for(int i=0;i>5] & (0x00000001 << (element & 0x01F)))!=0); +// #else +// result = ((m_p_nArray[element>>6] & (((unsigned long) 0x0000000000000001) << (element & 0x03F)))!=0); +// #endif // __32BITS__ + +// return result; +// } + +/* + * "Supposed" to return the node id of the (n+1)th set + * bit, IE n=0 => returns nodeid of first set bit, BUT + * since BigSet.C behaves strangely, this implementation + * will behave strangely just for reverse compatability. + * + * Was originally implemented for the flight data recorder + * FDR + */ + +// NodeID Set::elementAt(int n) const +// { +// if(isElement(n)) return (NodeID) true; +// else return 0; + +// /* +// int match = -1; +// for(int i=0;i=0; i--) { +#ifdef __32BITS__ + sprintf(buff,"%08X ",m_p_nArray[i]); +#else + sprintf(buff,"0x %016llX ",m_p_nArray[i]); +#endif // __32BITS__ + out << buff; + } + out << " ]"; + +} + + diff --git a/src/mem/ruby/common/OptBigSet.hh b/src/mem/ruby/common/OptBigSet.hh new file mode 100644 index 000000000..a57a07e13 --- /dev/null +++ b/src/mem/ruby/common/OptBigSet.hh @@ -0,0 +1,202 @@ + +/* + * 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. + */ + +/* + * Set.h + * + * Description: + * + * $Id: BigSet.h 1.6 05/01/19 13:12:25-06:00 mikem@maya.cs.wisc.edu $ + * + */ + +// modified by Dan Gibson on 05/20/05 to accomidate FASTER +// >32 set lengths, using an array of ints w/ 32 bits/int + +// NOTE: Never include this file directly, this should only be +// included from Set.h + +#ifndef SET_H +#define SET_H + +#include "Global.hh" +#include "Vector.hh" +#include "NodeID.hh" +#include "RubyConfig.hh" + +// gibson 05/20/05 +// enum PresenceBit {NotPresent, Present}; + +class Set { +public: + // Constructors + // creates and empty set + Set(); + Set (int size); + + // used during the replay mechanism + // Set(const char *str); + + Set(const Set& obj); + Set& operator=(const Set& obj); + + // Destructor + ~Set(); + + // Public Methods + + inline void add(NodeID index) + { +#ifdef __32BITS__ + m_p_nArray[index>>5] |= (1 << (index & 0x01F)); +#else + m_p_nArray[index>>6] |= (((unsigned long) 1) << (index & 0x03F)); +#endif // __32BITS__ + } + + void addSet(const Set& set); + void addRandom(); + + inline void remove(NodeID index) + { +#ifdef __32BITS__ + m_p_nArray[index>>5] &= ~(0x00000001 << (index & 0x01F)); +#else + m_p_nArray[index>>6] &= ~(((unsigned long) 0x0000000000000001) << (index & 0x03F)); +#endif // __32BITS__ + } + + + void removeSet(const Set& set); + + inline void clear() { for(int i=0; i>5] & (0x00000001 << (element & 0x01F)))!=0); +#else + return ((m_p_nArray[element>>6] & (((unsigned long) 0x0000000000000001) << (element & 0x03F)))!=0); +#endif // __32BITS__ + + } + + bool isBroadcast() const; + bool isEmpty() const; + + NodeID smallestElement() const; + + // int size() const; + void setSize (int size); + + // get element for a index + inline NodeID elementAt(int index) const + { + if(isElement(index)) return (NodeID) true; + else return 0; + } + + // gibson 05/20/05 + int getSize() const { return m_nSize; } + + // DEPRECATED METHODS + void addToSet(NodeID newElement) { add(newElement); } // Deprecated + void removeFromSet(NodeID newElement) { remove(newElement); } // Deprecated + void clearSet() { clear(); } // Deprecated + void setBroadcast() { broadcast(); } // Deprecated + bool presentInSet(NodeID element) const { return isElement(element); } // Deprecated + + void print(ostream& out) const; +private: + // Private Methods + + // Data Members (m_ prefix) + // gibson 05/20/05 + // Vector m_bits; // This is an vector of uint8 to reduce the size of the set + + int m_nSize; // the number of bits in this set + int m_nArrayLen; // the number of 32-bit words that are held in the array + + // Changed 5/24/05 for static allocation of array + // note that "long" corresponds to 32 bits on a 32-bit machine, + // 64 bits if the -m64 parameter is passed to g++, which it is + // for an AMD opteron under our configuration + + long * m_p_nArray; // an word array to hold the bits in the set + long m_p_nArray_Static[NUMBER_WORDS_PER_SET]; +}; + +// Output operator declaration +ostream& operator<<(ostream& out, const Set& obj); + +// ******************* Definitions ******************* + +// Output operator definition +extern inline +ostream& operator<<(ostream& out, const Set& obj) +{ + obj.print(out); + out << flush; + return out; +} + +#endif //SET_H + diff --git a/src/mem/ruby/common/Set.cc b/src/mem/ruby/common/Set.cc new file mode 100644 index 000000000..1f5b49f90 --- /dev/null +++ b/src/mem/ruby/common/Set.cc @@ -0,0 +1,231 @@ + +/* + * 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. + */ + +/* + * Set.C + * + * Description: See Set.h + * + * $Id$ + * + */ + +#include "Set.hh" +#include "RubyConfig.hh" + +#ifdef OPTBIGSET +#include "OptBigSet.cc" +#else + +#ifdef BIGSET +#include "BigSet.cc" // code to supports sets larger than 32 +#else + +Set::Set() +{ + setSize(RubyConfig::numberOfChips()); +} + +Set::Set(int size) +{ + setSize(size); +} + +bool Set::isEqual(const Set& set) +{ + return (m_bits == set.m_bits); +} + +void Set::add(NodeID index) +{ + assert((m_bits & m_mask) == m_bits); // check for any bits outside the range + assert(index < m_size); + m_bits |= (1 << index); + assert((m_bits & m_mask) == m_bits); // check for any bits outside the range +} + +void Set::addSet(const Set& set) +{ + assert(m_size == set.m_size); + m_bits |= set.m_bits; + assert((m_bits & m_mask) == m_bits); // check for any bits outside the range +} + +void Set::addRandom() +{ + m_bits |= random(); + m_bits &= m_mask; + assert((m_bits & m_mask) == m_bits); // check for any bits outside the range +} + +void Set::remove(NodeID index) +{ + assert(index < m_size); + m_bits &= ~(1 << index); + assert((m_bits & m_mask) == m_bits); // check for any bits outside the range +} + +void Set::removeSet(const Set& set) +{ + assert(m_size == set.m_size); + m_bits &= ~(set.m_bits); + assert((m_bits & m_mask) == m_bits); // check for any bits outside the range +} + +void Set::clear() +{ + m_bits = 0; +} + +void Set::broadcast() +{ + m_bits = m_mask; +} + +int Set::count() const +{ + int counter = 0; + for (int i=0; i 0); + int counter = 0; + for (int i=0; i 0); + int offset = m_address.getOffset(); + for(int i=0; isetByte(i, data.getByte(offset+i)); + } +} + +void SubBlock::internalMergeTo(DataBlock& data) const +{ + int size = getSize(); + assert(size > 0); + int offset = m_address.getOffset(); + for(int i=0; igetByte(i)); // This will detect crossing a cache line boundary + } +} + +void SubBlock::print(ostream& out) const +{ + out << "[" << m_address << ", " << getSize() << ", " << m_data << "]"; +} + + + diff --git a/src/mem/ruby/common/SubBlock.hh b/src/mem/ruby/common/SubBlock.hh new file mode 100644 index 000000000..43f91e191 --- /dev/null +++ b/src/mem/ruby/common/SubBlock.hh @@ -0,0 +1,105 @@ + +/* + * 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$ + * + */ + +#ifndef SubBlock_H +#define SubBlock_H + +#include "Global.hh" +#include "Address.hh" +#include "RubyConfig.hh" +#include "DataBlock.hh" +#include "Vector.hh" + +class SubBlock { +public: + // Constructors + SubBlock() { } + SubBlock(const Address& addr, int size); + SubBlock(const Address& addr, const Address& logicalAddress, int size); + + // Destructor + ~SubBlock() { } + + // Public Methods + const Address& getAddress() const { return m_address; } + const Address& getLogicalAddress() const { return m_logicalAddress; } + void setAddress(const Address& addr) { m_address = addr; } + void setLogicalAddress(const Address& addr) { m_logicalAddress = 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; } + + // 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 { if (DATA_BLOCK) { internalMergeTo(data); } } + void mergeFrom(const DataBlock& data) { if (DATA_BLOCK) { internalMergeFrom(data); } } + + void print(ostream& out) const; +private: + // Private Methods + // SubBlock(const SubBlock& obj); + // SubBlock& operator=(const SubBlock& obj); + // bool bytePresent(const Address& addr) { return ((addr.getAddress() >= m_address.getAddress()) && (addr.getAddress() < (m_address.getAddress()+getSize()))); } + // uint8 getByte(const Address& addr) { return m_data[addr.getAddress() - m_address.getAddress()]; } + + void internalMergeTo(DataBlock& data) const; + void internalMergeFrom(const DataBlock& data); + + // Data Members (m_ prefix) + Address m_address; + Address m_logicalAddress; + Vector 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) +{ + obj.print(out); + out << flush; + return out; +} + +#endif //SubBlock_H -- cgit v1.2.3 From ab5e4a22b3893fb0ccdfbf466d46983caeb5948e Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Mon, 11 May 2009 10:38:44 -0700 Subject: ruby: Removed System name clash by renaming ruby's System to RubySystem --- src/mem/ruby/common/Driver.hh | 2 +- src/mem/ruby/common/Global.cc | 2 +- src/mem/ruby/common/Global.hh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mem/ruby/common') diff --git a/src/mem/ruby/common/Driver.hh b/src/mem/ruby/common/Driver.hh index 911cb742b..1d5b883ac 100644 --- a/src/mem/ruby/common/Driver.hh +++ b/src/mem/ruby/common/Driver.hh @@ -35,7 +35,7 @@ #include "NodeID.hh" #include "CacheRequestType.hh" -class System; +class RubySystem; class SubBlock; class Address; class MachineID; diff --git a/src/mem/ruby/common/Global.cc b/src/mem/ruby/common/Global.cc index e60cd4fd3..4ebcd93ce 100644 --- a/src/mem/ruby/common/Global.cc +++ b/src/mem/ruby/common/Global.cc @@ -30,6 +30,6 @@ #include "Global.hh" EventQueue* g_eventQueue_ptr = NULL; -System* g_system_ptr = NULL; +RubySystem* g_system_ptr = NULL; Debug* g_debug_ptr = NULL; diff --git a/src/mem/ruby/common/Global.hh b/src/mem/ruby/common/Global.hh index eaec05d46..2977e696d 100644 --- a/src/mem/ruby/common/Global.hh +++ b/src/mem/ruby/common/Global.hh @@ -92,8 +92,8 @@ typedef int LinkID; class EventQueue; extern EventQueue* g_eventQueue_ptr; -class System; -extern System* g_system_ptr; +class RubySystem; +extern RubySystem* g_system_ptr; class Debug; extern Debug* g_debug_ptr; -- cgit v1.2.3 From 6e8373fad6f5faac0648c814f8c7ddc21023dc6c Mon Sep 17 00:00:00 2001 From: Derek Hower Date: Mon, 11 May 2009 10:38:45 -0700 Subject: ruby: Renamed Ruby's EventQueue to RubyEventQueue --HG-- rename : src/mem/ruby/eventqueue/EventQueue.cc => src/mem/ruby/eventqueue/RubyEventQueue.cc rename : src/mem/ruby/eventqueue/EventQueue.hh => src/mem/ruby/eventqueue/RubyEventQueue.hh rename : src/mem/ruby/eventqueue/EventQueueNode.cc => src/mem/ruby/eventqueue/RubyEventQueueNode.cc rename : src/mem/ruby/eventqueue/EventQueueNode.hh => src/mem/ruby/eventqueue/RubyEventQueueNode.hh --- src/mem/ruby/common/Consumer.hh | 2 +- src/mem/ruby/common/Debug.cc | 2 +- src/mem/ruby/common/Global.cc | 2 +- src/mem/ruby/common/Global.hh | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/mem/ruby/common') diff --git a/src/mem/ruby/common/Consumer.hh b/src/mem/ruby/common/Consumer.hh index bd51af7ba..e8dada9ca 100644 --- a/src/mem/ruby/common/Consumer.hh +++ b/src/mem/ruby/common/Consumer.hh @@ -40,7 +40,7 @@ #define CONSUMER_H #include "Global.hh" -#include "EventQueue.hh" +#include "RubyEventQueue.hh" class MessageBuffer; diff --git a/src/mem/ruby/common/Debug.cc b/src/mem/ruby/common/Debug.cc index f0319ceb8..a07e61b2d 100644 --- a/src/mem/ruby/common/Debug.cc +++ b/src/mem/ruby/common/Debug.cc @@ -37,7 +37,7 @@ #include "Global.hh" #include "Debug.hh" -#include "EventQueue.hh" +#include "RubyEventQueue.hh" class Debug; extern Debug* g_debug_ptr; diff --git a/src/mem/ruby/common/Global.cc b/src/mem/ruby/common/Global.cc index 4ebcd93ce..73a26269a 100644 --- a/src/mem/ruby/common/Global.cc +++ b/src/mem/ruby/common/Global.cc @@ -29,7 +29,7 @@ #include "Global.hh" -EventQueue* g_eventQueue_ptr = NULL; +RubyEventQueue* g_eventQueue_ptr = NULL; RubySystem* g_system_ptr = NULL; Debug* g_debug_ptr = NULL; diff --git a/src/mem/ruby/common/Global.hh b/src/mem/ruby/common/Global.hh index 2977e696d..e4014df9b 100644 --- a/src/mem/ruby/common/Global.hh +++ b/src/mem/ruby/common/Global.hh @@ -89,8 +89,8 @@ typedef unsigned int uint; typedef int SwitchID; typedef int LinkID; -class EventQueue; -extern EventQueue* g_eventQueue_ptr; +class RubyEventQueue; +extern RubyEventQueue* g_eventQueue_ptr; class RubySystem; extern RubySystem* g_system_ptr; -- cgit v1.2.3 From e1915f16d140f568dc713820189455cfdf5f9772 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Mon, 11 May 2009 10:38:45 -0700 Subject: ruby: fold the debugging options into Debug.cc --- src/mem/ruby/common/Debug.cc | 39 +++++++++++++++++++++++++-------------- src/mem/ruby/common/Debug.def | 17 ----------------- src/mem/ruby/common/Debug.hh | 21 +++++++++++++++++---- 3 files changed, 42 insertions(+), 35 deletions(-) delete mode 100644 src/mem/ruby/common/Debug.def (limited to 'src/mem/ruby/common') diff --git a/src/mem/ruby/common/Debug.cc b/src/mem/ruby/common/Debug.cc index a07e61b2d..4c2263b0c 100644 --- a/src/mem/ruby/common/Debug.cc +++ b/src/mem/ruby/common/Debug.cc @@ -43,20 +43,31 @@ class Debug; extern Debug* g_debug_ptr; std::ostream * debug_cout_ptr; -// component character list -const char DEFINE_COMP_CHAR[] = +struct DebugComponentData { -#undef DEFINE_COMP -#define DEFINE_COMP(component, character, description) character, -#include "Debug.def" + const char *desc; + const char ch; }; -// component description list -const char* DEFINE_COMP_DESCRIPTION[] = +// component character list +DebugComponentData debugComponents[] = { -#undef DEFINE_COMP -#define DEFINE_COMP(component, character, description) description, -#include "Debug.def" + {"System", 's' }, + {"Node", 'N' }, + {"Queue", 'q' }, + {"Event Queue", 'e' }, + {"Network", 'n' }, + {"Sequencer", 'S' }, + {"Tester", 't' }, + {"Generated", 'g' }, + {"SLICC", 'l' }, + {"Network Queues", 'Q' }, + {"Time", 'T' }, + {"Network Internals", 'i' }, + {"Store Buffer", 'b' }, + {"Cache", 'c' }, + {"Predictor", 'p' }, + {"Allocator", 'a' }, }; extern "C" void changeDebugVerbosity(VerbosityLevel vb); @@ -197,7 +208,7 @@ bool Debug::checkFilter(char ch) { for (int i=0; i Date: Mon, 11 May 2009 10:38:45 -0700 Subject: ruby: Make ruby #includes use full paths to the files they're including. This basically means changing all #include statements and changing autogenerated code so that it generates the correct paths. Because slicc generates #includes, I had to hard code the include paths to mem/protocol. --- src/mem/ruby/common/Address.cc | 2 +- src/mem/ruby/common/Address.hh | 8 ++++---- src/mem/ruby/common/BigSet.cc | 4 ++-- src/mem/ruby/common/BigSet.hh | 8 ++++---- src/mem/ruby/common/Consumer.hh | 4 ++-- src/mem/ruby/common/DataBlock.cc | 2 +- src/mem/ruby/common/DataBlock.hh | 6 +++--- src/mem/ruby/common/Debug.cc | 6 +++--- src/mem/ruby/common/Driver.cc | 2 +- src/mem/ruby/common/Driver.hh | 14 +++++++------- src/mem/ruby/common/Global.cc | 2 +- src/mem/ruby/common/Global.hh | 4 ++-- src/mem/ruby/common/Histogram.cc | 2 +- src/mem/ruby/common/Histogram.hh | 4 ++-- src/mem/ruby/common/Message.cc | 2 +- src/mem/ruby/common/NetDest.cc | 6 +++--- src/mem/ruby/common/NetDest.hh | 14 +++++++------- src/mem/ruby/common/OptBigSet.cc | 4 ++-- src/mem/ruby/common/OptBigSet.hh | 8 ++++---- src/mem/ruby/common/Set.cc | 4 ++-- src/mem/ruby/common/Set.hh | 12 ++++++------ src/mem/ruby/common/SubBlock.cc | 2 +- src/mem/ruby/common/SubBlock.hh | 10 +++++----- 23 files changed, 65 insertions(+), 65 deletions(-) (limited to 'src/mem/ruby/common') diff --git a/src/mem/ruby/common/Address.cc b/src/mem/ruby/common/Address.cc index 5d38faae0..b4ad39294 100644 --- a/src/mem/ruby/common/Address.cc +++ b/src/mem/ruby/common/Address.cc @@ -31,7 +31,7 @@ * $Id$ */ -#include "Address.hh" +#include "mem/ruby/common/Address.hh" void Address::output(ostream& out) const { diff --git a/src/mem/ruby/common/Address.hh b/src/mem/ruby/common/Address.hh index 3c3c5ad30..da218f177 100644 --- a/src/mem/ruby/common/Address.hh +++ b/src/mem/ruby/common/Address.hh @@ -25,10 +25,10 @@ #define ADDRESS_H #include -#include "Global.hh" -#include "RubyConfig.hh" -#include "NodeID.hh" -#include "MachineID.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/ruby/config/RubyConfig.hh" +#include "mem/ruby/system/NodeID.hh" +#include "mem/ruby/system/MachineID.hh" const int ADDRESS_WIDTH = 64; // address width in bytes diff --git a/src/mem/ruby/common/BigSet.cc b/src/mem/ruby/common/BigSet.cc index e16284f15..f55d7b79c 100644 --- a/src/mem/ruby/common/BigSet.cc +++ b/src/mem/ruby/common/BigSet.cc @@ -27,8 +27,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "Set.hh" -#include "RubyConfig.hh" +#include "mem/ruby/common/Set.hh" +#include "mem/ruby/config/RubyConfig.hh" Set::Set() { diff --git a/src/mem/ruby/common/BigSet.hh b/src/mem/ruby/common/BigSet.hh index 4eae01681..06ee6a66d 100644 --- a/src/mem/ruby/common/BigSet.hh +++ b/src/mem/ruby/common/BigSet.hh @@ -33,10 +33,10 @@ #ifndef SET_H #define SET_H -#include "Global.hh" -#include "Vector.hh" -#include "NodeID.hh" -#include "RubyConfig.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/gems_common/Vector.hh" +#include "mem/ruby/system/NodeID.hh" +#include "mem/ruby/config/RubyConfig.hh" enum PresenceBit {NotPresent, Present}; diff --git a/src/mem/ruby/common/Consumer.hh b/src/mem/ruby/common/Consumer.hh index e8dada9ca..34cd7864c 100644 --- a/src/mem/ruby/common/Consumer.hh +++ b/src/mem/ruby/common/Consumer.hh @@ -39,8 +39,8 @@ #ifndef CONSUMER_H #define CONSUMER_H -#include "Global.hh" -#include "RubyEventQueue.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/ruby/eventqueue/RubyEventQueue.hh" class MessageBuffer; diff --git a/src/mem/ruby/common/DataBlock.cc b/src/mem/ruby/common/DataBlock.cc index c4d6d7a33..ce72bc7f4 100644 --- a/src/mem/ruby/common/DataBlock.cc +++ b/src/mem/ruby/common/DataBlock.cc @@ -31,7 +31,7 @@ * $Id$ */ -#include "DataBlock.hh" +#include "mem/ruby/common/DataBlock.hh" DataBlock::DataBlock() { diff --git a/src/mem/ruby/common/DataBlock.hh b/src/mem/ruby/common/DataBlock.hh index aae364078..8711cb740 100644 --- a/src/mem/ruby/common/DataBlock.hh +++ b/src/mem/ruby/common/DataBlock.hh @@ -30,9 +30,9 @@ #ifndef DATABLOCK_H #define DATABLOCK_H -#include "Global.hh" -#include "RubyConfig.hh" -#include "Vector.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/ruby/config/RubyConfig.hh" +#include "mem/gems_common/Vector.hh" class DataBlock { public: diff --git a/src/mem/ruby/common/Debug.cc b/src/mem/ruby/common/Debug.cc index 4c2263b0c..02f4069ee 100644 --- a/src/mem/ruby/common/Debug.cc +++ b/src/mem/ruby/common/Debug.cc @@ -35,9 +35,9 @@ #include #include -#include "Global.hh" -#include "Debug.hh" -#include "RubyEventQueue.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/ruby/common/Debug.hh" +#include "mem/ruby/eventqueue/RubyEventQueue.hh" class Debug; extern Debug* g_debug_ptr; diff --git a/src/mem/ruby/common/Driver.cc b/src/mem/ruby/common/Driver.cc index 019ac6403..2d6034b02 100644 --- a/src/mem/ruby/common/Driver.cc +++ b/src/mem/ruby/common/Driver.cc @@ -27,7 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "Driver.hh" +#include "mem/ruby/common/Driver.hh" Driver::Driver() { diff --git a/src/mem/ruby/common/Driver.hh b/src/mem/ruby/common/Driver.hh index 1d5b883ac..c527e7d2b 100644 --- a/src/mem/ruby/common/Driver.hh +++ b/src/mem/ruby/common/Driver.hh @@ -30,10 +30,10 @@ #ifndef DRIVER_H #define DRIVER_H -#include "Global.hh" -#include "Consumer.hh" -#include "NodeID.hh" -#include "CacheRequestType.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/ruby/common/Consumer.hh" +#include "mem/ruby/system/NodeID.hh" +#include "mem/protocol/CacheRequestType.hh" class RubySystem; class SubBlock; @@ -62,15 +62,15 @@ public: virtual void notifyTrapStart( int procID, const Address & handlerPC, int threadID, int smtThread ) { assert(0); } //called by Sequencer virtual void notifyTrapComplete( int procID, const Address & newPC, int smtThread ) {assert(0); } // called by Sequencer virtual int getOpalTransactionLevel(int procID, int thread) const { - cout << "Driver.hh getOpalTransactionLevel() " << endl; + cout << "mem/ruby/common/Driver.hh getOpalTransactionLevel() " << endl; return 0; } //called by Sequencer virtual void addThreadDependency(int procID, int requestor_thread, int conflict_thread) const { assert(0);} virtual uint64 getOpalTime(int procID) const{ return 0; } //called by Sequencer virtual uint64 getOpalTimestamp(int procID, int thread) const{ - cout << "Driver.hh getOpalTimestamp " << endl; + cout << "mem/ruby/common/Driver.hh getOpalTimestamp " << endl; return 0; } // called by Sequencer virtual int inTransaction(int procID, int thread ) const{ - cout << "Driver.hh inTransaction " << endl; + cout << "mem/ruby/common/Driver.hh inTransaction " << endl; return false; } //called by Sequencer virtual void printDebug(){} //called by Sequencer diff --git a/src/mem/ruby/common/Global.cc b/src/mem/ruby/common/Global.cc index 73a26269a..7c7cab1e8 100644 --- a/src/mem/ruby/common/Global.cc +++ b/src/mem/ruby/common/Global.cc @@ -27,7 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "Global.hh" +#include "mem/ruby/common/Global.hh" RubyEventQueue* g_eventQueue_ptr = NULL; RubySystem* g_system_ptr = NULL; diff --git a/src/mem/ruby/common/Global.hh b/src/mem/ruby/common/Global.hh index e4014df9b..6b524bb70 100644 --- a/src/mem/ruby/common/Global.hh +++ b/src/mem/ruby/common/Global.hh @@ -78,8 +78,8 @@ typedef uint64 pa_t; typedef integer_t simtime_t; // external includes for all classes -#include "std-includes.hh" -#include "Debug.hh" +#include "mem/gems_common/std-includes.hh" +#include "mem/ruby/common/Debug.hh" // simple type declarations typedef Time LogicalTime; diff --git a/src/mem/ruby/common/Histogram.cc b/src/mem/ruby/common/Histogram.cc index 9c5e8e623..7f9a7027e 100644 --- a/src/mem/ruby/common/Histogram.cc +++ b/src/mem/ruby/common/Histogram.cc @@ -32,7 +32,7 @@ * */ -#include "Histogram.hh" +#include "mem/ruby/common/Histogram.hh" Histogram::Histogram(int binsize, int bins) { diff --git a/src/mem/ruby/common/Histogram.hh b/src/mem/ruby/common/Histogram.hh index e48efc35f..59afde867 100644 --- a/src/mem/ruby/common/Histogram.hh +++ b/src/mem/ruby/common/Histogram.hh @@ -37,8 +37,8 @@ #ifndef HISTOGRAM_H #define HISTOGRAM_H -#include "Global.hh" -#include "Vector.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/gems_common/Vector.hh" class Histogram { public: diff --git a/src/mem/ruby/common/Message.cc b/src/mem/ruby/common/Message.cc index baad8ac9b..bf3307687 100644 --- a/src/mem/ruby/common/Message.cc +++ b/src/mem/ruby/common/Message.cc @@ -31,4 +31,4 @@ * $Id$ */ -#include "Message.hh" +#include "mem/ruby/slicc_interface/Message.hh" diff --git a/src/mem/ruby/common/NetDest.cc b/src/mem/ruby/common/NetDest.cc index 79a6078e9..951307395 100644 --- a/src/mem/ruby/common/NetDest.cc +++ b/src/mem/ruby/common/NetDest.cc @@ -36,9 +36,9 @@ * */ -#include "NetDest.hh" -#include "RubyConfig.hh" -#include "Protocol.hh" +#include "mem/ruby/common/NetDest.hh" +#include "mem/ruby/config/RubyConfig.hh" +#include "mem/protocol/Protocol.hh" NetDest::NetDest() { diff --git a/src/mem/ruby/common/NetDest.hh b/src/mem/ruby/common/NetDest.hh index 04f7871f6..17ede03e9 100644 --- a/src/mem/ruby/common/NetDest.hh +++ b/src/mem/ruby/common/NetDest.hh @@ -44,13 +44,13 @@ #ifndef NETDEST_H #define NETDEST_H -#include "Global.hh" -#include "Vector.hh" -#include "NodeID.hh" -#include "MachineID.hh" -#include "RubyConfig.hh" -#include "Set.hh" -#include "MachineType.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/gems_common/Vector.hh" +#include "mem/ruby/system/NodeID.hh" +#include "mem/ruby/system/MachineID.hh" +#include "mem/ruby/config/RubyConfig.hh" +#include "mem/ruby/common/Set.hh" +#include "mem/protocol/MachineType.hh" class Set; diff --git a/src/mem/ruby/common/OptBigSet.cc b/src/mem/ruby/common/OptBigSet.cc index 51214e936..b4c4e4789 100644 --- a/src/mem/ruby/common/OptBigSet.cc +++ b/src/mem/ruby/common/OptBigSet.cc @@ -39,8 +39,8 @@ // modified (rewritten) 05/20/05 by Dan Gibson to accomimdate FASTER >32 bit // set sizes -#include "Set.hh" -#include "RubyConfig.hh" +#include "mem/ruby/common/Set.hh" +#include "mem/ruby/config/RubyConfig.hh" #if __amd64__ || __LP64__ #define __64BITS__ diff --git a/src/mem/ruby/common/OptBigSet.hh b/src/mem/ruby/common/OptBigSet.hh index a57a07e13..45f06e6aa 100644 --- a/src/mem/ruby/common/OptBigSet.hh +++ b/src/mem/ruby/common/OptBigSet.hh @@ -45,10 +45,10 @@ #ifndef SET_H #define SET_H -#include "Global.hh" -#include "Vector.hh" -#include "NodeID.hh" -#include "RubyConfig.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/gems_common/Vector.hh" +#include "mem/ruby/system/NodeID.hh" +#include "mem/ruby/config/RubyConfig.hh" // gibson 05/20/05 // enum PresenceBit {NotPresent, Present}; diff --git a/src/mem/ruby/common/Set.cc b/src/mem/ruby/common/Set.cc index 1f5b49f90..ce4b4af04 100644 --- a/src/mem/ruby/common/Set.cc +++ b/src/mem/ruby/common/Set.cc @@ -36,8 +36,8 @@ * */ -#include "Set.hh" -#include "RubyConfig.hh" +#include "mem/ruby/common/Set.hh" +#include "mem/ruby/config/RubyConfig.hh" #ifdef OPTBIGSET #include "OptBigSet.cc" diff --git a/src/mem/ruby/common/Set.hh b/src/mem/ruby/common/Set.hh index 7c33c840d..ea16c66a5 100644 --- a/src/mem/ruby/common/Set.hh +++ b/src/mem/ruby/common/Set.hh @@ -44,20 +44,20 @@ #define OPTBIGSET #ifdef OPTBIGSET -#include "OptBigSet.hh" +#include "mem/ruby/common/OptBigSet.hh" #else #ifdef BIGSET -#include "BigSet.hh" // code to supports sets larger than 32 +#include "mem/ruby/common/BigSet.hh" // code to supports sets larger than 32 #else #ifndef SET_H #define SET_H -#include "Global.hh" -#include "Vector.hh" -#include "NodeID.hh" -#include "RubyConfig.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/gems_common/Vector.hh" +#include "mem/ruby/system/NodeID.hh" +#include "mem/ruby/config/RubyConfig.hh" class Set { public: diff --git a/src/mem/ruby/common/SubBlock.cc b/src/mem/ruby/common/SubBlock.cc index f79e33d9c..568d3106a 100644 --- a/src/mem/ruby/common/SubBlock.cc +++ b/src/mem/ruby/common/SubBlock.cc @@ -31,7 +31,7 @@ * $Id$ */ -#include "SubBlock.hh" +#include "mem/ruby/common/SubBlock.hh" SubBlock::SubBlock(const Address& addr, int size) { diff --git a/src/mem/ruby/common/SubBlock.hh b/src/mem/ruby/common/SubBlock.hh index 43f91e191..5831be35a 100644 --- a/src/mem/ruby/common/SubBlock.hh +++ b/src/mem/ruby/common/SubBlock.hh @@ -35,11 +35,11 @@ #ifndef SubBlock_H #define SubBlock_H -#include "Global.hh" -#include "Address.hh" -#include "RubyConfig.hh" -#include "DataBlock.hh" -#include "Vector.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/ruby/common/Address.hh" +#include "mem/ruby/config/RubyConfig.hh" +#include "mem/ruby/common/DataBlock.hh" +#include "mem/gems_common/Vector.hh" class SubBlock { public: -- cgit v1.2.3 From 7311fd7182bfe65206c5655d058a72dd717cbe42 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Mon, 11 May 2009 10:38:46 -0700 Subject: ruby: Migrate all of ruby and slicc to SCons. Add the PROTOCOL sticky option sets the coherence protocol that slicc will parse and therefore ruby will use. This whole process was made difficult by the fact that the set of files that are output by slicc are not easily known ahead of time. The easiest thing wound up being to write a parser for slicc that would tell me. Incidentally this means we now have a slicc grammar written in python. --- src/mem/ruby/common/Debug.hh | 2 ++ src/mem/ruby/common/SConscript | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/mem/ruby/common/SConscript (limited to 'src/mem/ruby/common') diff --git a/src/mem/ruby/common/Debug.hh b/src/mem/ruby/common/Debug.hh index 5ac171275..6dce98dd5 100644 --- a/src/mem/ruby/common/Debug.hh +++ b/src/mem/ruby/common/Debug.hh @@ -37,6 +37,8 @@ #include #include +#include "config/ruby_debug.hh" + extern std::ostream * debug_cout_ptr; // component enumeration diff --git a/src/mem/ruby/common/SConscript b/src/mem/ruby/common/SConscript new file mode 100644 index 000000000..8313aa7ad --- /dev/null +++ b/src/mem/ruby/common/SConscript @@ -0,0 +1,42 @@ +# -*- mode:python -*- + +# Copyright (c) 2009 The Hewlett-Packard Development Company +# 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. +# +# Authors: Nathan Binkert + +Import('*') + +Source('Address.cc') +Source('DataBlock.cc') +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') -- cgit v1.2.3 From 7769cc9092ccfd8c6c2286762631f0d0f1f16d04 Mon Sep 17 00:00:00 2001 From: Polina Dudnik Date: Mon, 11 May 2009 10:38:46 -0700 Subject: ruby: decommission code 1. Set.* and BigSet.* are replaced with OptBigSet.* which was renamed Set.* 2. Decomissioned all bloom filters 3. Decomissioned ruby/simics directory --- src/mem/ruby/common/BigSet.cc | 249 ----------------- src/mem/ruby/common/BigSet.hh | 125 --------- src/mem/ruby/common/OptBigSet.cc | 576 --------------------------------------- src/mem/ruby/common/OptBigSet.hh | 202 -------------- src/mem/ruby/common/Set.cc | 549 ++++++++++++++++++++++++++++++------- src/mem/ruby/common/Set.hh | 117 +++++--- 6 files changed, 532 insertions(+), 1286 deletions(-) delete mode 100644 src/mem/ruby/common/BigSet.cc delete mode 100644 src/mem/ruby/common/BigSet.hh delete mode 100644 src/mem/ruby/common/OptBigSet.cc delete mode 100644 src/mem/ruby/common/OptBigSet.hh (limited to 'src/mem/ruby/common') diff --git a/src/mem/ruby/common/BigSet.cc b/src/mem/ruby/common/BigSet.cc deleted file mode 100644 index f55d7b79c..000000000 --- a/src/mem/ruby/common/BigSet.cc +++ /dev/null @@ -1,249 +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. - */ - -#include "mem/ruby/common/Set.hh" -#include "mem/ruby/config/RubyConfig.hh" - -Set::Set() -{ - setSize(RubyConfig::numberOfProcessors()); -} - -Set::Set(int size) -{ - setSize(size); -} - -void Set::add(NodeID index) -{ - m_bits[index] = Present; -} - -void Set::addSet(const Set& set) -{ - assert(m_bits.size() == set.getSize()); - for (int i=0; i> 1); // Shift the random number to look at the next bit - } -} - -void Set::remove(NodeID index) -{ - m_bits[index] = NotPresent; -} - -void Set::removeSet(const Set& set) -{ - assert(m_bits.size() == set.getSize()); - for (int i=0; i 0); - for (int i=0; i m_bits; // This is an vector of uint8 to reduce the size of the set -}; - -// Output operator declaration -ostream& operator<<(ostream& out, const Set& obj); - -// ******************* Definitions ******************* - -// Output operator definition -extern inline -ostream& operator<<(ostream& out, const Set& obj) -{ - obj.print(out); - out << flush; - return out; -} - -#endif //SET_H - diff --git a/src/mem/ruby/common/OptBigSet.cc b/src/mem/ruby/common/OptBigSet.cc deleted file mode 100644 index b4c4e4789..000000000 --- a/src/mem/ruby/common/OptBigSet.cc +++ /dev/null @@ -1,576 +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. - */ - -/* - * Set.C - * - * Description: See Set.h - * - * $Id: BigSet.C 1.9 05/01/19 13:12:25-06:00 mikem@maya.cs.wisc.edu $ - * - */ - -// modified (rewritten) 05/20/05 by Dan Gibson to accomimdate FASTER >32 bit -// set sizes - -#include "mem/ruby/common/Set.hh" -#include "mem/ruby/config/RubyConfig.hh" - -#if __amd64__ || __LP64__ -#define __64BITS__ -#else -#define __32BITS__ -#endif - -Set::Set() -{ - m_p_nArray = NULL; - setSize(RubyConfig::numberOfProcessors()); -} - -// copy constructor -Set::Set(const Set& obj) { - m_p_nArray = NULL; - setSize(obj.m_nSize); - - // copy from the host to this array - for(int i=0; i0); - setSize(size); -} - -Set::~Set() { - if( (m_p_nArray != (&m_p_nArray_Static[0])) && (m_p_nArray != NULL)) - delete [] m_p_nArray; - m_p_nArray = NULL; -} - - -// /* -// * This function should set the bit corresponding to index -// * to 1. -// */ - -// void Set::add(NodeID index) -// { -// assert(index= 0); - -// #ifdef __32BITS__ -// m_p_nArray[index>>5] |= (1 << (index & 0x01F)); -// #else -// m_p_nArray[index>>6] |= (((unsigned long) 1) << (index & 0x03F)); -// #endif // __32BITS__ - -// } - -/* - * This function should set all the bits in the current set - * that are already set in the parameter set - */ -void Set::addSet(const Set& set) -{ - assert(getSize()==set.getSize()); - for(int i=0; i> 1; - } - } -#else - long mask = 0x7FFFFFFFFFFFFFFF; - - // the number of populated spaces in the higest-order array slot is: - // m_nSize % 64, so the uppermost 64 - m_nSize%64 bits should be - // cleared - - if((m_nSize % 64) != 0) { - for(int j=0; j<64-(m_nSize&0x03F); j++) { - m_p_nArray[m_nArrayLen-1] &= mask; - mask = mask >> 1; - } - } -#endif // __32BITS__ - -} - -// /* -// * This function unsets the bit associated with index -// */ -// void Set::remove(NodeID index) -// { -// assert(index=0); - -// #ifdef __32BITS__ -// m_p_nArray[index>>5] &= ~(0x00000001 << (index & 0x01F)); -// #else -// m_p_nArray[index>>6] &= ~(((unsigned long) 0x0000000000000001) << (index & 0x03F)); -// #endif // __32BITS__ - -// } - - -/* - * This function clears bits that are =1 in the parameter set - */ -void Set::removeSet(const Set& set) -{ - - assert(m_nSize==set.m_nSize); - for(int i=0; i> 1; - } - } -#else - long mask = 0x7FFFFFFFFFFFFFFF; - - // the number of populated spaces in the higest-order array slot is: - // m_nSize % 64, so the uppermost 64 - m_nSize%64 bits should be - // cleared - - if((m_nSize % 64) != 0) { - for(int j=0; j<64-(m_nSize&0x03F); j++) { - m_p_nArray[m_nArrayLen-1] &= mask; - mask = mask >> 1; - } - } -#endif // __32BITS__ - -} - -/* - * This function returns the population count of 1's in the set - */ -int Set::count() const -{ - int counter = 0; - long mask; - for( int i=0; i 0); - long x; - for( int i=0; i> 1; - } -#else - for( int j=0; j<64; j++) { - if(x & 0x0000000000000001) { - return 64*i+j; - } - - x = x >> 1; - } -#endif // __32BITS__ - - ERROR_MSG("No smallest element of an empty set."); - } - } - - ERROR_MSG("No smallest element of an empty set."); - - return 0; -} - -/* - * this function returns true iff all bits are set - */ -bool Set::isBroadcast() const -{ - // check the fully-loaded words by equal to 0xffffffff - // only the last word may not be fully loaded, it is not - // fully loaded iff m_nSize % 32 or 64 !=0 => fully loaded iff - // m_nSize % 32 or 64 == 0 - -#ifdef __32BITS__ - for(int i=0; i< (((m_nSize % 32)==0) ? m_nArrayLen : m_nArrayLen-1); i++) { - if(m_p_nArray[i]!=-1) { - return false; - } - } - - // now check the last word, which may not be fully loaded - long mask = 1; - for(int j=0; j< (m_nSize % 32); j++) { - if((mask & m_p_nArray[m_nArrayLen-1])==0) { - return false; - } - mask = mask << 1; - } -#else - for(int i=0; i< (((m_nSize % 64)==0) ? m_nArrayLen : m_nArrayLen-1); i++) { - if(m_p_nArray[i]!=-1) { - return false; - } - } - - // now check the last word, which may not be fully loaded - long mask = 1; - for(int j=0; j< (m_nSize % 64); j++) { - if((mask & m_p_nArray[m_nArrayLen-1])==0) { - return false; - } - mask = mask << 1; - } - -#endif // __32BITS__ - - return true; -} - -/* - * this function returns true iff no bits are set - */ -bool Set::isEmpty() const -{ - - // here we can simply check if all = 0, since we ensure - // that "extra slots" are all zero - for(int i=0; i< m_nArrayLen ; i++) { - if(m_p_nArray[i]!=0) { - return false; - } - } - - return true; -} - -// returns the logical OR of "this" set and orSet -Set Set::OR(const Set& orSet) const -{ - Set result(m_nSize); - assert(m_nSize == orSet.m_nSize); - for(int i=0; i< m_nArrayLen; i++) { - result.m_p_nArray[i] = m_p_nArray[i] | orSet.m_p_nArray[i]; - } - - return result; - -} - -// returns the logical AND of "this" set and andSet -Set Set::AND(const Set& andSet) const -{ - Set result(m_nSize); - assert(m_nSize == andSet.m_nSize); - - for(int i=0; i< m_nArrayLen; i++) { - result.m_p_nArray[i] = m_p_nArray[i] & andSet.m_p_nArray[i]; - } - - return result; -} - -// // Returns true if the intersection of the two sets is non-empty -// bool Set::intersectionIsNotEmpty(const Set& other_set) const -// { -// assert(m_nSize == other_set.m_nSize); -// for(int i=0; i< m_nArrayLen; i++) { -// if(m_p_nArray[i] & other_set.m_p_nArray[i]) { -// return true; -// } -// } - -// return false; - -// } - -// // Returns true if the intersection of the two sets is empty -// bool Set::intersectionIsEmpty(const Set& other_set) const -// { -// assert(m_nSize == other_set.m_nSize); -// for(int i=0; i< m_nArrayLen; i++) { -// if(m_p_nArray[i] & other_set.m_p_nArray[i]) { -// return false; -// } -// } - -// return true; - -// } - -/* - * Returns false if a bit is set in the parameter set that is - * NOT set in this set - */ -bool Set::isSuperset(const Set& test) const -{ - assert(m_nSize == test.m_nSize); - - for(int i=0;i>5] & (0x00000001 << (element & 0x01F)))!=0); -// #else -// result = ((m_p_nArray[element>>6] & (((unsigned long) 0x0000000000000001) << (element & 0x03F)))!=0); -// #endif // __32BITS__ - -// return result; -// } - -/* - * "Supposed" to return the node id of the (n+1)th set - * bit, IE n=0 => returns nodeid of first set bit, BUT - * since BigSet.C behaves strangely, this implementation - * will behave strangely just for reverse compatability. - * - * Was originally implemented for the flight data recorder - * FDR - */ - -// NodeID Set::elementAt(int n) const -// { -// if(isElement(n)) return (NodeID) true; -// else return 0; - -// /* -// int match = -1; -// for(int i=0;i=0; i--) { -#ifdef __32BITS__ - sprintf(buff,"%08X ",m_p_nArray[i]); -#else - sprintf(buff,"0x %016llX ",m_p_nArray[i]); -#endif // __32BITS__ - out << buff; - } - out << " ]"; - -} - - diff --git a/src/mem/ruby/common/OptBigSet.hh b/src/mem/ruby/common/OptBigSet.hh deleted file mode 100644 index 45f06e6aa..000000000 --- a/src/mem/ruby/common/OptBigSet.hh +++ /dev/null @@ -1,202 +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. - */ - -/* - * Set.h - * - * Description: - * - * $Id: BigSet.h 1.6 05/01/19 13:12:25-06:00 mikem@maya.cs.wisc.edu $ - * - */ - -// modified by Dan Gibson on 05/20/05 to accomidate FASTER -// >32 set lengths, using an array of ints w/ 32 bits/int - -// NOTE: Never include this file directly, this should only be -// included from Set.h - -#ifndef SET_H -#define SET_H - -#include "mem/ruby/common/Global.hh" -#include "mem/gems_common/Vector.hh" -#include "mem/ruby/system/NodeID.hh" -#include "mem/ruby/config/RubyConfig.hh" - -// gibson 05/20/05 -// enum PresenceBit {NotPresent, Present}; - -class Set { -public: - // Constructors - // creates and empty set - Set(); - Set (int size); - - // used during the replay mechanism - // Set(const char *str); - - Set(const Set& obj); - Set& operator=(const Set& obj); - - // Destructor - ~Set(); - - // Public Methods - - inline void add(NodeID index) - { -#ifdef __32BITS__ - m_p_nArray[index>>5] |= (1 << (index & 0x01F)); -#else - m_p_nArray[index>>6] |= (((unsigned long) 1) << (index & 0x03F)); -#endif // __32BITS__ - } - - void addSet(const Set& set); - void addRandom(); - - inline void remove(NodeID index) - { -#ifdef __32BITS__ - m_p_nArray[index>>5] &= ~(0x00000001 << (index & 0x01F)); -#else - m_p_nArray[index>>6] &= ~(((unsigned long) 0x0000000000000001) << (index & 0x03F)); -#endif // __32BITS__ - } - - - void removeSet(const Set& set); - - inline void clear() { for(int i=0; i>5] & (0x00000001 << (element & 0x01F)))!=0); -#else - return ((m_p_nArray[element>>6] & (((unsigned long) 0x0000000000000001) << (element & 0x03F)))!=0); -#endif // __32BITS__ - - } - - bool isBroadcast() const; - bool isEmpty() const; - - NodeID smallestElement() const; - - // int size() const; - void setSize (int size); - - // get element for a index - inline NodeID elementAt(int index) const - { - if(isElement(index)) return (NodeID) true; - else return 0; - } - - // gibson 05/20/05 - int getSize() const { return m_nSize; } - - // DEPRECATED METHODS - void addToSet(NodeID newElement) { add(newElement); } // Deprecated - void removeFromSet(NodeID newElement) { remove(newElement); } // Deprecated - void clearSet() { clear(); } // Deprecated - void setBroadcast() { broadcast(); } // Deprecated - bool presentInSet(NodeID element) const { return isElement(element); } // Deprecated - - void print(ostream& out) const; -private: - // Private Methods - - // Data Members (m_ prefix) - // gibson 05/20/05 - // Vector m_bits; // This is an vector of uint8 to reduce the size of the set - - int m_nSize; // the number of bits in this set - int m_nArrayLen; // the number of 32-bit words that are held in the array - - // Changed 5/24/05 for static allocation of array - // note that "long" corresponds to 32 bits on a 32-bit machine, - // 64 bits if the -m64 parameter is passed to g++, which it is - // for an AMD opteron under our configuration - - long * m_p_nArray; // an word array to hold the bits in the set - long m_p_nArray_Static[NUMBER_WORDS_PER_SET]; -}; - -// Output operator declaration -ostream& operator<<(ostream& out, const Set& obj); - -// ******************* Definitions ******************* - -// Output operator definition -extern inline -ostream& operator<<(ostream& out, const Set& obj) -{ - obj.print(out); - out << flush; - return out; -} - -#endif //SET_H - diff --git a/src/mem/ruby/common/Set.cc b/src/mem/ruby/common/Set.cc index ce4b4af04..b4c4e4789 100644 --- a/src/mem/ruby/common/Set.cc +++ b/src/mem/ruby/common/Set.cc @@ -32,200 +32,545 @@ * * Description: See Set.h * - * $Id$ + * $Id: BigSet.C 1.9 05/01/19 13:12:25-06:00 mikem@maya.cs.wisc.edu $ * */ +// modified (rewritten) 05/20/05 by Dan Gibson to accomimdate FASTER >32 bit +// set sizes + #include "mem/ruby/common/Set.hh" #include "mem/ruby/config/RubyConfig.hh" -#ifdef OPTBIGSET -#include "OptBigSet.cc" -#else - -#ifdef BIGSET -#include "BigSet.cc" // code to supports sets larger than 32 +#if __amd64__ || __LP64__ +#define __64BITS__ #else +#define __32BITS__ +#endif Set::Set() { - setSize(RubyConfig::numberOfChips()); + m_p_nArray = NULL; + setSize(RubyConfig::numberOfProcessors()); +} + +// copy constructor +Set::Set(const Set& obj) { + m_p_nArray = NULL; + setSize(obj.m_nSize); + + // copy from the host to this array + for(int i=0; i0); setSize(size); } -bool Set::isEqual(const Set& set) -{ - return (m_bits == set.m_bits); +Set::~Set() { + if( (m_p_nArray != (&m_p_nArray_Static[0])) && (m_p_nArray != NULL)) + delete [] m_p_nArray; + m_p_nArray = NULL; } -void Set::add(NodeID index) -{ - assert((m_bits & m_mask) == m_bits); // check for any bits outside the range - assert(index < m_size); - m_bits |= (1 << index); - assert((m_bits & m_mask) == m_bits); // check for any bits outside the range -} +// /* +// * This function should set the bit corresponding to index +// * to 1. +// */ + +// void Set::add(NodeID index) +// { +// assert(index= 0); + +// #ifdef __32BITS__ +// m_p_nArray[index>>5] |= (1 << (index & 0x01F)); +// #else +// m_p_nArray[index>>6] |= (((unsigned long) 1) << (index & 0x03F)); +// #endif // __32BITS__ + +// } + +/* + * This function should set all the bits in the current set + * that are already set in the parameter set + */ void Set::addSet(const Set& set) { - assert(m_size == set.m_size); - m_bits |= set.m_bits; - assert((m_bits & m_mask) == m_bits); // check for any bits outside the range + assert(getSize()==set.getSize()); + for(int i=0; i> 1; + } + } +#else + long mask = 0x7FFFFFFFFFFFFFFF; + + // the number of populated spaces in the higest-order array slot is: + // m_nSize % 64, so the uppermost 64 - m_nSize%64 bits should be + // cleared + + if((m_nSize % 64) != 0) { + for(int j=0; j<64-(m_nSize&0x03F); j++) { + m_p_nArray[m_nArrayLen-1] &= mask; + mask = mask >> 1; + } + } +#endif // __32BITS__ + } +// /* +// * This function unsets the bit associated with index +// */ +// void Set::remove(NodeID index) +// { +// assert(index=0); + +// #ifdef __32BITS__ +// m_p_nArray[index>>5] &= ~(0x00000001 << (index & 0x01F)); +// #else +// m_p_nArray[index>>6] &= ~(((unsigned long) 0x0000000000000001) << (index & 0x03F)); +// #endif // __32BITS__ + +// } + + +/* + * This function clears bits that are =1 in the parameter set + */ void Set::removeSet(const Set& set) { - assert(m_size == set.m_size); - m_bits &= ~(set.m_bits); - assert((m_bits & m_mask) == m_bits); // check for any bits outside the range -} -void Set::clear() -{ - m_bits = 0; + assert(m_nSize==set.m_nSize); + for(int i=0; i> 1; + } + } +#else + long mask = 0x7FFFFFFFFFFFFFFF; + + // the number of populated spaces in the higest-order array slot is: + // m_nSize % 64, so the uppermost 64 - m_nSize%64 bits should be + // cleared + + if((m_nSize % 64) != 0) { + for(int j=0; j<64-(m_nSize&0x03F); j++) { + m_p_nArray[m_nArrayLen-1] &= mask; + mask = mask >> 1; + } + } +#endif // __32BITS__ + } +/* + * This function returns the population count of 1's in the set + */ int Set::count() const { int counter = 0; - for (int i=0; i 0); - int counter = 0; - for (int i=0; i> 1; + } +#else + for( int j=0; j<64; j++) { + if(x & 0x0000000000000001) { + return 64*i+j; + } + + x = x >> 1; + } +#endif // __32BITS__ + + ERROR_MSG("No smallest element of an empty set."); } } + ERROR_MSG("No smallest element of an empty set."); + + return 0; } -// Returns true iff all bits are set +/* + * this function returns true iff all bits are set + */ bool Set::isBroadcast() const { - assert((m_bits & m_mask) == m_bits); // check for any bits outside the range - return (m_mask == m_bits); + // check the fully-loaded words by equal to 0xffffffff + // only the last word may not be fully loaded, it is not + // fully loaded iff m_nSize % 32 or 64 !=0 => fully loaded iff + // m_nSize % 32 or 64 == 0 + +#ifdef __32BITS__ + for(int i=0; i< (((m_nSize % 32)==0) ? m_nArrayLen : m_nArrayLen-1); i++) { + if(m_p_nArray[i]!=-1) { + return false; + } + } + + // now check the last word, which may not be fully loaded + long mask = 1; + for(int j=0; j< (m_nSize % 32); j++) { + if((mask & m_p_nArray[m_nArrayLen-1])==0) { + return false; + } + mask = mask << 1; + } +#else + for(int i=0; i< (((m_nSize % 64)==0) ? m_nArrayLen : m_nArrayLen-1); i++) { + if(m_p_nArray[i]!=-1) { + return false; + } + } + + // now check the last word, which may not be fully loaded + long mask = 1; + for(int j=0; j< (m_nSize % 64); j++) { + if((mask & m_p_nArray[m_nArrayLen-1])==0) { + return false; + } + mask = mask << 1; + } + +#endif // __32BITS__ + + return true; } -// Returns true iff no bits are set +/* + * this function returns true iff no bits are set + */ bool Set::isEmpty() const { - assert((m_bits & m_mask) == m_bits); // check for any bits outside the range - return (m_bits == 0); + + // here we can simply check if all = 0, since we ensure + // that "extra slots" are all zero + for(int i=0; i< m_nArrayLen ; i++) { + if(m_p_nArray[i]!=0) { + return false; + } + } + + return true; } // returns the logical OR of "this" set and orSet Set Set::OR(const Set& orSet) const { - assert(m_size == orSet.m_size); - Set result(m_size); - result.m_bits = (m_bits | orSet.m_bits); - assert((result.m_bits & result.m_mask) == result.m_bits); // check for any bits outside the range + Set result(m_nSize); + assert(m_nSize == orSet.m_nSize); + for(int i=0; i< m_nArrayLen; i++) { + result.m_p_nArray[i] = m_p_nArray[i] | orSet.m_p_nArray[i]; + } + return result; + } // returns the logical AND of "this" set and andSet Set Set::AND(const Set& andSet) const { - assert(m_size == andSet.m_size); - Set result(m_size); - result.m_bits = (m_bits & andSet.m_bits); - assert((result.m_bits & result.m_mask) == result.m_bits); // check for any bits outside the range + Set result(m_nSize); + assert(m_nSize == andSet.m_nSize); + + for(int i=0; i< m_nArrayLen; i++) { + result.m_p_nArray[i] = m_p_nArray[i] & andSet.m_p_nArray[i]; + } + return result; } -// Returns true if the intersection of the two sets is non-empty -bool Set::intersectionIsNotEmpty(const Set& other_set) const -{ - assert(m_size == other_set.m_size); - return ((m_bits & other_set.m_bits) != 0); -} +// // Returns true if the intersection of the two sets is non-empty +// bool Set::intersectionIsNotEmpty(const Set& other_set) const +// { +// assert(m_nSize == other_set.m_nSize); +// for(int i=0; i< m_nArrayLen; i++) { +// if(m_p_nArray[i] & other_set.m_p_nArray[i]) { +// return true; +// } +// } -// Returns true if the intersection of the two sets is empty -bool Set::intersectionIsEmpty(const Set& other_set) const -{ - assert(m_size == other_set.m_size); - return ((m_bits & other_set.m_bits) == 0); -} +// return false; + +// } + +// // Returns true if the intersection of the two sets is empty +// bool Set::intersectionIsEmpty(const Set& other_set) const +// { +// assert(m_nSize == other_set.m_nSize); +// for(int i=0; i< m_nArrayLen; i++) { +// if(m_p_nArray[i] & other_set.m_p_nArray[i]) { +// return false; +// } +// } + +// return true; + +// } +/* + * Returns false if a bit is set in the parameter set that is + * NOT set in this set + */ bool Set::isSuperset(const Set& test) const { - assert(m_size == test.m_size); - uint32 temp = (test.m_bits & (~m_bits)); - return (temp == 0); -} + assert(m_nSize == test.m_nSize); -bool Set::isElement(NodeID element) const -{ - return ((m_bits & (1 << element)) != 0); + for(int i=0;i>5] & (0x00000001 << (element & 0x01F)))!=0); +// #else +// result = ((m_p_nArray[element>>6] & (((unsigned long) 0x0000000000000001) << (element & 0x03F)))!=0); +// #endif // __32BITS__ + +// return result; +// } + +/* + * "Supposed" to return the node id of the (n+1)th set + * bit, IE n=0 => returns nodeid of first set bit, BUT + * since BigSet.C behaves strangely, this implementation + * will behave strangely just for reverse compatability. + * + * Was originally implemented for the flight data recorder + * FDR + */ + +// NodeID Set::elementAt(int n) const +// { +// if(isElement(n)) return (NodeID) true; +// else return 0; + +// /* +// int match = -1; +// for(int i=0;i=0; i--) { +#ifdef __32BITS__ + sprintf(buff,"%08X ",m_p_nArray[i]); +#else + sprintf(buff,"0x %016llX ",m_p_nArray[i]); +#endif // __32BITS__ + out << buff; + } + out << " ]"; + +} -#endif // OPTBIGSET diff --git a/src/mem/ruby/common/Set.hh b/src/mem/ruby/common/Set.hh index ea16c66a5..45f06e6aa 100644 --- a/src/mem/ruby/common/Set.hh +++ b/src/mem/ruby/common/Set.hh @@ -32,24 +32,15 @@ * * Description: * - * $Id$ + * $Id: BigSet.h 1.6 05/01/19 13:12:25-06:00 mikem@maya.cs.wisc.edu $ * */ -// Define this to use the BigSet class which is slower, but supports -// sets of size larger than 32. +// modified by Dan Gibson on 05/20/05 to accomidate FASTER +// >32 set lengths, using an array of ints w/ 32 bits/int -// #define BIGSET - -#define OPTBIGSET - -#ifdef OPTBIGSET -#include "mem/ruby/common/OptBigSet.hh" -#else - -#ifdef BIGSET -#include "mem/ruby/common/BigSet.hh" // code to supports sets larger than 32 -#else +// NOTE: Never include this file directly, this should only be +// included from Set.h #ifndef SET_H #define SET_H @@ -59,46 +50,95 @@ #include "mem/ruby/system/NodeID.hh" #include "mem/ruby/config/RubyConfig.hh" +// gibson 05/20/05 +// enum PresenceBit {NotPresent, Present}; + class Set { public: // Constructors // creates and empty set Set(); - Set(int size); + Set (int size); // used during the replay mechanism // Set(const char *str); - // Set(const Set& obj); - // Set& operator=(const Set& obj); + Set(const Set& obj); + Set& operator=(const Set& obj); // Destructor - // ~Set(); + ~Set(); // Public Methods - void add(NodeID newElement); + inline void add(NodeID index) + { +#ifdef __32BITS__ + m_p_nArray[index>>5] |= (1 << (index & 0x01F)); +#else + m_p_nArray[index>>6] |= (((unsigned long) 1) << (index & 0x03F)); +#endif // __32BITS__ + } + void addSet(const Set& set); void addRandom(); - void remove(NodeID newElement); + + inline void remove(NodeID index) + { +#ifdef __32BITS__ + m_p_nArray[index>>5] &= ~(0x00000001 << (index & 0x01F)); +#else + m_p_nArray[index>>6] &= ~(((unsigned long) 0x0000000000000001) << (index & 0x03F)); +#endif // __32BITS__ + } + + void removeSet(const Set& set); - void clear(); + + inline void clear() { for(int i=0; i>5] & (0x00000001 << (element & 0x01F)))!=0); +#else + return ((m_p_nArray[element>>6] & (((unsigned long) 0x0000000000000001) << (element & 0x03F)))!=0); +#endif // __32BITS__ + + } + bool isBroadcast() const; bool isEmpty() const; @@ -108,8 +148,14 @@ public: void setSize (int size); // get element for a index - NodeID elementAt(int index); - int getSize() const { return m_size; } + inline NodeID elementAt(int index) const + { + if(isElement(index)) return (NodeID) true; + else return 0; + } + + // gibson 05/20/05 + int getSize() const { return m_nSize; } // DEPRECATED METHODS void addToSet(NodeID newElement) { add(newElement); } // Deprecated @@ -123,10 +169,19 @@ private: // Private Methods // Data Members (m_ prefix) - int m_size; - uint32 m_bits; // Set as a bit vector - uint32 m_mask; // a 000001111 mask where the number of 1s is equal to m_size + // gibson 05/20/05 + // Vector m_bits; // This is an vector of uint8 to reduce the size of the set + + int m_nSize; // the number of bits in this set + int m_nArrayLen; // the number of 32-bit words that are held in the array + + // Changed 5/24/05 for static allocation of array + // note that "long" corresponds to 32 bits on a 32-bit machine, + // 64 bits if the -m64 parameter is passed to g++, which it is + // for an AMD opteron under our configuration + long * m_p_nArray; // an word array to hold the bits in the set + long m_p_nArray_Static[NUMBER_WORDS_PER_SET]; }; // Output operator declaration @@ -144,6 +199,4 @@ ostream& operator<<(ostream& out, const Set& obj) } #endif //SET_H -#endif //BIGSET -#endif //OPTBIGSET -- cgit v1.2.3 From ebf2f5aaddcb81ba39692b716ed9ad658df27cd8 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Mon, 11 May 2009 10:38:46 -0700 Subject: ruby: Check stderr and not stdin before hanging on an assert. --- src/mem/ruby/common/Debug.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mem/ruby/common') diff --git a/src/mem/ruby/common/Debug.hh b/src/mem/ruby/common/Debug.hh index 6dce98dd5..8548e9772 100644 --- a/src/mem/ruby/common/Debug.hh +++ b/src/mem/ruby/common/Debug.hh @@ -154,7 +154,7 @@ const bool ASSERT_FLAG = true; << __PRETTY_FUNCTION__ << " in "\ << __FILE__ << ":"\ << __LINE__ << endl << flush;\ - if(isatty(STDIN_FILENO)) {\ + if(isatty(STDERR_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;\ @@ -175,7 +175,7 @@ const bool ASSERT_FLAG = true; << __PRETTY_FUNCTION__ << " in "\ << __FILE__ << ":"\ << __LINE__ << endl << flush;\ - if(isatty(STDIN_FILENO)) {\ + if(isatty(STDERR_FILENO)) {\ cerr << "press enter to continue" << endl;\ cerr << "PID: " << getpid();\ cerr << endl << flush; \ -- cgit v1.2.3 From 93f2f69657d0a2420a2c86b71505e6d27e6e2a38 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Mon, 11 May 2009 10:38:46 -0700 Subject: ruby: Working M5 interface and updated Ruby interface. This changeset also includes a lot of work from Derek Hower RubyMemory is now both a driver for Ruby and a port for M5. Changed makeRequest/hitCallback interface. Brought packets (superficially) into the sequencer. Modified tester infrastructure to be packet based. and Ruby can be used together through the example ruby_se.py script. SPARC parallel applications work, and the timing *seems* right from combined M5/Ruby debug traces. To run, % build/ALPHA_SE/m5.debug configs/example/ruby_se.py -c tests/test-progs/hello/bin/alpha/linux/hello -n 4 -t --- src/mem/ruby/common/Driver.hh | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'src/mem/ruby/common') diff --git a/src/mem/ruby/common/Driver.hh b/src/mem/ruby/common/Driver.hh index c527e7d2b..38bdbbf91 100644 --- a/src/mem/ruby/common/Driver.hh +++ b/src/mem/ruby/common/Driver.hh @@ -34,6 +34,7 @@ #include "mem/ruby/common/Consumer.hh" #include "mem/ruby/system/NodeID.hh" #include "mem/protocol/CacheRequestType.hh" +#include "mem/packet.hh" class RubySystem; class SubBlock; @@ -51,27 +52,10 @@ public: // Public Methods virtual void get_network_config() {} - virtual void hitCallback(NodeID proc, SubBlock& data, CacheRequestType type, int thread) = 0; // Called by sequencer - virtual void conflictCallback(NodeID proc, SubBlock& data, CacheRequestType type, int thread) { assert(0); } // Called by sequencer + virtual void hitCallback(Packet* pkt) = 0; virtual integer_t getInstructionCount(int procID) const { return 1; } virtual integer_t getCycleCount(int procID) const { return 1; } - virtual SimicsHypervisor * getHypervisor() { return NULL; } - virtual void notifySendNack( int procID, const Address & addr, uint64 remote_timestamp, const MachineID & remote_id) { assert(0); }; //Called by Sequencer - virtual void notifyReceiveNack( int procID, const Address & addr, uint64 remote_timestamp, const MachineID & remote_id) { assert(0); }; //Called by Sequencer - virtual void notifyReceiveNackFinal( int procID, const Address & addr) { assert(0); }; // Called by Sequencer - virtual void notifyTrapStart( int procID, const Address & handlerPC, int threadID, int smtThread ) { assert(0); } //called by Sequencer - virtual void notifyTrapComplete( int procID, const Address & newPC, int smtThread ) {assert(0); } // called by Sequencer - virtual int getOpalTransactionLevel(int procID, int thread) const { - cout << "mem/ruby/common/Driver.hh getOpalTransactionLevel() " << endl; - return 0; } //called by Sequencer - virtual void addThreadDependency(int procID, int requestor_thread, int conflict_thread) const { assert(0);} - virtual uint64 getOpalTime(int procID) const{ return 0; } //called by Sequencer - virtual uint64 getOpalTimestamp(int procID, int thread) const{ - cout << "mem/ruby/common/Driver.hh getOpalTimestamp " << endl; - return 0; } // called by Sequencer - virtual int inTransaction(int procID, int thread ) const{ - cout << "mem/ruby/common/Driver.hh inTransaction " << endl; -return false; } //called by Sequencer + virtual void printDebug(){} //called by Sequencer virtual void printStats(ostream& out) const = 0; @@ -79,8 +63,6 @@ return false; } //called by Sequencer virtual void printConfig(ostream& out) const = 0; - //virtual void abortCallback(NodeID proc){} - virtual integer_t readPhysicalMemory(int procID, physical_address_t address, int len ){ ASSERT(0); return 0; } -- cgit v1.2.3 From cf6b4ef734293e1efdfa015519230703be5d324a Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Mon, 11 May 2009 10:38:46 -0700 Subject: ruby: add RUBY sticky option that must be set to add ruby to the build Default is false --- src/mem/ruby/common/SConscript | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/mem/ruby/common') diff --git a/src/mem/ruby/common/SConscript b/src/mem/ruby/common/SConscript index 8313aa7ad..15df8312e 100644 --- a/src/mem/ruby/common/SConscript +++ b/src/mem/ruby/common/SConscript @@ -30,6 +30,9 @@ Import('*') +if not env['RUBY']: + Return() + Source('Address.cc') Source('DataBlock.cc') Source('Debug.cc') -- cgit v1.2.3