ruby: remove typedef of Index as int64

The Index type defined as typedef int64 does not really provide any help
since in most places we use primitive types instead of Index.  Also, the name
Index is very generic that it does not merit being used as a typename.
This commit is contained in:
Nilay Vaish 2014-09-01 16:55:50 -05:00
parent 4ccdf8fb81
commit 2cbe7c705b
11 changed files with 55 additions and 56 deletions

View file

@ -57,22 +57,22 @@ Address::makeNextStrideAddress(int stride)
+ RubySystem::getBlockSizeBytes()*stride; + RubySystem::getBlockSizeBytes()*stride;
} }
Index int64
Address::memoryModuleIndex() const Address::memoryModuleIndex() const
{ {
Index index = int64 index =
bitSelect(RubySystem::getBlockSizeBits() + bitSelect(RubySystem::getBlockSizeBits() +
RubySystem::getMemorySizeBits(), ADDRESS_WIDTH); RubySystem::getMemorySizeBits(), ADDRESS_WIDTH);
assert (index >= 0); assert (index >= 0);
return index; return index;
// Index indexHighPortion = // int64 indexHighPortion =
// address.bitSelect(MEMORY_SIZE_BITS - 1, // address.bitSelect(MEMORY_SIZE_BITS - 1,
// PAGE_SIZE_BITS + NUMBER_OF_MEMORY_MODULE_BITS); // PAGE_SIZE_BITS + NUMBER_OF_MEMORY_MODULE_BITS);
// Index indexLowPortion = // int64 indexLowPortion =
// address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS - 1); // address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS - 1);
// //
// Index index = indexLowPortion | // int64 index = indexLowPortion |
// (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS)); // (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS));
/* /*

View file

@ -72,7 +72,7 @@ class Address
void makePageAddress(); void makePageAddress();
void makeNextStrideAddress(int stride); void makeNextStrideAddress(int stride);
Index memoryModuleIndex() const; int64 memoryModuleIndex() const;
void print(std::ostream& out) const; void print(std::ostream& out) const;
void output(std::ostream& out) const; void output(std::ostream& out) const;

View file

@ -35,7 +35,6 @@ typedef long long int64;
typedef uint64 physical_address_t; typedef uint64 physical_address_t;
typedef int64 Index; // what the address bit ripper returns
typedef unsigned int LinkID; typedef unsigned int LinkID;
typedef unsigned int NodeID; typedef unsigned int NodeID;
typedef unsigned int SwitchID; typedef unsigned int SwitchID;

View file

@ -34,17 +34,17 @@
class AbstractReplacementPolicy class AbstractReplacementPolicy
{ {
public: public:
AbstractReplacementPolicy(Index num_sets, Index assoc); AbstractReplacementPolicy(int64 num_sets, int64 assoc);
virtual ~AbstractReplacementPolicy(); virtual ~AbstractReplacementPolicy();
/* touch a block. a.k.a. update timestamp */ /* touch a block. a.k.a. update timestamp */
virtual void touch(Index set, Index way, Tick time) = 0; virtual void touch(int64 set, int64 way, Tick time) = 0;
/* returns the way to replace */ /* returns the way to replace */
virtual Index getVictim(Index set) const = 0; virtual int64 getVictim(int64 set) const = 0;
/* get the time of the last access */ /* get the time of the last access */
Tick getLastAccess(Index set, Index way); Tick getLastAccess(int64 set, int64 way);
protected: protected:
unsigned m_num_sets; /** total number of sets */ unsigned m_num_sets; /** total number of sets */
@ -53,8 +53,8 @@ class AbstractReplacementPolicy
}; };
inline inline
AbstractReplacementPolicy::AbstractReplacementPolicy(Index num_sets, AbstractReplacementPolicy::AbstractReplacementPolicy(int64 num_sets,
Index assoc) int64 assoc)
{ {
m_num_sets = num_sets; m_num_sets = num_sets;
m_assoc = assoc; m_assoc = assoc;
@ -81,7 +81,7 @@ AbstractReplacementPolicy::~AbstractReplacementPolicy()
} }
inline Tick inline Tick
AbstractReplacementPolicy::getLastAccess(Index set, Index way) AbstractReplacementPolicy::getLastAccess(int64 set, int64 way)
{ {
return m_last_ref_ptr[set][way]; return m_last_ref_ptr[set][way];
} }

View file

@ -48,7 +48,7 @@ BankedArray::BankedArray(unsigned int banks, Cycles accessLatency,
} }
bool bool
BankedArray::tryAccess(Index idx) BankedArray::tryAccess(int64 idx)
{ {
if (accessLatency == 0) if (accessLatency == 0)
return true; return true;
@ -76,7 +76,7 @@ BankedArray::tryAccess(Index idx)
} }
unsigned int unsigned int
BankedArray::mapIndexToBank(Index idx) BankedArray::mapIndexToBank(int64 idx)
{ {
if (banks == 1) { if (banks == 1) {
return 0; return 0;

View file

@ -49,7 +49,7 @@ class BankedArray
{ {
public: public:
AccessRecord() : idx(0), startAccess(0), endAccess(0) {} AccessRecord() : idx(0), startAccess(0), endAccess(0) {}
Index idx; int64 idx;
Tick startAccess; Tick startAccess;
Tick endAccess; Tick endAccess;
}; };
@ -58,14 +58,14 @@ class BankedArray
// otherwise, schedule the event and wait for it to complete // otherwise, schedule the event and wait for it to complete
std::vector<AccessRecord> busyBanks; std::vector<AccessRecord> busyBanks;
unsigned int mapIndexToBank(Index idx); unsigned int mapIndexToBank(int64 idx);
public: public:
BankedArray(unsigned int banks, Cycles accessLatency, unsigned int startIndexBit); BankedArray(unsigned int banks, Cycles accessLatency, unsigned int startIndexBit);
// Note: We try the access based on the cache index, not the address // Note: We try the access based on the cache index, not the address
// This is so we don't get aliasing on blocks being replaced // This is so we don't get aliasing on blocks being replaced
bool tryAccess(Index idx); bool tryAccess(int64 idx);
}; };

View file

@ -104,7 +104,7 @@ CacheMemory::~CacheMemory()
} }
// convert a Address to its location in the cache // convert a Address to its location in the cache
Index int64
CacheMemory::addressToCacheSet(const Address& address) const CacheMemory::addressToCacheSet(const Address& address) const
{ {
assert(address == line_address(address)); assert(address == line_address(address));
@ -115,7 +115,7 @@ CacheMemory::addressToCacheSet(const Address& address) const
// Given a cache index: returns the index of the tag in a set. // Given a cache index: returns the index of the tag in a set.
// returns -1 if the tag is not found. // returns -1 if the tag is not found.
int int
CacheMemory::findTagInSet(Index cacheSet, const Address& tag) const CacheMemory::findTagInSet(int64 cacheSet, const Address& tag) const
{ {
assert(tag == line_address(tag)); assert(tag == line_address(tag));
// search the set for the tags // search the set for the tags
@ -130,7 +130,7 @@ CacheMemory::findTagInSet(Index cacheSet, const Address& tag) const
// Given a cache index: returns the index of the tag in a set. // Given a cache index: returns the index of the tag in a set.
// returns -1 if the tag is not found. // returns -1 if the tag is not found.
int int
CacheMemory::findTagInSetIgnorePermissions(Index cacheSet, CacheMemory::findTagInSetIgnorePermissions(int64 cacheSet,
const Address& tag) const const Address& tag) const
{ {
assert(tag == line_address(tag)); assert(tag == line_address(tag));
@ -147,7 +147,7 @@ CacheMemory::tryCacheAccess(const Address& address, RubyRequestType type,
{ {
assert(address == line_address(address)); assert(address == line_address(address));
DPRINTF(RubyCache, "address: %s\n", address); DPRINTF(RubyCache, "address: %s\n", address);
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address); int loc = findTagInSet(cacheSet, address);
if (loc != -1) { if (loc != -1) {
// Do we even have a tag match? // Do we even have a tag match?
@ -174,7 +174,7 @@ CacheMemory::testCacheAccess(const Address& address, RubyRequestType type,
{ {
assert(address == line_address(address)); assert(address == line_address(address));
DPRINTF(RubyCache, "address: %s\n", address); DPRINTF(RubyCache, "address: %s\n", address);
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address); int loc = findTagInSet(cacheSet, address);
if (loc != -1) { if (loc != -1) {
@ -196,7 +196,7 @@ bool
CacheMemory::isTagPresent(const Address& address) const CacheMemory::isTagPresent(const Address& address) const
{ {
assert(address == line_address(address)); assert(address == line_address(address));
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address); int loc = findTagInSet(cacheSet, address);
if (loc == -1) { if (loc == -1) {
@ -216,7 +216,7 @@ CacheMemory::cacheAvail(const Address& address) const
{ {
assert(address == line_address(address)); assert(address == line_address(address));
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
for (int i = 0; i < m_cache_assoc; i++) { for (int i = 0; i < m_cache_assoc; i++) {
AbstractCacheEntry* entry = m_cache[cacheSet][i]; AbstractCacheEntry* entry = m_cache[cacheSet][i];
@ -242,7 +242,7 @@ CacheMemory::allocate(const Address& address, AbstractCacheEntry* entry)
DPRINTF(RubyCache, "address: %s\n", address); DPRINTF(RubyCache, "address: %s\n", address);
// Find the first open slot // Find the first open slot
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
std::vector<AbstractCacheEntry*> &set = m_cache[cacheSet]; std::vector<AbstractCacheEntry*> &set = m_cache[cacheSet];
for (int i = 0; i < m_cache_assoc; i++) { for (int i = 0; i < m_cache_assoc; i++) {
if (!set[i] || set[i]->m_Permission == AccessPermission_NotPresent) { if (!set[i] || set[i]->m_Permission == AccessPermission_NotPresent) {
@ -268,7 +268,7 @@ CacheMemory::deallocate(const Address& address)
assert(address == line_address(address)); assert(address == line_address(address));
assert(isTagPresent(address)); assert(isTagPresent(address));
DPRINTF(RubyCache, "address: %s\n", address); DPRINTF(RubyCache, "address: %s\n", address);
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address); int loc = findTagInSet(cacheSet, address);
if (loc != -1) { if (loc != -1) {
delete m_cache[cacheSet][loc]; delete m_cache[cacheSet][loc];
@ -284,7 +284,7 @@ CacheMemory::cacheProbe(const Address& address) const
assert(address == line_address(address)); assert(address == line_address(address));
assert(!cacheAvail(address)); assert(!cacheAvail(address));
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
return m_cache[cacheSet][m_replacementPolicy_ptr->getVictim(cacheSet)]-> return m_cache[cacheSet][m_replacementPolicy_ptr->getVictim(cacheSet)]->
m_Address; m_Address;
} }
@ -294,7 +294,7 @@ AbstractCacheEntry*
CacheMemory::lookup(const Address& address) CacheMemory::lookup(const Address& address)
{ {
assert(address == line_address(address)); assert(address == line_address(address));
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address); int loc = findTagInSet(cacheSet, address);
if(loc == -1) return NULL; if(loc == -1) return NULL;
return m_cache[cacheSet][loc]; return m_cache[cacheSet][loc];
@ -305,7 +305,7 @@ const AbstractCacheEntry*
CacheMemory::lookup(const Address& address) const CacheMemory::lookup(const Address& address) const
{ {
assert(address == line_address(address)); assert(address == line_address(address));
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address); int loc = findTagInSet(cacheSet, address);
if(loc == -1) return NULL; if(loc == -1) return NULL;
return m_cache[cacheSet][loc]; return m_cache[cacheSet][loc];
@ -315,7 +315,7 @@ CacheMemory::lookup(const Address& address) const
void void
CacheMemory::setMRU(const Address& address) CacheMemory::setMRU(const Address& address)
{ {
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address); int loc = findTagInSet(cacheSet, address);
if(loc != -1) if(loc != -1)
@ -391,7 +391,7 @@ CacheMemory::setLocked(const Address& address, int context)
{ {
DPRINTF(RubyCache, "Setting Lock for addr: %x to %d\n", address, context); DPRINTF(RubyCache, "Setting Lock for addr: %x to %d\n", address, context);
assert(address == line_address(address)); assert(address == line_address(address));
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address); int loc = findTagInSet(cacheSet, address);
assert(loc != -1); assert(loc != -1);
m_cache[cacheSet][loc]->m_locked = context; m_cache[cacheSet][loc]->m_locked = context;
@ -402,7 +402,7 @@ CacheMemory::clearLocked(const Address& address)
{ {
DPRINTF(RubyCache, "Clear Lock for addr: %x\n", address); DPRINTF(RubyCache, "Clear Lock for addr: %x\n", address);
assert(address == line_address(address)); assert(address == line_address(address));
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address); int loc = findTagInSet(cacheSet, address);
assert(loc != -1); assert(loc != -1);
m_cache[cacheSet][loc]->m_locked = -1; m_cache[cacheSet][loc]->m_locked = -1;
@ -412,7 +412,7 @@ bool
CacheMemory::isLocked(const Address& address, int context) CacheMemory::isLocked(const Address& address, int context)
{ {
assert(address == line_address(address)); assert(address == line_address(address));
Index cacheSet = addressToCacheSet(address); int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address); int loc = findTagInSet(cacheSet, address);
assert(loc != -1); assert(loc != -1);
DPRINTF(RubyCache, "Testing Lock for addr: %llx cur %d con %d\n", DPRINTF(RubyCache, "Testing Lock for addr: %llx cur %d con %d\n",

View file

@ -131,12 +131,12 @@ class CacheMemory : public SimObject
private: private:
// convert a Address to its location in the cache // convert a Address to its location in the cache
Index addressToCacheSet(const Address& address) const; int64 addressToCacheSet(const Address& address) const;
// Given a cache tag: returns the index of the tag in a set. // Given a cache tag: returns the index of the tag in a set.
// returns -1 if the tag is not found. // returns -1 if the tag is not found.
int findTagInSet(Index line, const Address& tag) const; int findTagInSet(int64 line, const Address& tag) const;
int findTagInSetIgnorePermissions(Index cacheSet, int findTagInSetIgnorePermissions(int64 cacheSet,
const Address& tag) const; const Address& tag) const;
// Private copy constructor and assignment operator // Private copy constructor and assignment operator

View file

@ -171,7 +171,7 @@ DirectoryMemory::invalidateBlock(PhysAddress address)
else { else {
assert(isPresent(address)); assert(isPresent(address));
Index index = address.memoryModuleIndex(); int64 index = address.memoryModuleIndex();
if (index < 0 || index > m_size) { if (index < 0 || index > m_size) {
ERROR_MSG("Directory Memory Assertion: " ERROR_MSG("Directory Memory Assertion: "

View file

@ -36,15 +36,15 @@
class LRUPolicy : public AbstractReplacementPolicy class LRUPolicy : public AbstractReplacementPolicy
{ {
public: public:
LRUPolicy(Index num_sets, Index assoc); LRUPolicy(int64 num_sets, int64 assoc);
~LRUPolicy(); ~LRUPolicy();
void touch(Index set, Index way, Tick time); void touch(int64 set, int64 way, Tick time);
Index getVictim(Index set) const; int64 getVictim(int64 set) const;
}; };
inline inline
LRUPolicy::LRUPolicy(Index num_sets, Index assoc) LRUPolicy::LRUPolicy(int64 num_sets, int64 assoc)
: AbstractReplacementPolicy(num_sets, assoc) : AbstractReplacementPolicy(num_sets, assoc)
{ {
} }
@ -55,7 +55,7 @@ LRUPolicy::~LRUPolicy()
} }
inline void inline void
LRUPolicy::touch(Index set, Index index, Tick time) LRUPolicy::touch(int64 set, int64 index, Tick time)
{ {
assert(index >= 0 && index < m_assoc); assert(index >= 0 && index < m_assoc);
assert(set >= 0 && set < m_num_sets); assert(set >= 0 && set < m_num_sets);
@ -63,12 +63,12 @@ LRUPolicy::touch(Index set, Index index, Tick time)
m_last_ref_ptr[set][index] = time; m_last_ref_ptr[set][index] = time;
} }
inline Index inline int64
LRUPolicy::getVictim(Index set) const LRUPolicy::getVictim(int64 set) const
{ {
// assert(m_assoc != 0); // assert(m_assoc != 0);
Tick time, smallest_time; Tick time, smallest_time;
Index smallest_index; int64 smallest_index;
smallest_index = 0; smallest_index = 0;
smallest_time = m_last_ref_ptr[set][0]; smallest_time = m_last_ref_ptr[set][0];

View file

@ -47,11 +47,11 @@
class PseudoLRUPolicy : public AbstractReplacementPolicy class PseudoLRUPolicy : public AbstractReplacementPolicy
{ {
public: public:
PseudoLRUPolicy(Index num_sets, Index assoc); PseudoLRUPolicy(int64 num_sets, int64 assoc);
~PseudoLRUPolicy(); ~PseudoLRUPolicy();
void touch(Index set, Index way, Tick time); void touch(int64 set, int64 way, Tick time);
Index getVictim(Index set) const; int64 getVictim(int64 set) const;
private: private:
unsigned int m_effective_assoc; /** nearest (to ceiling) power of 2 */ unsigned int m_effective_assoc; /** nearest (to ceiling) power of 2 */
@ -61,11 +61,11 @@ class PseudoLRUPolicy : public AbstractReplacementPolicy
}; };
inline inline
PseudoLRUPolicy::PseudoLRUPolicy(Index num_sets, Index assoc) PseudoLRUPolicy::PseudoLRUPolicy(int64 num_sets, int64 assoc)
: AbstractReplacementPolicy(num_sets, assoc) : AbstractReplacementPolicy(num_sets, assoc)
{ {
// associativity cannot exceed capacity of tree representation // associativity cannot exceed capacity of tree representation
assert(num_sets > 0 && assoc > 1 && assoc <= (Index) sizeof(uint64)*4); assert(num_sets > 0 && assoc > 1 && assoc <= sizeof(uint64)*4);
m_trees = NULL; m_trees = NULL;
m_num_levels = 0; m_num_levels = 0;
@ -96,7 +96,7 @@ PseudoLRUPolicy::~PseudoLRUPolicy()
} }
inline void inline void
PseudoLRUPolicy::touch(Index set, Index index, Tick time) PseudoLRUPolicy::touch(int64 set, int64 index, Tick time)
{ {
assert(index >= 0 && index < m_assoc); assert(index >= 0 && index < m_assoc);
assert(set >= 0 && set < m_num_sets); assert(set >= 0 && set < m_num_sets);
@ -114,11 +114,11 @@ PseudoLRUPolicy::touch(Index set, Index index, Tick time)
m_last_ref_ptr[set][index] = time; m_last_ref_ptr[set][index] = time;
} }
inline Index inline int64
PseudoLRUPolicy::getVictim(Index set) const PseudoLRUPolicy::getVictim(int64 set) const
{ {
// assert(m_assoc != 0); // assert(m_assoc != 0);
Index index = 0; int64 index = 0;
int tree_index = 0; int tree_index = 0;
int node_val; int node_val;