summaryrefslogtreecommitdiff
path: root/src/mem/cache/prefetch/signature_path.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/cache/prefetch/signature_path.hh')
-rw-r--r--src/mem/cache/prefetch/signature_path.hh109
1 files changed, 97 insertions, 12 deletions
diff --git a/src/mem/cache/prefetch/signature_path.hh b/src/mem/cache/prefetch/signature_path.hh
index 0371b56e3..974c02746 100644
--- a/src/mem/cache/prefetch/signature_path.hh
+++ b/src/mem/cache/prefetch/signature_path.hh
@@ -50,6 +50,7 @@ struct SignaturePathPrefetcherParams;
class SignaturePathPrefetcher : public QueuedPrefetcher
{
+ protected:
/** Signature type */
typedef uint16_t signature_t;
/** Stride type */
@@ -96,7 +97,10 @@ class SignaturePathPrefetcher : public QueuedPrefetcher
{
/** group of stides */
std::vector<PatternStrideEntry> strideEntries;
- PatternEntry(size_t num_strides) : strideEntries(num_strides)
+ /** use counter, used by SPPv2 */
+ uint8_t counter;
+ PatternEntry(size_t num_strides) : strideEntries(num_strides),
+ counter(0)
{}
/** Reset the entries to their initial values */
@@ -106,6 +110,7 @@ class SignaturePathPrefetcher : public QueuedPrefetcher
entry.counter = 0;
entry.stride = 0;
}
+ counter = 0;
}
/**
@@ -157,34 +162,44 @@ class SignaturePathPrefetcher : public QueuedPrefetcher
/**
* Generates an address to be prefetched.
* @param ppn page number to prefetch from
- * @param block block number within the page, this value can be negative,
- * which means that the block refered is actualy in the previous
- * page (ppn-1), if the value is greater than (pageBytes/blkSize-1)
- * then the block refers to a block within the next page (ppn+1)
+ * @param last_block last accessed block within the page ppn
+ * @param delta difference, in number of blocks, from the last_block
+ * accessed to the block to prefetch. The block to prefetch is
+ * computed by this formula:
+ * ppn * pageBytes + (last_block + delta) * blkSize
+ * This value can be negative.
+ * @param path_confidence the confidence factor of this prefetch
+ * @param signature the current path signature
* @param is_secure whether this page is inside the secure memory area
- * @param addresses if allowed, the address will be added to this vector
+ * @param addresses addresses to prefetch will be added to this vector
*/
- void addPrefetch(Addr ppn, stride_t block, bool is_secure,
- std::vector<AddrPriority> &addresses);
+ void addPrefetch(Addr ppn, stride_t last_block, stride_t delta,
+ double path_confidence, signature_t signature,
+ bool is_secure,
+ std::vector<AddrPriority> &addresses);
/**
* Obtains the SignatureEntry of the given page, if the page is not found,
* it allocates a new one, replacing an existing entry if needed
+ * It also provides the stride of the current block and the initial
+ * path confidence of the corresponding entry
* @param ppn physical page number of the page
* @param is_secure whether this page is inside the secure memory area
* @param block accessed block within the page
- * @param miss output, if the entry is not found, this will be set to true
+ * @param miss if the entry is not found, this will be set to true
+ * @param stride set to the computed stride
+ * @param initial_confidence set to the initial confidence value
* @result a reference to the SignatureEntry
*/
- SignatureEntry & getSignatureEntry(Addr ppn, bool is_secure,
- stride_t block, bool &miss);
+ SignatureEntry &getSignatureEntry(Addr ppn, bool is_secure, stride_t block,
+ bool &miss, stride_t &stride, double &initial_confidence);
/**
* Obtains the PatternEntry of the given signature, if the signature is
* not found, it allocates a new one, replacing an existing entry if needed
* @param signature the signature of the desired entry
* @result a reference to the PatternEntry
*/
- PatternEntry & getPatternEntry(Addr signature);
+ PatternEntry& getPatternEntry(Addr signature);
/**
* Updates the pattern table with the provided signature and stride
@@ -194,6 +209,76 @@ class SignaturePathPrefetcher : public QueuedPrefetcher
*/
void updatePatternTable(Addr signature, stride_t stride);
+ /**
+ * Computes the lookahead path confidence of the provided pattern entry
+ * @param sig the PatternEntry to use
+ * @param lookahead PatternStrideEntry within the provided PatternEntry
+ * @return the computed confidence factor
+ */
+ virtual double calculateLookaheadConfidence(PatternEntry const &sig,
+ PatternStrideEntry const &lookahead) const;
+
+ /**
+ * Computes the prefetch confidence of the provided pattern entry
+ * @param sig the PatternEntry to use
+ * @param entry PatternStrideEntry within the provided PatternEntry
+ * @return the computed confidence factor
+ */
+ virtual double calculatePrefetchConfidence(PatternEntry const &sig,
+ PatternStrideEntry const &entry) const;
+
+ /**
+ * Increases the counter of a given PatternEntry/PatternStrideEntry
+ * @param pattern_entry the corresponding PatternEntry
+ * @param pstride_entry the PatternStrideEntry within the PatternEntry
+ */
+ virtual void increasePatternEntryCounter(PatternEntry &pattern_entry,
+ PatternStrideEntry &pstride_entry);
+
+ /**
+ * Whenever a new SignatureEntry is allocated, it computes the new
+ * signature to be used with the new entry, the resulting stride and the
+ * initial path confidence of the new entry.
+ * @param current_block accessed block within the page of the associated
+ entry
+ * @param new_signature new signature of the allocated entry
+ * @param new_conf the initial path confidence of this entry
+ * @param new_stride the resulting current stride
+ */
+ virtual void handleSignatureTableMiss(stride_t current_block,
+ signature_t &new_signature, double &new_conf,
+ stride_t &new_stride);
+
+ /**
+ * Auxiliar prefetch mechanism used at the end of calculatePrefetch.
+ * This prefetcher uses this to activate the next line prefetcher if
+ * no prefetch candidates have been found.
+ * @param ppn physical page number of the current accessed page
+ * @param current_block last accessed block within the page ppn
+ * @param is_secure whether this page is inside the secure memory area
+ * @param addresses the addresses to be prefetched are added to this vector
+ * @param updated_filter_entries set of addresses containing these that
+ * their filter has been updated, if this call updates a new entry
+ */
+ virtual void auxiliaryPrefetcher(Addr ppn, stride_t current_block,
+ bool is_secure, std::vector<AddrPriority> &addresses);
+
+ /**
+ * Handles the situation when the lookahead process has crossed the
+ * boundaries of the current page. This is not fully described in the
+ * paper that was used to implement this code, however, the article
+ * describing the upgraded version of this prefetcher provides some
+ * details. For this prefetcher, there are no specific actions to be
+ * done.
+ * @param signature the lookahead signature that crossed the page
+ * @param delta the current stride that caused it
+ * @param last_offset the last accessed block within the page
+ * @param path_confidence the path confidence at the moment of crossing
+ */
+ virtual void handlePageCrossingLookahead(signature_t signature,
+ stride_t last_offset, stride_t delta, double path_confidence) {
+ }
+
public:
SignaturePathPrefetcher(const SignaturePathPrefetcherParams* p);
~SignaturePathPrefetcher() {}