From 03bf748ac7226ebc46bbf2e2f861e3dacacd1739 Mon Sep 17 00:00:00 2001 From: Derek Hower Date: Tue, 25 Aug 2009 10:09:47 -0500 Subject: ruby: CacheMemory tag lookup uses a hash instead of a loop --- src/mem/ruby/system/CacheMemory.hh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/mem/ruby/system/CacheMemory.hh') diff --git a/src/mem/ruby/system/CacheMemory.hh b/src/mem/ruby/system/CacheMemory.hh index 7a46bd3a5..4b2bc7084 100644 --- a/src/mem/ruby/system/CacheMemory.hh +++ b/src/mem/ruby/system/CacheMemory.hh @@ -156,6 +156,7 @@ private: // The first index is the # of cache lines. // The second index is the the amount associativity. + m5::hash_map m_tag_index; Vector > m_cache; Vector > m_locked; @@ -286,6 +287,12 @@ int CacheMemory::findTagInSet(Index cacheSet, const Address& tag) const { assert(tag == line_address(tag)); // search the set for the tags + m5::hash_map::const_iterator it = m_tag_index.find(tag); + if (it != m_tag_index.end()) + if (m_cache[cacheSet][it->second]->m_Permission != AccessPermission_NotPresent) + return it->second; + return -1; // Not found + /* for (int i=0; i < m_cache_assoc; i++) { if ((m_cache[cacheSet][i] != NULL) && (m_cache[cacheSet][i]->m_Address == tag) && @@ -294,6 +301,7 @@ int CacheMemory::findTagInSet(Index cacheSet, const Address& tag) const } } return -1; // Not found + */ } // Given a cache index: returns the index of the tag in a set. @@ -301,6 +309,13 @@ int CacheMemory::findTagInSet(Index cacheSet, const Address& tag) const inline int CacheMemory::findTagInSetIgnorePermissions(Index cacheSet, const Address& tag) const { + assert(tag == line_address(tag)); + // search the set for the tags + m5::hash_map::const_iterator it = m_tag_index.find(tag); + if (it != m_tag_index.end()) + return it->second; + return -1; // Not found + /* assert(tag == line_address(tag)); // search the set for the tags for (int i=0; i < m_cache_assoc; i++) { @@ -308,6 +323,7 @@ int CacheMemory::findTagInSetIgnorePermissions(Index cacheSet, const Address& ta return i; } return -1; // Not found + */ } // PUBLIC METHODS @@ -418,6 +434,7 @@ void CacheMemory::allocate(const Address& address, AbstractCacheEntry* entry) m_cache[cacheSet][i]->m_Address = address; m_cache[cacheSet][i]->m_Permission = AccessPermission_Invalid; m_locked[cacheSet][i] = -1; + m_tag_index[address] = i; m_replacementPolicy_ptr->touch(cacheSet, i, g_eventQueue_ptr->getTime()); @@ -439,6 +456,7 @@ void CacheMemory::deallocate(const Address& address) delete m_cache[cacheSet][location]; m_cache[cacheSet][location] = NULL; m_locked[cacheSet][location] = -1; + m_tag_index.erase(address); } } -- cgit v1.2.3 From 11f3f8306847bf912a9c5a31186231d23b31030d Mon Sep 17 00:00:00 2001 From: Derek Hower Date: Mon, 14 Sep 2009 17:52:46 -0500 Subject: ruby:removed unused code from CacheMemory --- src/mem/ruby/system/CacheMemory.hh | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'src/mem/ruby/system/CacheMemory.hh') diff --git a/src/mem/ruby/system/CacheMemory.hh b/src/mem/ruby/system/CacheMemory.hh index 4b2bc7084..aeb52ba2e 100644 --- a/src/mem/ruby/system/CacheMemory.hh +++ b/src/mem/ruby/system/CacheMemory.hh @@ -292,16 +292,6 @@ int CacheMemory::findTagInSet(Index cacheSet, const Address& tag) const if (m_cache[cacheSet][it->second]->m_Permission != AccessPermission_NotPresent) return it->second; return -1; // Not found - /* - for (int i=0; i < m_cache_assoc; i++) { - if ((m_cache[cacheSet][i] != NULL) && - (m_cache[cacheSet][i]->m_Address == tag) && - (m_cache[cacheSet][i]->m_Permission != AccessPermission_NotPresent)) { - return i; - } - } - return -1; // Not found - */ } // Given a cache index: returns the index of the tag in a set. @@ -315,15 +305,6 @@ int CacheMemory::findTagInSetIgnorePermissions(Index cacheSet, const Address& ta if (it != m_tag_index.end()) return it->second; return -1; // Not found - /* - assert(tag == line_address(tag)); - // search the set for the tags - for (int i=0; i < m_cache_assoc; i++) { - if (m_cache[cacheSet][i] != NULL && m_cache[cacheSet][i]->m_Address == tag) - return i; - } - return -1; // Not found - */ } // PUBLIC METHODS -- cgit v1.2.3 From ceb8fde914aebc3568d55d50defb8aed36717ea6 Mon Sep 17 00:00:00 2001 From: Derek Hower Date: Fri, 13 Nov 2009 09:42:47 -0600 Subject: ruby: cache memory bugfix --- src/mem/ruby/system/CacheMemory.hh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mem/ruby/system/CacheMemory.hh') diff --git a/src/mem/ruby/system/CacheMemory.hh b/src/mem/ruby/system/CacheMemory.hh index aeb52ba2e..7268189ea 100644 --- a/src/mem/ruby/system/CacheMemory.hh +++ b/src/mem/ruby/system/CacheMemory.hh @@ -218,7 +218,8 @@ void CacheMemory::init(const vector & argv) } } - m_cache_num_sets = cache_size / m_cache_assoc; + int num_lines = (cache_size*1024)/RubySystem::getBlockSizeBytes(); + m_cache_num_sets = num_lines / m_cache_assoc; m_cache_num_set_bits = log_int(m_cache_num_sets); if(policy == "PSEUDO_LRU") -- cgit v1.2.3