gem5  v22.1.0.0
queued.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __MEM_CACHE_PREFETCH_QUEUED_HH__
39 #define __MEM_CACHE_PREFETCH_QUEUED_HH__
40 
41 #include <cstdint>
42 #include <list>
43 #include <utility>
44 
45 #include "arch/generic/mmu.hh"
46 #include "base/statistics.hh"
47 #include "base/types.hh"
49 #include "mem/packet.hh"
50 
51 namespace gem5
52 {
53 
54 struct QueuedPrefetcherParams;
55 
57 namespace prefetch
58 {
59 
60 class Queued : public Base
61 {
62  protected:
64  {
74  int32_t priority;
79 
89  int32_t prio) : owner(o), pfInfo(pfi), tick(t), pkt(nullptr),
90  priority(prio), translationRequest(), tc(nullptr),
91  ongoingTranslation(false) {
92  }
93 
94  bool operator>(const DeferredPacket& that) const
95  {
96  return priority > that.priority;
97  }
98  bool operator<(const DeferredPacket& that) const
99  {
100  return priority < that.priority;
101  }
102  bool operator<=(const DeferredPacket& that) const
103  {
104  return !(*this > that);
105  }
106 
117  void createPkt(Addr paddr, unsigned blk_size, RequestorID requestor_id,
118  bool tag_prefetch, Tick t);
119 
126  {
127  translationRequest = req;
128  }
129 
130  void markDelayed() override
131  {}
132 
133  void finish(const Fault &fault, const RequestPtr &req,
134  ThreadContext *tc, BaseMMU::Mode mode) override;
135 
141  };
142 
145 
148 
149  // PARAMETERS
150 
152  const unsigned queueSize;
153 
159 
162 
164  const bool queueSquash;
165 
167  const bool queueFilter;
168 
170  const bool cacheSnoop;
171 
173  const bool tagPrefetch;
174 
176  const unsigned int throttleControlPct;
177 
179  {
181  // STATS
190  public:
192 
193  Queued(const QueuedPrefetcherParams &p);
194  virtual ~Queued();
195 
196  void notify(const PacketPtr &pkt, const PrefetchInfo &pfi) override;
197 
198  void insert(const PacketPtr &pkt, PrefetchInfo &new_pfi, int32_t priority);
199 
200  virtual void calculatePrefetch(const PrefetchInfo &pfi,
201  std::vector<AddrPriority> &addresses) = 0;
202  PacketPtr getPacket() override;
203 
204  Tick nextPrefetchReadyTime() const override
205  {
206  return pfq.empty() ? MaxTick : pfq.front().tick;
207  }
208 
209  void printQueue(const std::list<DeferredPacket> &queue) const;
210 
211  private:
212 
218  void addToQueue(std::list<DeferredPacket> &queue, DeferredPacket &dpp);
219 
227  void processMissingTranslations(unsigned max);
228 
236  void translationComplete(DeferredPacket *dp, bool failed);
237 
247  const PrefetchInfo &pfi, int32_t priority);
248 
257  size_t getMaxPermittedPrefetches(size_t total) const;
258 
259  RequestPtr createPrefetchRequest(Addr addr, PrefetchInfo const &pfi,
260  PacketPtr pkt);
261 };
262 
263 } // namespace prefetch
264 } // namespace gem5
265 
266 #endif //__MEM_CACHE_PREFETCH_QUEUED_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Definition: base.hh:98
BaseTLB * tlb
Registered tlb for address translations.
Definition: base.hh:368
const bool queueSquash
Squash queued prefetch if demand access observed.
Definition: queued.hh:164
void translationComplete(DeferredPacket *dp, bool failed)
Indicates that the translation of the address of the provided deferred packet has been successfully c...
Definition: queued.cc:302
gem5::prefetch::Queued::QueuedStats statsQueued
std::list< DeferredPacket >::iterator iterator
Definition: queued.hh:147
Queued(const QueuedPrefetcherParams &p)
Definition: queued.cc:101
void printQueue(const std::list< DeferredPacket > &queue) const
Definition: queued.cc:121
const unsigned queueSize
Maximum size of the prefetch queue.
Definition: queued.hh:152
std::list< DeferredPacket > pfqMissingTranslation
Definition: queued.hh:144
void processMissingTranslations(unsigned max)
Starts the translations of the queued prefetches with a missing translation.
Definition: queued.cc:287
RequestPtr createPrefetchRequest(Addr addr, PrefetchInfo const &pfi, PacketPtr pkt)
Definition: queued.cc:374
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....
Definition: queued.cc:173
const bool queueFilter
Filter prefetches if already queued.
Definition: queued.hh:167
std::list< DeferredPacket >::const_iterator const_iterator
Definition: queued.hh:146
const bool tagPrefetch
Tag prefetch with PC of generating access?
Definition: queued.hh:173
const Cycles latency
Cycles after generation when a prefetch can first be issued.
Definition: queued.hh:161
const bool cacheSnoop
Snoop the cache before generating prefetch (cheating basically)
Definition: queued.hh:170
const unsigned int throttleControlPct
Percentage of requests that can be throttled.
Definition: queued.hh:176
void insert(const PacketPtr &pkt, PrefetchInfo &new_pfi, int32_t priority)
Definition: queued.cc:385
PacketPtr getPacket() override
Definition: queued.cc:238
void addToQueue(std::list< DeferredPacket > &queue, DeferredPacket &dpp)
Adds a DeferredPacket to the specified queue.
Definition: queued.cc:484
bool alreadyInQueue(std::list< DeferredPacket > &queue, const PrefetchInfo &pfi, int32_t priority)
Checks whether the specified prefetch request is already in the specified queue.
Definition: queued.cc:339
Tick nextPrefetchReadyTime() const override
Definition: queued.hh:204
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...
Definition: queued.cc:143
virtual void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses)=0
const unsigned missingTranslationQueueSize
Maximum size of the queue holding prefetch requests with missing address translations.
Definition: queued.hh:158
std::list< DeferredPacket > pfq
Definition: queued.hh:143
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
STL pair class.
Definition: stl.hh:58
STL vector class.
Definition: stl.hh:37
Miss and writeback queue declarations.
Bitfield< 4, 0 > mode
Definition: misc_types.hh:74
Bitfield< 47, 44 > dp
Definition: misc_types.hh:95
constexpr RegId o(int index)
Definition: int.hh:147
Bitfield< 51 > t
Definition: pagetable.hh:56
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 3 > addr
Definition: types.hh:84
const FlagsType total
Print the total.
Definition: info.hh:60
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
uint64_t Tick
Tick count type.
Definition: types.hh:58
const Tick MaxTick
Definition: types.hh:60
uint16_t RequestorID
Definition: request.hh:95
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Declaration of the Packet class.
Declaration of Statistics objects.
bool operator>(const DeferredPacket &that) const
Definition: queued.hh:94
int32_t priority
The priority of this prefetch.
Definition: queued.hh:74
Tick tick
Time when this prefetch becomes ready.
Definition: queued.hh:70
void startTranslation(BaseTLB *tlb)
Issues the translation request to the provided TLB.
Definition: queued.cc:81
DeferredPacket(Queued *o, PrefetchInfo const &pfi, Tick t, int32_t prio)
Constructor.
Definition: queued.hh:88
bool operator<=(const DeferredPacket &that) const
Definition: queued.hh:102
void setTranslationRequest(const RequestPtr &req)
Sets the translation request needed to obtain the physical address of this request.
Definition: queued.hh:125
void createPkt(Addr paddr, unsigned blk_size, RequestorID requestor_id, bool tag_prefetch, Tick t)
Create the associated memory packet.
Definition: queued.cc:59
Queued * owner
Owner of the packet.
Definition: queued.hh:66
void finish(const Fault &fault, const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
Definition: queued.cc:92
RequestPtr translationRequest
Request used when a translation is needed.
Definition: queued.hh:76
PacketPtr pkt
The memory packet generated by this prefetch.
Definition: queued.hh:72
bool operator<(const DeferredPacket &that) const
Definition: queued.hh:98
void markDelayed() override
Signal that the translation has been delayed due to a hw page table walk.
Definition: queued.hh:130
PrefetchInfo pfInfo
Prefetch info corresponding to this packet.
Definition: queued.hh:68
statistics::Scalar pfUsefulSpanPage
Definition: queued.hh:188
statistics::Scalar pfBufferHit
Definition: queued.hh:183
statistics::Scalar pfIdentified
Definition: queued.hh:182
statistics::Scalar pfRemovedDemand
Definition: queued.hh:185
statistics::Scalar pfRemovedFull
Definition: queued.hh:186
statistics::Scalar pfSpanPage
Definition: queued.hh:187
statistics::Scalar pfInCache
Definition: queued.hh:184
QueuedStats(statistics::Group *parent)
Definition: queued.cc:265

Generated on Wed Dec 21 2022 10:22:36 for gem5 by doxygen 1.9.1