mem-ruby: set RubySystem pointer during TBE alloc (#1930)
Currently the RubySystem pointer is set when set_tbe is performed, which effectively clears the NetDest objects from the TBE (if any). This is fine if the TBE has been just allocated before set_tbe is called (no NetDest info in the TBE). However, the CHI protocol has an action (RestoreFromHazard) that performs a set_tbe over a TBE that had already been set, i.e., it already has valid NetDest data. This patch sets the RubySystem pointer when the TBE is allocated, which is more natural and follows the style already adopted in the PerfectCacheMemory class (#1864). Co-authored-by: Adrià Armejach <adria.armejach@bsc.es>
This commit is contained in:
committed by
Bobby R. Bruce
parent
c9625ce9cc
commit
dc448c9530
@@ -45,6 +45,7 @@
|
||||
#include <unordered_map>
|
||||
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/system/RubySystem.hh"
|
||||
|
||||
namespace gem5
|
||||
{
|
||||
@@ -70,7 +71,7 @@ class TBETable
|
||||
return (m_number_of_TBEs - m_map.size()) >= n;
|
||||
}
|
||||
|
||||
void setBlockSize(const int block_size) { m_block_size = block_size; }
|
||||
void setRubySystem(RubySystem* rs);
|
||||
|
||||
ENTRY *getNullEntry();
|
||||
ENTRY *lookup(Addr address);
|
||||
@@ -89,6 +90,10 @@ class TBETable
|
||||
private:
|
||||
int m_number_of_TBEs = 0;
|
||||
int m_block_size = 0;
|
||||
RubySystem* m_ruby_system = nullptr;
|
||||
|
||||
static constexpr bool entryRequiresRubySystem =
|
||||
std::is_member_function_pointer_v<decltype(&ENTRY::setRubySystem)>;
|
||||
};
|
||||
|
||||
template<class ENTRY>
|
||||
@@ -100,6 +105,14 @@ operator<<(std::ostream& out, const TBETable<ENTRY>& obj)
|
||||
return out;
|
||||
}
|
||||
|
||||
template<class ENTRY>
|
||||
inline
|
||||
void TBETable<ENTRY>::setRubySystem(RubySystem* rs)
|
||||
{
|
||||
m_ruby_system = rs;
|
||||
m_block_size = rs->getBlockSizeBytes();
|
||||
}
|
||||
|
||||
template<class ENTRY>
|
||||
inline bool
|
||||
TBETable<ENTRY>::isPresent(Addr address) const
|
||||
@@ -116,7 +129,9 @@ TBETable<ENTRY>::allocate(Addr address)
|
||||
assert(!isPresent(address));
|
||||
assert(m_map.size() < m_number_of_TBEs);
|
||||
assert(m_block_size > 0);
|
||||
m_map.emplace(address, ENTRY(m_block_size));
|
||||
ENTRY new_entry = ENTRY(m_block_size);
|
||||
new_entry.setRubySystem(m_ruby_system);
|
||||
m_map.emplace(address, new_entry);
|
||||
}
|
||||
|
||||
template<class ENTRY>
|
||||
|
||||
@@ -831,13 +831,13 @@ $c_ident::init()
|
||||
comment = f"Type {vtype.ident} default"
|
||||
code('*$vid = ${{vtype["default"]}}; // $comment')
|
||||
|
||||
# For objects that require knowing the cache line size,
|
||||
# For objects that require a pointer to RubySystem,
|
||||
# set the value here.
|
||||
if vtype.c_ident in ("TBETable"):
|
||||
block_size_func = "m_ruby_system->getBlockSizeBytes()"
|
||||
code(f"(*{vid}).setBlockSize({block_size_func});")
|
||||
|
||||
if vtype.c_ident in ("NetDest", "PerfectCacheMemory"):
|
||||
if vtype.c_ident in (
|
||||
"NetDest",
|
||||
"PerfectCacheMemory",
|
||||
"TBETable",
|
||||
):
|
||||
code(f"(*{vid}).setRubySystem(m_ruby_system);")
|
||||
|
||||
for param in self.config_parameters:
|
||||
@@ -1271,7 +1271,6 @@ void
|
||||
$c_ident::set_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${{self.TBEType.c_ident}}* m_new_tbe)
|
||||
{
|
||||
m_tbe_ptr = m_new_tbe;
|
||||
m_tbe_ptr->setRubySystem(m_ruby_system);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user