Tiago Mück has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/31261 )
Change subject: mem-ruby: TBE table supports multiple entries
......................................................................
mem-ruby: TBE table supports multiple entries
allocateNext allows a new TBE to be allocated for the same address
before deallocating the current one. New entries are visible and
returned by lookup after the previous one is deallocated.
Change-Id: Ia97b1b328e1fa23b300b38402bdf381ee48b6ec7
Signed-off-by: Tiago Mück <tiago.m...@arm.com>
---
M src/mem/ruby/structures/TBETable.hh
1 file changed, 27 insertions(+), 10 deletions(-)
diff --git a/src/mem/ruby/structures/TBETable.hh
b/src/mem/ruby/structures/TBETable.hh
index b4a723b..1505743 100644
--- a/src/mem/ruby/structures/TBETable.hh
+++ b/src/mem/ruby/structures/TBETable.hh
@@ -42,6 +42,7 @@
#define __MEM_RUBY_STRUCTURES_TBETABLE_HH__
#include <iostream>
+#include <queue>
#include <unordered_map>
#include "mem/ruby/common/Address.hh"
@@ -51,17 +52,18 @@
{
public:
TBETable(int number_of_TBEs)
- : m_number_of_TBEs(number_of_TBEs)
+ : m_size(0), m_number_of_TBEs(number_of_TBEs)
{
}
bool isPresent(Addr address) const;
+ ENTRY* allocateNext(Addr address);
void allocate(Addr address);
void deallocate(Addr address);
bool
areNSlotsAvailable(int n, Tick current_time) const
{
- return (m_number_of_TBEs - m_map.size()) >= n;
+ return (m_number_of_TBEs - m_size) >= n;
}
ENTRY *getNullEntry();
@@ -76,7 +78,8 @@
TBETable& operator=(const TBETable& obj);
// Data Members (m_prefix)
- std::unordered_map<Addr, ENTRY> m_map;
+ int m_size;
+ std::unordered_map<Addr, std::queue<ENTRY>> m_map;
private:
int m_number_of_TBEs;
@@ -96,8 +99,8 @@
TBETable<ENTRY>::isPresent(Addr address) const
{
assert(address == makeLineAddress(address));
- assert(m_map.size() <= m_number_of_TBEs);
- return !!m_map.count(address);
+ assert(m_size <= m_number_of_TBEs);
+ return m_map.count(address) > 0;
}
template<class ENTRY>
@@ -105,8 +108,17 @@
TBETable<ENTRY>::allocate(Addr address)
{
assert(!isPresent(address));
- assert(m_map.size() < m_number_of_TBEs);
- m_map[address] = ENTRY();
+ allocateNext(address);
+}
+
+template<class ENTRY>
+inline ENTRY*
+TBETable<ENTRY>::allocateNext(Addr address)
+{
+ assert(m_size < m_number_of_TBEs);
+ m_map[address].emplace();
+ ++m_size;
+ return &(m_map[address].back());
}
template<class ENTRY>
@@ -114,8 +126,12 @@
TBETable<ENTRY>::deallocate(Addr address)
{
assert(isPresent(address));
- assert(m_map.size() > 0);
- m_map.erase(address);
+ assert(m_size > 0);
+ auto iter = m_map.find(address);
+ iter->second.pop();
+ if (iter->second.empty())
+ m_map.erase(iter);
+ --m_size;
}
template<class ENTRY>
@@ -130,7 +146,8 @@
inline ENTRY*
TBETable<ENTRY>::lookup(Addr address)
{
- if (m_map.find(address) != m_map.end()) return
&(m_map.find(address)->second);
+ if (m_map.find(address) != m_map.end())
+ return &(m_map.find(address)->second.front());
return NULL;
}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/31261
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ia97b1b328e1fa23b300b38402bdf381ee48b6ec7
Gerrit-Change-Number: 31261
Gerrit-PatchSet: 1
Gerrit-Owner: Tiago Mück <tiago.m...@arm.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s