gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
base.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013, 2015-2016, 2018-2019 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  * Authors: Erik Hallnor
41  * Steve Reinhardt
42  * Ron Dreslinski
43  * Andreas Hansson
44  * Nikos Nikoleris
45  */
46 
52 #ifndef __MEM_CACHE_BASE_HH__
53 #define __MEM_CACHE_BASE_HH__
54 
55 #include <cassert>
56 #include <cstdint>
57 #include <string>
58 
59 #include "base/addr_range.hh"
60 #include "base/statistics.hh"
61 #include "base/trace.hh"
62 #include "base/types.hh"
63 #include "debug/Cache.hh"
64 #include "debug/CachePort.hh"
65 #include "enums/Clusivity.hh"
66 #include "mem/cache/cache_blk.hh"
68 #include "mem/cache/mshr_queue.hh"
69 #include "mem/cache/tags/base.hh"
70 #include "mem/cache/write_queue.hh"
72 #include "mem/packet.hh"
73 #include "mem/packet_queue.hh"
74 #include "mem/qport.hh"
75 #include "mem/request.hh"
76 #include "params/WriteAllocator.hh"
77 #include "sim/clocked_object.hh"
78 #include "sim/eventq.hh"
79 #include "sim/probe/probe.hh"
80 #include "sim/serialize.hh"
81 #include "sim/sim_exit.hh"
82 #include "sim/system.hh"
83 
84 class BasePrefetcher;
85 class MSHR;
86 class MasterPort;
87 class QueueEntry;
88 struct BaseCacheParams;
89 
93 class BaseCache : public ClockedObject
94 {
95  protected:
102  };
103 
104  public:
113  };
114 
115  protected:
116 
127  {
128 
129  public:
130 
135  void schedSendEvent(Tick time)
136  {
137  DPRINTF(CachePort, "Scheduling send event at %llu\n", time);
138  reqQueue.schedSendEvent(time);
139  }
140 
141  protected:
142 
143  CacheMasterPort(const std::string &_name, BaseCache *_cache,
144  ReqPacketQueue &_reqQueue,
145  SnoopRespPacketQueue &_snoopRespQueue) :
146  QueuedMasterPort(_name, _cache, _reqQueue, _snoopRespQueue)
147  { }
148 
154  virtual bool isSnooping() const { return true; }
155  };
156 
164  {
165 
166  protected:
167 
170 
171  public:
172 
174  SnoopRespPacketQueue &snoop_resp_queue,
175  const std::string &label) :
176  ReqPacketQueue(cache, port, label), cache(cache),
177  snoopRespQueue(snoop_resp_queue) { }
178 
184  virtual void sendDeferredPacket();
185 
195  {
196  if (snoopRespQueue.checkConflict(pkt, cache.blkSize)) {
197  DPRINTF(CachePort, "Waiting for snoop response to be "
198  "sent\n");
199  Tick when = snoopRespQueue.deferredPacketReadyTime();
200  schedSendEvent(when);
201  return true;
202  }
203  return false;
204  }
205  };
206 
207 
213  {
214  private:
215 
218 
220 
221  // a pointer to our specific cache implementation
223 
224  protected:
225 
226  virtual void recvTimingSnoopReq(PacketPtr pkt);
227 
228  virtual bool recvTimingResp(PacketPtr pkt);
229 
230  virtual Tick recvAtomicSnoop(PacketPtr pkt);
231 
232  virtual void recvFunctionalSnoop(PacketPtr pkt);
233 
234  public:
235 
236  MemSidePort(const std::string &_name, BaseCache *_cache,
237  const std::string &_label);
238  };
239 
249  {
250 
251  public:
252 
254  void setBlocked();
255 
257  void clearBlocked();
258 
259  bool isBlocked() const { return blocked; }
260 
261  protected:
262 
263  CacheSlavePort(const std::string &_name, BaseCache *_cache,
264  const std::string &_label);
265 
268 
269  bool blocked;
270 
272 
273  private:
274 
275  void processSendRetry();
276 
278 
279  };
280 
286  {
287  private:
288 
289  // a pointer to our specific cache implementation
291 
292  protected:
293  virtual bool recvTimingSnoopResp(PacketPtr pkt) override;
294 
295  virtual bool tryTiming(PacketPtr pkt) override;
296 
297  virtual bool recvTimingReq(PacketPtr pkt) override;
298 
299  virtual Tick recvAtomic(PacketPtr pkt) override;
300 
301  virtual void recvFunctional(PacketPtr pkt) override;
302 
303  virtual AddrRangeList getAddrRanges() const override;
304 
305  public:
306 
307  CpuSidePort(const std::string &_name, BaseCache *_cache,
308  const std::string &_label);
309 
310  };
311 
314 
315  protected:
316 
319 
322 
325 
328 
331 
334 
337 
340 
356 
364 
369  std::unique_ptr<Packet> pendingDelete;
370 
375  void markInService(MSHR *mshr, bool pending_modified_resp)
376  {
377  bool wasFull = mshrQueue.isFull();
378  mshrQueue.markInService(mshr, pending_modified_resp);
379 
380  if (wasFull && !mshrQueue.isFull()) {
382  }
383  }
384 
386  {
387  bool wasFull = writeBuffer.isFull();
388  writeBuffer.markInService(entry);
389 
390  if (wasFull && !writeBuffer.isFull()) {
392  }
393  }
394 
408  inline bool allocOnFill(MemCmd cmd) const
409  {
410  return clusivity == Enums::mostly_incl ||
411  cmd == MemCmd::WriteLineReq ||
412  cmd == MemCmd::ReadReq ||
413  cmd == MemCmd::WriteReq ||
414  cmd.isPrefetch() ||
415  cmd.isLLSC();
416  }
417 
427 
436  Cycles calculateTagOnlyLatency(const uint32_t delay,
437  const Cycles lookup_lat) const;
447  Cycles calculateAccessLatency(const CacheBlk* blk, const uint32_t delay,
448  const Cycles lookup_lat) const;
449 
458  virtual bool access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat,
459  PacketList &writebacks);
460 
461  /*
462  * Handle a timing request that hit in the cache
463  *
464  * @param ptk The request packet
465  * @param blk The referenced block
466  * @param request_time The tick at which the block lookup is compete
467  */
468  virtual void handleTimingReqHit(PacketPtr pkt, CacheBlk *blk,
469  Tick request_time);
470 
471  /*
472  * Handle a timing request that missed in the cache
473  *
474  * Implementation specific handling for different cache
475  * implementations
476  *
477  * @param ptk The request packet
478  * @param blk The referenced block
479  * @param forward_time The tick at which we can process dependent requests
480  * @param request_time The tick at which the block lookup is compete
481  */
482  virtual void handleTimingReqMiss(PacketPtr pkt, CacheBlk *blk,
483  Tick forward_time,
484  Tick request_time) = 0;
485 
486  /*
487  * Handle a timing request that missed in the cache
488  *
489  * Common functionality across different cache implementations
490  *
491  * @param ptk The request packet
492  * @param blk The referenced block
493  * @param mshr Any existing mshr for the referenced cache block
494  * @param forward_time The tick at which we can process dependent requests
495  * @param request_time The tick at which the block lookup is compete
496  */
497  void handleTimingReqMiss(PacketPtr pkt, MSHR *mshr, CacheBlk *blk,
498  Tick forward_time, Tick request_time);
499 
504  virtual void recvTimingReq(PacketPtr pkt);
505 
511 
522  virtual void serviceMSHRTargets(MSHR *mshr, const PacketPtr pkt,
523  CacheBlk *blk) = 0;
524 
529  virtual void recvTimingResp(PacketPtr pkt);
530 
535  virtual void recvTimingSnoopReq(PacketPtr pkt) = 0;
536 
541  virtual void recvTimingSnoopResp(PacketPtr pkt) = 0;
542 
555  virtual Cycles handleAtomicReqMiss(PacketPtr pkt, CacheBlk *&blk,
556  PacketList &writebacks) = 0;
557 
563  virtual Tick recvAtomic(PacketPtr pkt);
564 
571  virtual Tick recvAtomicSnoop(PacketPtr pkt) = 0;
572 
579  virtual void functionalAccess(PacketPtr pkt, bool from_cpu_side);
580 
584  void cmpAndSwap(CacheBlk *blk, PacketPtr pkt);
585 
593 
597  virtual void doWritebacks(PacketList& writebacks, Tick forward_time) = 0;
598 
602  virtual void doWritebacksAtomic(PacketList& writebacks) = 0;
603 
619  virtual PacketPtr createMissPacket(PacketPtr cpu_pkt, CacheBlk *blk,
620  bool needs_writable,
621  bool is_whole_line_write) const = 0;
622 
630  const bool writebackClean;
631 
640 
647  assert(tempBlockWriteback != nullptr);
648  PacketList writebacks{tempBlockWriteback};
649  doWritebacksAtomic(writebacks);
650  tempBlockWriteback = nullptr;
651  }
652 
659 
684  bool updateCompressionData(CacheBlk *blk, const uint64_t* data,
685  PacketList &writebacks);
686 
697  virtual void satisfyRequest(PacketPtr pkt, CacheBlk *blk,
698  bool deferred_response = false,
699  bool pending_downgrade = false);
700 
710  void maintainClusivity(bool from_cache, CacheBlk *blk);
711 
721  bool handleEvictions(std::vector<CacheBlk*> &evict_blks,
722  PacketList &writebacks);
723 
743  PacketList &writebacks, bool allocate);
744 
757  CacheBlk *allocateBlock(const PacketPtr pkt, PacketList &writebacks);
766  M5_NODISCARD virtual PacketPtr evictBlock(CacheBlk *blk) = 0;
767 
776  void evictBlock(CacheBlk *blk, PacketList &writebacks);
777 
783  void invalidateBlock(CacheBlk *blk);
784 
792 
805 
809  virtual void memWriteback() override;
810 
818  virtual void memInvalidate() override;
819 
825  bool isDirty() const;
826 
835  bool inRange(Addr addr) const;
836 
840  Tick nextQueueReadyTime() const;
841 
843  const unsigned blkSize;
844 
850 
856 
863 
866 
873 
877  const bool sequentialAccess;
878 
880  const int numTarget;
881 
884 
890  const Enums::Clusivity clusivity;
891 
898  const bool isReadOnly;
899 
904  uint8_t blocked;
905 
907  uint64_t order;
908 
911 
914 
917 
922 
923  public:
926 
927  struct CacheCmdStats : public Stats::Group
928  {
929  CacheCmdStats(BaseCache &c, const std::string &name);
930 
937  void regStatsFromParent();
938 
939  const BaseCache &cache;
940 
974  };
975 
976  struct CacheStats : public Stats::Group
977  {
979 
980  void regStats() override;
981 
983  return *cmd[p->cmdToIndex()];
984  }
985 
986  const BaseCache &cache;
987 
992 
997 
1002 
1007 
1012 
1017 
1022 
1025 
1029 
1032 
1037 
1042 
1045 
1050 
1053 
1058 
1063 
1066 
1069 
1072 
1075  } stats;
1076 
1078  void regProbePoints() override;
1079 
1080  public:
1081  BaseCache(const BaseCacheParams *p, unsigned blk_size);
1082  ~BaseCache();
1083 
1084  void init() override;
1085 
1086  Port &getPort(const std::string &if_name,
1087  PortID idx=InvalidPortID) override;
1088 
1093  unsigned
1095  {
1096  return blkSize;
1097  }
1098 
1099  const AddrRangeList &getAddrRanges() const { return addrRanges; }
1100 
1101  MSHR *allocateMissBuffer(PacketPtr pkt, Tick time, bool sched_send = true)
1102  {
1103  MSHR *mshr = mshrQueue.allocate(pkt->getBlockAddr(blkSize), blkSize,
1104  pkt, time, order++,
1105  allocOnFill(pkt->cmd));
1106 
1107  if (mshrQueue.isFull()) {
1109  }
1110 
1111  if (sched_send) {
1112  // schedule the send
1113  schedMemSideSendEvent(time);
1114  }
1115 
1116  return mshr;
1117  }
1118 
1120  {
1121  // should only see writes or clean evicts here
1122  assert(pkt->isWrite() || pkt->cmd == MemCmd::CleanEvict);
1123 
1124  Addr blk_addr = pkt->getBlockAddr(blkSize);
1125 
1126  // If using compression, on evictions the block is decompressed and
1127  // the operation's latency is added to the payload delay. Consume
1128  // that payload delay here, meaning that the data is always stored
1129  // uncompressed in the writebuffer
1130  if (compressor) {
1131  time += pkt->payloadDelay;
1132  pkt->payloadDelay = 0;
1133  }
1134 
1135  WriteQueueEntry *wq_entry =
1136  writeBuffer.findMatch(blk_addr, pkt->isSecure());
1137  if (wq_entry && !wq_entry->inService) {
1138  DPRINTF(Cache, "Potential to merge writeback %s", pkt->print());
1139  }
1140 
1141  writeBuffer.allocate(blk_addr, blkSize, pkt, time, order++);
1142 
1143  if (writeBuffer.isFull()) {
1145  }
1146 
1147  // schedule the send
1148  schedMemSideSendEvent(time);
1149  }
1150 
1154  bool isBlocked() const
1155  {
1156  return blocked != 0;
1157  }
1158 
1165  {
1166  uint8_t flag = 1 << cause;
1167  if (blocked == 0) {
1168  stats.blocked_causes[cause]++;
1169  blockedCycle = curCycle();
1170  cpuSidePort.setBlocked();
1171  }
1172  blocked |= flag;
1173  DPRINTF(Cache,"Blocking for cause %d, mask=%d\n", cause, blocked);
1174  }
1175 
1184  {
1185  uint8_t flag = 1 << cause;
1186  blocked &= ~flag;
1187  DPRINTF(Cache,"Unblocking for cause %d, mask=%d\n", cause, blocked);
1188  if (blocked == 0) {
1189  stats.blocked_cycles[cause] += curCycle() - blockedCycle;
1190  cpuSidePort.clearBlocked();
1191  }
1192  }
1193 
1203  {
1204  memSidePort.schedSendEvent(time);
1205  }
1206 
1207  bool inCache(Addr addr, bool is_secure) const {
1208  return tags->findBlock(addr, is_secure);
1209  }
1210 
1211  bool hasBeenPrefetched(Addr addr, bool is_secure) const {
1212  CacheBlk *block = tags->findBlock(addr, is_secure);
1213  if (block) {
1214  return block->wasPrefetched();
1215  } else {
1216  return false;
1217  }
1218  }
1219 
1220  bool inMissQueue(Addr addr, bool is_secure) const {
1221  return mshrQueue.findMatch(addr, is_secure);
1222  }
1223 
1225  {
1226  assert(pkt->req->masterId() < system->maxMasters());
1227  stats.cmdStats(pkt).misses[pkt->req->masterId()]++;
1228  pkt->req->incAccessDepth();
1229  if (missCount) {
1230  --missCount;
1231  if (missCount == 0)
1232  exitSimLoop("A cache reached the maximum miss count");
1233  }
1234  }
1236  {
1237  assert(pkt->req->masterId() < system->maxMasters());
1238  stats.cmdStats(pkt).hits[pkt->req->masterId()]++;
1239  }
1240 
1246  bool coalesce() const;
1247 
1248 
1253  void writebackVisitor(CacheBlk &blk);
1254 
1260  void invalidateVisitor(CacheBlk &blk);
1261 
1270  virtual bool sendMSHRQueuePacket(MSHR* mshr);
1271 
1280  bool sendWriteQueuePacket(WriteQueueEntry* wq_entry);
1281 
1287  void serialize(CheckpointOut &cp) const override;
1288  void unserialize(CheckpointIn &cp) override;
1289 };
1290 
1306 class WriteAllocator : public SimObject {
1307  public:
1308  WriteAllocator(const WriteAllocatorParams *p) :
1309  SimObject(p),
1310  coalesceLimit(p->coalesce_limit * p->block_size),
1311  noAllocateLimit(p->no_allocate_limit * p->block_size),
1312  delayThreshold(p->delay_threshold)
1313  {
1314  reset();
1315  }
1316 
1323  bool coalesce() const {
1324  return mode != WriteMode::ALLOCATE;
1325  }
1326 
1332  bool allocate() const {
1333  return mode != WriteMode::NO_ALLOCATE;
1334  }
1335 
1342  void reset() {
1343  mode = WriteMode::ALLOCATE;
1344  byteCount = 0;
1345  nextAddr = 0;
1346  }
1347 
1354  bool delay(Addr blk_addr) {
1355  if (delayCtr[blk_addr] > 0) {
1356  --delayCtr[blk_addr];
1357  return true;
1358  } else {
1359  return false;
1360  }
1361  }
1362 
1368  void resetDelay(Addr blk_addr) {
1369  delayCtr.erase(blk_addr);
1370  }
1371 
1382  void updateMode(Addr write_addr, unsigned write_size, Addr blk_addr);
1383 
1384  private:
1390  enum class WriteMode : char {
1391  ALLOCATE,
1392  COALESCE,
1393  NO_ALLOCATE,
1394  };
1396 
1399 
1404  uint32_t byteCount;
1405 
1409  const uint32_t coalesceLimit;
1410  const uint32_t noAllocateLimit;
1414  const uint32_t delayThreshold;
1415 
1420  std::unordered_map<Addr, Counter> delayCtr;
1421 };
1422 
1423 #endif //__MEM_CACHE_BASE_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:75
virtual bool access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat, PacketList &writebacks)
Does all the processing necessary to perform the provided request.
Definition: base.cc:1033
Stats::Formula demandMissLatency
Total number of cycles spent waiting for demand misses.
Definition: base.hh:999
#define DPRINTF(x,...)
Definition: trace.hh:229
virtual Cycles handleAtomicReqMiss(PacketPtr pkt, CacheBlk *&blk, PacketList &writebacks)=0
Handle a request in atomic mode that missed in this cache.
virtual CacheBlk * findBlock(Addr addr, bool is_secure) const
Finds the block in the cache without touching it.
Definition: base.cc:80
bool forwardSnoops
Do we forward snoops from mem side port through to cpu side port?
Definition: base.hh:883
void regProbePoints() override
Registers probes.
Definition: base.cc:2276
Ports are used to interface objects to each other.
Definition: port.hh:60
BaseCache(const BaseCacheParams *p, unsigned blk_size)
Definition: base.cc:79
std::unordered_map< Addr, Counter > delayCtr
Keep track of the number of times the allocator has delayed an WriteReq MSHR.
Definition: base.hh:1420
Special instance of CacheBlk for use with tempBlk that deals with its block address regeneration...
Definition: cache_blk.hh:444
Declaration of a simple PacketQueue that is associated with a port on which it attempts to send packe...
PacketPtr writebackBlk(CacheBlk *blk)
Create a writeback request for the given block.
Definition: base.cc:1488
bool inService
True if the entry has been sent downstream.
Definition: queue_entry.hh:108
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Stats::Formula demandHits
Number of hits for demand accesses.
Definition: base.hh:989
Tick recvAtomicSnoop(PacketPtr pkt) override
Default implementations.
Definition: port.hh:224
A Class for maintaining a list of pending and allocated memory requests.
Definition: mshr_queue.hh:61
Definition: packet.hh:76
void writebackVisitor(CacheBlk &blk)
Cache block visitor that writes back dirty cache blocks using functional writes.
Definition: base.cc:1606
Stats::Vector missLatency
Total number of cycles per thread/command spent waiting for a miss.
Definition: base.hh:951
CpuSidePort cpuSidePort
Definition: base.hh:312
Stats::Formula avgMshrUncacheableLatency
The average latency of an MSHR miss, per command and thread.
Definition: base.hh:973
const PortID InvalidPortID
Definition: types.hh:238
The memory-side port extends the base cache master port with access functions for functional...
Definition: base.hh:212
QueueEntry * getNextQueueEntry()
Return the next queue entry to service, either a pending miss from the MSHR queue, a buffered write from the write buffer, or something from the prefetcher.
Definition: base.cc:720
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: base.cc:182
void recvFunctionalSnoop(PacketPtr pkt) override
Receive a functional snoop request packet from the peer.
Definition: port.hh:231
WriteQueue writeBuffer
Write/writeback buffer.
Definition: base.hh:321
Stats::Formula overallMshrMissLatency
Total cycle latency of overall MSHR misses.
Definition: base.hh:1049
Write queue entry.
const BaseCache & cache
Definition: base.hh:939
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:999
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: base.cc:191
Stats::Vector mshr_miss_latency
Total cycle latency of each MSHR miss, per command and thread.
Definition: base.hh:965
Stats::Scalar replacements
Number of replacements of valid blocks.
Definition: base.hh:1068
MSHR * noTargetMSHR
Pointer to the MSHR that has no targets.
Definition: base.hh:913
Stats::Formula overallMshrUncacheableLatency
Total cycle latency of overall MSHR misses.
Definition: base.hh:1052
const Cycles lookupLatency
The latency of tag lookup of a cache.
Definition: base.hh:849
std::vector< std::unique_ptr< CacheCmdStats > > cmd
Per-command statistics.
Definition: base.hh:1074
A write queue for all eviction packets, i.e.
Definition: write_queue.hh:59
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Stats::Vector mshr_hits
Number of misses that hit in the MSHRs per command and thread.
Definition: base.hh:959
EventFunctionWrapper writebackTempBlockAtomicEvent
An event to writeback the tempBlock after recvAtomic finishes.
Definition: base.hh:658
bool tryTiming(PacketPtr pkt) const
Check if the slave can handle a timing request.
Definition: port.hh:451
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:890
Stats::Formula demandMshrMisses
Demand misses that miss in the MSHRs.
Definition: base.hh:1039
The QueuedMasterPort combines two queues, a request queue and a snoop response queue, that both share the same port.
Definition: qport.hh:108
ip6_addr_t addr
Definition: inet.hh:335
System * system
System we are currently operating in.
Definition: base.hh:925
const bool isReadOnly
Is this cache read only, for example the instruction cache, or table-walker cache.
Definition: base.hh:898
ProbePointArg< PacketPtr > * ppMiss
To probe when a cache miss occurs.
Definition: base.hh:336
virtual void handleTimingReqMiss(PacketPtr pkt, CacheBlk *blk, Tick forward_time, Tick request_time)=0
const AddrRangeList addrRanges
The address range to which the cache responds on the CPU side.
Definition: base.hh:921
Stats::Formula overallMshrMisses
Total number of misses that miss in the MSHRs.
Definition: base.hh:1041
BaseCache::CacheStats stats
void invalidateBlock(CacheBlk *blk)
Invalidate a cache block.
Definition: base.cc:1462
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:835
void reset()
Definition: statistics.cc:570
Stats::Formula overallMshrUncacheable
Total number of misses that miss in the MSHRs.
Definition: base.hh:1044
virtual void regStats()
Callback to set stat parameters.
Definition: group.cc:66
BaseCache * cache
Definition: base.hh:222
Definition of a basic cache compressor.
MSHR * allocateMissBuffer(PacketPtr pkt, Tick time, bool sched_send=true)
Definition: base.hh:1101
Definition: system.hh:77
A vector of scalar stats.
Definition: statistics.hh:2550
bool allocate() const
Should writes allocate?
Definition: base.hh:1332
bool isBlocked() const
Returns true if the cache is blocked for accesses.
Definition: base.hh:1154
A queued port is a port that has an infinite queue for outgoing packets and thus decouples the module...
Definition: qport.hh:60
const Cycles dataLatency
The latency of data access of a cache.
Definition: base.hh:855
bool coalesce() const
Checks if the cache is coalescing writes.
Definition: base.cc:1600
Definition: cprintf.cc:42
const Cycles fillLatency
The latency to fill a cache block.
Definition: base.hh:865
bool handleEvictions(std::vector< CacheBlk *> &evict_blks, PacketList &writebacks)
Try to evict the given blocks.
Definition: base.cc:798
Bitfield< 4, 0 > mode
WriteAllocator *const writeAllocator
The writeAllocator drive optimizations for streaming writes.
Definition: base.hh:355
void markInService(WriteQueueEntry *entry)
Mark the given entry as in service.
Definition: write_queue.cc:78
Stats::Formula overallMissLatency
Total number of cycles spent waiting for all misses.
Definition: base.hh:1001
void schedSendEvent(Tick when)
Schedule a send event if we are not already waiting for a retry.
Declaration of a structure to manage MSHRs.
bool sendWriteQueuePacket(WriteQueueEntry *wq_entry)
Similar to sendMSHR, but for a write-queue entry instead.
Definition: base.cc:1762
Stats::Formula overallAvgMshrUncacheableLatency
The average overall latency of an MSHR miss.
Definition: base.hh:1065
const uint32_t noAllocateLimit
Definition: base.hh:1410
bool isWrite() const
Definition: packet.hh:529
Declaration of Statistics objects.
const BaseCache & cache
Definition: base.hh:986
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
CacheReqPacketQueue(BaseCache &cache, MasterPort &port, SnoopRespPacketQueue &snoop_resp_queue, const std::string &label)
Definition: base.hh:173
SnoopRespPacketQueue & snoopRespQueue
Definition: base.hh:169
STL vector class.
Definition: stl.hh:40
Stats::Vector writebacks
Number of blocks written back per thread.
Definition: base.hh:1031
MemSidePort memSidePort
Definition: base.hh:313
Cycles calculateTagOnlyLatency(const uint32_t delay, const Cycles lookup_lat) const
Calculate latency of accesses that only touch the tag array.
Definition: base.cc:990
Stats::Scalar dataExpansions
Number of data expansions.
Definition: base.hh:1071
EventFunctionWrapper sendRetryEvent
Definition: base.hh:277
CacheCmdStats & cmdStats(const PacketPtr p)
Definition: base.hh:982
CacheBlk * allocateBlock(const PacketPtr pkt, PacketList &writebacks)
Allocate a new block and perform any necessary writebacks.
Definition: base.cc:1406
Addr getBlockAddr(unsigned int blk_size) const
Definition: packet.hh:750
Stats::Vector hits
Number of hits per thread for each type of command.
Definition: base.hh:943
RequestPtr req
A pointer to the original request.
Definition: packet.hh:327
virtual void memWriteback() override
Write back dirty blocks in the cache using functional accesses.
Definition: base.cc:1582
void markInService(WriteQueueEntry *entry)
Definition: base.hh:385
const Cycles responseLatency
The latency of sending reponse to its upper level cache/core on a linefill.
Definition: base.hh:872
Stats::Vector mshr_uncacheable_lat
Total cycle latency of each MSHR miss, per command and thread.
Definition: base.hh:967
WriteMode
The current mode for write coalescing and allocation, either normal operation (ALLOCATE), write coalescing (COALESCE), or write coalescing without allocation (NO_ALLOCATE).
Definition: base.hh:1390
Stats::Formula demandMshrMissRate
The demand miss rate in the MSHRs.
Definition: base.hh:1055
ProbePointArg< PacketPtr > * ppFill
To probe when a cache fill occurs.
Definition: base.hh:339
Declaration of a common base class for cache tagstore objects.
virtual void recvTimingReq(PacketPtr pkt)
Performs the access specified by the request.
Definition: base.cc:337
void invalidateVisitor(CacheBlk &blk)
Cache block visitor that invalidates all blocks in the cache.
Definition: base.cc:1629
A coherent cache that can be arranged in flexible topologies.
Definition: cache.hh:69
Declaration of the queued port.
virtual Tick recvAtomic(PacketPtr pkt)
Performs the access specified by the request.
Definition: base.cc:543
Cycles blockedCycle
Stores time the cache blocked for statistics.
Definition: base.hh:910
const uint32_t coalesceLimit
Limits for when to switch between the different write modes.
Definition: base.hh:1409
A cache master port is used for the memory-side port of the cache, and in addition to the basic timin...
Definition: base.hh:126
A Basic Cache block.
Definition: cache_blk.hh:87
#define M5_NODISCARD
Definition: compiler.hh:88
Stats::Vector mshr_misses
Number of misses that miss in the MSHRs, per command and thread.
Definition: base.hh:961
PacketPtr tempBlockWriteback
Writebacks from the tempBlock, resulting on the response path in atomic mode, must happen after the c...
Definition: base.hh:639
CacheMasterPort(const std::string &_name, BaseCache *_cache, ReqPacketQueue &_reqQueue, SnoopRespPacketQueue &_snoopRespQueue)
Definition: base.hh:143
bool isBlocked() const
Definition: base.hh:259
Stats::Vector blocked_causes
The number of times this cache blocked for each blocked cause.
Definition: base.hh:1021
Stats::Formula avg_blocked
The average number of cycles blocked for each blocked cause.
Definition: base.hh:1024
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: base.cc:1806
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:61
bool inRange(Addr addr) const
Determine if an address is in the ranges covered by this cache.
Definition: base.cc:203
const bool sequentialAccess
Whether tags and data are accessed sequentially.
Definition: base.hh:877
virtual void recvTimingSnoopResp(PacketPtr pkt)=0
Handle a snoop response.
uint64_t Tick
Tick count type.
Definition: types.hh:63
WriteMode mode
Definition: base.hh:1395
void incMissCount(PacketPtr pkt)
Definition: base.hh:1224
BaseCache * cache
Definition: base.hh:290
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
PacketPtr writecleanBlk(CacheBlk *blk, Request::Flags dest, PacketId id)
Create a writeclean request for the given block.
Definition: base.cc:1536
Miss Status and handling Register.
Definition: mshr.hh:72
void markInService(MSHR *mshr, bool pending_modified_resp)
Mark the given MSHR as in service.
Definition: mshr_queue.cc:99
ClockedObject declaration and implementation.
Stats::Formula demandMshrHits
Demand misses that hit in the MSHRs.
Definition: base.hh:1034
Stats::Formula overallAvgMissLatency
The average miss latency for all misses.
Definition: base.hh:1016
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:369
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
void allocateWriteBuffer(PacketPtr pkt, Tick time)
Definition: base.hh:1119
A basic cache interface.
Definition: base.hh:93
Stats::Vector blocked_cycles
The total number of cycles blocked for each blocked cause.
Definition: base.hh:1019
CacheReqPacketQueue _reqQueue
The cache-specific queue.
Definition: base.hh:217
void cmpAndSwap(CacheBlk *blk, PacketPtr pkt)
Handle doing the Compare and Swap function for SPARC.
Definition: base.cc:680
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.
Stats::Formula overallHits
Number of hit for all accesses.
Definition: base.hh:991
virtual void handleTimingReqHit(PacketPtr pkt, CacheBlk *blk, Tick request_time)
Definition: base.cc:214
Stats::Formula overallMissRate
The miss rate for all accesses.
Definition: base.hh:1011
Stats::Formula overallAccesses
The number of overall accesses.
Definition: base.hh:1006
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:194
virtual void memInvalidate() override
Invalidates all blocks in the cache.
Definition: base.cc:1588
Stats::Formula demandAvgMissLatency
The average miss latency for demand misses.
Definition: base.hh:1014
bool isLLSC() const
Definition: packet.hh:221
void reset()
Reset the write allocator state, meaning that it allocates for writes and has not recorded any inform...
Definition: base.hh:1342
void setBlocked()
Do not accept any new requests.
Definition: base.cc:135
uint8_t blocked
Bit vector of the blocking reasons for the access path.
Definition: base.hh:904
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void schedMemSideSendEvent(Tick time)
Schedule a send event for the memory-side port.
Definition: base.hh:1202
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
Definition: packet.hh:384
Base cache compressor interface.
Definition: base.hh:54
uint32_t byteCount
Bytes written contiguously.
Definition: base.hh:1404
CacheBlk * handleFill(PacketPtr pkt, CacheBlk *blk, PacketList &writebacks, bool allocate)
Handle a fill operation caused by a received packet.
Definition: base.cc:1309
const bool writebackClean
Determine if clean lines should be written back or not.
Definition: base.hh:630
WriteAllocator(const WriteAllocatorParams *p)
Definition: base.hh:1308
const unsigned blkSize
Block size of this cache.
Definition: base.hh:843
int64_t Counter
Statistics counter type.
Definition: types.hh:58
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
void recvTimingSnoopReq(PacketPtr pkt) override
Receive a timing snoop request from the peer.
Definition: port.hh:237
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:166
Statistics container.
Definition: group.hh:85
Stats::Vector misses
Number of misses per thread for each type of command.
Definition: base.hh:946
uint64_t order
Increasing order number assigned to each incoming request.
Definition: base.hh:907
Stats::Formula demandMisses
Number of misses for demand accesses.
Definition: base.hh:994
virtual M5_NODISCARD PacketPtr evictBlock(CacheBlk *blk)=0
Evict a cache block.
MasterID maxMasters()
Get the number of masters registered in the system.
Definition: system.hh:412
TempCacheBlk * tempBlock
Temporary cache block for occasional transitory use.
Definition: base.hh:363
int cmdToIndex() const
Return the index of this command.
Definition: packet.hh:526
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3012
const uint32_t delayThreshold
The number of times the allocator will delay an WriteReq MSHR.
Definition: base.hh:1414
A queue entry base class, to be used by both the MSHRs and write-queue entries.
Definition: queue_entry.hh:61
virtual void doWritebacksAtomic(PacketList &writebacks)=0
Send writebacks down the memory hierarchy in atomic mode.
Definitions of a simple cache block class.
Override the default behaviour of sendDeferredPacket to enable the memory-side cache port to also sen...
Definition: base.hh:163
ProbePointArg< PacketPtr > * ppHit
To probe when a cache hit occurs.
Definition: base.hh:333
const AddrRangeList & getAddrRanges() const
Definition: base.hh:1099
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:907
Stats::Formula mshrMissRate
The miss rate in the MSHRs pre command and thread.
Definition: base.hh:969
ProbePointArg generates a point for the class of Arg.
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:90
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:375
Bitfield< 29 > c
ReqPacketQueue & reqQueue
Packet queue used to store outgoing requests.
Definition: qport.hh:114
Stats::Formula missRate
The miss rate per command and thread.
Definition: base.hh:955
bool allocOnFill(MemCmd cmd) const
Determine whether we should allocate on a fill or not.
Definition: base.hh:408
AddrRangeList getAddrRanges() const
Get the address ranges of the connected slave port.
Definition: port.cc:93
Stats::Formula avgMshrMissLatency
The average latency of an MSHR miss, per command and thread.
Definition: base.hh:971
Declaration of the Packet class.
A cache slave port is used for the CPU-side port of the cache, and it is basically a simple timing po...
Definition: base.hh:248
std::ostream CheckpointOut
Definition: serialize.hh:68
virtual void doWritebacks(PacketList &writebacks, Tick forward_time)=0
Insert writebacks into the write buffer.
void serialize(CheckpointOut &cp) const override
Serialize the state of the caches.
Definition: base.cc:1786
void schedSendEvent(Tick time)
Schedule a send of a request packet (from the MSHR).
Definition: base.hh:135
void setBlocked(BlockedCause cause)
Marks the access path of the cache as blocked for the given cause.
Definition: base.hh:1164
void print(std::ostream &o, int verbosity=0, const std::string &prefix="") const
Definition: packet.cc:376
MemCmd cmd
The command field of the packet.
Definition: packet.hh:322
The write allocator inspects write packets and detects streaming patterns.
Definition: base.hh:1306
Stats::Formula avgMissLatency
The average miss latency per command and thread.
Definition: base.hh:957
RespPacketQueue queue
A normal packet queue used to store responses.
Definition: base.hh:267
bool inMissQueue(Addr addr, bool is_secure) const
Definition: base.hh:1220
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:106
Stats::Formula accesses
The number of accesses per command and thread.
Definition: base.hh:953
Tick deferredPacketReadyTime() const
Get the next packet ready time.
BlockedCause
Reasons for caches to be blocked.
Definition: base.hh:108
bool checkConflict(const PacketPtr pkt, const int blk_size) const
Check if a packet corresponding to the same address exists in the queue.
Definition: packet_queue.cc:75
MSHRQueueIndex
Indexes to enumerate the MSHR queues.
Definition: base.hh:99
Stats::Formula overallMshrMissRate
The overall miss rate in the MSHRs.
Definition: base.hh:1057
~BaseCache()
Definition: base.cc:129
const int numTarget
The number of targets for each MSHR.
Definition: base.hh:880
virtual bool sendMSHRQueuePacket(MSHR *mshr)
Take an MSHR, turn it into a suitable downstream packet, and send it out.
Definition: base.cc:1659
const Cycles forwardLatency
This is the forward latency of the cache.
Definition: base.hh:862
unsigned getBlockSize() const
Query block size of a cache.
Definition: base.hh:1094
bool coalesce() const
Should writes be coalesced? This is true if the mode is set to NO_ALLOCATE.
Definition: base.hh:1323
bool inCache(Addr addr, bool is_secure) const
Definition: base.hh:1207
void resetDelay(Addr blk_addr)
Clear delay counter for the input block.
Definition: base.hh:1368
bool isSecure() const
Definition: packet.hh:755
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
Stats::Formula overallMshrHits
Total number of misses that hit in the MSHRs.
Definition: base.hh:1036
Stats::Formula demandAccesses
The number of demand accesses.
Definition: base.hh:1004
Counter missCount
The number of misses to trigger an exit event.
Definition: base.hh:916
virtual bool isSnooping() const
Memory-side port always snoops.
Definition: base.hh:154
Stats::Scalar unusedPrefetches
The number of times a HW-prefetched block is evicted w/o reference.
Definition: base.hh:1028
virtual void serviceMSHRTargets(MSHR *mshr, const PacketPtr pkt, CacheBlk *blk)=0
Service non-deferred MSHR targets using the received response.
Addr regenerateBlkAddr(CacheBlk *blk)
Regenerate block address using tags.
Definition: base.cc:172
virtual bool recvTimingResp(PacketPtr pkt)=0
Receive a timing response from the peer.
SnoopRespPacketQueue _snoopRespQueue
Definition: base.hh:219
Tick nextQueueReadyTime() const
Find next request ready time from among possible sources.
Definition: base.cc:1642
bool isPrefetch() const
Definition: packet.hh:224
Write queue entry.
BaseCacheCompressor * compressor
Compression method being used.
Definition: base.hh:327
void writebackTempBlockAtomic()
Send the outstanding tempBlock writeback.
Definition: base.hh:646
bool wasPrefetched() const
Check if this block was the result of a hardware prefetch, yet to be touched.
Definition: cache_blk.hh:239
Stats::Formula demandMissRate
The miss rate of all demand accesses.
Definition: base.hh:1009
BasePrefetcher * prefetcher
Prefetcher.
Definition: base.hh:330
Bitfield< 0 > p
A common base class of Cache tagstore objects.
Definition: base.hh:73
Addr nextAddr
Address to match writes against to detect streams.
Definition: base.hh:1398
const char data[]
WriteQueueEntry * allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, Tick when_ready, Counter order)
Allocates a new WriteQueueEntry for the request and size.
Definition: write_queue.cc:61
uint64_t PacketId
Definition: packet.hh:74
void handleUncacheableWriteResp(PacketPtr pkt)
Handling the special case of uncacheable write responses to make recvTimingResp less cluttered...
Definition: base.cc:393
void incHitCount(PacketPtr pkt)
Definition: base.hh:1235
bool isDirty() const
Determine if there are any dirty blocks in the cache.
Definition: base.cc:1594
bool delay(Addr blk_addr)
Access whether we need to delay the current write.
Definition: base.hh:1354
bool hasBeenPrefetched(Addr addr, bool is_secure) const
Definition: base.hh:1211
Stats::Formula demandAvgMshrMissLatency
The average latency of a demand MSHR miss.
Definition: base.hh:1060
Abstract superclass for simulation objects.
Definition: sim_object.hh:96
BaseTags * tags
Tag and data Storage.
Definition: base.hh:324
bool isFull() const
Definition: queue.hh:148
Stats::Vector mshr_uncacheable
Number of misses that miss in the MSHRs, per command and thread.
Definition: base.hh:963
void clearBlocked(BlockedCause cause)
Marks the cache as unblocked for the given cause.
Definition: base.hh:1183
virtual void functionalAccess(PacketPtr pkt, bool from_cpu_side)
Performs the access specified by the request.
Definition: base.cc:623
MSHRQueue mshrQueue
Miss status registers.
Definition: base.hh:318
The CPU-side port extends the base cache slave port with access functions for functional, atomic and timing requests.
Definition: base.hh:285
void maintainClusivity(bool from_cache, CacheBlk *blk)
Maintain the clusivity of this cache by potentially invalidating a block.
Definition: base.cc:1297
Stats::Formula demandMshrMissLatency
Total cycle latency of demand MSHR misses.
Definition: base.hh:1047
Stats::Formula overallMisses
Number of misses for all accesses.
Definition: base.hh:996
Stats::Formula overallAvgMshrMissLatency
The average overall latency of an MSHR miss.
Definition: base.hh:1062
void clearBlocked()
Return to normal operation and accept new requests.
Definition: base.cc:150

Generated on Fri Feb 28 2020 16:26:58 for gem5 by doxygen 1.8.13