gem5 v24.0.0.0
Loading...
Searching...
No Matches
RubyPrefetcherProxy.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 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
39
40#include "debug/HWPrefetch.hh"
42
43namespace gem5
44{
45
46namespace ruby
47{
48
50 prefetch::Base* _prefetcher,
51 MessageBuffer *_pf_queue)
52 :Named(_parent->name()),
53 prefetcher(_prefetcher),
54 cacheCntrl(_parent),
55 pfQueue(_pf_queue),
56 pfEvent([this]{ issuePrefetch(); }, name()),
57 ppHit(nullptr), ppMiss(nullptr),
58 ppFill(nullptr), ppDataUpdate(nullptr)
59{
60 fatal_if(!cacheCntrl,
61 "initializing a RubyPrefetcherProxy without a parent");
62 if (prefetcher) {
63 fatal_if(!pfQueue,
64 "%s initializing a RubyPrefetcherProxy without a prefetch queue",
65 name());
66 prefetcher->setParentInfo(
67 cacheCntrl->params().system,
68 cacheCntrl->getProbeManager(),
70 }
71}
72
73void
75{
76 if (pfEvent.scheduled())
77 return;
78
79 Tick next_pf_time = std::max(prefetcher->nextPrefetchReadyTime(),
81 if (next_pf_time != MaxTick) {
82 DPRINTF(HWPrefetch, "Next prefetch ready at %d\n", next_pf_time);
83 cacheCntrl->schedule(&pfEvent, next_pf_time);
84 }
85}
86
87void
93
94void
96{
97 assert(makeLineAddress(addr) == addr);
98 assert(issuedPfPkts.count(addr) == 1);
99 DPRINTF(HWPrefetch, "Prefetch request for addr %#x completed\n", addr);
100 delete issuedPfPkts[addr];
101 issuedPfPkts.erase(addr);
102}
103
104void
106{
107 assert(prefetcher);
108 assert(pfQueue);
109
112
113 if (pkt) {
114 DPRINTF(HWPrefetch, "Next prefetch ready %s\n", pkt->print());
115 unsigned blk_size = RubySystem::getBlockSizeBytes();
116 Addr line_addr = pkt->getBlockAddr(blk_size);
117
118 if (issuedPfPkts.count(line_addr) == 0) {
119 DPRINTF(HWPrefetch, "Issued PF request for paddr=%#x, "
120 "line_addr=%#x, is_write=%d\n",
121 pkt->getAddr(), line_addr,
122 pkt->needsWritable());
123
124 RubyRequestType req_type = pkt->needsWritable() ?
125 RubyRequestType_ST : RubyRequestType_LD;
126
127 std::shared_ptr<RubyRequest> msg =
128 std::make_shared<RubyRequest>(cacheCntrl->clockEdge(),
129 pkt->getAddr(),
130 blk_size,
131 0, // pc
132 req_type,
133 RubyAccessMode_Supervisor,
134 pkt,
135 PrefetchBit_Yes);
136
137 // enqueue request into prefetch queue to the cache
140
141 // track all pending PF requests
142 issuedPfPkts[line_addr] = pkt;
143 } else {
144 DPRINTF(HWPrefetch, "Aborted PF request for address being "
145 "prefetched\n");
146 delete pkt;
147 }
148 }
149 } else {
150 DPRINTF(HWPrefetch, "No prefetch slots are available\n");
151 }
152
154}
155
156void
158 const DataBlock& data_blk)
159{
160 assert(ppHit);
161 assert(req);
162 Packet pkt(req, is_read ? Packet::makeReadCmd(req) :
164 // NOTE: for now we only communicate physical address with prefetchers
165 pkt.dataStaticConst<uint8_t>(data_blk.getData(getOffset(req->getPaddr()),
166 pkt.getSize()));
167 DPRINTF(HWPrefetch, "notify hit: %s\n", pkt.print());
168 ppHit->notify(CacheAccessProbeArg(&pkt, *this));
170}
171
172void
174 const DataBlock& data_blk)
175{
176 assert(ppMiss);
177 assert(req);
178 Packet pkt(req, is_read ? Packet::makeReadCmd(req) :
180 // NOTE: for now we only communicate physical address with prefetchers
181 pkt.dataStaticConst<uint8_t>(data_blk.getData(getOffset(req->getPaddr()),
182 pkt.getSize()));
183 DPRINTF(HWPrefetch, "notify miss: %s\n", pkt.print());
184 ppMiss->notify(CacheAccessProbeArg(&pkt, *this));
186}
187
188void
190 const DataBlock& data_blk,
191 bool from_pf)
192{
193 assert(ppFill);
194 assert(req);
195 Packet pkt(req, Packet::makeReadCmd(req));
196 if (from_pf)
197 pkt.cmd = Packet::Command::HardPFReq;
198 // NOTE: for now we only communicate physical address with prefetchers
199 pkt.dataStaticConst<uint8_t>(data_blk.getData(getOffset(req->getPaddr()),
200 pkt.getSize()));
201 DPRINTF(HWPrefetch, "notify fill: %s\n", pkt.print());
202 ppFill->notify(CacheAccessProbeArg(&pkt, *this));
204}
205
206void
207RubyPrefetcherProxy::notifyPfEvict(Addr blkAddr, bool hwPrefetched,
208 RequestorID requestorID)
209{
210 DPRINTF(HWPrefetch, "notify evict: %#x hw_pf=%d\n", blkAddr, hwPrefetched);
211 CacheDataUpdateProbeArg data_update(
212 blkAddr, false, requestorID, *this);
213 data_update.hwPrefetched = hwPrefetched;
214 ppDataUpdate->notify(data_update);
216}
217
218void
232
233} // namespace ruby
234} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:210
Information provided to probes on a cache event.
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Tick cyclesToTicks(Cycles c) const
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
Interface for things with names.
Definition named.hh:39
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Addr getAddr() const
Definition packet.hh:807
bool needsWritable() const
Definition packet.hh:599
void print(std::ostream &o, int verbosity=0, const std::string &prefix="") const
Definition packet.cc:368
static MemCmd makeWriteCmd(const RequestPtr &req)
Generate the appropriate write MemCmd based on the Request flags.
Definition packet.hh:1016
Addr getBlockAddr(unsigned int blk_size) const
Definition packet.hh:831
unsigned getSize() const
Definition packet.hh:817
void dataStaticConst(const T *p)
Set the data pointer to the following value that should not be freed.
Definition packet.hh:1192
static MemCmd makeReadCmd(const RequestPtr &req)
Generate the appropriate read MemCmd based on the Request flags.
Definition packet.hh:993
MemCmd cmd
The command field of the packet.
Definition packet.hh:372
ProbePointArg generates a point for the class of Arg.
Definition probe.hh:264
virtual PacketPtr getPacket()=0
virtual Tick nextPrefetchReadyTime() const =0
const uint8_t * getData(int offset, int len) const
Definition DataBlock.cc:157
bool areNSlotsAvailable(unsigned int n, Tick curTime)
void enqueue(MsgPtr message, Tick curTime, Tick delta, bool bypassStrictFIFO=false)
void regProbePoints()
Registers probes.
void issuePrefetch()
Issue prefetch to the contoller prefetch queue.
void notifyPfEvict(Addr blkAddr, bool hwPrefetched, RequestorID requestorID)
prefetch::Base * prefetcher
Prefetcher from classic memory.
ProbePointArg< CacheAccessProbeArg > * ppMiss
To probe when a cache miss occurs.
EventFunctionWrapper pfEvent
Prefetch event.
void notifyPfMiss(const RequestPtr &req, bool is_read, const DataBlock &data_blk)
ProbePointArg< CacheAccessProbeArg > * ppFill
To probe when a cache fill occurs.
void scheduleNextPrefetch()
Schedule the next ready prefetch.
void notifyPfHit(const RequestPtr &req, bool is_read, const DataBlock &data_blk)
Notify PF probes hit/miss/fill.
void completePrefetch(Addr addr)
Notifies a completed prefetch request.
AbstractController * cacheCntrl
Ruby cache controller.
void deschedulePrefetch()
Deschedled the ready prefetch event.
void notifyPfFill(const RequestPtr &req, const DataBlock &data_blk, bool from_pf)
ProbePointArg< CacheAccessProbeArg > * ppHit
To probe when a cache hit occurs.
MessageBuffer * pfQueue
Prefetch queue to the cache controller.
ProbePointArg< CacheDataUpdateProbeArg > * ppDataUpdate
To probe when the contents of a block are updated.
std::unordered_map< Addr, PacketPtr > issuedPfPkts
List of issued prefetch request packets.
RubyPrefetcherProxy(AbstractController *parent, prefetch::Base *prefetcher, MessageBuffer *pf_queue)
static uint32_t getBlockSizeBytes()
Definition RubySystem.hh:72
void deschedule(Event &event)
Definition eventq.hh:1021
bool scheduled() const
Determine if the current event is scheduled.
Definition eventq.hh:458
void schedule(Event &event, Tick when)
Definition eventq.hh:1012
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition logging.hh:236
ProbeManager * getProbeManager()
Get the probe manager for this object.
Bitfield< 3 > addr
Definition types.hh:84
Addr makeLineAddress(Addr addr)
Definition Address.cc:60
Addr getOffset(Addr addr)
Definition Address.cc:54
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< Request > RequestPtr
Definition request.hh:94
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46
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
A data contents update is composed of the updated block's address, the old contents,...
bool hwPrefetched
Set if the update is from a prefetch or evicting a prefetched block that was never used.
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0