Nikos Nikoleris has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/37597 )

Change subject: mem-cache: Fix indexing policies in prefetchers
......................................................................

mem-cache: Fix indexing policies in prefetchers

Many prefetches use a set-associative array for their internal
state. In most cases, either the address or the PC of a request is
used to calculate the index in these arrays. The index depends on the
size of the *tracked* block and the associativity. This patch moves
the index calculation inside the indexing to policy to fix some bugs
and allow more flexibility.

Change-Id: Ia2273cb34705fecce10480881e102ad1764050e0
Signed-off-by: Nikos Nikoleris <nikos.nikole...@arm.com>
---
M src/mem/cache/prefetch/Prefetcher.py
M src/mem/cache/prefetch/access_map_pattern_matching.cc
M src/mem/cache/prefetch/irregular_stream_buffer.cc
M src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc
4 files changed, 42 insertions(+), 21 deletions(-)



diff --git a/src/mem/cache/prefetch/Prefetcher.py b/src/mem/cache/prefetch/Prefetcher.py
index 758803f..f8f39bc 100644
--- a/src/mem/cache/prefetch/Prefetcher.py
+++ b/src/mem/cache/prefetch/Prefetcher.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012, 2014, 2019 ARM Limited
+# Copyright (c) 2012, 2014, 2019-2020 ARM Limited
 # All rights reserved.
 #
 # The license below extends only to copyright in the software and shall
@@ -299,8 +299,9 @@
     access_map_table_assoc = Param.Unsigned(8,
         "Associativity of the access map table")
     access_map_table_indexing_policy = Param.BaseIndexingPolicy(
- SetAssociative(entry_size = 1, assoc = Parent.access_map_table_assoc,
-        size = Parent.access_map_table_entries),
+        SetAssociative(entry_size=Self.hot_zone_size,
+                       assoc=Parent.access_map_table_assoc,
+                       size=Parent.access_map_table_entries),
         "Indexing policy of the access map table")
access_map_table_replacement_policy = Param.BaseReplacementPolicy(LRURP(),
         "Replacement policy of the access map table")
@@ -340,6 +341,10 @@
         "Number of entries in the table")
     table_assoc = Param.Unsigned(128,
         "Associativity of the table")
+
+    # FIXME: Highly unlikely that 1 is the right value for entry_size.
+    # I would expect the instruction size would be a more sensible
+    # value to avoid underutilizing the table.
     table_indexing_policy = Param.BaseIndexingPolicy(
         SetAssociative(entry_size = 1, assoc = Parent.table_assoc,
         size = Parent.table_entries),
@@ -369,6 +374,10 @@
         "Associativity of the training unit")
     training_unit_entries = Param.MemorySize("128",
         "Number of entries of the training unit")
+
+    # FIXME: Highly unlikely that 1 is the right value for entry_size.
+    # I would expect the instruction size would be a more sensible
+    # value to avoid underutilizing the table.
     training_unit_indexing_policy = Param.BaseIndexingPolicy(
         SetAssociative(entry_size = 1, assoc = Parent.training_unit_assoc,
         size = Parent.training_unit_entries),
@@ -383,17 +392,17 @@
     address_map_cache_entries = Param.MemorySize("128",
         "Number of entries of the PS/SP AMCs")
     ps_address_map_cache_indexing_policy = Param.BaseIndexingPolicy(
-        SetAssociative(entry_size = 1,
-        assoc = Parent.address_map_cache_assoc,
-        size = Parent.address_map_cache_entries),
+        SetAssociative(entry_size=Self.prefetch_candidates_per_entry,
+                       assoc=Parent.address_map_cache_assoc,
+                       size=Parent.address_map_cache_entries),
         "Indexing policy of the Physical-to-Structural Address Map Cache")
     ps_address_map_cache_replacement_policy = Param.BaseReplacementPolicy(
         LRURP(),
"Replacement policy of the Physical-to-Structural Address Map Cache")
     sp_address_map_cache_indexing_policy = Param.BaseIndexingPolicy(
-        SetAssociative(entry_size = 1,
-        assoc = Parent.address_map_cache_assoc,
-        size = Parent.address_map_cache_entries),
+        SetAssociative(entry_size=Self.prefetch_candidates_per_entry,
+                       assoc=Parent.address_map_cache_assoc,
+                       size=Parent.address_map_cache_entries),
         "Indexing policy of the Structural-to-Physical Address Mao Cache")
     sp_address_map_cache_replacement_policy = Param.BaseReplacementPolicy(
         LRURP(),
@@ -463,9 +472,9 @@
     active_generation_table_assoc = Param.Unsigned(64,
         "Associativity of the active generation table")
     active_generation_table_indexing_policy = Param.BaseIndexingPolicy(
-        SetAssociative(entry_size = 1,
-            assoc = Parent.active_generation_table_assoc,
-            size = Parent.active_generation_table_entries),
+        SetAssociative(entry_size=Self.spatial_region_size,
+                       assoc=Parent.active_generation_table_assoc,
+                       size=Parent.active_generation_table_entries),
         "Indexing policy of the active generation table")
active_generation_table_replacement_policy = Param.BaseReplacementPolicy(
         LRURP(), "Replacement policy of the active generation table")
diff --git a/src/mem/cache/prefetch/access_map_pattern_matching.cc b/src/mem/cache/prefetch/access_map_pattern_matching.cc
index ad10138..47f5d5f 100644
--- a/src/mem/cache/prefetch/access_map_pattern_matching.cc
+++ b/src/mem/cache/prefetch/access_map_pattern_matching.cc
@@ -157,7 +157,7 @@
     assert(addresses.empty());

     bool is_secure = pfi.isSecure();
-    Addr am_addr = pfi.getAddr() / hotZoneSize;
+    Addr am_addr = pfi.getAddr();
     Addr current_block = (pfi.getAddr() % hotZoneSize) / blkSize;
     uint64_t lines_per_zone = hotZoneSize / blkSize;

@@ -165,9 +165,9 @@
     // following ones
     AccessMapEntry *am_entry_curr = getAccessMapEntry(am_addr, is_secure);
     AccessMapEntry *am_entry_prev = (am_addr > 0) ?
-        getAccessMapEntry(am_addr-1, is_secure) : nullptr;
-    AccessMapEntry *am_entry_next = (am_addr < (MaxAddr/hotZoneSize)) ?
-        getAccessMapEntry(am_addr+1, is_secure) : nullptr;
+        getAccessMapEntry(am_addr + hotZoneSize, is_secure) : nullptr;
+    AccessMapEntry *am_entry_next = (am_addr < MaxAddr) ?
+        getAccessMapEntry(am_addr + hotZoneSize, is_secure) : nullptr;
     assert(am_entry_curr != am_entry_prev);
     assert(am_entry_curr != am_entry_next);
     assert(am_entry_prev != am_entry_next);
diff --git a/src/mem/cache/prefetch/irregular_stream_buffer.cc b/src/mem/cache/prefetch/irregular_stream_buffer.cc
index d73f464..37fbdd0 100644
--- a/src/mem/cache/prefetch/irregular_stream_buffer.cc
+++ b/src/mem/cache/prefetch/irregular_stream_buffer.cc
@@ -1,4 +1,16 @@
 /**
+ * Copyright (c) 2020 ARM Limited
+ * All rights reserved.
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
  * Copyright (c) 2018 Metempsy Technology Consulting
  * All rights reserved.
  *
@@ -137,14 +149,14 @@
     // - if it exists, use it to generate prefetches for the subsequent
     //   addresses in ascending order, as many as indicated by the degree
// (given the structured address S, prefetch S+1, S+2, .. up to S+degree)
-    Addr amc_address = addr / prefetchCandidatesPerEntry;
+    Addr amc_address = addr;
     Addr map_index   = addr % prefetchCandidatesPerEntry;
AddressMappingEntry *ps_am = psAddressMappingCache.findEntry(amc_address, is_secure);
     if (ps_am != nullptr) {
         AddressMapping &mapping = ps_am->mappings[map_index];
         if (mapping.counter > 0) {
-            Addr sp_address = mapping.address / prefetchCandidatesPerEntry;
+            Addr sp_address = mapping.address;
             Addr sp_index   = mapping.address % prefetchCandidatesPerEntry;
             AddressMappingEntry *sp_am =
                 spAddressMappingCache.findEntry(sp_address, is_secure);
@@ -170,7 +182,7 @@
 IrregularStreamBuffer::AddressMapping&
 IrregularStreamBuffer::getPSMapping(Addr paddr, bool is_secure)
 {
-    Addr amc_address = paddr / prefetchCandidatesPerEntry;
+    Addr amc_address = paddr;
     Addr map_index   = paddr % prefetchCandidatesPerEntry;
     AddressMappingEntry *ps_entry =
         psAddressMappingCache.findEntry(amc_address, is_secure);
@@ -190,7 +202,7 @@
 IrregularStreamBuffer::addStructuralToPhysicalEntry(
     Addr structural_address, bool is_secure, Addr physical_address)
 {
-    Addr amc_address = structural_address / prefetchCandidatesPerEntry;
+    Addr amc_address = structural_address;
     Addr map_index   = structural_address % prefetchCandidatesPerEntry;
     AddressMappingEntry *sp_entry =
         spAddressMappingCache.findEntry(amc_address, is_secure);
diff --git a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc
index 53374a9..b3b1061 100644
--- a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc
+++ b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc
@@ -126,7 +126,7 @@
     Addr pc = pfi.getPC();
     bool is_secure = pfi.isSecure();
     // Spatial region address
-    Addr sr_addr = pfi.getAddr() / spatialRegionSize;
+    Addr sr_addr = pfi.getAddr();
     Addr paddr = pfi.getPaddr();

     // Offset in cachelines within the spatial region

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/37597
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: Ia2273cb34705fecce10480881e102ad1764050e0
Gerrit-Change-Number: 37597
Gerrit-PatchSet: 1
Gerrit-Owner: Nikos Nikoleris <nikos.nikole...@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

Reply via email to