diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mem/protocol/MESI_CMP_directory-dir.sm | 12 | ||||
-rw-r--r-- | src/mem/protocol/MI_example-dir.sm | 12 | ||||
-rw-r--r-- | src/mem/protocol/MOESI_CMP_directory-dir.sm | 12 | ||||
-rw-r--r-- | src/mem/protocol/MOESI_CMP_token-dir.sm | 12 | ||||
-rw-r--r-- | src/mem/protocol/MOESI_hammer-dir.sm | 12 | ||||
-rw-r--r-- | src/mem/protocol/RubySlicc_Types.sm | 1 | ||||
-rw-r--r-- | src/mem/ruby/system/DirectoryMemory.cc | 44 | ||||
-rw-r--r-- | src/mem/ruby/system/DirectoryMemory.hh | 8 | ||||
-rw-r--r-- | src/mem/ruby/system/SparseMemory.cc | 35 | ||||
-rw-r--r-- | src/mem/ruby/system/SparseMemory.hh | 6 | ||||
-rw-r--r-- | src/mem/slicc/ast/FormalParamAST.py | 5 | ||||
-rw-r--r-- | src/mem/slicc/ast/LocalVariableAST.py | 4 | ||||
-rw-r--r-- | src/mem/slicc/ast/MemberExprAST.py | 5 | ||||
-rw-r--r-- | src/mem/slicc/ast/MethodCallExprAST.py | 6 |
14 files changed, 112 insertions, 62 deletions
diff --git a/src/mem/protocol/MESI_CMP_directory-dir.sm b/src/mem/protocol/MESI_CMP_directory-dir.sm index 423272905..d026e7b90 100644 --- a/src/mem/protocol/MESI_CMP_directory-dir.sm +++ b/src/mem/protocol/MESI_CMP_directory-dir.sm @@ -110,8 +110,16 @@ machine(Directory, "MESI_CMP_filter_directory protocol") void set_tbe(TBE tbe); void unset_tbe(); - Entry getDirectoryEntry(Address addr), return_by_ref="yes" { - return static_cast(Entry, directory[addr]); + Entry getDirectoryEntry(Address addr), return_by_pointer="yes" { + Entry dir_entry := static_cast(Entry, "pointer", directory[addr]); + + if (is_valid(dir_entry)) { + return dir_entry; + } + + dir_entry := static_cast(Entry, "pointer", + directory.allocate(addr, new Entry)); + return dir_entry; } State getState(TBE tbe, Address addr) { diff --git a/src/mem/protocol/MI_example-dir.sm b/src/mem/protocol/MI_example-dir.sm index 2bd3afa44..40b919c92 100644 --- a/src/mem/protocol/MI_example-dir.sm +++ b/src/mem/protocol/MI_example-dir.sm @@ -79,8 +79,16 @@ machine(Directory, "Directory protocol") void set_tbe(TBE b); void unset_tbe(); - Entry getDirectoryEntry(Address addr), return_by_ref="yes" { - return static_cast(Entry, directory[addr]); + Entry getDirectoryEntry(Address addr), return_by_pointer="yes" { + Entry dir_entry := static_cast(Entry, "pointer", directory[addr]); + + if (is_valid(dir_entry)) { + return dir_entry; + } + + dir_entry := static_cast(Entry, "pointer", + directory.allocate(addr, new Entry)); + return dir_entry; } State getState(TBE tbe, Address addr) { diff --git a/src/mem/protocol/MOESI_CMP_directory-dir.sm b/src/mem/protocol/MOESI_CMP_directory-dir.sm index b71518b3f..202bd11f6 100644 --- a/src/mem/protocol/MOESI_CMP_directory-dir.sm +++ b/src/mem/protocol/MOESI_CMP_directory-dir.sm @@ -126,8 +126,16 @@ machine(Directory, "Directory protocol") void set_tbe(TBE b); void unset_tbe(); - Entry getDirectoryEntry(Address addr), return_by_ref="yes" { - return static_cast(Entry, directory[addr]); + Entry getDirectoryEntry(Address addr), return_by_pointer="yes" { + Entry dir_entry := static_cast(Entry, "pointer", directory[addr]); + + if (is_valid(dir_entry)) { + return dir_entry; + } + + dir_entry := static_cast(Entry, "pointer", + directory.allocate(addr, new Entry)); + return dir_entry; } State getState(TBE tbe, Address addr) { diff --git a/src/mem/protocol/MOESI_CMP_token-dir.sm b/src/mem/protocol/MOESI_CMP_token-dir.sm index 9e6c6c99b..39e8a8d27 100644 --- a/src/mem/protocol/MOESI_CMP_token-dir.sm +++ b/src/mem/protocol/MOESI_CMP_token-dir.sm @@ -165,8 +165,16 @@ machine(Directory, "Token protocol") void set_tbe(TBE b); void unset_tbe(); - Entry getDirectoryEntry(Address addr), return_by_ref="yes" { - return static_cast(Entry, directory[addr]); + Entry getDirectoryEntry(Address addr), return_by_pointer="yes" { + Entry dir_entry := static_cast(Entry, "pointer", directory[addr]); + + if (is_valid(dir_entry)) { + return dir_entry; + } + + dir_entry := static_cast(Entry, "pointer", + directory.allocate(addr, new Entry)); + return dir_entry; } DataBlock getDataBlock(Address addr), return_by_ref="yes" { diff --git a/src/mem/protocol/MOESI_hammer-dir.sm b/src/mem/protocol/MOESI_hammer-dir.sm index a4f4bf17a..a20619d46 100644 --- a/src/mem/protocol/MOESI_hammer-dir.sm +++ b/src/mem/protocol/MOESI_hammer-dir.sm @@ -186,8 +186,16 @@ machine(Directory, "AMD Hammer-like protocol") TBETable TBEs, template_hack="<Directory_TBE>"; - Entry getDirectoryEntry(Address addr), return_by_ref="yes" { - return static_cast(Entry, directory[addr]); + Entry getDirectoryEntry(Address addr), return_by_pointer="yes" { + Entry dir_entry := static_cast(Entry, "pointer", directory[addr]); + + if (is_valid(dir_entry)) { + return dir_entry; + } + + dir_entry := static_cast(Entry, "pointer", + directory.allocate(addr, new Entry)); + return dir_entry; } DataBlock getDataBlock(Address addr), return_by_ref="yes" { diff --git a/src/mem/protocol/RubySlicc_Types.sm b/src/mem/protocol/RubySlicc_Types.sm index cc404394d..c76e0fe3e 100644 --- a/src/mem/protocol/RubySlicc_Types.sm +++ b/src/mem/protocol/RubySlicc_Types.sm @@ -125,6 +125,7 @@ structure(AbstractEntry, primitive="yes", external = "yes") { } structure (DirectoryMemory, external = "yes") { + AbstractEntry allocate(Address, AbstractEntry); AbstractEntry lookup(Address); bool isPresent(Address); void invalidateBlock(Address); diff --git a/src/mem/ruby/system/DirectoryMemory.cc b/src/mem/ruby/system/DirectoryMemory.cc index a91f05a69..03aa68919 100644 --- a/src/mem/ruby/system/DirectoryMemory.cc +++ b/src/mem/ruby/system/DirectoryMemory.cc @@ -59,7 +59,7 @@ DirectoryMemory::init() if (m_use_map) { m_sparseMemory = new SparseMemory(m_map_levels); } else { - m_entries = new Directory_Entry*[m_num_entries]; + m_entries = new AbstractEntry*[m_num_entries]; for (int i = 0; i < m_num_entries; i++) m_entries[i] = NULL; m_ram = g_system_ptr->getMemoryVector(); @@ -150,38 +150,40 @@ DirectoryMemory::mapAddressToLocalIdx(PhysAddress address) return ret >> (RubySystem::getBlockSizeBits()); } -Directory_Entry& +AbstractEntry* DirectoryMemory::lookup(PhysAddress address) { assert(isPresent(address)); - Directory_Entry* entry; + DPRINTF(RubyCache, "Looking up address: %s\n", address); + + if (m_use_map) { + return m_sparseMemory->lookup(address); + } else { + uint64_t idx = mapAddressToLocalIdx(address); + assert(idx < m_num_entries); + return m_entries[idx]; + } +} + +AbstractEntry* +DirectoryMemory::allocate(const PhysAddress& address, AbstractEntry* entry) +{ + assert(isPresent(address)); uint64 idx; DPRINTF(RubyCache, "Looking up address: %s\n", address); if (m_use_map) { - if (m_sparseMemory->exist(address)) { - entry = m_sparseMemory->lookup(address); - assert(entry != NULL); - } else { - // Note: SparseMemory internally creates a new Directory Entry - m_sparseMemory->add(address); - entry = m_sparseMemory->lookup(address); - entry->changePermission(AccessPermission_Read_Write); - } + m_sparseMemory->add(address, entry); + entry->changePermission(AccessPermission_Read_Write); } else { idx = mapAddressToLocalIdx(address); assert(idx < m_num_entries); - entry = m_entries[idx]; - - if (entry == NULL) { - entry = new Directory_Entry(); - entry->getDataBlk().assign(m_ram->getBlockPtr(address)); - entry->changePermission(AccessPermission_Read_Only); - m_entries[idx] = entry; - } + entry->getDataBlk().assign(m_ram->getBlockPtr(address)); + entry->changePermission(AccessPermission_Read_Only); + m_entries[idx] = entry; } - return *entry; + return entry; } void diff --git a/src/mem/ruby/system/DirectoryMemory.hh b/src/mem/ruby/system/DirectoryMemory.hh index 79b04726a..7005ce234 100644 --- a/src/mem/ruby/system/DirectoryMemory.hh +++ b/src/mem/ruby/system/DirectoryMemory.hh @@ -32,9 +32,9 @@ #include <iostream> #include <string> -#include "mem/protocol/Directory_Entry.hh" #include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Global.hh" +#include "mem/ruby/slicc_interface/AbstractEntry.hh" #include "mem/ruby/system/MemoryVector.hh" #include "mem/ruby/system/SparseMemory.hh" #include "params/RubyDirectoryMemory.hh" @@ -58,7 +58,9 @@ class DirectoryMemory : public SimObject void printConfig(std::ostream& out) const; static void printGlobalConfig(std::ostream & out); bool isPresent(PhysAddress address); - Directory_Entry& lookup(PhysAddress address); + AbstractEntry* lookup(PhysAddress address); + AbstractEntry* allocate(const PhysAddress& address, + AbstractEntry* new_entry); void invalidateBlock(PhysAddress address); @@ -72,7 +74,7 @@ class DirectoryMemory : public SimObject private: const std::string m_name; - Directory_Entry **m_entries; + AbstractEntry **m_entries; // int m_size; // # of memory module blocks this directory is // responsible for uint64 m_size_bytes; diff --git a/src/mem/ruby/system/SparseMemory.cc b/src/mem/ruby/system/SparseMemory.cc index fd90e2214..8e4f37c46 100644 --- a/src/mem/ruby/system/SparseMemory.cc +++ b/src/mem/ruby/system/SparseMemory.cc @@ -92,9 +92,7 @@ SparseMemory::recursivelyRemoveTables(SparseMapType* curTable, int curLevel) delete nextTable; } else { // If at the last level, delete the directory entry - Directory_Entry* dirEntry; - dirEntry = (Directory_Entry*)(entryStruct->entry); - delete dirEntry; + delete (AbstractEntry*)(entryStruct->entry); } entryStruct->entry = NULL; } @@ -149,7 +147,7 @@ SparseMemory::exist(const Address& address) const // add an address to memory void -SparseMemory::add(const Address& address) +SparseMemory::add(const Address& address, AbstractEntry* entry) { assert(address == line_address(address)); assert(!exist(address)); @@ -187,9 +185,8 @@ SparseMemory::add(const Address& address) // if the last level, add a directory entry. Otherwise add a map. if (level == (m_number_of_levels - 1)) { - Directory_Entry* tempDirEntry = new Directory_Entry(); - tempDirEntry->getDataBlk().clear(); - newEntry = (void*)tempDirEntry; + entry->getDataBlk().clear(); + newEntry = (void*)entry; } else { SparseMapType* tempMap = new SparseMapType; newEntry = (void*)(tempMap); @@ -262,10 +259,8 @@ SparseMemory::recursivelyRemoveLevels(const Address& address, // if this is the last level, we have reached the Directory // Entry and thus we should delete it including the // SparseMemEntry container struct. - Directory_Entry* dirEntry; - dirEntry = (Directory_Entry*)(entryStruct->entry); + delete (AbstractEntry*)(entryStruct->entry); entryStruct->entry = NULL; - delete dirEntry; curInfo.curTable->erase(curAddress); m_removes_per_level[curInfo.level]++; } @@ -303,17 +298,14 @@ SparseMemory::remove(const Address& address) } // looks an address up in memory -Directory_Entry* +AbstractEntry* SparseMemory::lookup(const Address& address) { - assert(exist(address)); assert(address == line_address(address)); - DPRINTF(RubyCache, "address: %s\n", address); - Address curAddress; SparseMapType* curTable = m_map_head; - Directory_Entry* entry = NULL; + AbstractEntry* entry = NULL; // Initiallize the high bit to be the total number of bits plus // the block offset. However the highest bit index is one less @@ -336,13 +328,18 @@ SparseMemory::lookup(const Address& address) // Adjust the highBit value for the next level highBit -= m_number_of_bits_per_level[level]; - // The entry should be in the table and valid - curTable = (SparseMapType*)(((*curTable)[curAddress]).entry); - assert(curTable != NULL); + // If the address is found, move on to the next level. + // Otherwise, return not found + if (curTable->count(curAddress) != 0) { + curTable = (SparseMapType*)(((*curTable)[curAddress]).entry); + } else { + DPRINTF(RubyCache, "Not found\n"); + return NULL; + } } // The last entry actually points to the Directory entry not a table - entry = (Directory_Entry*)curTable; + entry = (AbstractEntry*)curTable; return entry; } diff --git a/src/mem/ruby/system/SparseMemory.hh b/src/mem/ruby/system/SparseMemory.hh index 78a3080a1..f6937ef54 100644 --- a/src/mem/ruby/system/SparseMemory.hh +++ b/src/mem/ruby/system/SparseMemory.hh @@ -32,7 +32,7 @@ #include <iostream> #include "base/hashmap.hh" -#include "mem/protocol/Directory_Entry.hh" +#include "mem/ruby/slicc_interface/AbstractEntry.hh" #include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Global.hh" @@ -60,10 +60,10 @@ class SparseMemory void printConfig(std::ostream& out) { } bool exist(const Address& address) const; - void add(const Address& address); + void add(const Address& address, AbstractEntry*); void remove(const Address& address); - Directory_Entry* lookup(const Address& address); + AbstractEntry* lookup(const Address& address); // Print cache contents void print(std::ostream& out) const; diff --git a/src/mem/slicc/ast/FormalParamAST.py b/src/mem/slicc/ast/FormalParamAST.py index e94f24ccb..6ed5bca0a 100644 --- a/src/mem/slicc/ast/FormalParamAST.py +++ b/src/mem/slicc/ast/FormalParamAST.py @@ -52,8 +52,9 @@ class FormalParamAST(AST): self.pairs) self.symtab.newSymbol(v) if self.pointer or str(type) == "TBE" or ( - "interface" in type and type["interface"] == "AbstractCacheEntry"): - + "interface" in type and ( + type["interface"] == "AbstractCacheEntry" or + type["interface"] == "AbstractEntry")): return type, "%s* %s" % (type.c_ident, param) else: return type, "const %s& %s" % (type.c_ident, param) diff --git a/src/mem/slicc/ast/LocalVariableAST.py b/src/mem/slicc/ast/LocalVariableAST.py index b779415f3..0b77323b7 100644 --- a/src/mem/slicc/ast/LocalVariableAST.py +++ b/src/mem/slicc/ast/LocalVariableAST.py @@ -52,7 +52,9 @@ class LocalVariableAST(StatementAST): self.pairs) self.symtab.newSymbol(v) if self.pointer or str(type) == "TBE" or ( - "interface" in type and type["interface"] == "AbstractCacheEntry"): + "interface" in type and ( + type["interface"] == "AbstractCacheEntry" or + type["interface"] == "AbstractEntry")): code += "%s* %s" % (type.c_ident, ident) else: code += "%s %s" % (type.c_ident, ident) diff --git a/src/mem/slicc/ast/MemberExprAST.py b/src/mem/slicc/ast/MemberExprAST.py index 412c178d8..6a6fc49bb 100644 --- a/src/mem/slicc/ast/MemberExprAST.py +++ b/src/mem/slicc/ast/MemberExprAST.py @@ -41,7 +41,10 @@ class MemberExprAST(ExprAST): return_type, gcode = self.expr_ast.inline(True) fix = code.nofix() - if str(return_type) == "TBE" or ("interface" in return_type and return_type["interface"] == "AbstractCacheEntry"): + if str(return_type) == "TBE" \ + or ("interface" in return_type and + (return_type["interface"] == "AbstractCacheEntry" or + return_type["interface"] == "AbstractEntry")): code("(*$gcode).m_${{self.field}}") else: code("($gcode).m_${{self.field}}") diff --git a/src/mem/slicc/ast/MethodCallExprAST.py b/src/mem/slicc/ast/MethodCallExprAST.py index cfee9b19d..cf30cfa96 100644 --- a/src/mem/slicc/ast/MethodCallExprAST.py +++ b/src/mem/slicc/ast/MethodCallExprAST.py @@ -162,8 +162,10 @@ class MemberMethodCallExprAST(MethodCallExprAST): prefix = "static_cast<%s &>" % return_type.c_ident if str(obj_type) == "AbstractCacheEntry" or \ - ("interface" in obj_type and - obj_type["interface"] == "AbstractCacheEntry"): + str(obj_type) == "AbstractEntry" or \ + ("interface" in obj_type and ( + obj_type["interface"] == "AbstractCacheEntry" or + obj_type["interface"] == "AbstractEntry")): prefix = "%s((*(%s))." % (prefix, code) else: prefix = "%s((%s)." % (prefix, code) |