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