Go to the documentation of this file.
   45 #include "debug/HWPrefetch.hh" 
   46 #include "debug/HWPrefetchQueue.hh" 
   49 #include "params/QueuedPrefetcher.hh" 
   64     RequestPtr req = std::make_shared<Request>(paddr, blk_size,
 
   83     assert(translationRequest != 
nullptr);
 
   84     if (!ongoingTranslation) {
 
   85         ongoingTranslation = 
true;
 
   95     assert(ongoingTranslation);
 
   96     ongoingTranslation = 
false;
 
   97     bool failed = (fault != 
NoFault);
 
   98     owner->translationComplete(
this, failed);
 
  104         p.max_prefetch_requests_with_pending_translation),
 
  124     std::string queue_name = 
"";
 
  125     if (&queue == &
pfq) {
 
  129         queue_name = 
"PFTransQ";
 
  134         DPRINTF(HWPrefetchQueue, 
"%s[%d]: Prefetch Req Addr: %#x prio: %3d\n",
 
  135                 queue_name, pos, it->pkt->getAddr(), it->priority);
 
  158     size_t max_pfs = 
total;
 
  161         size_t min_pfs = (
total - throttle_pfs) == 0 ?
 
  162             1 : (
total - throttle_pfs);
 
  163         max_pfs = min_pfs + (
total - min_pfs) *
 
  177         auto itr = 
pfq.begin();
 
  178         while (itr != 
pfq.end()) {
 
  179             if (itr->pfInfo.getAddr() == blk_addr &&
 
  180                 itr->pfInfo.isSecure() == is_secure) {
 
  181                 DPRINTF(HWPrefetch, 
"Removing pf candidate addr: %#x " 
  182                         "(cl: %#x), demand request going to the same addr\n",
 
  183                         itr->pfInfo.getAddr(),
 
  186                 itr = 
pfq.erase(itr);
 
  212         bool can_cross_page = (
tlb != 
nullptr);
 
  216             DPRINTF(HWPrefetch, 
"Found a pf candidate addr: %#x, " 
  217                     "inserting into prefetch queue.\n", new_pfi.
getAddr());
 
  219             insert(pkt, new_pfi, addr_prio.second);
 
  221             if (num_pfs == max_pfs) {
 
  225             DPRINTF(HWPrefetch, 
"Ignoring page crossing prefetch.\n");
 
  233     DPRINTF(HWPrefetch, 
"Requesting a prefetch to issue.\n");
 
  242         DPRINTF(HWPrefetch, 
"No hardware prefetches available.\n");
 
  251     assert(pkt != 
nullptr);
 
  252     DPRINTF(HWPrefetch, 
"Generating prefetch for %#x.\n", pkt->
getAddr());
 
  259     : statistics::
Group(parent),
 
  260     ADD_STAT(pfIdentified, statistics::units::Count::get(),
 
  261              "number of prefetch candidates identified"),
 
  262     ADD_STAT(pfBufferHit, statistics::units::Count::get(),
 
  263              "number of redundant prefetches already in prefetch queue"),
 
  264     ADD_STAT(pfInCache, statistics::units::Count::get(),
 
  265              "number of redundant prefetches already in cache/mshr dropped"),
 
  266     ADD_STAT(pfRemovedDemand, statistics::units::Count::get(),
 
  267              "number of prefetches dropped due to a demand for the same " 
  269     ADD_STAT(pfRemovedFull, statistics::units::Count::get(),
 
  270              "number of prefetches dropped due to prefetch queue size"),
 
  271     ADD_STAT(pfSpanPage, statistics::units::Count::get(),
 
  272              "number of prefetches that crossed the page")
 
  287         dp.startTranslation(
tlb);
 
  304         DPRINTF(HWPrefetch, 
"%s Translation of vaddr %#x succeeded: " 
  306                 it->translationRequest->getVaddr(),
 
  307                 it->translationRequest->getPaddr());
 
  308         Addr target_paddr = it->translationRequest->getPaddr();
 
  311                     inMissQueue(target_paddr, it->pfInfo.isSecure()))) {
 
  313             DPRINTF(HWPrefetch, 
"Dropping redundant in " 
  314                     "cache/MSHR prefetch addr:%#x\n", target_paddr);
 
  317             it->createPkt(it->translationRequest->getPaddr(), 
blkSize,
 
  322         DPRINTF(HWPrefetch, 
"%s Translation of vaddr %#x failed, dropping " 
  323                 "prefetch request %#x \n", 
tlb->
name(),
 
  324                 it->translationRequest->getVaddr());
 
  335     for (it = queue.begin(); it != queue.end() && !found; it++) {
 
  336         found = it->pfInfo.sameAddr(pfi);
 
  340     if (it != queue.end()) {
 
  342         if (it->priority < priority) {
 
  344             it->priority = priority;
 
  346             while (prev != queue.begin()) {
 
  350                     std::swap(*it, *prev);
 
  354             DPRINTF(HWPrefetch, 
"Prefetch addr already in " 
  355                 "prefetch queue, priority updated\n");
 
  357             DPRINTF(HWPrefetch, 
"Prefetch addr already in " 
  368     RequestPtr translation_req = std::make_shared<Request>(
 
  370             pkt->
req->contextId());
 
  372     return translation_req;
 
  401         pkt->
req->getVaddr() : pkt->
req->getPaddr();
 
  402     bool positive_stride = new_pfi.
getAddr() >= orig_addr;
 
  404         (new_pfi.
getAddr() - orig_addr) : (orig_addr - new_pfi.
getAddr());
 
  407     bool has_target_pa = 
false;
 
  414             target_paddr = positive_stride ? (pkt->
req->getPaddr() + 
stride) :
 
  417             target_paddr = new_pfi.
getAddr();
 
  419         has_target_pa = 
true;
 
  424         if (!pkt->
req->hasContextId()) {
 
  428             has_target_pa = 
false;
 
  431         } 
else if (pkt->
req->hasVaddr()) {
 
  432             has_target_pa = 
false;
 
  434             Addr target_vaddr = positive_stride ?
 
  449         DPRINTF(HWPrefetch, 
"Dropping redundant in " 
  450                 "cache/MSHR prefetch addr:%#x\n", target_paddr);
 
  460         DPRINTF(HWPrefetch, 
"Prefetch queued. " 
  461                 "addr:%#x priority: %3d tick:%lld.\n",
 
  462                 new_pfi.
getAddr(), priority, pf_time);
 
  468         DPRINTF(HWPrefetch, 
"Prefetch queued with no translation. " 
  469                 "addr:%#x priority: %3d\n", new_pfi.
getAddr(), priority);
 
  484             "Prefetch queue is both full and empty!");
 
  488             "Prefetch queue is full with 1 element!");
 
  492         while (cont && prev != queue.begin()) {
 
  495             cont = prev->priority == it->priority;
 
  500         DPRINTF(HWPrefetch, 
"Prefetch queue full, removing lowest priority " 
  501                             "oldest packet, addr: %#x\n",it->pfInfo.getAddr());
 
  506     if ((queue.size() == 0) || (dpp <= queue.back())) {
 
  507         queue.emplace_back(dpp);
 
  512         } 
while (it != queue.begin() && dpp > *it);
 
  515         if (it == queue.begin() && dpp <= *it)
 
  517         queue.insert(it, dpp);
 
  520     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.
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
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
Addr getPC() const
Returns the program counter that generated this request.
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.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
@ SECURE
The request targets the secure memory space.
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.
void startTranslation(BaseTLB *tlb)
Issues the translation request to the provided TLB.
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.
virtual void translateTiming(const RequestPtr &req, ThreadContext *tc, BaseMMU::Translation *translation, BaseMMU::Mode mode)=0
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.
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
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.
BaseCache * cache
Pointr to the parent cache.
unsigned blkSize
The block size of the parent cache.
BaseTLB * tlb
Registered tlb for address translations.
@ PREFETCH
The request is a prefetch.
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 Tue Sep 21 2021 12:25:29 for gem5 by  doxygen 1.8.17