gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
base.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2013, 2015-2016, 2018-2019, 2023-2024 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 * Copyright (c) 2003-2005 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
45
46#ifndef __MEM_CACHE_BASE_HH__
47#define __MEM_CACHE_BASE_HH__
48
49#include <cassert>
50#include <cstdint>
51#include <string>
52
53#include "base/addr_range.hh"
54#include "base/compiler.hh"
55#include "base/statistics.hh"
56#include "base/trace.hh"
57#include "base/types.hh"
58#include "debug/Cache.hh"
59#include "debug/CachePort.hh"
60#include "enums/Clusivity.hh"
66#include "mem/packet.hh"
67#include "mem/packet_queue.hh"
68#include "mem/qport.hh"
69#include "mem/request.hh"
70#include "params/WriteAllocator.hh"
71#include "sim/clocked_object.hh"
72#include "sim/eventq.hh"
73#include "sim/probe/probe.hh"
74#include "sim/serialize.hh"
75#include "sim/sim_exit.hh"
76#include "sim/system.hh"
77
78namespace gem5
79{
80
81namespace prefetch
82{
83 class Base;
84}
86{
87 class PartitionManager;
88}
89namespace compression
90{
91class Base;
92}
93class MSHR;
94class MSHRQueue;
95class RequestPort;
96class QueueEntry;
97class WriteQueueEntry;
98struct BaseCacheParams;
99
104{
105 protected:
114
115 public:
126
127 protected:
128
139 {
140
141 public:
142
148 {
149 DPRINTF(CachePort, "Scheduling send event at %llu\n", time);
150 reqQueue.schedSendEvent(time);
151 }
152
153 protected:
154
155 CacheRequestPort(const std::string &_name,
156 ReqPacketQueue &_reqQueue,
157 SnoopRespPacketQueue &_snoopRespQueue) :
158 QueuedRequestPort(_name, _reqQueue, _snoopRespQueue)
159 { }
160
166 virtual bool isSnooping() const { return true; }
167 };
168
176 {
177
178 protected:
179
182
183 public:
184
186 SnoopRespPacketQueue &snoop_resp_queue,
187 const std::string &label) :
189 snoopRespQueue(snoop_resp_queue) { }
190
196 virtual void sendDeferredPacket();
197
207 {
208 if (snoopRespQueue.checkConflict(pkt, cache.blkSize)) {
209 DPRINTF(CachePort, "Waiting for snoop response to be "
210 "sent\n");
211 Tick when = snoopRespQueue.deferredPacketReadyTime();
212 schedSendEvent(when);
213 return true;
214 }
215 return false;
216 }
217 };
218
219
225 {
226 private:
227
230
232
233 // a pointer to our specific cache implementation
235
236 protected:
237
238 virtual void recvTimingSnoopReq(PacketPtr pkt);
239
240 virtual bool recvTimingResp(PacketPtr pkt);
241
242 virtual Tick recvAtomicSnoop(PacketPtr pkt);
243
244 virtual void recvFunctionalSnoop(PacketPtr pkt);
245
246 public:
247
248 MemSidePort(const std::string &_name, BaseCache *_cache,
249 const std::string &_label);
250 };
251
261 {
262
263 public:
264
266 void setBlocked();
267
269 void clearBlocked();
270
271 bool isBlocked() const { return blocked; }
272
273 protected:
274
275 CacheResponsePort(const std::string &_name, BaseCache& _cache,
276 const std::string &_label);
277
279
282
284
286
287 private:
288
289 void processSendRetry();
290
292
293 };
294
300 {
301 protected:
302 virtual bool recvTimingSnoopResp(PacketPtr pkt) override;
303
304 virtual bool tryTiming(PacketPtr pkt) override;
305
306 virtual bool recvTimingReq(PacketPtr pkt) override;
307
308 virtual Tick recvAtomic(PacketPtr pkt) override;
309
310 virtual void recvFunctional(PacketPtr pkt) override;
311
312 virtual AddrRangeList getAddrRanges() const override;
313
314 public:
315
316 CpuSidePort(const std::string &_name, BaseCache& _cache,
317 const std::string &_label);
318
319 };
320
323
324 protected:
325
327 {
329
330 CacheAccessorImpl(BaseCache &_cache) :cache(_cache) {}
331
332 bool inCache(Addr addr, bool is_secure) const override
333 { return cache.inCache(addr, is_secure); }
334
335 bool hasBeenPrefetched(Addr addr, bool is_secure) const override
336 { return cache.hasBeenPrefetched(addr, is_secure); }
337
338 bool hasBeenPrefetched(Addr addr, bool is_secure,
339 RequestorID requestor) const override
340 { return cache.hasBeenPrefetched(addr, is_secure, requestor); }
341
342 bool inMissQueue(Addr addr, bool is_secure) const override
343 { return cache.inMissQueue(addr, is_secure); }
344
345 bool coalesce() const override
346 { return cache.coalesce(); }
347
349
352
355
358
361
364
367
370
373
376
383
399
407
412 std::unique_ptr<Packet> pendingDelete;
413
418 void markInService(MSHR *mshr, bool pending_modified_resp)
419 {
420 bool wasFull = mshrQueue.isFull();
421 mshrQueue.markInService(mshr, pending_modified_resp);
422
423 if (wasFull && !mshrQueue.isFull()) {
425 }
426 }
427
428 void markInService(WriteQueueEntry *entry);
429
443 inline bool allocOnFill(MemCmd cmd) const
444 {
445 return clusivity == enums::mostly_incl ||
446 cmd == MemCmd::WriteLineReq ||
447 cmd == MemCmd::ReadReq ||
448 cmd == MemCmd::WriteReq ||
449 cmd.isPrefetch() ||
450 cmd.isLLSC();
451 }
452
462
471 Cycles calculateTagOnlyLatency(const uint32_t delay,
472 const Cycles lookup_lat) const;
482 Cycles calculateAccessLatency(const CacheBlk* blk, const uint32_t delay,
483 const Cycles lookup_lat) const;
484
493 virtual bool access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat,
494 PacketList &writebacks);
495
496 /*
497 * Handle a timing request that hit in the cache
498 *
499 * @param ptk The request packet
500 * @param blk The referenced block
501 * @param request_time The tick at which the block lookup is compete
502 */
503 virtual void handleTimingReqHit(PacketPtr pkt, CacheBlk *blk,
504 Tick request_time);
505
506 /*
507 * Handle a timing request that missed in the cache
508 *
509 * Implementation specific handling for different cache
510 * implementations
511 *
512 * @param ptk The request packet
513 * @param blk The referenced block
514 * @param forward_time The tick at which we can process dependent requests
515 * @param request_time The tick at which the block lookup is compete
516 */
517 virtual void handleTimingReqMiss(PacketPtr pkt, CacheBlk *blk,
518 Tick forward_time,
519 Tick request_time) = 0;
520
521 /*
522 * Handle a timing request that missed in the cache
523 *
524 * Common functionality across different cache implementations
525 *
526 * @param ptk The request packet
527 * @param blk The referenced block
528 * @param mshr Any existing mshr for the referenced cache block
529 * @param forward_time The tick at which we can process dependent requests
530 * @param request_time The tick at which the block lookup is compete
531 */
532 void handleTimingReqMiss(PacketPtr pkt, MSHR *mshr, CacheBlk *blk,
533 Tick forward_time, Tick request_time);
534
539 virtual void recvTimingReq(PacketPtr pkt);
540
546
557 virtual void serviceMSHRTargets(MSHR *mshr, const PacketPtr pkt,
558 CacheBlk *blk) = 0;
559
564 virtual void recvTimingResp(PacketPtr pkt);
565
570 virtual void recvTimingSnoopReq(PacketPtr pkt) = 0;
571
576 virtual void recvTimingSnoopResp(PacketPtr pkt) = 0;
577
591 PacketList &writebacks) = 0;
592
598 virtual Tick recvAtomic(PacketPtr pkt);
599
607
614 virtual void functionalAccess(PacketPtr pkt, bool from_cpu_side);
615
625 void updateBlockData(CacheBlk *blk, const PacketPtr cpkt,
626 bool has_old_data);
627
631 void cmpAndSwap(CacheBlk *blk, PacketPtr pkt);
632
640
644 virtual void doWritebacks(PacketList& writebacks, Tick forward_time) = 0;
645
649 virtual void doWritebacksAtomic(PacketList& writebacks) = 0;
650
667 bool needs_writable,
668 bool is_whole_line_write) const = 0;
669
677 const bool writebackClean;
678
687
694 assert(tempBlockWriteback != nullptr);
695 PacketList writebacks{tempBlockWriteback};
696 doWritebacksAtomic(writebacks);
697 tempBlockWriteback = nullptr;
698 }
699
706
731 bool updateCompressionData(CacheBlk *&blk, const uint64_t* data,
732 PacketList &writebacks);
733
744 virtual void satisfyRequest(PacketPtr pkt, CacheBlk *blk,
745 bool deferred_response = false,
746 bool pending_downgrade = false);
747
757 void maintainClusivity(bool from_cache, CacheBlk *blk);
758
769 PacketList &writebacks);
770
790 PacketList &writebacks, bool allocate);
791
804 CacheBlk *allocateBlock(const PacketPtr pkt, PacketList &writebacks);
813 [[nodiscard]] virtual PacketPtr evictBlock(CacheBlk *blk) = 0;
814
823 void evictBlock(CacheBlk *blk, PacketList &writebacks);
824
830 void invalidateBlock(CacheBlk *blk);
831
839
852
856 virtual void memWriteback() override;
857
865 virtual void memInvalidate() override;
866
872 bool isDirty() const;
873
882 bool inRange(Addr addr) const;
883
887 Tick nextQueueReadyTime() const;
888
890 const unsigned blkSize;
891
897
903
910
913
920
925
927 const int numTarget;
928
931
937 const enums::Clusivity clusivity;
938
945 const bool isReadOnly;
946
954
962
967 uint8_t blocked;
968
970 uint64_t order;
971
974
977
980
985
986 public:
989
1043
1045 {
1047
1048 void regStats() override;
1049
1051 return *cmd[p->cmdToIndex()];
1052 }
1053
1055
1064
1069
1074
1079
1084
1089
1094
1097
1100
1105
1110
1113
1118
1121
1126
1131
1134
1137
1140
1146
1150
1152 void regProbePoints() override;
1153
1154 public:
1155 BaseCache(const BaseCacheParams &p, unsigned blk_size);
1156 ~BaseCache();
1157
1158 void init() override;
1159
1160 Port &getPort(const std::string &if_name,
1161 PortID idx=InvalidPortID) override;
1162
1167 unsigned
1169 {
1170 return blkSize;
1171 }
1172
1173 const AddrRangeList &getAddrRanges() const { return addrRanges; }
1174
1175 MSHR *allocateMissBuffer(PacketPtr pkt, Tick time, bool sched_send = true)
1176 {
1177 MSHR *mshr = mshrQueue.allocate(pkt->getBlockAddr(blkSize), blkSize,
1178 pkt, time, order++,
1179 allocOnFill(pkt->cmd));
1180
1181 if (mshrQueue.isFull()) {
1183 }
1184
1185 if (sched_send) {
1186 // schedule the send
1188 }
1189
1190 return mshr;
1191 }
1192
1193 void allocateWriteBuffer(PacketPtr pkt, Tick time);
1194
1198 bool isBlocked() const
1199 {
1200 return blocked != 0;
1201 }
1202
1209 {
1210 uint8_t flag = 1 << cause;
1211 if (blocked == 0) {
1212 stats.blockedCauses[cause]++;
1214 cpuSidePort.setBlocked();
1215 }
1216 blocked |= flag;
1217 DPRINTF(Cache,"Blocking for cause %d, mask=%d\n", cause, blocked);
1218 }
1219
1228 {
1229 uint8_t flag = 1 << cause;
1230 blocked &= ~flag;
1231 DPRINTF(Cache,"Unblocking for cause %d, mask=%d\n", cause, blocked);
1232 if (blocked == 0) {
1233 stats.blockedCycles[cause] += curCycle() - blockedCycle;
1234 cpuSidePort.clearBlocked();
1235 }
1236 }
1237
1247 {
1248 memSidePort.schedSendEvent(time);
1249 }
1250
1251 bool inCache(Addr addr, bool is_secure) const {
1252 return tags->findBlock({addr, is_secure});
1253 }
1254
1255 bool hasBeenPrefetched(Addr addr, bool is_secure) const {
1256 CacheBlk *block = tags->findBlock({addr, is_secure});
1257 return block && block->wasPrefetched();
1258 }
1259
1260 bool hasBeenPrefetched(Addr addr, bool is_secure,
1261 RequestorID requestor) const {
1262 CacheBlk *block = tags->findBlock({addr, is_secure});
1263 return block && block->wasPrefetched() &&
1264 (block->getSrcRequestorId() == requestor);
1265 }
1266
1267 bool inMissQueue(Addr addr, bool is_secure) const {
1268 return mshrQueue.findMatch(addr, is_secure);
1269 }
1270
1272 {
1273 assert(pkt->req->requestorId() < system->maxRequestors());
1274 stats.cmdStats(pkt).misses[pkt->req->requestorId()]++;
1275 pkt->req->incAccessDepth();
1276 if (missCount) {
1277 --missCount;
1278 if (missCount == 0)
1279 exitSimLoop("A cache reached the maximum miss count");
1280 }
1281 }
1283 {
1284 assert(pkt->req->requestorId() < system->maxRequestors());
1285 stats.cmdStats(pkt).hits[pkt->req->requestorId()]++;
1286 }
1287
1293 bool coalesce() const;
1294
1295
1300 void writebackVisitor(CacheBlk &blk);
1301
1307 void invalidateVisitor(CacheBlk &blk);
1308
1317 virtual bool sendMSHRQueuePacket(MSHR* mshr);
1318
1327 bool sendWriteQueuePacket(WriteQueueEntry* wq_entry);
1328
1334 void serialize(CheckpointOut &cp) const override;
1335 void unserialize(CheckpointIn &cp) override;
1336};
1337
1354{
1355 public:
1356 WriteAllocator(const WriteAllocatorParams &p) :
1357 SimObject(p),
1358 coalesceLimit(p.coalesce_limit * p.block_size),
1359 noAllocateLimit(p.no_allocate_limit * p.block_size),
1360 delayThreshold(p.delay_threshold)
1361 {
1362 reset();
1363 }
1364
1371 bool coalesce() const {
1372 return mode != WriteMode::ALLOCATE;
1373 }
1374
1380 bool allocate() const {
1381 return mode != WriteMode::NO_ALLOCATE;
1382 }
1383
1390 void reset() {
1392 byteCount = 0;
1393 nextAddr = 0;
1394 }
1395
1402 bool delay(Addr blk_addr) {
1403 if (delayCtr[blk_addr] > 0) {
1404 --delayCtr[blk_addr];
1405 return true;
1406 } else {
1407 return false;
1408 }
1409 }
1410
1416 void resetDelay(Addr blk_addr) {
1417 delayCtr.erase(blk_addr);
1418 }
1419
1430 void updateMode(Addr write_addr, unsigned write_size, Addr blk_addr);
1431
1432 private:
1438 enum class WriteMode : char
1439 {
1443 };
1445
1448
1453 uint32_t byteCount;
1454
1458 const uint32_t coalesceLimit;
1459 const uint32_t noAllocateLimit;
1463 const uint32_t delayThreshold;
1464
1469 std::unordered_map<Addr, Counter> delayCtr;
1470};
1471
1472} // namespace gem5
1473
1474#endif //__MEM_CACHE_BASE_HH__
#define DPRINTF(x,...)
Definition trace.hh:209
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Definitions of a simple cache block class.
const char data[]
Override the default behaviour of sendDeferredPacket to enable the memory-side cache port to also sen...
Definition base.hh:176
bool checkConflictingSnoop(const PacketPtr pkt)
Check if there is a conflicting snoop response about to be send out, and if so simply stall any reque...
Definition base.hh:206
CacheReqPacketQueue(BaseCache &cache, RequestPort &port, SnoopRespPacketQueue &snoop_resp_queue, const std::string &label)
Definition base.hh:185
virtual void sendDeferredPacket()
Override the normal sendDeferredPacket and do not only consider the transmit list (used for responses...
Definition base.cc:2723
SnoopRespPacketQueue & snoopRespQueue
Definition base.hh:181
CacheRequestPort(const std::string &_name, ReqPacketQueue &_reqQueue, SnoopRespPacketQueue &_snoopRespQueue)
Definition base.hh:155
void schedSendEvent(Tick time)
Schedule a send of a request packet (from the MSHR).
Definition base.hh:147
virtual bool isSnooping() const
Memory-side port always snoops.
Definition base.hh:166
CacheResponsePort(const std::string &_name, BaseCache &_cache, const std::string &_label)
Definition base.cc:71
void clearBlocked()
Return to normal operation and accept new requests.
Definition base.cc:167
EventFunctionWrapper sendRetryEvent
Definition base.hh:291
void setBlocked()
Do not accept any new requests.
Definition base.cc:152
RespPacketQueue queue
A normal packet queue used to store responses.
Definition base.hh:281
The CPU-side port extends the base cache response port with access functions for functional,...
Definition base.hh:300
virtual bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition base.cc:2593
virtual Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the peer.
Definition base.cc:2640
CpuSidePort(const std::string &_name, BaseCache &_cache, const std::string &_label)
Definition base.cc:2672
virtual bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the peer.
Definition base.cc:2622
virtual bool tryTiming(PacketPtr pkt) override
Availability request from the peer.
Definition base.cc:2607
virtual void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the peer.
Definition base.cc:2651
virtual AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition base.cc:2665
The memory-side port extends the base cache request port with access functions for functional,...
Definition base.hh:225
virtual Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from our peer.
Definition base.cc:2702
virtual void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the peer.
Definition base.cc:2711
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition base.cc:2684
virtual void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the peer.
Definition base.cc:2692
CacheReqPacketQueue _reqQueue
The cache-specific queue.
Definition base.hh:229
SnoopRespPacketQueue _snoopRespQueue
Definition base.hh:231
MemSidePort(const std::string &_name, BaseCache *_cache, const std::string &_label)
Definition base.cc:2758
virtual void serviceMSHRTargets(MSHR *mshr, const PacketPtr pkt, CacheBlk *blk)=0
Service non-deferred MSHR targets using the received response.
virtual void functionalAccess(PacketPtr pkt, bool from_cpu_side)
Performs the access specified by the request.
Definition base.cc:765
const bool isReadOnly
Is this cache read only, for example the instruction cache, or table-walker cache.
Definition base.hh:945
virtual void recvTimingReq(PacketPtr pkt)
Performs the access specified by the request.
Definition base.cc:454
virtual void recvTimingSnoopReq(PacketPtr pkt)=0
Snoops bus transactions to maintain coherence.
gem5::BaseCache::CacheAccessorImpl accessor
virtual void doWritebacks(PacketList &writebacks, Tick forward_time)=0
Insert writebacks into the write buffer.
const Cycles fillLatency
The latency to fill a cache block.
Definition base.hh:912
const Cycles dataLatency
The latency of data access of a cache.
Definition base.hh:902
void invalidateVisitor(CacheBlk &blk)
Cache block visitor that invalidates all blocks in the cache.
Definition base.cc:1900
virtual Cycles handleAtomicReqMiss(PacketPtr pkt, CacheBlk *&blk, PacketList &writebacks)=0
Handle a request in atomic mode that missed in this cache.
virtual void doWritebacksAtomic(PacketList &writebacks)=0
Send writebacks down the memory hierarchy in atomic mode.
bool hasBeenPrefetched(Addr addr, bool is_secure, RequestorID requestor) const
Definition base.hh:1260
void updateBlockData(CacheBlk *blk, const PacketPtr cpkt, bool has_old_data)
Update the data contents of a block.
Definition base.cc:821
PacketPtr tempBlockWriteback
Writebacks from the tempBlock, resulting on the response path in atomic mode, must happen after the c...
Definition base.hh:686
MSHR * allocateMissBuffer(PacketPtr pkt, Tick time, bool sched_send=true)
Definition base.hh:1175
CpuSidePort cpuSidePort
Definition base.hh:321
bool isDirty() const
Determine if there are any dirty blocks in the cache.
Definition base.cc:1864
void invalidateBlock(CacheBlk *blk)
Invalidate a cache block.
Definition base.cc:1727
MSHR * noTargetMSHR
Pointer to the MSHR that has no targets.
Definition base.hh:976
const bool writebackClean
Determine if clean lines should be written back or not.
Definition base.hh:677
bool sendWriteQueuePacket(WriteQueueEntry *wq_entry)
Similar to sendMSHR, but for a write-queue entry instead.
Definition base.cc:2033
bool inRange(Addr addr) const
Determine if an address is in the ranges covered by this cache.
Definition base.cc:220
virtual void handleTimingReqMiss(PacketPtr pkt, CacheBlk *blk, Tick forward_time, Tick request_time)=0
bool allocOnFill(MemCmd cmd) const
Determine whether we should allocate on a fill or not.
Definition base.hh:443
bool forwardSnoops
Do we forward snoops from mem side port through to cpu side port?
Definition base.hh:930
uint64_t order
Increasing order number assigned to each incoming request.
Definition base.hh:970
void incHitCount(PacketPtr pkt)
Definition base.hh:1282
MSHRQueueIndex
Indexes to enumerate the MSHR queues.
Definition base.hh:110
@ MSHRQueue_WriteBuffer
Definition base.hh:112
virtual void satisfyRequest(PacketPtr pkt, CacheBlk *blk, bool deferred_response=false, bool pending_downgrade=false)
Perform any necessary updates to the block and perform any data exchange between the packet and the b...
Definition base.cc:1146
virtual void memWriteback() override
Write back dirty blocks in the cache using functional accesses.
Definition base.cc:1852
bool updateCompressionData(CacheBlk *&blk, const uint64_t *data, PacketList &writebacks)
When a block is overwriten, its compression information must be updated, and it may need to be recomp...
Definition base.cc:1033
bool isBlocked() const
Returns true if the cache is blocked for accesses.
Definition base.hh:1198
gem5::BaseCache::CacheStats stats
bool inMissQueue(Addr addr, bool is_secure) const
Definition base.hh:1267
const Cycles lookupLatency
The latency of tag lookup of a cache.
Definition base.hh:896
Cycles calculateAccessLatency(const CacheBlk *blk, const uint32_t delay, const Cycles lookup_lat) const
Calculate access latency in ticks given a tag lookup latency, and whether access was a hit or miss.
Definition base.cc:1256
Tick nextQueueReadyTime() const
Find next request ready time from among possible sources.
Definition base.cc:1913
void regProbePoints() override
Registers probes.
Definition base.cc:2574
virtual void memInvalidate() override
Invalidates all blocks in the cache.
Definition base.cc:1858
MSHRQueue mshrQueue
Miss status registers.
Definition base.hh:351
virtual PacketPtr createMissPacket(PacketPtr cpu_pkt, CacheBlk *blk, bool needs_writable, bool is_whole_line_write) const =0
Create an appropriate downstream bus request packet.
bool hasBeenPrefetched(Addr addr, bool is_secure) const
Definition base.hh:1255
ProbePointArg< CacheAccessProbeArg > * ppFill
To probe when a cache fill occurs.
Definition base.hh:375
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition base.cc:208
QueueEntry * getNextQueueEntry()
Return the next queue entry to service, either a pending miss from the MSHR queue,...
Definition base.cc:905
unsigned getBlockSize() const
Query block size of a cache.
Definition base.hh:1168
bool inCache(Addr addr, bool is_secure) const
Definition base.hh:1251
void handleUncacheableWriteResp(PacketPtr pkt)
Handling the special case of uncacheable write responses to make recvTimingResp less cluttered.
Definition base.cc:527
const unsigned blkSize
Block size of this cache.
Definition base.hh:890
void writebackTempBlockAtomic()
Send the outstanding tempBlock writeback.
Definition base.hh:693
BlockedCause
Reasons for caches to be blocked.
Definition base.hh:120
@ NUM_BLOCKED_CAUSES
Definition base.hh:124
@ Blocked_NoTargets
Definition base.hh:123
@ Blocked_NoWBBuffers
Definition base.hh:122
const Cycles forwardLatency
This is the forward latency of the cache.
Definition base.hh:909
compression::Base * compressor
Compression method being used.
Definition base.hh:360
const Cycles responseLatency
The latency of sending reponse to its upper level cache/core on a linefill.
Definition base.hh:919
PacketPtr writecleanBlk(CacheBlk *blk, Request::Flags dest, PacketId id)
Create a writeclean request for the given block.
Definition base.cc:1806
void schedMemSideSendEvent(Tick time)
Schedule a send event for the memory-side port.
Definition base.hh:1246
MemSidePort memSidePort
Definition base.hh:322
virtual void handleTimingReqHit(PacketPtr pkt, CacheBlk *blk, Tick request_time)
Definition base.cc:275
virtual Tick recvAtomic(PacketPtr pkt)
Performs the access specified by the request.
Definition base.cc:685
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition base.cc:2077
Counter missCount
The number of misses to trigger an exit event.
Definition base.hh:979
void cmpAndSwap(CacheBlk *blk, PacketPtr pkt)
Handle doing the Compare and Swap function for SPARC.
Definition base.cc:850
virtual void recvTimingResp(PacketPtr pkt)
Handles a response (cache line fill/write ack) from the bus.
Definition base.cc:539
virtual void recvTimingSnoopResp(PacketPtr pkt)=0
Handle a snoop response.
virtual bool access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat, PacketList &writebacks)
Does all the processing necessary to perform the provided request.
Definition base.cc:1290
void setBlocked(BlockedCause cause)
Marks the access path of the cache as blocked for the given cause.
Definition base.hh:1208
BaseCache(const BaseCacheParams &p, unsigned blk_size)
Definition base.cc:82
Addr regenerateBlkAddr(CacheBlk *blk)
Regenerate block address using tags.
Definition base.cc:189
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
Definition base.hh:412
CacheBlk * allocateBlock(const PacketPtr pkt, PacketList &writebacks)
Allocate a new block and perform any necessary writebacks.
Definition base.cc:1667
ProbePointArg< CacheDataUpdateProbeArg > * ppDataUpdate
To probe when the contents of a block are updated.
Definition base.hh:382
prefetch::Base * prefetcher
Prefetcher.
Definition base.hh:366
uint8_t blocked
Bit vector of the blocking reasons for the access path.
Definition base.hh:967
virtual Tick recvAtomicSnoop(PacketPtr pkt)=0
Snoop for the provided request in the cache and return the estimated time taken.
TempCacheBlk * tempBlock
Temporary cache block for occasional transitory use.
Definition base.hh:406
const AddrRangeList addrRanges
The address range to which the cache responds on the CPU side.
Definition base.hh:984
ProbePointArg< CacheAccessProbeArg > * ppHit
To probe when a cache hit occurs.
Definition base.hh:369
const int numTarget
The number of targets for each MSHR.
Definition base.hh:927
const bool moveContractions
Similar to data expansions, after a block improves its compression, it may need to be moved elsewhere...
Definition base.hh:961
WriteAllocator *const writeAllocator
The writeAllocator drive optimizations for streaming writes.
Definition base.hh:398
void markInService(MSHR *mshr, bool pending_modified_resp)
Mark a request as in service (sent downstream in the memory system), effectively making this MSHR the...
Definition base.hh:418
void allocateWriteBuffer(PacketPtr pkt, Tick time)
Definition base.cc:231
Cycles calculateTagOnlyLatency(const uint32_t delay, const Cycles lookup_lat) const
Calculate latency of accesses that only touch the tag array.
Definition base.cc:1247
CacheBlk * handleFill(PacketPtr pkt, CacheBlk *blk, PacketList &writebacks, bool allocate)
Handle a fill operation caused by a received packet.
Definition base.cc:1571
void incMissCount(PacketPtr pkt)
Definition base.hh:1271
WriteQueue writeBuffer
Write/writeback buffer.
Definition base.hh:354
const bool replaceExpansions
when a data expansion of a compressed block happens it will not be able to co-allocate where it is at...
Definition base.hh:953
void serialize(CheckpointOut &cp) const override
Serialize the state of the caches.
Definition base.cc:2057
bool coalesce() const
Checks if the cache is coalescing writes.
Definition base.cc:1871
Cycles blockedCycle
Stores time the cache blocked for statistics.
Definition base.hh:973
const bool sequentialAccess
Whether tags and data are accessed sequentially.
Definition base.hh:924
bool handleEvictions(std::vector< CacheBlk * > &evict_blks, PacketList &writebacks)
Try to evict the given blocks.
Definition base.cc:996
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition base.cc:199
PacketPtr writebackBlk(CacheBlk *blk)
Create a writeback request for the given block.
Definition base.cc:1756
void clearBlocked(BlockedCause cause)
Marks the cache as unblocked for the given cause.
Definition base.hh:1227
const AddrRangeList & getAddrRanges() const
Definition base.hh:1173
virtual PacketPtr evictBlock(CacheBlk *blk)=0
Evict a cache block.
void writebackVisitor(CacheBlk &blk)
Cache block visitor that writes back dirty cache blocks using functional writes.
Definition base.cc:1877
EventFunctionWrapper writebackTempBlockAtomicEvent
An event to writeback the tempBlock after recvAtomic finishes.
Definition base.hh:705
BaseTags * tags
Tag and data Storage.
Definition base.hh:357
const enums::Clusivity clusivity
Clusivity with respect to the upstream cache, determining if we fill into both this cache and the cac...
Definition base.hh:937
ProbePointArg< CacheAccessProbeArg > * ppMiss
To probe when a cache miss occurs.
Definition base.hh:372
virtual bool sendMSHRQueuePacket(MSHR *mshr)
Take an MSHR, turn it into a suitable downstream packet, and send it out.
Definition base.cc:1930
void maintainClusivity(bool from_cache, CacheBlk *blk)
Maintain the clusivity of this cache by potentially invalidating a block.
Definition base.cc:1559
System * system
System we are currently operating in.
Definition base.hh:988
partitioning_policy::PartitionManager * partitionManager
Partitioning manager.
Definition base.hh:363
A common base class of Cache tagstore objects.
Definition base.hh:74
A Basic Cache block.
Definition cache_blk.hh:72
uint32_t getSrcRequestorId() const
Get the requestor id associated to this block.
Definition cache_blk.hh:291
bool wasPrefetched() const
Check if this block was the result of a hardware prefetch, yet to be touched.
Definition cache_blk.hh:252
A coherent cache that can be arranged in flexible topologies.
Definition cache.hh:68
ClockedObject(const ClockedObjectParams &p)
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.
Definition types.hh:79
A Class for maintaining a list of pending and allocated memory requests.
Definition mshr_queue.hh:62
Miss Status and handling Register.
Definition mshr.hh:75
bool isLLSC() const
Definition packet.hh:251
bool isPrefetch() const
Definition packet.hh:255
const std::string _name
Definition named.hh:54
virtual std::string name() const
Definition named.hh:60
const std::string label
Label to use for print request packets label stack.
void schedSendEvent(Tick when)
Schedule a send event if we are not already waiting for a retry.
Addr getBlockAddr(unsigned int blk_size) const
Definition packet.hh:831
RequestPtr req
A pointer to the original request.
Definition packet.hh:377
MemCmd cmd
The command field of the packet.
Definition packet.hh:372
Ports are used to interface objects to each other.
Definition port.hh:62
ProbePointArg generates a point for the class of Arg.
Definition probe.hh:273
A queue entry base class, to be used by both the MSHRs and write-queue entries.
QueuedRequestPort(const std::string &name, ReqPacketQueue &req_queue, SnoopRespPacketQueue &snoop_resp_queue, PortID id=InvalidPortID)
Create a QueuedPort with a given name, and a supplied implementation of two packet queues.
Definition qport.hh:134
ReqPacketQueue & reqQueue
Packet queue used to store outgoing requests.
Definition qport.hh:116
QueuedResponsePort(const std::string &name, RespPacketQueue &resp_queue, PortID id=InvalidPortID)
Create a QueuedPort with a given name, owner, and a supplied implementation of a packet queue.
Definition qport.hh:80
ReqPacketQueue(EventManager &_em, RequestPort &_mem_side_port, const std::string _label="ReqPacketQueue")
Create a request packet queue, linked to an event manager, a memory-side port, and a label that will ...
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:136
gem5::Flags< FlagsType > Flags
Definition request.hh:102
Special instance of CacheBlk for use with tempBlk that deals with its block address regeneration.
Definition cache_blk.hh:517
The write allocator inspects write packets and detects streaming patterns.
Definition base.hh:1354
const uint32_t noAllocateLimit
Definition base.hh:1459
bool coalesce() const
Should writes be coalesced?
Definition base.hh:1371
bool delay(Addr blk_addr)
Access whether we need to delay the current write.
Definition base.hh:1402
WriteAllocator(const WriteAllocatorParams &p)
Definition base.hh:1356
const uint32_t delayThreshold
The number of times the allocator will delay an WriteReq MSHR.
Definition base.hh:1463
std::unordered_map< Addr, Counter > delayCtr
Keep track of the number of times the allocator has delayed an WriteReq MSHR.
Definition base.hh:1469
WriteMode
The current mode for write coalescing and allocation, either normal operation (ALLOCATE),...
Definition base.hh:1439
void reset()
Reset the write allocator state, meaning that it allocates for writes and has not recorded any inform...
Definition base.hh:1390
bool allocate() const
Should writes allocate?
Definition base.hh:1380
void updateMode(Addr write_addr, unsigned write_size, Addr blk_addr)
Update the write mode based on the current write packet.
Definition base.cc:2768
const uint32_t coalesceLimit
Limits for when to switch between the different write modes.
Definition base.hh:1458
uint32_t byteCount
Bytes written contiguously.
Definition base.hh:1453
void resetDelay(Addr blk_addr)
Clear delay counter for the input block.
Definition base.hh:1416
Addr nextAddr
Address to match writes against to detect streams.
Definition base.hh:1447
A write queue for all eviction packets, i.e.
Base cache compressor interface.
Definition base.hh:65
A formula for statistics that is calculated when printed.
Statistics container.
Definition group.hh:93
This is a simple scalar statistic, like a counter.
A vector of scalar stats.
STL vector class.
Definition stl.hh:37
ClockedObject declaration and implementation.
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
Definition addr_range.hh:64
SimObject(const Params &p)
Definition sim_object.cc:58
Declaration of a common base class for cache tagstore objects.
Declaration of a structure to manage MSHRs.
Bitfield< 29 > c
Definition misc_types.hh:53
Bitfield< 0 > p
Bitfield< 3 > addr
Definition types.hh:84
double Counter
All counters are of 64-bit values.
Definition types.hh:46
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
const PortID InvalidPortID
Definition types.hh:246
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
The "old style" exitSimLoop functions.
uint64_t Tick
Tick count type.
Definition types.hh:58
uint64_t PacketId
Definition packet.hh:74
uint16_t RequestorID
Definition request.hh:95
Packet * PacketPtr
std::list< PacketPtr > PacketList
Definition packet.hh:73
Declaration of the Packet class.
Declaration of a simple PacketQueue that is associated with a port on which it attempts to send packe...
Declaration of the queued port.
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Declaration of Statistics objects.
bool hasBeenPrefetched(Addr addr, bool is_secure) const override
Determine if address has been prefetched.
Definition base.hh:335
bool hasBeenPrefetched(Addr addr, bool is_secure, RequestorID requestor) const override
Determine if address has been prefetched by the requestor.
Definition base.hh:338
bool inCache(Addr addr, bool is_secure) const override
Determine if address is in cache.
Definition base.hh:332
bool coalesce() const override
Determine if cache is coalescing writes.
Definition base.hh:345
bool inMissQueue(Addr addr, bool is_secure) const override
Determine if address is in cache miss queue.
Definition base.hh:342
CacheAccessorImpl(BaseCache &_cache)
Definition base.hh:330
statistics::Formula accesses
The number of accesses per command and thread.
Definition base.hh:1021
statistics::Formula avgMshrMissLatency
The average latency of an MSHR miss, per command and thread.
Definition base.hh:1039
void regStatsFromParent()
Callback to register stats from parent CacheStats::regStats().
Definition base.cc:2129
statistics::Formula avgMshrUncacheableLatency
The average latency of an MSHR miss, per command and thread.
Definition base.hh:1041
statistics::Vector misses
Number of misses per thread for each type of command.
Definition base.hh:1009
statistics::Formula missRate
The miss rate per command and thread.
Definition base.hh:1023
statistics::Vector missLatency
Total number of ticks per thread/command spent waiting for a miss.
Definition base.hh:1019
statistics::Formula mshrMissRate
The miss rate in the MSHRs pre command and thread.
Definition base.hh:1037
const BaseCache & cache
Definition base.hh:1002
statistics::Vector mshrUncacheableLatency
Total tick latency of each MSHR miss, per command and thread.
Definition base.hh:1035
statistics::Vector hitLatency
Total number of ticks per thread/command spent waiting for a hit.
Definition base.hh:1014
statistics::Vector mshrHits
Number of misses that hit in the MSHRs per command and thread.
Definition base.hh:1027
statistics::Vector mshrUncacheable
Number of misses that miss in the MSHRs, per command and thread.
Definition base.hh:1031
CacheCmdStats(BaseCache &c, const std::string &name)
Definition base.cc:2089
statistics::Formula avgMissLatency
The average miss latency per command and thread.
Definition base.hh:1025
statistics::Vector mshrMisses
Number of misses that miss in the MSHRs, per command and thread.
Definition base.hh:1029
statistics::Vector mshrMissLatency
Total tick latency of each MSHR miss, per command and thread.
Definition base.hh:1033
statistics::Vector hits
Number of hits per thread for each type of command.
Definition base.hh:1006
statistics::Formula overallMshrMissLatency
Total tick latency of overall MSHR misses.
Definition base.hh:1117
statistics::Formula demandMshrMissLatency
Total tick latency of demand MSHR misses.
Definition base.hh:1115
statistics::Formula overallAvgMshrUncacheableLatency
The average overall latency of an MSHR miss.
Definition base.hh:1133
const BaseCache & cache
Definition base.hh:1054
statistics::Formula demandHits
Number of hits for demand accesses.
Definition base.hh:1057
statistics::Formula demandHitLatency
Total number of ticks spent waiting for demand hits.
Definition base.hh:1061
statistics::Formula demandAccesses
The number of demand accesses.
Definition base.hh:1076
statistics::Scalar replacements
Number of replacements of valid blocks.
Definition base.hh:1136
statistics::Formula overallAvgMshrMissLatency
The average overall latency of an MSHR miss.
Definition base.hh:1130
statistics::Formula demandMissRate
The miss rate of all demand accesses.
Definition base.hh:1081
statistics::Formula overallMissRate
The miss rate for all accesses.
Definition base.hh:1083
statistics::Formula demandAvgMshrMissLatency
The average latency of a demand MSHR miss.
Definition base.hh:1128
statistics::Formula demandMshrMisses
Demand misses that miss in the MSHRs.
Definition base.hh:1107
statistics::Formula overallMshrMisses
Total number of misses that miss in the MSHRs.
Definition base.hh:1109
statistics::Formula overallMshrHits
Total number of misses that hit in the MSHRs.
Definition base.hh:1104
statistics::Formula overallHitLatency
Total number of ticks spent waiting for all hits.
Definition base.hh:1063
statistics::Scalar dataContractions
Number of data contractions (blocks that had their compression factor improved).
Definition base.hh:1145
CacheStats(BaseCache &c)
Definition base.cc:2262
void regStats() override
Callback to set stat parameters.
Definition base.cc:2346
statistics::Scalar dataExpansions
Number of data expansions.
Definition base.hh:1139
statistics::Formula overallMshrUncacheable
Total number of misses that miss in the MSHRs.
Definition base.hh:1112
statistics::Formula demandMissLatency
Total number of ticks spent waiting for demand misses.
Definition base.hh:1071
statistics::Formula overallMisses
Number of misses for all accesses.
Definition base.hh:1068
statistics::Formula overallMshrMissRate
The overall miss rate in the MSHRs.
Definition base.hh:1125
statistics::Formula overallAccesses
The number of overall accesses.
Definition base.hh:1078
std::vector< std::unique_ptr< CacheCmdStats > > cmd
Per-command statistics.
Definition base.hh:1148
statistics::Formula demandMshrMissRate
The demand miss rate in the MSHRs.
Definition base.hh:1123
statistics::Formula avgBlocked
The average number of cycles blocked for each blocked cause.
Definition base.hh:1096
statistics::Formula overallMshrUncacheableLatency
Total tick latency of overall MSHR misses.
Definition base.hh:1120
statistics::Formula demandMisses
Number of misses for demand accesses.
Definition base.hh:1066
statistics::Formula demandAvgMissLatency
The average miss latency for demand misses.
Definition base.hh:1086
statistics::Formula overallMissLatency
Total number of ticks spent waiting for all misses.
Definition base.hh:1073
statistics::Formula demandMshrHits
Demand misses that hit in the MSHRs.
Definition base.hh:1102
statistics::Formula overallAvgMissLatency
The average miss latency for all misses.
Definition base.hh:1088
statistics::Vector blockedCauses
The number of times this cache blocked for each blocked cause.
Definition base.hh:1093
statistics::Vector writebacks
Number of blocks written back per thread.
Definition base.hh:1099
statistics::Vector blockedCycles
The total number of cycles blocked for each blocked cause.
Definition base.hh:1091
statistics::Formula overallHits
Number of hit for all accesses.
Definition base.hh:1059
CacheCmdStats & cmdStats(const PacketPtr p)
Definition base.hh:1050
Provides generic cache lookup functions.

Generated on Mon Oct 27 2025 04:13:01 for gem5 by doxygen 1.14.0