Go to the documentation of this file.
45 #include "debug/HWPrefetch.hh"
46 #include "debug/HWPrefetchQueue.hh"
49 #include "params/QueuedPrefetcher.hh"
63 RequestPtr req = std::make_shared<Request>(paddr, blk_size,
82 assert(translationRequest !=
nullptr);
83 if (!ongoingTranslation) {
84 ongoingTranslation =
true;
94 assert(ongoingTranslation);
95 ongoingTranslation =
false;
96 bool failed = (fault !=
NoFault);
97 owner->translationComplete(
this, failed);
103 p.max_prefetch_requests_with_pending_translation),
123 std::string queue_name =
"";
124 if (&queue == &
pfq) {
128 queue_name =
"PFTransQ";
135 Addr paddr = it->pkt ? it->pkt->getAddr() : 0;
136 DPRINTF(HWPrefetchQueue,
"%s[%d]: Prefetch Req VA: %#x PA: %#x "
137 "prio: %3d\n", queue_name, pos,
vaddr, paddr, it->priority);
160 size_t max_pfs =
total;
163 size_t min_pfs = (
total - throttle_pfs) == 0 ?
164 1 : (
total - throttle_pfs);
165 max_pfs = min_pfs + (
total - min_pfs) *
179 auto itr =
pfq.begin();
180 while (itr !=
pfq.end()) {
181 if (itr->pfInfo.getAddr() == blk_addr &&
182 itr->pfInfo.isSecure() == is_secure) {
183 DPRINTF(HWPrefetch,
"Removing pf candidate addr: %#x "
184 "(cl: %#x), demand request going to the same addr\n",
185 itr->pfInfo.getAddr(),
188 itr =
pfq.erase(itr);
218 bool can_cross_page = (
mmu !=
nullptr);
222 DPRINTF(HWPrefetch,
"Found a pf candidate addr: %#x, "
223 "inserting into prefetch queue.\n", new_pfi.
getAddr());
225 insert(pkt, new_pfi, addr_prio.second);
227 if (num_pfs == max_pfs) {
231 DPRINTF(HWPrefetch,
"Ignoring page crossing prefetch.\n");
239 DPRINTF(HWPrefetch,
"Requesting a prefetch to issue.\n");
248 DPRINTF(HWPrefetch,
"No hardware prefetches available.\n");
257 assert(pkt !=
nullptr);
258 DPRINTF(HWPrefetch,
"Generating prefetch for %#x.\n", pkt->
getAddr());
265 : statistics::
Group(parent),
267 "number of prefetch candidates identified"),
269 "number of redundant prefetches already in prefetch queue"),
271 "number of redundant prefetches already in cache/mshr dropped"),
273 "number of prefetches dropped due to a demand for the same "
276 "number of prefetches dropped due to prefetch queue size"),
278 "number of prefetches that crossed the page"),
280 "number of prefetches that is useful and crossed the page")
295 dp.startTranslation(
mmu);
312 DPRINTF(HWPrefetch,
"%s Translation of vaddr %#x succeeded: "
314 it->translationRequest->getVaddr(),
315 it->translationRequest->getPaddr());
316 Addr target_paddr = it->translationRequest->getPaddr();
319 inMissQueue(target_paddr, it->pfInfo.isSecure()))) {
321 DPRINTF(HWPrefetch,
"Dropping redundant in "
322 "cache/MSHR prefetch addr:%#x\n", target_paddr);
330 DPRINTF(HWPrefetch,
"%s Translation of vaddr %#x failed, dropping "
331 "prefetch request %#x \n",
mmu->
name(),
332 it->translationRequest->getVaddr());
343 for (it = queue.begin(); it != queue.end() && !found; it++) {
344 found = it->pfInfo.sameAddr(pfi);
348 if (it != queue.end()) {
354 while (prev != queue.begin()) {
358 std::swap(*it, *prev);
362 DPRINTF(HWPrefetch,
"Prefetch addr already in "
363 "prefetch queue, priority updated\n");
365 DPRINTF(HWPrefetch,
"Prefetch addr already in "
376 RequestPtr translation_req = std::make_shared<Request>(
378 pkt->
req->contextId());
380 return translation_req;
409 pkt->
req->getVaddr() : pkt->
req->getPaddr();
410 bool positive_stride = new_pfi.
getAddr() >= orig_addr;
412 (new_pfi.
getAddr() - orig_addr) : (orig_addr - new_pfi.
getAddr());
415 bool has_target_pa =
false;
422 target_paddr = positive_stride ? (pkt->
req->getPaddr() +
stride) :
425 target_paddr = new_pfi.
getAddr();
427 has_target_pa =
true;
432 if (!pkt->
req->hasContextId()) {
436 has_target_pa =
false;
439 }
else if (pkt->
req->hasVaddr()) {
440 has_target_pa =
false;
442 Addr target_vaddr = positive_stride ?
457 DPRINTF(HWPrefetch,
"Dropping redundant in "
458 "cache/MSHR prefetch addr:%#x\n", target_paddr);
468 DPRINTF(HWPrefetch,
"Prefetch queued. "
469 "addr:%#x priority: %3d tick:%lld.\n",
476 DPRINTF(HWPrefetch,
"Prefetch queued with no translation. "
492 "Prefetch queue is both full and empty!");
496 "Prefetch queue is full with 1 element!");
500 while (cont && prev != queue.begin()) {
503 cont = prev->priority == it->priority;
508 DPRINTF(HWPrefetch,
"Prefetch queue full, removing lowest priority "
509 "oldest packet, addr: %#x\n",it->pfInfo.getAddr());
514 if ((queue.size() == 0) || (dpp <= queue.back())) {
515 queue.emplace_back(dpp);
520 }
while (it != queue.begin() && dpp > *it);
523 if (it == queue.begin() && dpp <= *it)
525 queue.insert(it, dpp);
528 if (debug::HWPrefetchQueue)
Addr getAddr() const
Obtains the address value of this Prefetcher address.
void finish(const Fault &fault, const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
Tick curTick()
The universal simulation clock.
void startTranslation(BaseMMU *mmu)
Issues the translation request to the provided MMU.
const bool useVirtualAddresses
Use Virtual Addresses for prefetching.
const bool cacheSnoop
Snoop the cache before generating prefetch (cheating basically)
constexpr decltype(nullptr) NoFault
void notify(const PacketPtr &pkt, const PrefetchInfo &pfi) override
Notify prefetcher of cache access (may be any access or just misses, depending on cache parameters....
std::list< DeferredPacket >::iterator iterator
bool hasBeenPrefetched(Addr addr, bool is_secure) const
void addToQueue(std::list< DeferredPacket > &queue, DeferredPacket &dpp)
Adds a DeferredPacket to the specified queue.
statistics::Scalar pfRemovedDemand
Tick tick
Time when this prefetch becomes ready.
size_t getMaxPermittedPrefetches(size_t total) const
Returns the maxmimum number of prefetch requests that are allowed to be created from the number of pr...
void setTranslationRequest(const RequestPtr &req)
Sets the translation request needed to obtain the physical address of this request.
statistics::Scalar pfInCache
bool isSecure() const
Returns true if the address targets the secure memory space.
statistics::Scalar pfSpanPage
statistics::Scalar pfIssued
RequestPtr req
A pointer to the original request.
const unsigned missingTranslationQueueSize
Maximum size of the queue holding prefetch requests with missing address translations.
bool inMissQueue(Addr addr, bool is_secure) const
Determine if address is in cache miss queue.
void printQueue(const std::list< DeferredPacket > &queue) const
Addr blockAddress(Addr a) const
Determine the address of the block in which a lays.
statistics::Scalar pfIdentified
const bool tagPrefetch
Tag prefetch with PC of generating access?
const RequestorID requestorId
Request id for prefetches.
void insert(const PacketPtr &pkt, PrefetchInfo &new_pfi, int32_t priority)
virtual void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses)=0
BaseMMU * mmu
Registered mmu for address translations.
statistics::Scalar pfUsefulSpanPage
Addr getPC() const
Returns the program counter that generated this request.
Bitfield< 3, 0 > priority
const Cycles latency
Cycles after generation when a prefetch can first be issued.
bool samePage(Addr a, Addr b) const
Determine if addresses are on the same page.
@ PREFETCH
The request is a prefetch.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual std::string name() const
std::shared_ptr< FaultBase > Fault
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
bool alreadyInQueue(std::list< DeferredPacket > &queue, const PrefetchInfo &pfi, int32_t priority)
Checks whether the specified prefetch request is already in the specified queue.
uint64_t usefulPrefetches
Total prefetches that has been useful.
ProbePointArg< PacketInfo > Packet
Packet probe point.
uint64_t Tick
Tick count type.
std::shared_ptr< Request > RequestPtr
statistics::Scalar pfBufferHit
void createPkt(Addr paddr, unsigned blk_size, RequestorID requestor_id, bool tag_prefetch, Tick t)
Create the associated memory packet.
const unsigned int throttleControlPct
Percentage of requests that can be throttled.
PacketPtr getPacket() override
std::list< DeferredPacket > pfq
QueuedStats(statistics::Group *parent)
const bool queueFilter
Filter prefetches if already queued.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
virtual void translateTiming(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode)
void translationComplete(DeferredPacket *dp, bool failed)
Indicates that the translation of the address of the provided deferred packet has been successfully c...
const unsigned queueSize
Maximum size of the prefetch queue.
gem5::prefetch::Base::StatGroup prefetchStats
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
PrefetchInfo pfInfo
Prefetch info corresponding to this packet.
uint64_t issuedPrefetches
Total prefetches issued.
void processMissingTranslations(unsigned max)
Starts the translations of the queued prefetches with a missing translation.
void allocate()
Allocate memory for the packet.
PacketPtr pkt
The memory packet generated by this prefetch.
Queued(const QueuedPrefetcherParams &p)
System * system
System we are currently operating in.
@ SECURE
The request targets the secure memory space.
BaseCache * cache
Pointr to the parent cache.
unsigned blkSize
The block size of the parent cache.
bool inCache(Addr addr, bool is_secure) const
Determine if address is in cache.
RequestPtr createPrefetchRequest(Addr addr, PrefetchInfo const &pfi, PacketPtr pkt)
std::list< DeferredPacket >::const_iterator const_iterator
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const FlagsType total
Print the total.
Bitfield< 21, 20 > stride
Class containing the information needed by the prefetch to train and generate new prefetch requests.
statistics::Scalar pfRemovedFull
std::list< DeferredPacket > pfqMissingTranslation
bool hasPC() const
Returns true if the associated program counter is valid.
const bool queueSquash
Squash queued prefetch if demand access observed.
gem5::prefetch::Queued::QueuedStats statsQueued
Generated on Sun Jul 30 2023 01:56:57 for gem5 by doxygen 1.8.17