50 #include "debug/Cache.hh" 51 #include "debug/CacheComp.hh" 52 #include "debug/CachePort.hh" 53 #include "debug/CacheRepl.hh" 54 #include "debug/CacheVerbose.hh" 60 #include "params/BaseCache.hh" 61 #include "params/WriteAllocator.hh" 68 const std::string &_label)
70 queue(*_cache, *this, true, _label),
71 blocked(false), mustSendRetry(false),
80 mshrQueue(
"MSHRs", p->mshrs, 0, p->demand_mshr_reserve),
81 writeBuffer(
"write buffer", p->write_buffers, p->mshrs),
106 addrRanges(
p->addr_ranges.begin(),
p->addr_ranges.end()),
135 DPRINTF(CachePort,
"Port is blocking new requests\n");
139 if (sendRetryEvent.scheduled()) {
140 owner.deschedule(sendRetryEvent);
141 DPRINTF(CachePort,
"Port descheduled retry\n");
142 mustSendRetry =
true;
150 DPRINTF(CachePort,
"Port is accepting new requests\n");
154 owner.schedule(sendRetryEvent,
curTick() + 1);
161 DPRINTF(CachePort,
"Port is sending retry\n");
164 mustSendRetry =
false;
182 fatal(
"Cache ports on %s are not connected\n",
name());
190 if (if_name ==
"mem_side") {
192 }
else if (if_name ==
"cpu_side") {
203 if (
r.contains(addr)) {
227 DPRINTF(
Cache,
"%s satisfied %s, no response needed\n", __func__,
240 Tick forward_time,
Tick request_time)
243 pkt && pkt->
isWrite() && !pkt->
req->isUncacheable()) {
322 pkt->
req->isCacheMaintenance());
342 bool satisfied =
false;
347 satisfied =
access(pkt, blk, lat, writebacks);
409 "%s saw a non-zero packet delay\n",
name());
411 const bool is_error = pkt->
isError();
414 DPRINTF(
Cache,
"%s: Cache received %s with error\n", __func__,
424 assert(pkt->
req->isUncacheable());
443 if (pkt->
req->isUncacheable()) {
465 if (is_fill && !is_error) {
466 DPRINTF(
Cache,
"Block for addr %#llx being updated in Cache\n",
471 blk =
handleFill(pkt, blk, writebacks, allocate);
472 assert(blk !=
nullptr);
488 if (blk && blk->isWritable() && !pkt->
req->isCacheInvalidate()) {
534 DPRINTF(CacheVerbose,
"%s: Leaving with %s\n", __func__, pkt->
print());
552 bool satisfied =
access(pkt, blk, lat, writebacks);
559 DPRINTF(CacheVerbose,
"%s: packet %s found block: %s\n",
562 writebacks.push_back(wb_pkt);
569 assert(writebacks.empty());
637 bool have_data = blk && blk->
isValid()
644 have_data && (blk->
isDirty() ||
647 bool done = have_dirty ||
653 DPRINTF(CacheVerbose,
"%s: %s %s%s%s\n", __func__, pkt->
print(),
654 (blk && blk->
isValid()) ?
"valid " :
"",
655 have_data ?
"data " :
"", done ?
"done " :
"");
681 uint64_t overwrite_val;
683 uint64_t condition_val64;
684 uint32_t condition_val32;
689 assert(
sizeof(uint64_t) >= pkt->
getSize());
691 overwrite_mem =
true;
694 pkt->
writeData((uint8_t *)&overwrite_val);
697 if (pkt->
req->isCondSwap()) {
698 if (pkt->
getSize() ==
sizeof(uint64_t)) {
699 condition_val64 = pkt->
req->getExtraData();
700 overwrite_mem = !std::memcmp(&condition_val64, blk_data,
702 }
else if (pkt->
getSize() ==
sizeof(uint32_t)) {
703 condition_val32 = (uint32_t)pkt->
req->getExtraData();
704 overwrite_mem = !std::memcmp(&condition_val32, blk_data,
707 panic(
"Invalid size for conditional read/write\n");
711 std::memcpy(blk_data, &overwrite_val, pkt->
getSize());
731 if (conflict_mshr && conflict_mshr->
order < wq_entry->
order) {
733 return conflict_mshr;
740 }
else if (miss_mshr) {
756 return conflict_mshr;
766 assert(!miss_mshr && !wq_entry);
798 bool replacement =
false;
799 for (
const auto& blk : evict_blks) {
800 if (blk->isValid()) {
821 for (
auto& blk : evict_blks) {
822 if (blk->isValid()) {
847 std::size_t compression_size = 0;
858 const std::size_t M5_VAR_USED prev_size = compression_blk->
getSizeBits();
861 const bool is_co_allocatable = superblock->
isCompressed(compression_blk) &&
870 const bool was_compressed = compression_blk->
isCompressed();
871 if (was_compressed && !is_co_allocatable) {
873 for (
const auto& sub_blk : superblock->
blks) {
874 if (sub_blk->isValid() && (compression_blk != sub_blk)) {
875 evict_blks.push_back(sub_blk);
887 DPRINTF(CacheComp,
"Data expansion: expanding [%s] from %d to %d bits" 888 "\n", blk->
print(), prev_size, compression_size);
892 if (is_co_allocatable) {
951 DPRINTF(CacheVerbose,
"%s for %s (write)\n", __func__, pkt->
print());
952 }
else if (pkt->
isRead()) {
976 DPRINTF(CacheVerbose,
"%s for %s (invalidation)\n", __func__,
988 const Cycles lookup_lat)
const 997 const Cycles lookup_lat)
const 1001 if (blk !=
nullptr) {
1015 if (when_ready > tick &&
1037 "Should never see a write in a read-only cache %s\n",
1045 blk ?
"hit " + blk->
print() :
"miss");
1047 if (pkt->
req->isCacheMaintenance()) {
1076 assert(wbPkt->isWriteback());
1120 DPRINTF(
Cache,
"Clean writeback %#llx to block with MSHR, " 1121 "dropping\n", pkt->
getAddr());
1286 pkt->
req->setExtraData(0);
1334 DPRINTF(
Cache,
"using temp block for %#llx (%s)\n", addr,
1335 is_secure ?
"s" :
"ns");
1345 assert(blk->
isSecure() == is_secure);
1378 "in read-only cache %s\n",
name());
1383 DPRINTF(
Cache,
"Block addr %#llx (%s) moving from state %x to %s\n",
1384 addr, is_secure ?
"s" :
"ns", old_state, blk->
print());
1409 const bool is_secure = pkt->
isSecure();
1414 std::size_t blk_size_bits =
blkSize*8;
1425 decompression_lat, blk_size_bits);
1438 DPRINTF(CacheRepl,
"Replacement victim: %s\n", victim->
print());
1480 writebacks.push_back(pkt);
1488 "Writeback from read-only cache");
1505 DPRINTF(
Cache,
"Create Writeback %s writable: %d, dirty: %d\n",
1546 req->setFlags(dest);
1608 RequestPtr request = std::make_shared<Request>(
1629 warn_once(
"Invalidating dirty cache lines. " \
1630 "Expect things to break.\n");
1647 nextReady = std::min(nextReady,
1676 DPRINTF(CacheVerbose,
"Delaying pkt %s %llu ticks to allow " 1677 "for write coalescing\n", tgt_pkt->
print(), delay);
1701 pkt =
new Packet(tgt_pkt,
false,
true);
1736 bool pending_modified_resp = !pkt->
hasSharers() &&
1745 DPRINTF(CacheVerbose,
"%s: packet %s found block: %s\n",
1750 writebacks.push_back(wb_pkt);
1788 warn(
"*** The cache still contains dirty data. ***\n");
1789 warn(
" Make sure to drain the system using the correct flags.\n");
1790 warn(
" This checkpoint will not restore correctly " \
1791 "and dirty data in the cache will be lost!\n");
1798 bool bad_checkpoint(dirty);
1805 bool bad_checkpoint;
1807 if (bad_checkpoint) {
1808 fatal(
"Restoring from checkpoints with dirty caches is not " 1809 "supported in the classic memory system. Please remove any " 1810 "caches or drain them properly before taking checkpoints.\n");
1816 const std::string &
name)
1820 this, (name +
"_hits").c_str(),
1821 (
"number of " + name +
" hits").c_str()),
1823 this, (name +
"_misses").c_str(),
1824 (
"number of " + name +
" misses").c_str()),
1826 this, (name +
"_miss_latency").c_str(),
1827 (
"number of " + name +
" miss cycles").c_str()),
1829 this, (name +
"_accesses").c_str(),
1830 (
"number of " + name +
" accesses(hits+misses)").c_str()),
1832 this, (name +
"_miss_rate").c_str(),
1833 (
"miss rate for " + name +
" accesses").c_str()),
1835 this, (name +
"_avg_miss_latency").c_str(),
1836 (
"average " + name +
" miss latency").c_str()),
1838 this, (name +
"_mshr_hits").c_str(),
1839 (
"number of " + name +
" MSHR hits").c_str()),
1841 this, (name +
"_mshr_misses").c_str(),
1842 (
"number of " + name +
" MSHR misses").c_str()),
1844 this, (name +
"_mshr_uncacheable").c_str(),
1845 (
"number of " + name +
" MSHR uncacheable").c_str()),
1847 this, (name +
"_mshr_miss_latency").c_str(),
1848 (
"number of " + name +
" MSHR miss cycles").c_str()),
1849 mshr_uncacheable_lat(
1850 this, (name +
"_mshr_uncacheable_latency").c_str(),
1851 (
"number of " + name +
" MSHR uncacheable cycles").c_str()),
1853 this, (name +
"_mshr_miss_rate").c_str(),
1854 (
"mshr miss rate for " + name +
" accesses").c_str()),
1856 this, (name +
"_avg_mshr_miss_latency").c_str(),
1857 (
"average " + name +
" mshr miss latency").c_str()),
1858 avgMshrUncacheableLatency(
1859 this, (name +
"_avg_mshr_uncacheable_latency").c_str(),
1860 (
"average " + name +
" mshr uncacheable latency").c_str())
1867 using namespace Stats;
1871 const auto max_masters = system->
maxMasters();
1877 for (
int i = 0;
i < max_masters;
i++) {
1886 for (
int i = 0;
i < max_masters;
i++) {
1895 for (
int i = 0;
i < max_masters;
i++) {
1902 for (
int i = 0;
i < max_masters;
i++) {
1909 for (
int i = 0;
i < max_masters;
i++) {
1916 for (
int i = 0;
i < max_masters;
i++) {
1926 for (
int i = 0;
i < max_masters;
i++) {
1935 for (
int i = 0;
i < max_masters;
i++) {
1944 for (
int i = 0;
i < max_masters;
i++) {
1953 for (
int i = 0;
i < max_masters;
i++) {
1962 for (
int i = 0;
i < max_masters;
i++) {
1970 for (
int i = 0;
i < max_masters;
i++) {
1977 for (
int i = 0;
i < max_masters;
i++) {
1984 for (
int i = 0;
i < max_masters;
i++) {
1992 demandHits(this,
"demand_hits",
"number of demand (read+write) hits"),
1994 overallHits(this,
"overall_hits",
"number of overall hits"),
1995 demandMisses(this,
"demand_misses",
1996 "number of demand (read+write) misses"),
1997 overallMisses(this,
"overall_misses",
"number of overall misses"),
1998 demandMissLatency(this,
"demand_miss_latency",
1999 "number of demand (read+write) miss cycles"),
2000 overallMissLatency(this,
"overall_miss_latency",
2001 "number of overall miss cycles"),
2002 demandAccesses(this,
"demand_accesses",
2003 "number of demand (read+write) accesses"),
2004 overallAccesses(this,
"overall_accesses",
2005 "number of overall (read+write) accesses"),
2006 demandMissRate(this,
"demand_miss_rate",
2007 "miss rate for demand accesses"),
2008 overallMissRate(this,
"overall_miss_rate",
2009 "miss rate for overall accesses"),
2010 demandAvgMissLatency(this,
"demand_avg_miss_latency",
2011 "average overall miss latency"),
2012 overallAvgMissLatency(this,
"overall_avg_miss_latency",
2013 "average overall miss latency"),
2014 blocked_cycles(this,
"blocked_cycles",
2015 "number of cycles access was blocked"),
2016 blocked_causes(this,
"blocked",
"number of cycles access was blocked"),
2017 avg_blocked(this,
"avg_blocked_cycles",
2018 "average number of cycles each access was blocked"),
2019 unusedPrefetches(this,
"unused_prefetches",
2020 "number of HardPF blocks evicted w/o reference"),
2021 writebacks(this,
"writebacks",
"number of writebacks"),
2022 demandMshrHits(this,
"demand_mshr_hits",
2023 "number of demand (read+write) MSHR hits"),
2024 overallMshrHits(this,
"overall_mshr_hits",
2025 "number of overall MSHR hits"),
2026 demandMshrMisses(this,
"demand_mshr_misses",
2027 "number of demand (read+write) MSHR misses"),
2028 overallMshrMisses(this,
"overall_mshr_misses",
2029 "number of overall MSHR misses"),
2030 overallMshrUncacheable(this,
"overall_mshr_uncacheable_misses",
2031 "number of overall MSHR uncacheable misses"),
2032 demandMshrMissLatency(this,
"demand_mshr_miss_latency",
2033 "number of demand (read+write) MSHR miss cycles"),
2034 overallMshrMissLatency(this,
"overall_mshr_miss_latency",
2035 "number of overall MSHR miss cycles"),
2036 overallMshrUncacheableLatency(this,
"overall_mshr_uncacheable_latency",
2037 "number of overall MSHR uncacheable cycles"),
2038 demandMshrMissRate(this,
"demand_mshr_miss_rate",
2039 "mshr miss rate for demand accesses"),
2040 overallMshrMissRate(this,
"overall_mshr_miss_rate",
2041 "mshr miss rate for overall accesses"),
2042 demandAvgMshrMissLatency(this,
"demand_avg_mshr_miss_latency",
2043 "average overall mshr miss latency"),
2044 overallAvgMshrMissLatency(this,
"overall_avg_mshr_miss_latency",
2045 "average overall mshr miss latency"),
2046 overallAvgMshrUncacheableLatency(
2047 this,
"overall_avg_mshr_uncacheable_latency",
2048 "average overall mshr uncacheable latency"),
2049 replacements(this,
"replacements",
"number of replacements"),
2051 dataExpansions(this,
"data_expansions",
"number of data expansions"),
2052 cmd(
MemCmd::NUM_MEM_CMDS)
2061 using namespace Stats;
2066 const auto max_masters = system->
maxMasters();
2068 for (
auto &cs :
cmd)
2069 cs->regStatsFromParent();
2074 #define SUM_DEMAND(s) \ 2075 (cmd[MemCmd::ReadReq]->s + cmd[MemCmd::WriteReq]->s + \ 2076 cmd[MemCmd::WriteLineReq]->s + cmd[MemCmd::ReadExReq]->s + \ 2077 cmd[MemCmd::ReadCleanReq]->s + cmd[MemCmd::ReadSharedReq]->s) 2080 #define SUM_NON_DEMAND(s) \ 2081 (cmd[MemCmd::SoftPFReq]->s + cmd[MemCmd::HardPFReq]->s + \ 2082 cmd[MemCmd::SoftPFExReq]->s) 2086 for (
int i = 0;
i < max_masters;
i++) {
2092 for (
int i = 0;
i < max_masters;
i++) {
2098 for (
int i = 0;
i < max_masters;
i++) {
2104 for (
int i = 0;
i < max_masters;
i++) {
2110 for (
int i = 0;
i < max_masters;
i++) {
2116 for (
int i = 0;
i < max_masters;
i++) {
2122 for (
int i = 0;
i < max_masters;
i++) {
2128 for (
int i = 0;
i < max_masters;
i++) {
2134 for (
int i = 0;
i < max_masters;
i++) {
2140 for (
int i = 0;
i < max_masters;
i++) {
2146 for (
int i = 0;
i < max_masters;
i++) {
2152 for (
int i = 0;
i < max_masters;
i++) {
2181 for (
int i = 0;
i < max_masters;
i++) {
2187 for (
int i = 0;
i < max_masters;
i++) {
2193 for (
int i = 0;
i < max_masters;
i++) {
2199 for (
int i = 0;
i < max_masters;
i++) {
2205 for (
int i = 0;
i < max_masters;
i++) {
2211 for (
int i = 0;
i < max_masters;
i++) {
2218 for (
int i = 0;
i < max_masters;
i++) {
2225 for (
int i = 0;
i < max_masters;
i++) {
2234 for (
int i = 0;
i < max_masters;
i++) {
2240 for (
int i = 0;
i < max_masters;
i++) {
2246 for (
int i = 0;
i < max_masters;
i++) {
2252 for (
int i = 0;
i < max_masters;
i++) {
2258 for (
int i = 0;
i < max_masters;
i++) {
2265 for (
int i = 0;
i < max_masters;
i++) {
2305 }
else if (
blocked || mustSendRetry) {
2307 mustSendRetry =
true;
2310 mustSendRetry =
false;
2325 }
else if (tryTiming(pkt)) {
2366 const std::string &_label)
2419 assert(!waitingOnRetry);
2424 assert(deferredPacketReadyTime() ==
MaxTick);
2446 if (!waitingOnRetry) {
2453 const std::string &_label)
2455 _reqQueue(*_cache, *this, _snoopRespQueue, _label),
2456 _snoopRespQueue(*_cache, *this, true, _label),
cache(_cache)
2465 if (nextAddr == write_addr) {
2466 delayCtr[blk_addr] = delayThreshold;
2468 if (
mode != WriteMode::NO_ALLOCATE) {
2469 byteCount += write_size;
2472 if (
mode == WriteMode::ALLOCATE &&
2473 byteCount > coalesceLimit) {
2474 mode = WriteMode::COALESCE;
2476 }
else if (
mode == WriteMode::COALESCE &&
2477 byteCount > noAllocateLimit) {
2480 mode = WriteMode::NO_ALLOCATE;
2487 byteCount = write_size;
2488 mode = WriteMode::ALLOCATE;
2489 resetDelay(blk_addr);
2491 nextAddr = write_addr + write_size;
2495 WriteAllocatorParams::create()
virtual bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the peer.
virtual std::unique_ptr< CompressionData > compress(const uint64_t *cache_line, Cycles &comp_lat, Cycles &decomp_lat)=0
Apply the compression process to the cache line.
bool trySatisfyFunctional(PacketPtr pkt)
Miss Status and Handling Register (MSHR) declaration.
virtual bool access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat, PacketList &writebacks)
Does all the processing necessary to perform the provided request.
#define panic(...)
This implements a cprintf based panic() function.
Stats::Formula demandMissLatency
Total number of cycles spent waiting for demand misses.
virtual AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
virtual Cycles handleAtomicReqMiss(PacketPtr pkt, CacheBlk *&blk, PacketList &writebacks)=0
Handle a request in atomic mode that missed in this cache.
void setDecompressionLatency(const Cycles lat)
Set number of cycles needed to decompress this block.
void insert(const Addr addr, const bool is_secure, const int src_master_ID=0, const uint32_t task_ID=0) override
Set member variables when a block insertion occurs.
bool forwardSnoops
Do we forward snoops from mem side port through to cpu side port?
void regProbePoints() override
Registers probes.
Declares a basic cache interface BaseCache.
virtual Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from our peer.
Ports are used to interface objects to each other.
BaseCache(const BaseCacheParams *p, unsigned blk_size)
const SectorBlk * getSectorBlock() const
Get sector block associated to this block.
Special instance of CacheBlk for use with tempBlk that deals with its block address regeneration...
bool isSecure
True if the entry targets the secure memory space.
bool needsWritable() const
The pending* and post* flags are only valid if inService is true.
bool isExpressSnoop() const
virtual bool tryTiming(PacketPtr pkt) override
Availability request from the peer.
PacketPtr writebackBlk(CacheBlk *blk)
Create a writeback request for the given block.
void setHasSharers()
On fills, the hasSharers flag is used by the caches in combination with the cacheResponding flag...
bool inService
True if the entry has been sent downstream.
State status
The current status of this block.
void sendRangeChange() const
Called by the owner to send a range change.
Derived & subname(off_type index, const std::string &name)
Set the subfield name for the given index, and marks this stat to print at the end of simulation...
Cycles is a wrapper class for representing cycle counts, i.e.
Stats::Formula demandHits
Number of hits for demand accesses.
#define fatal(...)
This implements a cprintf based fatal() function.
void writebackVisitor(CacheBlk &blk)
Cache block visitor that writes back dirty cache blocks using functional writes.
Stats::Vector missLatency
Total number of cycles per thread/command spent waiting for a miss.
AtomicOpFunctor * getAtomicOp() const
Accessor function to atomic op.
bool isValid() const
Checks that a block is valid.
Stats::Formula avgMshrUncacheableLatency
The average latency of an MSHR miss, per command and thread.
bool isWritable() const
Checks the write permissions of this block.
std::string getMasterName(MasterID master_id)
Get the name of an object for a given request id.
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.
virtual void sendDeferredPacket()
Override the normal sendDeferredPacket and do not only consider the transmit list (used for responses...
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
WriteQueue writeBuffer
Write/writeback buffer.
Stats::Formula overallMshrMissLatency
Total cycle latency of overall MSHR misses.
std::string print() const override
Pretty-print tag, set and way, and interpret state bits to readable form including mapping to a MOESI...
bool isWholeLineWrite() const
Check if this MSHR contains only compatible writes, and if they span the entire cache line...
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...
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
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.
const FlagsType nonan
Don't print if this is NAN.
void makeTimingResponse()
MSHR * noTargetMSHR
Pointer to the MSHR that has no targets.
#define SUM_NON_DEMAND(s)
int getNumTargets() const
Returns the current number of allocated 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.
bool isCleanEviction() const
Is this packet a clean eviction, including both actual clean evict packets, but also clean writebacks...
virtual void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the peer.
std::shared_ptr< Request > RequestPtr
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.
Entry * getNext() const
Returns the WriteQueueEntry at the head of the readyList.
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.
std::vector< SectorSubBlk * > blks
List of blocks associated to this sector.
System * system
System we are currently operating in.
bool cacheResponding() const
void updateMode(Addr write_addr, unsigned write_size, Addr blk_addr)
Update the write mode based on the current write packet.
const bool isReadOnly
Is this cache read only, for example the instruction cache, or table-walker cache.
The request targets the secure memory space.
ProbePointArg< PacketPtr > * ppMiss
To probe when a cache miss occurs.
virtual void handleTimingReqMiss(PacketPtr pkt, CacheBlk *blk, Tick forward_time, Tick request_time)=0
bool isPendingModified() const
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.
BaseCache::CacheStats stats
void invalidateBlock(CacheBlk *blk)
Invalidate a cache block.
virtual void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the peer.
bool trySatisfyFunctional(PacketPtr pkt)
Check the list of buffered packets against the supplied functional request.
void invalidate() override
Invalidate the block and clear all state.
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...
Stats::Formula overallMshrUncacheable
Total number of misses that miss in the MSHRs.
void setUncompressed()
Clear compression bit.
Simple class to provide virtual print() method on cache blocks without allocating a vtable pointer fo...
Definition of a basic cache compressor.
MSHR * allocateMissBuffer(PacketPtr pkt, Tick time, bool sched_send=true)
bool canPrefetch() const
Returns true if sufficient mshrs for prefetch.
Overload hash function for BasicBlockRange type.
bool allocate() const
Should writes allocate?
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the slave port by calling its corresponding receive function...
bool isConnected() const
Is this port currently connected to a peer?
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.
bool coalesce() const
Checks if the cache is coalescing writes.
virtual Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the peer.
bool handleEvictions(std::vector< CacheBlk *> &evict_blks, PacketList &writebacks)
Try to evict the given blocks.
const Cycles fillLatency
The latency to fill a cache block.
WriteAllocator *const writeAllocator
The writeAllocator drive optimizations for streaming writes.
void promoteWritable()
Promotes deferred targets that do not require writable.
Stats::Formula overallMissLatency
Total number of cycles spent waiting for all misses.
virtual bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
Counter order
Order number assigned to disambiguate writes and misses.
virtual Tick nextPrefetchReadyTime() const =0
bool sendWriteQueuePacket(WriteQueueEntry *wq_entry)
Similar to sendMSHR, but for a write-queue entry instead.
void setSizeBits(const std::size_t size)
Set size, in bits, of this compressed block's data.
void pushLabel(const std::string &lbl)
Push label for PrintReq (safe to call unconditionally).
Stats::Formula overallAvgMshrUncacheableLatency
The average overall latency of an MSHR miss.
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
bool isInvalidate() const
void setSatisfied()
Set when a request hits in a cache and the cache is not going to respond.
#define chatty_assert(cond,...)
The chatty assert macro will function like a normal assert, but will allow the specification of addit...
Prefetcher::Base * prefetcher
Prefetcher.
This master id is used for functional requests that don't come from a particular device.
void markPending(MSHR *mshr)
Mark an in service entry as pending, used to resend a request.
Derived & init(size_type size)
Set this vector to have the given size.
std::size_t getSizeBits() const
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
Stats::Vector writebacks
Number of blocks written back per thread.
block was a hardware prefetch yet unaccessed
Cycles calculateTagOnlyLatency(const uint32_t delay, const Cycles lookup_lat) const
Calculate latency of accesses that only touch the tag array.
Stats::Scalar dataExpansions
Number of data expansions.
CacheCmdStats & cmdStats(const PacketPtr p)
bool needsWritable() const
CacheBlk * allocateBlock(const PacketPtr pkt, PacketList &writebacks)
Allocate a new block and perform any necessary writebacks.
Addr getBlockAddr(unsigned int blk_size) const
void sendFunctionalSnoop(PacketPtr pkt) const
Send a functional snoop request packet, where the data is instantly updated everywhere in the memory ...
Stats::Vector hits
Number of hits per thread for each type of command.
RequestPtr req
A pointer to the original request.
virtual void memWriteback() override
Write back dirty blocks in the cache using functional accesses.
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.
Stats::Formula demandMshrMissRate
The demand miss rate in the MSHRs.
ProbePointArg< PacketPtr > * ppFill
To probe when a cache fill occurs.
void deallocate(Entry *entry)
Removes the given entry from the queue.
virtual void recvTimingReq(PacketPtr pkt)
Performs the access specified by the request.
Tick cyclesToTicks(Cycles c) const
void invalidateVisitor(CacheBlk &blk)
Cache block visitor that invalidates all blocks in the cache.
A coherent cache that can be arranged in flexible topologies.
static void setSizeBits(CacheBlk *blk, const std::size_t size_bits)
Set the size of the compressed block, in bits.
#define UNSERIALIZE_SCALAR(scalar)
virtual Tick recvAtomic(PacketPtr pkt)
Performs the access specified by the request.
A cache master port is used for the memory-side port of the cache, and in addition to the basic timin...
Tick curTick()
The current simulated tick.
CacheSlavePort(const std::string &_name, BaseCache *_cache, const std::string &_label)
Stats::Vector mshr_misses
Number of misses that miss in the MSHRs, per command and thread.
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
PacketPtr tempBlockWriteback
Writebacks from the tempBlock, resulting on the response path in atomic mode, must happen after the c...
bool checkWrite(PacketPtr pkt)
Handle interaction of load-locked operations and stores.
bool needsResponse() const
void trackLoadLocked(PacketPtr pkt)
Track the fact that a local locked was issued to the block.
void allocateTarget(PacketPtr target, Tick when, Counter order, bool alloc_on_fill)
Add a request to the list of targets.
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.
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
bool canCoAllocate(const std::size_t compressed_size) const
Checks whether a superblock can co-allocate given compressed data block.
Addr getOffset(unsigned int blk_size) const
void unserialize(CheckpointIn &cp) override
Unserialize an object.
bool inRange(Addr addr) const
Determine if an address is in the ranges covered by this cache.
virtual void setCache(BaseCache *_cache)
void schedTimingResp(PacketPtr pkt, Tick when)
Schedule the sending of a timing response.
void setData(const uint8_t *p)
Copy data into the packet from the provided pointer.
const bool sequentialAccess
Whether tags and data are accessed sequentially.
CpuSidePort(const std::string &_name, BaseCache *_cache, const std::string &_label)
void makeAtomicResponse()
Copyright (c) 2018 Inria All rights reserved.
virtual void recvTimingSnoopResp(PacketPtr pkt)=0
Handle a snoop response.
uint64_t Tick
Tick count type.
void incMissCount(PacketPtr pkt)
Target * getTarget() override
Returns a reference to the first target.
bool trySatisfyFunctional(PacketPtr other)
Check a functional request against a memory value stored in another packet (i.e.
void popLabel()
Pop label for PrintReq (safe to call unconditionally).
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.
unsigned State
block state: OR of CacheBlkStatusBit
A superblock is composed of sub-blocks, and each sub-block has information regarding its superblock a...
bool isSecure() const
Check if this block holds data from the secure memory space.
Miss Status and handling Register.
virtual void recvTimingResp(PacketPtr pkt)
Handles a response (cache line fill/write ack) from the bus.
QueueEntry::Target * getTarget() override
Returns a reference to the first target.
virtual PacketPtr getPacket()=0
Stats::Formula demandMshrHits
Demand misses that hit in the MSHRs.
bool writeThrough() const
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.
void writeData(uint8_t *p) const
Copy data from the packet to the memory at the provided pointer.
void schedule(Event &event, Tick when)
bool trySatisfyFunctional(PacketPtr pkt)
Check the list of buffered packets against the supplied functional request.
void cmpAndSwap(CacheBlk *blk, PacketPtr pkt)
Handle doing the Compare and Swap function for SPARC.
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.
void setWhenReady(const Tick tick)
Set tick at which block's data will be available for access.
Stats::Formula overallHits
Number of hit for all accesses.
virtual void handleTimingReqHit(PacketPtr pkt, CacheBlk *blk, Tick request_time)
Stats::Formula overallMissRate
The miss rate for all accesses.
bool isSnooping() const
Find out if the peer master port is snooping or not.
Stats::Formula overallAccesses
The number of overall accesses.
virtual void memInvalidate() override
Invalidates all blocks in the cache.
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...
virtual void recvTimingSnoopReq(PacketPtr pkt)=0
Snoops bus transactions to maintain coherence.
void setBlocked()
Do not accept any new requests.
uint8_t blocked
Bit vector of the blocking reasons for the access path.
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...
CacheBlk * handleFill(PacketPtr pkt, CacheBlk *blk, PacketList &writebacks, bool allocate)
Handle a fill operation caused by a received packet.
const bool writebackClean
Determine if clean lines should be written back or not.
const unsigned blkSize
Block size of this cache.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
void regStatsFromParent()
Callback to register stats from parent CacheStats::regStats().
bool isReadable() const
Checks the read permissions of this block.
Entry * findMatch(Addr blk_addr, bool is_secure, bool ignore_uncacheable=true) const
Find the first entry that matches the provided address.
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Stats::Vector misses
Number of misses per thread for each type of command.
void setDataFromBlock(const uint8_t *blk_data, int blkSize)
Copy data into the packet from the provided block pointer, which is aligned to the given block size...
uint64_t order
Increasing order number assigned to each incoming request.
void setCompressed()
Set compression bit.
Stats::Formula demandMisses
Number of misses for demand accesses.
A queue entry is holding packets that will be serviced as soon as resources are available.
const FlagsType total
Print the total.
virtual M5_NODISCARD PacketPtr evictBlock(CacheBlk *blk)=0
Evict a cache block.
MasterID maxMasters()
Get the number of masters registered in the system.
Entry * findPending(const QueueEntry *entry) const
Find any pending requests that overlap the given request of a different queue.
#define SERIALIZE_SCALAR(scalar)
TempCacheBlk * tempBlock
Temporary cache block for occasional transitory use.
ProbeManager * getProbeManager()
Get the probe manager for this object.
A queue entry base class, to be used by both the MSHRs and write-queue entries.
bool isCompressed() const
Check if this block holds compressed data.
virtual void doWritebacksAtomic(PacketList &writebacks)=0
Send writebacks down the memory hierarchy in atomic mode.
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
ProbePointArg< PacketPtr > * ppHit
To probe when a cache hit occurs.
const AddrRangeList & getAddrRanges() const
virtual const std::string name() const
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...
Stats::Formula mshrMissRate
The miss rate in the MSHRs pre command and thread.
ProbePointArg generates a point for the class of Arg.
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...
bool wasWholeLineWrite
Track if we sent this as a whole line write or not.
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.
Cycles ticksToCycles(Tick t) const
Addr blkAddr
Block aligned address.
Stats::Formula avgMshrMissLatency
The average latency of an MSHR miss, per command and thread.
MemSidePort(const std::string &_name, BaseCache *_cache, const std::string &_label)
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
virtual Tick recvAtomicSnoop(PacketPtr pkt)=0
Snoop for the provided request in the cache and return the estimated time taken.
void delay(MSHR *mshr, Tick delay_ticks)
Adds a delay to the provided MSHR and moves MSHRs that will be ready earlier than this entry to the t...
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.
void setBlocked(BlockedCause cause)
Marks the access path of the cache as blocked for the given cause.
bool isCompressed(const CompressionBlk *ignored_blk=nullptr) const
Returns whether the superblock contains compressed blocks or not.
void print(std::ostream &o, int verbosity=0, const std::string &prefix="") const
MemCmd cmd
The command field of the packet.
bool bypassCaches() const
Should caches be bypassed?
The write allocator inspects write packets and detects streaming patterns.
static const Priority Delayed_Writeback_Pri
For some reason "delayed" inter-cluster writebacks are scheduled before regular writebacks (which hav...
bool isForward
True if the entry is just a simple forward from an upper level.
void promoteReadable()
Promotes deferred targets that do not require writable.
Stats::Formula avgMissLatency
The average miss latency per command and thread.
const std::string name() const
Return port name (for DPRINTF).
int getNumTargets() const
Returns the current number of allocated targets.
Stats::Formula accesses
The number of accesses per command and thread.
Cycles getDecompressionLatency(const CacheBlk *blk)
Get the decompression latency if the block is compressed.
bool promoteDeferredTargets()
void writeDataToBlock(uint8_t *blk_data, int blkSize) const
Copy data from the packet to the provided block pointer, which is aligned to the given block size...
Addr getAddr() const
Get block's address.
const PacketPtr pkt
Pending request packet.
Stats::Formula overallMshrMissRate
The overall miss rate in the MSHRs.
const int numTarget
The number of targets for each MSHR.
const T * getConstPtr() const
void regStats() override
Callback to set stat parameters.
CacheCmdStats(BaseCache &c, const std::string &name)
virtual bool sendMSHRQueuePacket(MSHR *mshr)
Take an MSHR, turn it into a suitable downstream packet, and send it out.
uint32_t task_id
Task Id associated with this block.
const Tick recvTime
Time when request was received (for stats)
const Cycles forwardLatency
This is the forward latency of the cache.
bool coalesce() const
Should writes be coalesced? This is true if the mode is set to NO_ALLOCATE.
void pushSenderState(SenderState *sender_state)
Push a new sender state to the packet and make the current sender state the predecessor of the new on...
virtual bool sendPacket(BaseCache &cache)=0
Send this queue entry as a downstream packet, with the exact behaviour depending on the specific entr...
void resetDelay(Addr blk_addr)
Clear delay counter for the input block.
SenderState * popSenderState()
Pop the top of the state stack and return a pointer to it.
void sendFunctional(PacketPtr pkt) const
Send a functional request packet, where the data is instantly updated everywhere in the memory system...
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 void regStats()
Callback to set stat parameters.
Stats::Scalar unusedPrefetches
The number of times a HW-prefetched block is evicted w/o reference.
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.
Tick nextQueueReadyTime() const
Find next request ready time from among possible sources.
This master id is used for writeback requests by the caches.
BaseCacheCompressor * compressor
Compression method being used.
void writebackTempBlockAtomic()
Send the outstanding tempBlock writeback.
Stats::Formula demandMissRate
The miss rate of all demand accesses.
bool wasPrefetched() const
Check if this block was the result of a hardware prefetch, yet to be touched.
Tick sendAtomic(PacketPtr pkt)
Send an atomic request packet, where the data is moved and the state is updated in zero time...
static void setDecompressionLatency(CacheBlk *blk, const Cycles lat)
Set the decompression latency of compressed block.
Miss and writeback queue declarations.
const FlagsType nozero
Don't print if this is zero.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Tick getWhenReady() const
Get tick at which block's data will be available for access.
virtual void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the peer.
read permission (yes, block can be valid but not readable)
void handleUncacheableWriteResp(PacketPtr pkt)
Handling the special case of uncacheable write responses to make recvTimingResp less cluttered...
void incHitCount(PacketPtr pkt)
bool isDirty() const
Determine if there are any dirty blocks in the cache.
A basic compression superblock.
uint8_t * data
Contains a copy of the data in this block for easy access.
bool delay(Addr blk_addr)
Access whether we need to delay the current write.
Stats::Formula demandAvgMshrMissLatency
The average latency of a demand MSHR miss.
BaseTags * tags
Tag and data Storage.
void allocate()
Allocate memory for the packet.
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.
virtual void functionalAccess(PacketPtr pkt, bool from_cpu_side)
Performs the access specified by the request.
Tick nextReadyTime() const
ProbePointArg< PacketInfo > Packet
Packet probe point.
virtual Target * getTarget()=0
Returns a pointer to the first target.
MSHRQueue mshrQueue
Miss status registers.
void maintainClusivity(bool from_cache, CacheBlk *blk)
Maintain the clusivity of this cache by potentially invalidating a block.
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.
bool isDirty() const
Check to see if a block has been written.
void setCacheResponding()
Snoop flags.
void setWriteThrough()
A writeback/writeclean cmd gets propagated further downstream by the receiver when the flag is set...