46 #ifndef __MEM_CACHE_BASE_HH__ 47 #define __MEM_CACHE_BASE_HH__ 57 #include "debug/Cache.hh" 58 #include "debug/CachePort.hh" 59 #include "enums/Clusivity.hh" 70 #include "params/WriteAllocator.hh" 84 struct BaseCacheParams;
105 Blocked_NoMSHRs = MSHRQueue_MSHRs,
106 Blocked_NoWBBuffers = MSHRQueue_WriteBuffer,
133 DPRINTF(CachePort,
"Scheduling send event at %llu\n", time);
134 reqQueue.schedSendEvent(time);
171 const std::string &label) :
173 snoopRespQueue(snoop_resp_queue) { }
180 virtual void sendDeferredPacket();
193 DPRINTF(CachePort,
"Waiting for snoop response to be " 196 schedSendEvent(when);
222 virtual void recvTimingSnoopReq(
PacketPtr pkt);
224 virtual bool recvTimingResp(
PacketPtr pkt);
228 virtual void recvFunctionalSnoop(
PacketPtr pkt);
233 const std::string &_label);
260 const std::string &_label);
271 void processSendRetry();
289 virtual bool recvTimingSnoopResp(
PacketPtr pkt)
override;
291 virtual bool tryTiming(
PacketPtr pkt)
override;
293 virtual bool recvTimingReq(
PacketPtr pkt)
override;
297 virtual void recvFunctional(
PacketPtr pkt)
override;
304 const std::string &_label);
373 bool wasFull = mshrQueue.
isFull();
376 if (wasFull && !mshrQueue.
isFull()) {
377 clearBlocked(Blocked_NoMSHRs);
383 bool wasFull = writeBuffer.
isFull();
386 if (wasFull && !writeBuffer.
isFull()) {
387 clearBlocked(Blocked_NoWBBuffers);
406 return clusivity == Enums::mostly_incl ||
432 Cycles calculateTagOnlyLatency(
const uint32_t delay,
433 const Cycles lookup_lat)
const;
443 Cycles calculateAccessLatency(
const CacheBlk* blk,
const uint32_t delay,
444 const Cycles lookup_lat)
const;
480 Tick request_time) = 0;
494 Tick forward_time,
Tick request_time);
500 virtual void recvTimingReq(
PacketPtr pkt);
506 void handleUncacheableWriteResp(
PacketPtr pkt);
518 virtual void serviceMSHRTargets(
MSHR *mshr,
const PacketPtr pkt,
525 virtual void recvTimingResp(
PacketPtr pkt);
531 virtual void recvTimingSnoopReq(
PacketPtr pkt) = 0;
537 virtual void recvTimingSnoopResp(
PacketPtr pkt) = 0;
575 virtual void functionalAccess(
PacketPtr pkt,
bool from_cpu_side);
593 virtual void doWritebacks(
PacketList& writebacks,
Tick forward_time) = 0;
598 virtual void doWritebacksAtomic(
PacketList& writebacks) = 0;
617 bool is_whole_line_write)
const = 0;
643 assert(tempBlockWriteback !=
nullptr);
645 doWritebacksAtomic(writebacks);
646 tempBlockWriteback =
nullptr;
680 bool updateCompressionData(
CacheBlk *blk,
const uint64_t*
data,
694 bool deferred_response =
false,
695 bool pending_downgrade =
false);
706 void maintainClusivity(
bool from_cache,
CacheBlk *blk);
779 void invalidateBlock(
CacheBlk *blk);
805 virtual void memWriteback()
override;
814 virtual void memInvalidate()
override;
821 bool isDirty()
const;
836 Tick nextQueueReadyTime()
const;
933 void regStatsFromParent();
976 void regStats()
override;
1074 void regProbePoints()
override;
1077 BaseCache(
const BaseCacheParams *
p,
unsigned blk_size);
1080 void init()
override;
1082 Port &getPort(
const std::string &if_name,
1101 allocOnFill(pkt->cmd));
1103 if (mshrQueue.
isFull()) {
1109 schedMemSideSendEvent(time);
1137 writeBuffer.
allocate(blk_addr, blkSize, pkt, time, order++);
1139 if (writeBuffer.
isFull()) {
1144 schedMemSideSendEvent(time);
1152 return blocked != 0;
1162 uint8_t flag = 1 << cause;
1164 stats.blocked_causes[cause]++;
1165 blockedCycle = curCycle();
1169 DPRINTF(
Cache,
"Blocking for cause %d, mask=%d\n", cause, blocked);
1181 uint8_t flag = 1 << cause;
1183 DPRINTF(
Cache,
"Unblocking for cause %d, mask=%d\n", cause, blocked);
1185 stats.blocked_cycles[cause] += curCycle() - blockedCycle;
1204 return tags->
findBlock(addr, is_secure);
1217 return mshrQueue.
findMatch(addr, is_secure);
1223 stats.cmdStats(pkt).misses[pkt->
req->masterId()]++;
1224 pkt->
req->incAccessDepth();
1228 exitSimLoop(
"A cache reached the maximum miss count");
1234 stats.cmdStats(pkt).hits[pkt->
req->masterId()]++;
1242 bool coalesce()
const;
1249 void writebackVisitor(
CacheBlk &blk);
1256 void invalidateVisitor(
CacheBlk &blk);
1266 virtual bool sendMSHRQueuePacket(
MSHR* mshr);
1306 coalesceLimit(p->coalesce_limit * p->block_size),
1307 noAllocateLimit(p->no_allocate_limit * p->block_size),
1308 delayThreshold(p->delay_threshold)
1320 return mode != WriteMode::ALLOCATE;
1329 return mode != WriteMode::NO_ALLOCATE;
1339 mode = WriteMode::ALLOCATE;
1351 if (delayCtr[blk_addr] > 0) {
1352 --delayCtr[blk_addr];
1365 delayCtr.erase(blk_addr);
1378 void updateMode(
Addr write_addr,
unsigned write_size,
Addr blk_addr);
1419 #endif //__MEM_CACHE_BASE_HH__ A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Stats::Formula demandMissLatency
Total number of cycles spent waiting for demand misses.
bool forwardSnoops
Do we forward snoops from mem side port through to cpu side port?
Ports are used to interface objects to each other.
std::unordered_map< Addr, Counter > delayCtr
Keep track of the number of times the allocator has delayed an WriteReq MSHR.
Special instance of CacheBlk for use with tempBlk that deals with its block address regeneration...
Declaration of a simple PacketQueue that is associated with a port on which it attempts to send packe...
bool inService
True if the entry has been sent downstream.
Cycles is a wrapper class for representing cycle counts, i.e.
Stats::Formula demandHits
Number of hits for demand accesses.
A Class for maintaining a list of pending and allocated memory requests.
Stats::Vector missLatency
Total number of cycles per thread/command spent waiting for a miss.
const std::string & name()
Stats::Formula avgMshrUncacheableLatency
The average latency of an MSHR miss, per command and thread.
const PortID InvalidPortID
The memory-side port extends the base cache master port with access functions for functional...
WriteQueue writeBuffer
Write/writeback buffer.
Stats::Formula overallMshrMissLatency
Total cycle latency of overall MSHR misses.
Stats::Vector mshr_miss_latency
Total cycle latency of each MSHR miss, per command and thread.
Stats::Scalar replacements
Number of replacements of valid blocks.
MSHR * noTargetMSHR
Pointer to the MSHR that has no targets.
Stats::Formula overallMshrUncacheableLatency
Total cycle latency of overall MSHR misses.
const Cycles lookupLatency
The latency of tag lookup of a cache.
std::vector< std::unique_ptr< CacheCmdStats > > cmd
Per-command statistics.
A write queue for all eviction packets, i.e.
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.
EventFunctionWrapper writebackTempBlockAtomicEvent
An event to writeback the tempBlock after recvAtomic finishes.
const Enums::Clusivity clusivity
Clusivity with respect to the upstream cache, determining if we fill into both this cache and the cac...
Stats::Formula demandMshrMisses
Demand misses that miss in the MSHRs.
The QueuedMasterPort combines two queues, a request queue and a snoop response queue, that both share the same port.
System * system
System we are currently operating in.
const bool isReadOnly
Is this cache read only, for example the instruction cache, or table-walker cache.
ProbePointArg< PacketPtr > * ppMiss
To probe when a cache miss occurs.
const AddrRangeList addrRanges
The address range to which the cache responds on the CPU side.
Stats::Formula overallMshrMisses
Total number of misses that miss in the MSHRs.
Stats::Formula overallMshrUncacheable
Total number of misses that miss in the MSHRs.
Definition of a basic cache compressor.
MSHR * allocateMissBuffer(PacketPtr pkt, Tick time, bool sched_send=true)
A vector of scalar stats.
bool allocate() const
Should writes allocate?
bool isBlocked() const
Returns true if the cache is blocked for accesses.
A queued port is a port that has an infinite queue for outgoing packets and thus decouples the module...
const Cycles dataLatency
The latency of data access of a cache.
const Cycles fillLatency
The latency to fill a cache block.
WriteAllocator *const writeAllocator
The writeAllocator drive optimizations for streaming writes.
void markInService(WriteQueueEntry *entry)
Mark the given entry as in service.
Stats::Formula overallMissLatency
Total number of cycles spent waiting for all misses.
Declaration of a structure to manage MSHRs.
Stats::Formula overallAvgMshrUncacheableLatency
The average overall latency of an MSHR miss.
const uint32_t noAllocateLimit
Declaration of Statistics objects.
Prefetcher::Base * prefetcher
Prefetcher.
This is a simple scalar statistic, like a counter.
CacheReqPacketQueue(BaseCache &cache, MasterPort &port, SnoopRespPacketQueue &snoop_resp_queue, const std::string &label)
SnoopRespPacketQueue & snoopRespQueue
Stats::Vector writebacks
Number of blocks written back per thread.
Stats::Scalar dataExpansions
Number of data expansions.
EventFunctionWrapper sendRetryEvent
CacheCmdStats & cmdStats(const PacketPtr p)
Addr getBlockAddr(unsigned int blk_size) const
Stats::Vector hits
Number of hits per thread for each type of command.
RequestPtr req
A pointer to the original request.
void markInService(WriteQueueEntry *entry)
const Cycles responseLatency
The latency of sending reponse to its upper level cache/core on a linefill.
Stats::Vector mshr_uncacheable_lat
Total cycle latency of each MSHR miss, per command and thread.
WriteMode
The current mode for write coalescing and allocation, either normal operation (ALLOCATE), write coalescing (COALESCE), or write coalescing without allocation (NO_ALLOCATE).
Stats::Formula demandMshrMissRate
The demand miss rate in the MSHRs.
ProbePointArg< PacketPtr > * ppFill
To probe when a cache fill occurs.
A coherent cache that can be arranged in flexible topologies.
Declaration of the queued port.
Cycles blockedCycle
Stores time the cache blocked for statistics.
const uint32_t coalesceLimit
Limits for when to switch between the different write modes.
A cache master port is used for the memory-side port of the cache, and in addition to the basic timin...
Stats::Vector mshr_misses
Number of misses that miss in the MSHRs, per command and thread.
PacketPtr tempBlockWriteback
Writebacks from the tempBlock, resulting on the response path in atomic mode, must happen after the c...
CacheMasterPort(const std::string &_name, BaseCache *_cache, ReqPacketQueue &_reqQueue, SnoopRespPacketQueue &_snoopRespQueue)
Stats::Vector blocked_causes
The number of times this cache blocked for each blocked cause.
Stats::Formula avg_blocked
The average number of cycles blocked for each blocked cause.
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.
const bool sequentialAccess
Whether tags and data are accessed sequentially.
uint64_t Tick
Tick count type.
void incMissCount(PacketPtr pkt)
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Miss Status and handling Register.
void markInService(MSHR *mshr, bool pending_modified_resp)
Mark the given MSHR as in service.
ClockedObject declaration and implementation.
Stats::Formula demandMshrHits
Demand misses that hit in the MSHRs.
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
Stats::Formula overallAvgMissLatency
The average miss latency for all misses.
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
void allocateWriteBuffer(PacketPtr pkt, Tick time)
Stats::Vector blocked_cycles
The total number of cycles blocked for each blocked cause.
CacheReqPacketQueue _reqQueue
The cache-specific queue.
Stats::Formula overallHits
Number of hit for all accesses.
Stats::Formula overallMissRate
The miss rate for all accesses.
Stats::Formula overallAccesses
The number of overall accesses.
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...
Stats::Formula demandAvgMissLatency
The average miss latency for demand misses.
void reset()
Reset the write allocator state, meaning that it allocates for writes and has not recorded any inform...
void setBlocked()
Do not accept any new requests.
uint8_t blocked
Bit vector of the blocking reasons for the access path.
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.
void schedMemSideSendEvent(Tick time)
Schedule a send event for the memory-side port.
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
Base cache compressor interface.
uint32_t byteCount
Bytes written contiguously.
const bool writebackClean
Determine if clean lines should be written back or not.
WriteAllocator(const WriteAllocatorParams *p)
const unsigned blkSize
Block size of this cache.
int64_t Counter
Statistics counter type.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Entry * findMatch(Addr blk_addr, bool is_secure, bool ignore_uncacheable=true) const
Find the first entry that matches the provided address.
Stats::Vector misses
Number of misses per thread for each type of command.
uint64_t order
Increasing order number assigned to each incoming request.
Stats::Formula demandMisses
Number of misses for demand accesses.
MasterID maxMasters()
Get the number of masters registered in the system.
TempCacheBlk * tempBlock
Temporary cache block for occasional transitory use.
int cmdToIndex() const
Return the index of this command.
const uint32_t delayThreshold
The number of times the allocator will delay an WriteReq MSHR.
A queue entry base class, to be used by both the MSHRs and write-queue entries.
Definitions of a simple cache block class.
Override the default behaviour of sendDeferredPacket to enable the memory-side cache port to also sen...
ProbePointArg< PacketPtr > * ppHit
To probe when a cache hit occurs.
const AddrRangeList & getAddrRanges() const
Stats::Formula mshrMissRate
The miss rate in the MSHRs pre command and thread.
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 (...
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...
Stats::Formula missRate
The miss rate per command and thread.
bool allocOnFill(MemCmd cmd) const
Determine whether we should allocate on a fill or not.
Stats::Formula avgMshrMissLatency
The average latency of an MSHR miss, per command and thread.
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...
std::ostream CheckpointOut
void schedSendEvent(Tick time)
Schedule a send of a request packet (from the MSHR).
void setBlocked(BlockedCause cause)
Marks the access path of the cache as blocked for the given cause.
void print(std::ostream &o, int verbosity=0, const std::string &prefix="") const
MemCmd cmd
The command field of the packet.
The write allocator inspects write packets and detects streaming patterns.
Stats::Formula avgMissLatency
The average miss latency per command and thread.
RespPacketQueue queue
A normal packet queue used to store responses.
bool inMissQueue(Addr addr, bool is_secure) const
Stats::Formula accesses
The number of accesses per command and thread.
Tick deferredPacketReadyTime() const
Get the next packet ready time.
BlockedCause
Reasons for caches to be blocked.
bool checkConflict(const PacketPtr pkt, const int blk_size) const
Check if a packet corresponding to the same address exists in the queue.
MSHRQueueIndex
Indexes to enumerate the MSHR queues.
Stats::Formula overallMshrMissRate
The overall miss rate in the MSHRs.
const int numTarget
The number of targets for each MSHR.
const Cycles forwardLatency
This is the forward latency of the cache.
unsigned getBlockSize() const
Query block size of a cache.
bool coalesce() const
Should writes be coalesced? This is true if the mode is set to NO_ALLOCATE.
void unserialize(ThreadContext &tc, CheckpointIn &cp)
bool inCache(Addr addr, bool is_secure) const
void resetDelay(Addr blk_addr)
Clear delay counter for the input block.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Stats::Formula overallMshrHits
Total number of misses that hit in the MSHRs.
Stats::Formula demandAccesses
The number of demand accesses.
Counter missCount
The number of misses to trigger an exit event.
virtual bool isSnooping() const
Memory-side port always snoops.
Stats::Scalar unusedPrefetches
The number of times a HW-prefetched block is evicted w/o reference.
SnoopRespPacketQueue _snoopRespQueue
Copyright (c) 2018 Metempsy Technology Consulting All rights reserved.
BaseCacheCompressor * compressor
Compression method being used.
void writebackTempBlockAtomic()
Send the outstanding tempBlock writeback.
bool wasPrefetched() const
Check if this block was the result of a hardware prefetch, yet to be touched.
Stats::Formula demandMissRate
The miss rate of all demand accesses.
Addr nextAddr
Address to match writes against to detect streams.
WriteQueueEntry * allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, Tick when_ready, Counter order)
Allocates a new WriteQueueEntry for the request and size.
void incHitCount(PacketPtr pkt)
bool delay(Addr blk_addr)
Access whether we need to delay the current write.
bool hasBeenPrefetched(Addr addr, bool is_secure) const
Stats::Formula demandAvgMshrMissLatency
The average latency of a demand MSHR miss.
Abstract superclass for simulation objects.
BaseTags * tags
Tag and data Storage.
const FlagsType init
This Stat is Initialized.
Stats::Vector mshr_uncacheable
Number of misses that miss in the MSHRs, per command and thread.
void clearBlocked(BlockedCause cause)
Marks the cache as unblocked for the given cause.
MSHRQueue mshrQueue
Miss status registers.
The CPU-side port extends the base cache slave port with access functions for functional, atomic and timing requests.
Stats::Formula demandMshrMissLatency
Total cycle latency of demand MSHR misses.
Stats::Formula overallMisses
Number of misses for all accesses.
Stats::Formula overallAvgMshrMissLatency
The average overall latency of an MSHR miss.
void clearBlocked()
Return to normal operation and accept new requests.