gem5 v24.0.0.0
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
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"
68#include "mem/packet.hh"
69#include "mem/packet_queue.hh"
70#include "mem/qport.hh"
71#include "mem/request.hh"
72#include "params/WriteAllocator.hh"
73#include "sim/clocked_object.hh"
74#include "sim/eventq.hh"
75#include "sim/probe/probe.hh"
76#include "sim/serialize.hh"
77#include "sim/sim_exit.hh"
78#include "sim/system.hh"
79
80namespace gem5
81{
82
83namespace prefetch
84{
85 class Base;
86}
87namespace partitioning_policy
88{
89 class PartitionManager;
90}
91class MSHR;
92class RequestPort;
93class QueueEntry;
94struct BaseCacheParams;
95
100{
101 protected:
110
111 public:
122
123 protected:
124
135 {
136
137 public:
138
144 {
145 DPRINTF(CachePort, "Scheduling send event at %llu\n", time);
147 }
148
149 protected:
150
151 CacheRequestPort(const std::string &_name,
152 ReqPacketQueue &_reqQueue,
153 SnoopRespPacketQueue &_snoopRespQueue) :
154 QueuedRequestPort(_name, _reqQueue, _snoopRespQueue)
155 { }
156
162 virtual bool isSnooping() const { return true; }
163 };
164
172 {
173
174 protected:
175
178
179 public:
180
182 SnoopRespPacketQueue &snoop_resp_queue,
183 const std::string &label) :
185 snoopRespQueue(snoop_resp_queue) { }
186
192 virtual void sendDeferredPacket();
193
203 {
205 DPRINTF(CachePort, "Waiting for snoop response to be "
206 "sent\n");
208 schedSendEvent(when);
209 return true;
210 }
211 return false;
212 }
213 };
214
215
221 {
222 private:
223
226
228
229 // a pointer to our specific cache implementation
231
232 protected:
233
234 virtual void recvTimingSnoopReq(PacketPtr pkt);
235
236 virtual bool recvTimingResp(PacketPtr pkt);
237
238 virtual Tick recvAtomicSnoop(PacketPtr pkt);
239
240 virtual void recvFunctionalSnoop(PacketPtr pkt);
241
242 public:
243
244 MemSidePort(const std::string &_name, BaseCache *_cache,
245 const std::string &_label);
246 };
247
257 {
258
259 public:
260
262 void setBlocked();
263
265 void clearBlocked();
266
267 bool isBlocked() const { return blocked; }
268
269 protected:
270
271 CacheResponsePort(const std::string &_name, BaseCache& _cache,
272 const std::string &_label);
273
275
278
280
282
283 private:
284
285 void processSendRetry();
286
288
289 };
290
296 {
297 protected:
298 virtual bool recvTimingSnoopResp(PacketPtr pkt) override;
299
300 virtual bool tryTiming(PacketPtr pkt) override;
301
302 virtual bool recvTimingReq(PacketPtr pkt) override;
303
304 virtual Tick recvAtomic(PacketPtr pkt) override;
305
306 virtual void recvFunctional(PacketPtr pkt) override;
307
308 virtual AddrRangeList getAddrRanges() const override;
309
310 public:
311
312 CpuSidePort(const std::string &_name, BaseCache& _cache,
313 const std::string &_label);
314
315 };
316
319
320 protected:
321
323 {
325
326 CacheAccessorImpl(BaseCache &_cache) :cache(_cache) {}
327
328 bool inCache(Addr addr, bool is_secure) const override
329 { return cache.inCache(addr, is_secure); }
330
331 bool hasBeenPrefetched(Addr addr, bool is_secure) const override
332 { return cache.hasBeenPrefetched(addr, is_secure); }
333
334 bool hasBeenPrefetched(Addr addr, bool is_secure,
335 RequestorID requestor) const override
336 { return cache.hasBeenPrefetched(addr, is_secure, requestor); }
337
338 bool inMissQueue(Addr addr, bool is_secure) const override
339 { return cache.inMissQueue(addr, is_secure); }
340
341 bool coalesce() const override
342 { return cache.coalesce(); }
343
345
348
351
354
357
360
363
366
369
372
379
395
403
408 std::unique_ptr<Packet> pendingDelete;
409
414 void markInService(MSHR *mshr, bool pending_modified_resp)
415 {
416 bool wasFull = mshrQueue.isFull();
417 mshrQueue.markInService(mshr, pending_modified_resp);
418
419 if (wasFull && !mshrQueue.isFull()) {
421 }
422 }
423
425 {
426 bool wasFull = writeBuffer.isFull();
428
429 if (wasFull && !writeBuffer.isFull()) {
431 }
432 }
433
447 inline bool allocOnFill(MemCmd cmd) const
448 {
449 return clusivity == enums::mostly_incl ||
450 cmd == MemCmd::WriteLineReq ||
451 cmd == MemCmd::ReadReq ||
452 cmd == MemCmd::WriteReq ||
453 cmd.isPrefetch() ||
454 cmd.isLLSC();
455 }
456
466
475 Cycles calculateTagOnlyLatency(const uint32_t delay,
476 const Cycles lookup_lat) const;
486 Cycles calculateAccessLatency(const CacheBlk* blk, const uint32_t delay,
487 const Cycles lookup_lat) const;
488
497 virtual bool access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat,
498 PacketList &writebacks);
499
500 /*
501 * Handle a timing request that hit in the cache
502 *
503 * @param ptk The request packet
504 * @param blk The referenced block
505 * @param request_time The tick at which the block lookup is compete
506 */
507 virtual void handleTimingReqHit(PacketPtr pkt, CacheBlk *blk,
508 Tick request_time);
509
510 /*
511 * Handle a timing request that missed in the cache
512 *
513 * Implementation specific handling for different cache
514 * implementations
515 *
516 * @param ptk The request packet
517 * @param blk The referenced block
518 * @param forward_time The tick at which we can process dependent requests
519 * @param request_time The tick at which the block lookup is compete
520 */
521 virtual void handleTimingReqMiss(PacketPtr pkt, CacheBlk *blk,
522 Tick forward_time,
523 Tick request_time) = 0;
524
525 /*
526 * Handle a timing request that missed in the cache
527 *
528 * Common functionality across different cache implementations
529 *
530 * @param ptk The request packet
531 * @param blk The referenced block
532 * @param mshr Any existing mshr for the referenced cache block
533 * @param forward_time The tick at which we can process dependent requests
534 * @param request_time The tick at which the block lookup is compete
535 */
536 void handleTimingReqMiss(PacketPtr pkt, MSHR *mshr, CacheBlk *blk,
537 Tick forward_time, Tick request_time);
538
543 virtual void recvTimingReq(PacketPtr pkt);
544
550
561 virtual void serviceMSHRTargets(MSHR *mshr, const PacketPtr pkt,
562 CacheBlk *blk) = 0;
563
568 virtual void recvTimingResp(PacketPtr pkt);
569
574 virtual void recvTimingSnoopReq(PacketPtr pkt) = 0;
575
580 virtual void recvTimingSnoopResp(PacketPtr pkt) = 0;
581
595 PacketList &writebacks) = 0;
596
602 virtual Tick recvAtomic(PacketPtr pkt);
603
611
618 virtual void functionalAccess(PacketPtr pkt, bool from_cpu_side);
619
629 void updateBlockData(CacheBlk *blk, const PacketPtr cpkt,
630 bool has_old_data);
631
635 void cmpAndSwap(CacheBlk *blk, PacketPtr pkt);
636
644
648 virtual void doWritebacks(PacketList& writebacks, Tick forward_time) = 0;
649
653 virtual void doWritebacksAtomic(PacketList& writebacks) = 0;
654
671 bool needs_writable,
672 bool is_whole_line_write) const = 0;
673
681 const bool writebackClean;
682
691
698 assert(tempBlockWriteback != nullptr);
699 PacketList writebacks{tempBlockWriteback};
700 doWritebacksAtomic(writebacks);
701 tempBlockWriteback = nullptr;
702 }
703
710
735 bool updateCompressionData(CacheBlk *&blk, const uint64_t* data,
736 PacketList &writebacks);
737
748 virtual void satisfyRequest(PacketPtr pkt, CacheBlk *blk,
749 bool deferred_response = false,
750 bool pending_downgrade = false);
751
761 void maintainClusivity(bool from_cache, CacheBlk *blk);
762
773 PacketList &writebacks);
774
794 PacketList &writebacks, bool allocate);
795
808 CacheBlk *allocateBlock(const PacketPtr pkt, PacketList &writebacks);
817 [[nodiscard]] virtual PacketPtr evictBlock(CacheBlk *blk) = 0;
818
827 void evictBlock(CacheBlk *blk, PacketList &writebacks);
828
834 void invalidateBlock(CacheBlk *blk);
835
843
856
860 virtual void memWriteback() override;
861
869 virtual void memInvalidate() override;
870
876 bool isDirty() const;
877
886 bool inRange(Addr addr) const;
887
891 Tick nextQueueReadyTime() const;
892
894 const unsigned blkSize;
895
901
907
914
917
924
929
931 const int numTarget;
932
935
941 const enums::Clusivity clusivity;
942
949 const bool isReadOnly;
950
958
966
971 uint8_t blocked;
972
974 uint64_t order;
975
978
981
984
989
990 public:
993
1047
1049 {
1051
1052 void regStats() override;
1053
1055 return *cmd[p->cmdToIndex()];
1056 }
1057
1059
1068
1073
1078
1083
1088
1093
1098
1101
1104
1109
1114
1117
1122
1125
1130
1135
1138
1141
1144
1150
1154
1156 void regProbePoints() override;
1157
1158 public:
1159 BaseCache(const BaseCacheParams &p, unsigned blk_size);
1160 ~BaseCache();
1161
1162 void init() override;
1163
1164 Port &getPort(const std::string &if_name,
1165 PortID idx=InvalidPortID) override;
1166
1171 unsigned
1173 {
1174 return blkSize;
1175 }
1176
1177 const AddrRangeList &getAddrRanges() const { return addrRanges; }
1178
1179 MSHR *allocateMissBuffer(PacketPtr pkt, Tick time, bool sched_send = true)
1180 {
1182 pkt, time, order++,
1183 allocOnFill(pkt->cmd));
1184
1185 if (mshrQueue.isFull()) {
1187 }
1188
1189 if (sched_send) {
1190 // schedule the send
1192 }
1193
1194 return mshr;
1195 }
1196
1198 {
1199 // should only see writes or clean evicts here
1200 assert(pkt->isWrite() || pkt->cmd == MemCmd::CleanEvict);
1201
1202 Addr blk_addr = pkt->getBlockAddr(blkSize);
1203
1204 // If using compression, on evictions the block is decompressed and
1205 // the operation's latency is added to the payload delay. Consume
1206 // that payload delay here, meaning that the data is always stored
1207 // uncompressed in the writebuffer
1208 if (compressor) {
1209 time += pkt->payloadDelay;
1210 pkt->payloadDelay = 0;
1211 }
1212
1213 WriteQueueEntry *wq_entry =
1214 writeBuffer.findMatch(blk_addr, pkt->isSecure());
1215 if (wq_entry && !wq_entry->inService) {
1216 DPRINTF(Cache, "Potential to merge writeback %s", pkt->print());
1217 }
1218
1219 writeBuffer.allocate(blk_addr, blkSize, pkt, time, order++);
1220
1221 if (writeBuffer.isFull()) {
1223 }
1224
1225 // schedule the send
1227 }
1228
1232 bool isBlocked() const
1233 {
1234 return blocked != 0;
1235 }
1236
1243 {
1244 uint8_t flag = 1 << cause;
1245 if (blocked == 0) {
1246 stats.blockedCauses[cause]++;
1249 }
1250 blocked |= flag;
1251 DPRINTF(Cache,"Blocking for cause %d, mask=%d\n", cause, blocked);
1252 }
1253
1262 {
1263 uint8_t flag = 1 << cause;
1264 blocked &= ~flag;
1265 DPRINTF(Cache,"Unblocking for cause %d, mask=%d\n", cause, blocked);
1266 if (blocked == 0) {
1269 }
1270 }
1271
1281 {
1283 }
1284
1285 bool inCache(Addr addr, bool is_secure) const {
1286 return tags->findBlock(addr, is_secure);
1287 }
1288
1289 bool hasBeenPrefetched(Addr addr, bool is_secure) const {
1290 CacheBlk *block = tags->findBlock(addr, is_secure);
1291 return block && block->wasPrefetched();
1292 }
1293
1294 bool hasBeenPrefetched(Addr addr, bool is_secure,
1295 RequestorID requestor) const {
1296 CacheBlk *block = tags->findBlock(addr, is_secure);
1297 return block && block->wasPrefetched() &&
1298 (block->getSrcRequestorId() == requestor);
1299 }
1300
1301 bool inMissQueue(Addr addr, bool is_secure) const {
1302 return mshrQueue.findMatch(addr, is_secure);
1303 }
1304
1306 {
1307 assert(pkt->req->requestorId() < system->maxRequestors());
1308 stats.cmdStats(pkt).misses[pkt->req->requestorId()]++;
1309 pkt->req->incAccessDepth();
1310 if (missCount) {
1311 --missCount;
1312 if (missCount == 0)
1313 exitSimLoop("A cache reached the maximum miss count");
1314 }
1315 }
1317 {
1318 assert(pkt->req->requestorId() < system->maxRequestors());
1319 stats.cmdStats(pkt).hits[pkt->req->requestorId()]++;
1320 }
1321
1327 bool coalesce() const;
1328
1329
1334 void writebackVisitor(CacheBlk &blk);
1335
1341 void invalidateVisitor(CacheBlk &blk);
1342
1351 virtual bool sendMSHRQueuePacket(MSHR* mshr);
1352
1361 bool sendWriteQueuePacket(WriteQueueEntry* wq_entry);
1362
1368 void serialize(CheckpointOut &cp) const override;
1369 void unserialize(CheckpointIn &cp) override;
1370};
1371
1388{
1389 public:
1390 WriteAllocator(const WriteAllocatorParams &p) :
1391 SimObject(p),
1392 coalesceLimit(p.coalesce_limit * p.block_size),
1393 noAllocateLimit(p.no_allocate_limit * p.block_size),
1394 delayThreshold(p.delay_threshold)
1395 {
1396 reset();
1397 }
1398
1405 bool coalesce() const {
1406 return mode != WriteMode::ALLOCATE;
1407 }
1408
1414 bool allocate() const {
1415 return mode != WriteMode::NO_ALLOCATE;
1416 }
1417
1424 void reset() {
1426 byteCount = 0;
1427 nextAddr = 0;
1428 }
1429
1436 bool delay(Addr blk_addr) {
1437 if (delayCtr[blk_addr] > 0) {
1438 --delayCtr[blk_addr];
1439 return true;
1440 } else {
1441 return false;
1442 }
1443 }
1444
1450 void resetDelay(Addr blk_addr) {
1451 delayCtr.erase(blk_addr);
1452 }
1453
1464 void updateMode(Addr write_addr, unsigned write_size, Addr blk_addr);
1465
1466 private:
1472 enum class WriteMode : char
1473 {
1474 ALLOCATE,
1475 COALESCE,
1477 };
1479
1482
1487 uint32_t byteCount;
1488
1492 const uint32_t coalesceLimit;
1493 const uint32_t noAllocateLimit;
1497 const uint32_t delayThreshold;
1498
1503 std::unordered_map<Addr, Counter> delayCtr;
1504};
1505
1506} // namespace gem5
1507
1508#endif //__MEM_CACHE_BASE_HH__
#define DPRINTF(x,...)
Definition trace.hh:210
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:172
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:202
CacheReqPacketQueue(BaseCache &cache, RequestPort &port, SnoopRespPacketQueue &snoop_resp_queue, const std::string &label)
Definition base.hh:181
virtual void sendDeferredPacket()
Override the normal sendDeferredPacket and do not only consider the transmit list (used for responses...
Definition base.cc:2672
SnoopRespPacketQueue & snoopRespQueue
Definition base.hh:177
A cache request port is used for the memory-side port of the cache, and in addition to the basic timi...
Definition base.hh:135
CacheRequestPort(const std::string &_name, ReqPacketQueue &_reqQueue, SnoopRespPacketQueue &_snoopRespQueue)
Definition base.hh:151
void schedSendEvent(Tick time)
Schedule a send of a request packet (from the MSHR).
Definition base.hh:143
virtual bool isSnooping() const
Memory-side port always snoops.
Definition base.hh:162
A cache response port is used for the CPU-side port of the cache, and it is basically a simple timing...
Definition base.hh:257
CacheResponsePort(const std::string &_name, BaseCache &_cache, const std::string &_label)
Definition base.cc:70
void clearBlocked()
Return to normal operation and accept new requests.
Definition base.cc:164
EventFunctionWrapper sendRetryEvent
Definition base.hh:287
void setBlocked()
Do not accept any new requests.
Definition base.cc:149
RespPacketQueue queue
A normal packet queue used to store responses.
Definition base.hh:277
The CPU-side port extends the base cache response port with access functions for functional,...
Definition base.hh:296
virtual bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition base.cc:2542
virtual Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the peer.
Definition base.cc:2589
CpuSidePort(const std::string &_name, BaseCache &_cache, const std::string &_label)
Definition base.cc:2621
virtual bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the peer.
Definition base.cc:2571
virtual bool tryTiming(PacketPtr pkt) override
Availability request from the peer.
Definition base.cc:2556
virtual void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the peer.
Definition base.cc:2600
virtual AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition base.cc:2614
The memory-side port extends the base cache request port with access functions for functional,...
Definition base.hh:221
virtual Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from our peer.
Definition base.cc:2651
virtual void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the peer.
Definition base.cc:2660
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition base.cc:2633
virtual void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the peer.
Definition base.cc:2641
CacheReqPacketQueue _reqQueue
The cache-specific queue.
Definition base.hh:225
SnoopRespPacketQueue _snoopRespQueue
Definition base.hh:227
MemSidePort(const std::string &_name, BaseCache *_cache, const std::string &_label)
Definition base.cc:2707
A basic cache interface.
Definition base.hh:100
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:718
const bool isReadOnly
Is this cache read only, for example the instruction cache, or table-walker cache.
Definition base.hh:949
virtual void recvTimingReq(PacketPtr pkt)
Performs the access specified by the request.
Definition base.cc:407
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:916
const Cycles dataLatency
The latency of data access of a cache.
Definition base.hh:906
void invalidateVisitor(CacheBlk &blk)
Cache block visitor that invalidates all blocks in the cache.
Definition base.cc:1852
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:1294
void updateBlockData(CacheBlk *blk, const PacketPtr cpkt, bool has_old_data)
Update the data contents of a block.
Definition base.cc:774
PacketPtr tempBlockWriteback
Writebacks from the tempBlock, resulting on the response path in atomic mode, must happen after the c...
Definition base.hh:690
MSHR * allocateMissBuffer(PacketPtr pkt, Tick time, bool sched_send=true)
Definition base.hh:1179
CpuSidePort cpuSidePort
Definition base.hh:317
bool isDirty() const
Determine if there are any dirty blocks in the cache.
Definition base.cc:1816
void invalidateBlock(CacheBlk *blk)
Invalidate a cache block.
Definition base.cc:1679
MSHR * noTargetMSHR
Pointer to the MSHR that has no targets.
Definition base.hh:980
const bool writebackClean
Determine if clean lines should be written back or not.
Definition base.hh:681
bool sendWriteQueuePacket(WriteQueueEntry *wq_entry)
Similar to sendMSHR, but for a write-queue entry instead.
Definition base.cc:1985
bool inRange(Addr addr) const
Determine if an address is in the ranges covered by this cache.
Definition base.cc:217
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:447
bool forwardSnoops
Do we forward snoops from mem side port through to cpu side port?
Definition base.hh:934
uint64_t order
Increasing order number assigned to each incoming request.
Definition base.hh:974
void incHitCount(PacketPtr pkt)
Definition base.hh:1316
MSHRQueueIndex
Indexes to enumerate the MSHR queues.
Definition base.hh:106
@ MSHRQueue_WriteBuffer
Definition base.hh:108
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:1098
virtual void memWriteback() override
Write back dirty blocks in the cache using functional accesses.
Definition base.cc:1804
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:986
bool isBlocked() const
Returns true if the cache is blocked for accesses.
Definition base.hh:1232
gem5::BaseCache::CacheStats stats
bool inMissQueue(Addr addr, bool is_secure) const
Definition base.hh:1301
const Cycles lookupLatency
The latency of tag lookup of a cache.
Definition base.hh:900
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:1208
Tick nextQueueReadyTime() const
Find next request ready time from among possible sources.
Definition base.cc:1865
void regProbePoints() override
Registers probes.
Definition base.cc:2523
virtual void memInvalidate() override
Invalidates all blocks in the cache.
Definition base.cc:1810
MSHRQueue mshrQueue
Miss status registers.
Definition base.hh:347
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:1289
void markInService(WriteQueueEntry *entry)
Definition base.hh:424
ProbePointArg< CacheAccessProbeArg > * ppFill
To probe when a cache fill occurs.
Definition base.hh:371
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition base.cc:205
QueueEntry * getNextQueueEntry()
Return the next queue entry to service, either a pending miss from the MSHR queue,...
Definition base.cc:858
unsigned getBlockSize() const
Query block size of a cache.
Definition base.hh:1172
bool inCache(Addr addr, bool is_secure) const
Definition base.hh:1285
void handleUncacheableWriteResp(PacketPtr pkt)
Handling the special case of uncacheable write responses to make recvTimingResp less cluttered.
Definition base.cc:480
const unsigned blkSize
Block size of this cache.
Definition base.hh:894
void writebackTempBlockAtomic()
Send the outstanding tempBlock writeback.
Definition base.hh:697
BlockedCause
Reasons for caches to be blocked.
Definition base.hh:116
@ NUM_BLOCKED_CAUSES
Definition base.hh:120
@ Blocked_NoTargets
Definition base.hh:119
@ Blocked_NoWBBuffers
Definition base.hh:118
const Cycles forwardLatency
This is the forward latency of the cache.
Definition base.hh:913
compression::Base * compressor
Compression method being used.
Definition base.hh:356
const Cycles responseLatency
The latency of sending reponse to its upper level cache/core on a linefill.
Definition base.hh:923
PacketPtr writecleanBlk(CacheBlk *blk, Request::Flags dest, PacketId id)
Create a writeclean request for the given block.
Definition base.cc:1758
void schedMemSideSendEvent(Tick time)
Schedule a send event for the memory-side port.
Definition base.hh:1280
MemSidePort memSidePort
Definition base.hh:318
virtual void handleTimingReqHit(PacketPtr pkt, CacheBlk *blk, Tick request_time)
Definition base.cc:228
virtual Tick recvAtomic(PacketPtr pkt)
Performs the access specified by the request.
Definition base.cc:638
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition base.cc:2029
Counter missCount
The number of misses to trigger an exit event.
Definition base.hh:983
void cmpAndSwap(CacheBlk *blk, PacketPtr pkt)
Handle doing the Compare and Swap function for SPARC.
Definition base.cc:803
virtual void recvTimingResp(PacketPtr pkt)
Handles a response (cache line fill/write ack) from the bus.
Definition base.cc:492
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:1242
void setBlocked(BlockedCause cause)
Marks the access path of the cache as blocked for the given cause.
Definition base.hh:1242
BaseCache(const BaseCacheParams &p, unsigned blk_size)
Definition base.cc:81
Addr regenerateBlkAddr(CacheBlk *blk)
Regenerate block address using tags.
Definition base.cc:186
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:408
CacheBlk * allocateBlock(const PacketPtr pkt, PacketList &writebacks)
Allocate a new block and perform any necessary writebacks.
Definition base.cc:1619
ProbePointArg< CacheDataUpdateProbeArg > * ppDataUpdate
To probe when the contents of a block are updated.
Definition base.hh:378
prefetch::Base * prefetcher
Prefetcher.
Definition base.hh:362
uint8_t blocked
Bit vector of the blocking reasons for the access path.
Definition base.hh:971
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:402
const AddrRangeList addrRanges
The address range to which the cache responds on the CPU side.
Definition base.hh:988
ProbePointArg< CacheAccessProbeArg > * ppHit
To probe when a cache hit occurs.
Definition base.hh:365
const int numTarget
The number of targets for each MSHR.
Definition base.hh:931
const bool moveContractions
Similar to data expansions, after a block improves its compression, it may need to be moved elsewhere...
Definition base.hh:965
WriteAllocator *const writeAllocator
The writeAllocator drive optimizations for streaming writes.
Definition base.hh:394
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:414
void allocateWriteBuffer(PacketPtr pkt, Tick time)
Definition base.hh:1197
Cycles calculateTagOnlyLatency(const uint32_t delay, const Cycles lookup_lat) const
Calculate latency of accesses that only touch the tag array.
Definition base.cc:1199
CacheBlk * handleFill(PacketPtr pkt, CacheBlk *blk, PacketList &writebacks, bool allocate)
Handle a fill operation caused by a received packet.
Definition base.cc:1523
void incMissCount(PacketPtr pkt)
Definition base.hh:1305
WriteQueue writeBuffer
Write/writeback buffer.
Definition base.hh:350
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:957
void serialize(CheckpointOut &cp) const override
Serialize the state of the caches.
Definition base.cc:2009
bool coalesce() const
Checks if the cache is coalescing writes.
Definition base.cc:1823
Cycles blockedCycle
Stores time the cache blocked for statistics.
Definition base.hh:977
const bool sequentialAccess
Whether tags and data are accessed sequentially.
Definition base.hh:928
bool handleEvictions(std::vector< CacheBlk * > &evict_blks, PacketList &writebacks)
Try to evict the given blocks.
Definition base.cc:949
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition base.cc:196
PacketPtr writebackBlk(CacheBlk *blk)
Create a writeback request for the given block.
Definition base.cc:1708
void clearBlocked(BlockedCause cause)
Marks the cache as unblocked for the given cause.
Definition base.hh:1261
const AddrRangeList & getAddrRanges() const
Definition base.hh:1177
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:1829
EventFunctionWrapper writebackTempBlockAtomicEvent
An event to writeback the tempBlock after recvAtomic finishes.
Definition base.hh:709
BaseTags * tags
Tag and data Storage.
Definition base.hh:353
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:941
ProbePointArg< CacheAccessProbeArg > * ppMiss
To probe when a cache miss occurs.
Definition base.hh:368
virtual bool sendMSHRQueuePacket(MSHR *mshr)
Take an MSHR, turn it into a suitable downstream packet, and send it out.
Definition base.cc:1882
void maintainClusivity(bool from_cache, CacheBlk *blk)
Maintain the clusivity of this cache by potentially invalidating a block.
Definition base.cc:1511
System * system
System we are currently operating in.
Definition base.hh:992
partitioning_policy::PartitionManager * partitionManager
Partitioning manager.
Definition base.hh:359
A common base class of Cache tagstore objects.
Definition base.hh:74
virtual CacheBlk * findBlock(Addr addr, bool is_secure) const
Finds the block in the cache without touching it.
Definition base.cc:82
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
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
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
void markInService(MSHR *mshr, bool pending_modified_resp)
Mark the given MSHR as in service.
MSHR * allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, Tick when_ready, Counter order, bool alloc_on_fill)
Allocates a new MSHR for the request and size.
Definition mshr_queue.cc:63
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:41
virtual std::string name() const
Definition named.hh:47
const std::string label
Label to use for print request packets label stack.
bool checkConflict(const PacketPtr pkt, const int blk_size) const
Check if a packet corresponding to the same address exists in the queue.
void schedSendEvent(Tick when)
Schedule a send event if we are not already waiting for a retry.
Tick deferredPacketReadyTime() const
Get the next packet ready time.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
bool isSecure() const
Definition packet.hh:836
void print(std::ostream &o, int verbosity=0, const std::string &prefix="") const
Definition packet.cc:368
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
Definition packet.hh:449
bool isWrite() const
Definition packet.hh:594
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:264
A queue entry base class, to be used by both the MSHRs and write-queue entries.
bool inService
True if the entry has been sent downstream.
Entry * findMatch(Addr blk_addr, bool is_secure, bool ignore_uncacheable=true) const
Find the first entry that matches the provided address.
Definition queue.hh:168
bool isFull() const
Definition queue.hh:150
The QueuedRequestPort combines two queues, a request queue and a snoop response queue,...
Definition qport.hh:111
ReqPacketQueue & reqQueue
Packet queue used to store outgoing requests.
Definition qport.hh:116
A queued port is a port that has an infinite queue for outgoing packets and thus decouples the module...
Definition qport.hh:62
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:136
Abstract superclass for simulation objects.
RequestorID maxRequestors()
Get the number of requestors registered in the system.
Definition system.hh:495
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:1388
const uint32_t noAllocateLimit
Definition base.hh:1493
bool coalesce() const
Should writes be coalesced? This is true if the mode is set to NO_ALLOCATE.
Definition base.hh:1405
bool delay(Addr blk_addr)
Access whether we need to delay the current write.
Definition base.hh:1436
WriteAllocator(const WriteAllocatorParams &p)
Definition base.hh:1390
const uint32_t delayThreshold
The number of times the allocator will delay an WriteReq MSHR.
Definition base.hh:1497
std::unordered_map< Addr, Counter > delayCtr
Keep track of the number of times the allocator has delayed an WriteReq MSHR.
Definition base.hh:1503
WriteMode
The current mode for write coalescing and allocation, either normal operation (ALLOCATE),...
Definition base.hh:1473
void reset()
Reset the write allocator state, meaning that it allocates for writes and has not recorded any inform...
Definition base.hh:1424
bool allocate() const
Should writes allocate?
Definition base.hh:1414
void updateMode(Addr write_addr, unsigned write_size, Addr blk_addr)
Update the write mode based on the current write packet.
Definition base.cc:2717
const uint32_t coalesceLimit
Limits for when to switch between the different write modes.
Definition base.hh:1492
uint32_t byteCount
Bytes written contiguously.
Definition base.hh:1487
void resetDelay(Addr blk_addr)
Clear delay counter for the input block.
Definition base.hh:1450
Addr nextAddr
Address to match writes against to detect streams.
Definition base.hh:1481
A write queue for all eviction packets, i.e.
void markInService(WriteQueueEntry *entry)
Mark the given entry as in service.
WriteQueueEntry * allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, Tick when_ready, Counter order)
Allocates a new WriteQueueEntry for the request and size.
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.
Definition of a basic cache compressor.
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 - Pranith Kumar Copyright (c) 2020 Inria 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
uint64_t Tick
Tick count type.
Definition types.hh:58
uint64_t PacketId
Definition packet.hh:74
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
Schedule an event to exit the simulation loop (returning to Python) at the end of the current cycle (...
Definition sim_events.cc:88
uint16_t RequestorID
Definition request.hh:95
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:331
bool hasBeenPrefetched(Addr addr, bool is_secure, RequestorID requestor) const override
Determine if address has been prefetched by the requestor.
Definition base.hh:334
bool inCache(Addr addr, bool is_secure) const override
Determine if address is in cache.
Definition base.hh:328
bool coalesce() const override
Determine if cache is coalescing writes.
Definition base.hh:341
bool inMissQueue(Addr addr, bool is_secure) const override
Determine if address is in cache miss queue.
Definition base.hh:338
CacheAccessorImpl(BaseCache &_cache)
Definition base.hh:326
statistics::Formula accesses
The number of accesses per command and thread.
Definition base.hh:1025
statistics::Formula avgMshrMissLatency
The average latency of an MSHR miss, per command and thread.
Definition base.hh:1043
void regStatsFromParent()
Callback to register stats from parent CacheStats::regStats().
Definition base.cc:2081
statistics::Formula avgMshrUncacheableLatency
The average latency of an MSHR miss, per command and thread.
Definition base.hh:1045
statistics::Vector misses
Number of misses per thread for each type of command.
Definition base.hh:1013
statistics::Formula missRate
The miss rate per command and thread.
Definition base.hh:1027
statistics::Vector missLatency
Total number of ticks per thread/command spent waiting for a miss.
Definition base.hh:1023
statistics::Formula mshrMissRate
The miss rate in the MSHRs pre command and thread.
Definition base.hh:1041
const BaseCache & cache
Definition base.hh:1006
statistics::Vector mshrUncacheableLatency
Total tick latency of each MSHR miss, per command and thread.
Definition base.hh:1039
statistics::Vector hitLatency
Total number of ticks per thread/command spent waiting for a hit.
Definition base.hh:1018
statistics::Vector mshrHits
Number of misses that hit in the MSHRs per command and thread.
Definition base.hh:1031
statistics::Vector mshrUncacheable
Number of misses that miss in the MSHRs, per command and thread.
Definition base.hh:1035
CacheCmdStats(BaseCache &c, const std::string &name)
Definition base.cc:2041
statistics::Formula avgMissLatency
The average miss latency per command and thread.
Definition base.hh:1029
statistics::Vector mshrMisses
Number of misses that miss in the MSHRs, per command and thread.
Definition base.hh:1033
statistics::Vector mshrMissLatency
Total tick latency of each MSHR miss, per command and thread.
Definition base.hh:1037
statistics::Vector hits
Number of hits per thread for each type of command.
Definition base.hh:1010
statistics::Formula overallMshrMissLatency
Total tick latency of overall MSHR misses.
Definition base.hh:1121
statistics::Formula demandMshrMissLatency
Total tick latency of demand MSHR misses.
Definition base.hh:1119
statistics::Formula overallAvgMshrUncacheableLatency
The average overall latency of an MSHR miss.
Definition base.hh:1137
const BaseCache & cache
Definition base.hh:1058
statistics::Formula demandHits
Number of hits for demand accesses.
Definition base.hh:1061
statistics::Formula demandHitLatency
Total number of ticks spent waiting for demand hits.
Definition base.hh:1065
statistics::Formula demandAccesses
The number of demand accesses.
Definition base.hh:1080
statistics::Scalar replacements
Number of replacements of valid blocks.
Definition base.hh:1140
statistics::Formula overallAvgMshrMissLatency
The average overall latency of an MSHR miss.
Definition base.hh:1134
statistics::Formula demandMissRate
The miss rate of all demand accesses.
Definition base.hh:1085
statistics::Formula overallMissRate
The miss rate for all accesses.
Definition base.hh:1087
statistics::Formula demandAvgMshrMissLatency
The average latency of a demand MSHR miss.
Definition base.hh:1132
statistics::Formula demandMshrMisses
Demand misses that miss in the MSHRs.
Definition base.hh:1111
statistics::Formula overallMshrMisses
Total number of misses that miss in the MSHRs.
Definition base.hh:1113
statistics::Formula overallMshrHits
Total number of misses that hit in the MSHRs.
Definition base.hh:1108
statistics::Formula overallHitLatency
Total number of ticks spent waiting for all hits.
Definition base.hh:1067
statistics::Scalar dataContractions
Number of data contractions (blocks that had their compression factor improved).
Definition base.hh:1149
CacheStats(BaseCache &c)
Definition base.cc:2214
void regStats() override
Callback to set stat parameters.
Definition base.cc:2298
statistics::Scalar dataExpansions
Number of data expansions.
Definition base.hh:1143
statistics::Formula overallMshrUncacheable
Total number of misses that miss in the MSHRs.
Definition base.hh:1116
statistics::Formula demandMissLatency
Total number of ticks spent waiting for demand misses.
Definition base.hh:1075
statistics::Formula overallMisses
Number of misses for all accesses.
Definition base.hh:1072
statistics::Formula overallMshrMissRate
The overall miss rate in the MSHRs.
Definition base.hh:1129
statistics::Formula overallAccesses
The number of overall accesses.
Definition base.hh:1082
std::vector< std::unique_ptr< CacheCmdStats > > cmd
Per-command statistics.
Definition base.hh:1152
statistics::Formula demandMshrMissRate
The demand miss rate in the MSHRs.
Definition base.hh:1127
statistics::Formula avgBlocked
The average number of cycles blocked for each blocked cause.
Definition base.hh:1100
statistics::Formula overallMshrUncacheableLatency
Total tick latency of overall MSHR misses.
Definition base.hh:1124
statistics::Formula demandMisses
Number of misses for demand accesses.
Definition base.hh:1070
statistics::Formula demandAvgMissLatency
The average miss latency for demand misses.
Definition base.hh:1090
statistics::Formula overallMissLatency
Total number of ticks spent waiting for all misses.
Definition base.hh:1077
statistics::Formula demandMshrHits
Demand misses that hit in the MSHRs.
Definition base.hh:1106
statistics::Formula overallAvgMissLatency
The average miss latency for all misses.
Definition base.hh:1092
statistics::Vector blockedCauses
The number of times this cache blocked for each blocked cause.
Definition base.hh:1097
statistics::Vector writebacks
Number of blocks written back per thread.
Definition base.hh:1103
statistics::Vector blockedCycles
The total number of cycles blocked for each blocked cause.
Definition base.hh:1095
statistics::Formula overallHits
Number of hit for all accesses.
Definition base.hh:1063
CacheCmdStats & cmdStats(const PacketPtr p)
Definition base.hh:1054
Provides generic cache lookup functions.
Write queue entry.

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