53 #include "debug/Cache.hh" 54 #include "debug/CacheComp.hh" 55 #include "debug/CachePort.hh" 56 #include "debug/CacheRepl.hh" 57 #include "debug/CacheVerbose.hh" 63 #include "params/BaseCache.hh" 64 #include "params/WriteAllocator.hh" 71 const std::string &_label)
73 queue(*_cache, *this, true, _label),
74 blocked(false), mustSendRetry(false),
83 mshrQueue(
"MSHRs", p->mshrs, 0, p->demand_mshr_reserve),
84 writeBuffer(
"write buffer", p->write_buffers, p->mshrs),
109 addrRanges(
p->addr_ranges.begin(),
p->addr_ranges.end()),
138 DPRINTF(CachePort,
"Port is blocking new requests\n");
142 if (sendRetryEvent.scheduled()) {
143 owner.deschedule(sendRetryEvent);
144 DPRINTF(CachePort,
"Port descheduled retry\n");
145 mustSendRetry =
true;
153 DPRINTF(CachePort,
"Port is accepting new requests\n");
157 owner.schedule(sendRetryEvent,
curTick() + 1);
164 DPRINTF(CachePort,
"Port is sending retry\n");
167 mustSendRetry =
false;
185 fatal(
"Cache ports on %s are not connected\n",
name());
193 if (if_name ==
"mem_side") {
195 }
else if (if_name ==
"cpu_side") {
206 if (
r.contains(addr)) {
230 DPRINTF(
Cache,
"%s satisfied %s, no response needed\n", __func__,
243 Tick forward_time,
Tick request_time)
246 pkt && pkt->
isWrite() && !pkt->
req->isUncacheable()) {
325 pkt->
req->isCacheMaintenance());
345 bool satisfied =
false;
350 satisfied =
access(pkt, blk, lat, writebacks);
412 "%s saw a non-zero packet delay\n",
name());
414 const bool is_error = pkt->
isError();
417 DPRINTF(
Cache,
"%s: Cache received %s with error\n", __func__,
427 assert(pkt->
req->isUncacheable());
446 if (pkt->
req->isUncacheable()) {
468 if (is_fill && !is_error) {
469 DPRINTF(
Cache,
"Block for addr %#llx being updated in Cache\n",
474 blk =
handleFill(pkt, blk, writebacks, allocate);
475 assert(blk !=
nullptr);
491 if (blk && blk->isWritable() && !pkt->
req->isCacheInvalidate()) {
537 DPRINTF(CacheVerbose,
"%s: Leaving with %s\n", __func__, pkt->
print());
555 bool satisfied =
access(pkt, blk, lat, writebacks);
562 DPRINTF(CacheVerbose,
"%s: packet %s found block: %s\n",
565 writebacks.push_back(wb_pkt);
572 assert(writebacks.empty());
640 bool have_data = blk && blk->
isValid()
647 have_data && (blk->
isDirty() ||
650 bool done = have_dirty ||
656 DPRINTF(CacheVerbose,
"%s: %s %s%s%s\n", __func__, pkt->
print(),
657 (blk && blk->
isValid()) ?
"valid " :
"",
658 have_data ?
"data " :
"", done ?
"done " :
"");
684 uint64_t overwrite_val;
686 uint64_t condition_val64;
687 uint32_t condition_val32;
692 assert(
sizeof(uint64_t) >= pkt->
getSize());
694 overwrite_mem =
true;
697 pkt->
writeData((uint8_t *)&overwrite_val);
700 if (pkt->
req->isCondSwap()) {
701 if (pkt->
getSize() ==
sizeof(uint64_t)) {
702 condition_val64 = pkt->
req->getExtraData();
703 overwrite_mem = !std::memcmp(&condition_val64, blk_data,
705 }
else if (pkt->
getSize() ==
sizeof(uint32_t)) {
706 condition_val32 = (uint32_t)pkt->
req->getExtraData();
707 overwrite_mem = !std::memcmp(&condition_val32, blk_data,
710 panic(
"Invalid size for conditional read/write\n");
714 std::memcpy(blk_data, &overwrite_val, pkt->
getSize());
734 if (conflict_mshr && conflict_mshr->
order < wq_entry->
order) {
736 return conflict_mshr;
743 }
else if (miss_mshr) {
759 return conflict_mshr;
769 assert(!miss_mshr && !wq_entry);
801 bool replacement =
false;
802 for (
const auto& blk : evict_blks) {
803 if (blk->isValid()) {
824 for (
auto& blk : evict_blks) {
825 if (blk->isValid()) {
850 std::size_t compression_size = 0;
864 const bool is_co_allocatable = superblock->
isCompressed(compression_blk) &&
873 const bool was_compressed = compression_blk->
isCompressed();
874 if (was_compressed && !is_co_allocatable) {
876 for (
const auto& sub_blk : superblock->
blks) {
877 if (sub_blk->isValid() && (compression_blk != sub_blk)) {
878 evict_blks.push_back(sub_blk);
890 DPRINTF(CacheComp,
"Data expansion: expanding [%s] from %d to %d bits" 891 "\n", blk->
print(), prev_size, compression_size);
895 if (is_co_allocatable) {
954 DPRINTF(CacheVerbose,
"%s for %s (write)\n", __func__, pkt->
print());
955 }
else if (pkt->
isRead()) {
979 DPRINTF(CacheVerbose,
"%s for %s (invalidation)\n", __func__,
991 const Cycles lookup_lat)
const 1000 const Cycles lookup_lat)
const 1004 if (blk !=
nullptr) {
1018 if (when_ready > tick &&
1040 "Should never see a write in a read-only cache %s\n",
1048 blk ?
"hit " + blk->
print() :
"miss");
1050 if (pkt->
req->isCacheMaintenance()) {
1079 assert(wbPkt->isWriteback());
1123 DPRINTF(
Cache,
"Clean writeback %#llx to block with MSHR, " 1124 "dropping\n", pkt->
getAddr());
1289 pkt->
req->setExtraData(0);
1337 DPRINTF(
Cache,
"using temp block for %#llx (%s)\n", addr,
1338 is_secure ?
"s" :
"ns");
1348 assert(blk->
isSecure() == is_secure);
1381 "in read-only cache %s\n",
name());
1386 DPRINTF(
Cache,
"Block addr %#llx (%s) moving from state %x to %s\n",
1387 addr, is_secure ?
"s" :
"ns", old_state, blk->
print());
1412 const bool is_secure = pkt->
isSecure();
1417 std::size_t blk_size_bits =
blkSize*8;
1428 decompression_lat, blk_size_bits);
1441 DPRINTF(CacheRepl,
"Replacement victim: %s\n", victim->
print());
1483 writebacks.push_back(pkt);
1491 "Writeback from read-only cache");
1508 DPRINTF(
Cache,
"Create Writeback %s writable: %d, dirty: %d\n",
1549 req->setFlags(dest);
1611 RequestPtr request = std::make_shared<Request>(
1632 warn_once(
"Invalidating dirty cache lines. " \
1633 "Expect things to break.\n");
1650 nextReady = std::min(nextReady,
1679 DPRINTF(CacheVerbose,
"Delaying pkt %s %llu ticks to allow " 1680 "for write coalescing\n", tgt_pkt->
print(), delay);
1704 pkt =
new Packet(tgt_pkt,
false,
true);
1739 bool pending_modified_resp = !pkt->
hasSharers() &&
1748 DPRINTF(CacheVerbose,
"%s: packet %s found block: %s\n",
1753 writebacks.push_back(wb_pkt);
1791 warn(
"*** The cache still contains dirty data. ***\n");
1792 warn(
" Make sure to drain the system using the correct flags.\n");
1793 warn(
" This checkpoint will not restore correctly " \
1794 "and dirty data in the cache will be lost!\n");
1801 bool bad_checkpoint(dirty);
1808 bool bad_checkpoint;
1810 if (bad_checkpoint) {
1811 fatal(
"Restoring from checkpoints with dirty caches is not " 1812 "supported in the classic memory system. Please remove any " 1813 "caches or drain them properly before taking checkpoints.\n");
1819 const std::string &
name)
1823 this, (name +
"_hits").c_str(),
1824 (
"number of " + name +
" hits").c_str()),
1826 this, (name +
"_misses").c_str(),
1827 (
"number of " + name +
" misses").c_str()),
1829 this, (name +
"_miss_latency").c_str(),
1830 (
"number of " + name +
" miss cycles").c_str()),
1832 this, (name +
"_accesses").c_str(),
1833 (
"number of " + name +
" accesses(hits+misses)").c_str()),
1835 this, (name +
"_miss_rate").c_str(),
1836 (
"miss rate for " + name +
" accesses").c_str()),
1838 this, (name +
"_avg_miss_latency").c_str(),
1839 (
"average " + name +
" miss latency").c_str()),
1841 this, (name +
"_mshr_hits").c_str(),
1842 (
"number of " + name +
" MSHR hits").c_str()),
1844 this, (name +
"_mshr_misses").c_str(),
1845 (
"number of " + name +
" MSHR misses").c_str()),
1847 this, (name +
"_mshr_uncacheable").c_str(),
1848 (
"number of " + name +
" MSHR uncacheable").c_str()),
1850 this, (name +
"_mshr_miss_latency").c_str(),
1851 (
"number of " + name +
" MSHR miss cycles").c_str()),
1852 mshr_uncacheable_lat(
1853 this, (name +
"_mshr_uncacheable_latency").c_str(),
1854 (
"number of " + name +
" MSHR uncacheable cycles").c_str()),
1856 this, (name +
"_mshr_miss_rate").c_str(),
1857 (
"mshr miss rate for " + name +
" accesses").c_str()),
1859 this, (name +
"_avg_mshr_miss_latency").c_str(),
1860 (
"average " + name +
" mshr miss latency").c_str()),
1861 avgMshrUncacheableLatency(
1862 this, (name +
"_avg_mshr_uncacheable_latency").c_str(),
1863 (
"average " + name +
" mshr uncacheable latency").c_str())
1870 using namespace Stats;
1874 const auto max_masters = system->
maxMasters();
1880 for (
int i = 0;
i < max_masters;
i++) {
1889 for (
int i = 0;
i < max_masters;
i++) {
1898 for (
int i = 0;
i < max_masters;
i++) {
1905 for (
int i = 0;
i < max_masters;
i++) {
1912 for (
int i = 0;
i < max_masters;
i++) {
1919 for (
int i = 0;
i < max_masters;
i++) {
1929 for (
int i = 0;
i < max_masters;
i++) {
1938 for (
int i = 0;
i < max_masters;
i++) {
1947 for (
int i = 0;
i < max_masters;
i++) {
1956 for (
int i = 0;
i < max_masters;
i++) {
1965 for (
int i = 0;
i < max_masters;
i++) {
1973 for (
int i = 0;
i < max_masters;
i++) {
1980 for (
int i = 0;
i < max_masters;
i++) {
1987 for (
int i = 0;
i < max_masters;
i++) {
1995 demandHits(this,
"demand_hits",
"number of demand (read+write) hits"),
1997 overallHits(this,
"overall_hits",
"number of overall hits"),
1998 demandMisses(this,
"demand_misses",
1999 "number of demand (read+write) misses"),
2000 overallMisses(this,
"overall_misses",
"number of overall misses"),
2001 demandMissLatency(this,
"demand_miss_latency",
2002 "number of demand (read+write) miss cycles"),
2003 overallMissLatency(this,
"overall_miss_latency",
2004 "number of overall miss cycles"),
2005 demandAccesses(this,
"demand_accesses",
2006 "number of demand (read+write) accesses"),
2007 overallAccesses(this,
"overall_accesses",
2008 "number of overall (read+write) accesses"),
2009 demandMissRate(this,
"demand_miss_rate",
2010 "miss rate for demand accesses"),
2011 overallMissRate(this,
"overall_miss_rate",
2012 "miss rate for overall accesses"),
2013 demandAvgMissLatency(this,
"demand_avg_miss_latency",
2014 "average overall miss latency"),
2015 overallAvgMissLatency(this,
"overall_avg_miss_latency",
2016 "average overall miss latency"),
2017 blocked_cycles(this,
"blocked_cycles",
2018 "number of cycles access was blocked"),
2019 blocked_causes(this,
"blocked",
"number of cycles access was blocked"),
2020 avg_blocked(this,
"avg_blocked_cycles",
2021 "average number of cycles each access was blocked"),
2022 unusedPrefetches(this,
"unused_prefetches",
2023 "number of HardPF blocks evicted w/o reference"),
2024 writebacks(this,
"writebacks",
"number of writebacks"),
2025 demandMshrHits(this,
"demand_mshr_hits",
2026 "number of demand (read+write) MSHR hits"),
2027 overallMshrHits(this,
"overall_mshr_hits",
2028 "number of overall MSHR hits"),
2029 demandMshrMisses(this,
"demand_mshr_misses",
2030 "number of demand (read+write) MSHR misses"),
2031 overallMshrMisses(this,
"overall_mshr_misses",
2032 "number of overall MSHR misses"),
2033 overallMshrUncacheable(this,
"overall_mshr_uncacheable_misses",
2034 "number of overall MSHR uncacheable misses"),
2035 demandMshrMissLatency(this,
"demand_mshr_miss_latency",
2036 "number of demand (read+write) MSHR miss cycles"),
2037 overallMshrMissLatency(this,
"overall_mshr_miss_latency",
2038 "number of overall MSHR miss cycles"),
2039 overallMshrUncacheableLatency(this,
"overall_mshr_uncacheable_latency",
2040 "number of overall MSHR uncacheable cycles"),
2041 demandMshrMissRate(this,
"demand_mshr_miss_rate",
2042 "mshr miss rate for demand accesses"),
2043 overallMshrMissRate(this,
"overall_mshr_miss_rate",
2044 "mshr miss rate for overall accesses"),
2045 demandAvgMshrMissLatency(this,
"demand_avg_mshr_miss_latency",
2046 "average overall mshr miss latency"),
2047 overallAvgMshrMissLatency(this,
"overall_avg_mshr_miss_latency",
2048 "average overall mshr miss latency"),
2049 overallAvgMshrUncacheableLatency(
2050 this,
"overall_avg_mshr_uncacheable_latency",
2051 "average overall mshr uncacheable latency"),
2052 replacements(this,
"replacements",
"number of replacements"),
2054 dataExpansions(this,
"data_expansions",
"number of data expansions"),
2055 cmd(
MemCmd::NUM_MEM_CMDS)
2064 using namespace Stats;
2069 const auto max_masters = system->
maxMasters();
2071 for (
auto &cs :
cmd)
2072 cs->regStatsFromParent();
2077 #define SUM_DEMAND(s) \ 2078 (cmd[MemCmd::ReadReq]->s + cmd[MemCmd::WriteReq]->s + \ 2079 cmd[MemCmd::WriteLineReq]->s + cmd[MemCmd::ReadExReq]->s + \ 2080 cmd[MemCmd::ReadCleanReq]->s + cmd[MemCmd::ReadSharedReq]->s) 2083 #define SUM_NON_DEMAND(s) \ 2084 (cmd[MemCmd::SoftPFReq]->s + cmd[MemCmd::HardPFReq]->s + \ 2085 cmd[MemCmd::SoftPFExReq]->s) 2089 for (
int i = 0;
i < max_masters;
i++) {
2095 for (
int i = 0;
i < max_masters;
i++) {
2101 for (
int i = 0;
i < max_masters;
i++) {
2107 for (
int i = 0;
i < max_masters;
i++) {
2113 for (
int i = 0;
i < max_masters;
i++) {
2119 for (
int i = 0;
i < max_masters;
i++) {
2125 for (
int i = 0;
i < max_masters;
i++) {
2131 for (
int i = 0;
i < max_masters;
i++) {
2137 for (
int i = 0;
i < max_masters;
i++) {
2143 for (
int i = 0;
i < max_masters;
i++) {
2149 for (
int i = 0;
i < max_masters;
i++) {
2155 for (
int i = 0;
i < max_masters;
i++) {
2184 for (
int i = 0;
i < max_masters;
i++) {
2190 for (
int i = 0;
i < max_masters;
i++) {
2196 for (
int i = 0;
i < max_masters;
i++) {
2202 for (
int i = 0;
i < max_masters;
i++) {
2208 for (
int i = 0;
i < max_masters;
i++) {
2214 for (
int i = 0;
i < max_masters;
i++) {
2221 for (
int i = 0;
i < max_masters;
i++) {
2228 for (
int i = 0;
i < max_masters;
i++) {
2237 for (
int i = 0;
i < max_masters;
i++) {
2243 for (
int i = 0;
i < max_masters;
i++) {
2249 for (
int i = 0;
i < max_masters;
i++) {
2255 for (
int i = 0;
i < max_masters;
i++) {
2261 for (
int i = 0;
i < max_masters;
i++) {
2268 for (
int i = 0;
i < max_masters;
i++) {
2308 }
else if (
blocked || mustSendRetry) {
2310 mustSendRetry =
true;
2313 mustSendRetry =
false;
2328 }
else if (tryTiming(pkt)) {
2369 const std::string &_label)
2422 assert(!waitingOnRetry);
2427 assert(deferredPacketReadyTime() ==
MaxTick);
2449 if (!waitingOnRetry) {
2456 const std::string &_label)
2458 _reqQueue(*_cache, *this, _snoopRespQueue, _label),
2459 _snoopRespQueue(*_cache, *this, true, _label),
cache(_cache)
2468 if (nextAddr == write_addr) {
2469 delayCtr[blk_addr] = delayThreshold;
2471 if (
mode != WriteMode::NO_ALLOCATE) {
2472 byteCount += write_size;
2475 if (
mode == WriteMode::ALLOCATE &&
2476 byteCount > coalesceLimit) {
2477 mode = WriteMode::COALESCE;
2479 }
else if (
mode == WriteMode::COALESCE &&
2480 byteCount > noAllocateLimit) {
2483 mode = WriteMode::NO_ALLOCATE;
2490 byteCount = write_size;
2491 mode = WriteMode::ALLOCATE;
2492 resetDelay(blk_addr);
2494 nextAddr = write_addr + write_size;
2498 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.
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
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.
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.
The request targets the secure memory space.
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.
virtual void regStats()
Callback to set stat parameters.
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?
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.
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...
This master id is used for writeback requests by the caches.
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.
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.
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.
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.
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.
virtual const std::string name() const
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...
This master id is used for functional requests that don't come from a particular device.
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.
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 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.
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.
ProbeManager * getProbeManager()
Get the probe manager for this object.
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.
virtual void setCache(BaseCache *_cache)
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.
void schedule(Event &event, Tick when)
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.
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.
static const int NumArgumentRegs M5_VAR_USED
virtual Tick nextPrefetchReadyTime() const =0
static const Priority Delayed_Writeback_Pri
For some reason "delayed" inter-cluster writebacks are scheduled before regular writebacks (which hav...
Tick nextQueueReadyTime() const
Find next request ready time from among possible sources.
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.
BasePrefetcher * prefetcher
Prefetcher.
#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.
virtual PacketPtr getPacket()=0
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...