47#include "debug/RubyPrefetcher.hh"
59 m_array(
p.num_streams), m_train_misses(
p.train_misses),
60 m_num_startup_pfs(
p.num_startup_pfs),
61 unitFilter(
p.unit_filter),
62 negativeFilter(
p.unit_filter),
63 nonUnitFilter(
p.nonunit_filter),
64 m_prefetch_cross_pages(
p.cross_page),
65 pageShift(
p.page_shift),
66 rubyPrefetcherStats(this)
74 : statistics::
Group(parent,
"RubyPrefetcher"),
75 ADD_STAT(numMissObserved,
"Number of misses observed"),
76 ADD_STAT(numAllocatedStreams,
"Number of streams allocated for "
78 ADD_STAT(numPrefetchRequested,
"Number of prefetch requests made"),
79 ADD_STAT(numHits,
"Number of prefetched blocks accessed "
80 "(for the first time)"),
81 ADD_STAT(numPartialHits,
"Number of misses observed for a block being "
83 ADD_STAT(numPagesCrossed,
"Number of prefetches across pages"),
84 ADD_STAT(numMissedPrefetchedBlocks,
"Number of misses for blocks that "
85 "were prefetched, yet missed")
99 if (pfEntry != NULL) {
155 if (stream == NULL) {
161 if (stream == NULL) {
193 uint32_t lru_index = 0;
200 if (
m_array[
i].m_use_time < lru_access) {
211 uint32_t
index,
const RubyRequestType&
type)
259 -(
m_array[
i].m_stride*j)) == address) {
272 for (
auto& entry : *filter) {
273 if (entry.addr == line_addr) {
293 const RubyRequestType&
type)
302 int delta = line_addr - entry.addr;
307 if (delta == entry.stride) {
315 const int stride = entry.stride /
330 entry.addr = line_addr;
331 entry.stride = delta;
348 out <<
name() <<
" Prefetcher State\n";
350 out <<
"unit table:\n";
352 out << entry.addr << std::endl;
355 out <<
"negative table:\n";
357 out << entry.addr << std::endl;
361 out <<
"non-unit table:\n";
363 out << entry.addr <<
" "
364 << entry.stride <<
" "
365 << entry.hits << std::endl;
374 <<
m_array[
i].m_use_time << std::endl;
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
Cycles is a wrapper class for representing cycle counts, i.e.
virtual std::string name() const
Abstract superclass for simulation objects.
virtual void enqueuePrefetch(const Addr &, const RubyRequestType &)
Function for enqueuing a prefetch request.
RubyRequestType m_type
L1D prefetches loads and stores.
int m_stride
stride distance to get next address from
std::bitset< MAX_PF_INFLIGHT > requestIssued
Bitset for tracking prefetches for which addresses have been issued, which ones have completed.
bool m_is_valid
valid bit for each stream
std::bitset< MAX_PF_INFLIGHT > requestCompleted
Cycles m_use_time
the last time that any prefetched request was used
Addr m_address
The base address for the stream prefetch.
CircularQueue< UnitFilterEntry > negativeFilter
A negative unit stride filter array: helps reduce BW requirement of prefetching.
void initializeStream(Addr address, int stride, uint32_t index, const RubyRequestType &type)
allocate a new stream buffer at a specific index
uint32_t m_num_streams
number of prefetch streams available
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats rubyPrefetcherStats
bool accessNonunitFilter(Addr line_addr, const RubyRequestType &type)
Access a non-unit stride filter to determine if there is a hit, and update it otherwise.
RubyPrefetcher(const Params &p)
PrefetchEntry * getPrefetchEntry(Addr address, uint32_t &index)
get pointer to the matching stream entry, returns NULL if not found index holds the multiple of the s...
CircularQueue< UnitFilterEntry > unitFilter
A unit stride filter array: helps reduce BW requirement of prefetching.
void observeMiss(Addr address, const RubyRequestType &type)
Observe a memory miss from the cache.
AbstractController * m_controller
void observePfHit(Addr address)
Implement the prefetch hit(miss) callback interface.
uint32_t m_num_startup_pfs
number of initial prefetches to startup a stream
void print(std::ostream &out) const
Print out some statistics.
std::vector< PrefetchEntry > m_array
an array of the active prefetch streams
CircularQueue< NonUnitFilterEntry > nonUnitFilter
A non-unit stride filter array: helps reduce BW requirement of prefetching.
uint32_t getLRUindex(void)
Returns an unused stream buffer (or if all are used, returns the least recently used (accessed) strea...
RubyPrefetcherParams Params
void issueNextPrefetch(Addr address, PrefetchEntry *stream)
void observePfMiss(Addr address)
bool accessUnitFilter(CircularQueue< UnitFilterEntry > *const filter, Addr line_addr, int stride, const RubyRequestType &type)
Access a unit stride filter to determine if there is a hit, and update it otherwise.
uint32_t m_train_misses
number of misses I must see before allocating a stream
bool m_prefetch_cross_pages
Used for allowing prefetches across pages.
Addr pageAddress(Addr addr) const
determine the page aligned address
static uint32_t getBlockSizeBytes()
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
void push_back(typename std::vector< T >::value_type val)
Pushes an element at the end of the queue.
constexpr T mbits(T val, unsigned first, unsigned last)
Mask off the given bits in place like bits() but without shifting.
Bitfield< 21, 20 > stride
Addr makeNextStrideAddress(Addr addr, int stride)
Addr makeLineAddress(Addr addr)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
statistics::Scalar numPartialHits
Count of partial successful prefetches.
RubyPrefetcherStats(statistics::Group *parent)
statistics::Scalar numPagesCrossed
Count of pages crossed.
statistics::Scalar numMissObserved
Count of accesses to the prefetcher.
statistics::Scalar numHits
Count of successful prefetches.
statistics::Scalar numAllocatedStreams
Count of prefetch streams allocated.
statistics::Scalar numPrefetchRequested
Count of prefetch requests made.
statistics::Scalar numMissedPrefetchedBlocks
Count of misses incurred for blocks that were prefetched.