gem5  v20.1.0.0
CacheMemory.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood
15  * Copyright (c) 2013 Advanced Micro Devices, Inc.
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
43 
44 #include "base/intmath.hh"
45 #include "base/logging.hh"
46 #include "debug/HtmMem.hh"
47 #include "debug/RubyCache.hh"
48 #include "debug/RubyCacheTrace.hh"
49 #include "debug/RubyResourceStalls.hh"
50 #include "debug/RubyStats.hh"
52 #include "mem/ruby/protocol/AccessPermission.hh"
54 
55 using namespace std;
56 
57 ostream&
58 operator<<(ostream& out, const CacheMemory& obj)
59 {
60  obj.print(out);
61  out << flush;
62  return out;
63 }
64 
66 RubyCacheParams::create()
67 {
68  return new CacheMemory(this);
69 }
70 
72  : SimObject(p),
73  dataArray(p->dataArrayBanks, p->dataAccessLatency,
74  p->start_index_bit, p->ruby_system),
75  tagArray(p->tagArrayBanks, p->tagAccessLatency,
76  p->start_index_bit, p->ruby_system)
77 {
78  m_cache_size = p->size;
79  m_cache_assoc = p->assoc;
80  m_replacementPolicy_ptr = p->replacement_policy;
81  m_start_index_bit = p->start_index_bit;
82  m_is_instruction_only_cache = p->is_icache;
83  m_resource_stalls = p->resourceStalls;
84  m_block_size = p->block_size; // may be 0 at this point. Updated in init()
85  m_use_occupancy = dynamic_cast<WeightedLRUPolicy*>(
86  m_replacementPolicy_ptr) ? true : false;
87 }
88 
89 void
91 {
92  if (m_block_size == 0) {
94  }
96  assert(m_cache_num_sets > 1);
98  assert(m_cache_num_set_bits > 0);
99 
100  m_cache.resize(m_cache_num_sets,
104  // instantiate all the replacement_data here
105  for (int i = 0; i < m_cache_num_sets; i++) {
106  for ( int j = 0; j < m_cache_assoc; j++) {
107  replacement_data[i][j] =
109  }
110  }
111 }
112 
114 {
117  for (int i = 0; i < m_cache_num_sets; i++) {
118  for (int j = 0; j < m_cache_assoc; j++) {
119  delete m_cache[i][j];
120  }
121  }
122 }
123 
124 // convert a Address to its location in the cache
125 int64_t
127 {
128  assert(address == makeLineAddress(address));
129  return bitSelect(address, m_start_index_bit,
131 }
132 
133 // Given a cache index: returns the index of the tag in a set.
134 // returns -1 if the tag is not found.
135 int
136 CacheMemory::findTagInSet(int64_t cacheSet, Addr tag) const
137 {
138  assert(tag == makeLineAddress(tag));
139  // search the set for the tags
140  auto it = m_tag_index.find(tag);
141  if (it != m_tag_index.end())
142  if (m_cache[cacheSet][it->second]->m_Permission !=
143  AccessPermission_NotPresent)
144  return it->second;
145  return -1; // Not found
146 }
147 
148 // Given a cache index: returns the index of the tag in a set.
149 // returns -1 if the tag is not found.
150 int
152  Addr tag) const
153 {
154  assert(tag == makeLineAddress(tag));
155  // search the set for the tags
156  auto it = m_tag_index.find(tag);
157  if (it != m_tag_index.end())
158  return it->second;
159  return -1; // Not found
160 }
161 
162 // Given an unique cache block identifier (idx): return the valid address
163 // stored by the cache block. If the block is invalid/notpresent, the
164 // function returns the 0 address
165 Addr
167 {
168  Addr tmp(0);
169 
170  int set = idx / m_cache_assoc;
171  assert(set < m_cache_num_sets);
172 
173  int way = idx - set * m_cache_assoc;
174  assert (way < m_cache_assoc);
175 
176  AbstractCacheEntry* entry = m_cache[set][way];
177  if (entry == NULL ||
178  entry->m_Permission == AccessPermission_Invalid ||
179  entry->m_Permission == AccessPermission_NotPresent) {
180  return tmp;
181  }
182  return entry->m_Address;
183 }
184 
185 bool
186 CacheMemory::tryCacheAccess(Addr address, RubyRequestType type,
187  DataBlock*& data_ptr)
188 {
189  DPRINTF(RubyCache, "address: %#x\n", address);
190  AbstractCacheEntry* entry = lookup(address);
191  if (entry != nullptr) {
192  // Do we even have a tag match?
194  entry->setLastAccess(curTick());
195  data_ptr = &(entry->getDataBlk());
196 
197  if (entry->m_Permission == AccessPermission_Read_Write) {
198  return true;
199  }
200  if ((entry->m_Permission == AccessPermission_Read_Only) &&
201  (type == RubyRequestType_LD || type == RubyRequestType_IFETCH)) {
202  return true;
203  }
204  // The line must not be accessible
205  }
206  data_ptr = NULL;
207  return false;
208 }
209 
210 bool
211 CacheMemory::testCacheAccess(Addr address, RubyRequestType type,
212  DataBlock*& data_ptr)
213 {
214  DPRINTF(RubyCache, "address: %#x\n", address);
215  AbstractCacheEntry* entry = lookup(address);
216  if (entry != nullptr) {
217  // Do we even have a tag match?
219  entry->setLastAccess(curTick());
220  data_ptr = &(entry->getDataBlk());
221 
222  return entry->m_Permission != AccessPermission_NotPresent;
223  }
224 
225  data_ptr = NULL;
226  return false;
227 }
228 
229 // tests to see if an address is present in the cache
230 bool
232 {
233  const AbstractCacheEntry* const entry = lookup(address);
234  if (entry == nullptr) {
235  // We didn't find the tag
236  DPRINTF(RubyCache, "No tag match for address: %#x\n", address);
237  return false;
238  }
239  DPRINTF(RubyCache, "address: %#x found\n", address);
240  return true;
241 }
242 
243 // Returns true if there is:
244 // a) a tag match on this address or there is
245 // b) an unused line in the same cache "way"
246 bool
248 {
249  assert(address == makeLineAddress(address));
250 
251  int64_t cacheSet = addressToCacheSet(address);
252 
253  for (int i = 0; i < m_cache_assoc; i++) {
254  AbstractCacheEntry* entry = m_cache[cacheSet][i];
255  if (entry != NULL) {
256  if (entry->m_Address == address ||
257  entry->m_Permission == AccessPermission_NotPresent) {
258  // Already in the cache or we found an empty entry
259  return true;
260  }
261  } else {
262  return true;
263  }
264  }
265  return false;
266 }
267 
270 {
271  assert(address == makeLineAddress(address));
272  assert(!isTagPresent(address));
273  assert(cacheAvail(address));
274  DPRINTF(RubyCache, "address: %#x\n", address);
275 
276  // Find the first open slot
277  int64_t cacheSet = addressToCacheSet(address);
278  std::vector<AbstractCacheEntry*> &set = m_cache[cacheSet];
279  for (int i = 0; i < m_cache_assoc; i++) {
280  if (!set[i] || set[i]->m_Permission == AccessPermission_NotPresent) {
281  if (set[i] && (set[i] != entry)) {
282  warn_once("This protocol contains a cache entry handling bug: "
283  "Entries in the cache should never be NotPresent! If\n"
284  "this entry (%#x) is not tracked elsewhere, it will memory "
285  "leak here. Fix your protocol to eliminate these!",
286  address);
287  }
288  set[i] = entry; // Init entry
289  set[i]->m_Address = address;
290  set[i]->m_Permission = AccessPermission_Invalid;
291  DPRINTF(RubyCache, "Allocate clearing lock for addr: %x\n",
292  address);
293  set[i]->m_locked = -1;
294  m_tag_index[address] = i;
295  set[i]->setPosition(cacheSet, i);
296  set[i]->replacementData = replacement_data[cacheSet][i];
297  set[i]->setLastAccess(curTick());
298 
299  // Call reset function here to set initial value for different
300  // replacement policies.
302 
303  return entry;
304  }
305  }
306  panic("Allocate didn't find an available entry");
307 }
308 
309 void
311 {
312  DPRINTF(RubyCache, "address: %#x\n", address);
313  AbstractCacheEntry* entry = lookup(address);
314  assert(entry != nullptr);
316  uint32_t cache_set = entry->getSet();
317  uint32_t way = entry->getWay();
318  delete entry;
319  m_cache[cache_set][way] = NULL;
320  m_tag_index.erase(address);
321 }
322 
323 // Returns with the physical address of the conflicting cache line
324 Addr
326 {
327  assert(address == makeLineAddress(address));
328  assert(!cacheAvail(address));
329 
330  int64_t cacheSet = addressToCacheSet(address);
332  for (int i = 0; i < m_cache_assoc; i++) {
333  candidates.push_back(static_cast<ReplaceableEntry*>(
334  m_cache[cacheSet][i]));
335  }
336  return m_cache[cacheSet][m_replacementPolicy_ptr->
337  getVictim(candidates)->getWay()]->m_Address;
338 }
339 
340 // looks an address up in the cache
343 {
344  assert(address == makeLineAddress(address));
345  int64_t cacheSet = addressToCacheSet(address);
346  int loc = findTagInSet(cacheSet, address);
347  if (loc == -1) return NULL;
348  return m_cache[cacheSet][loc];
349 }
350 
351 // looks an address up in the cache
352 const AbstractCacheEntry*
353 CacheMemory::lookup(Addr address) const
354 {
355  assert(address == makeLineAddress(address));
356  int64_t cacheSet = addressToCacheSet(address);
357  int loc = findTagInSet(cacheSet, address);
358  if (loc == -1) return NULL;
359  return m_cache[cacheSet][loc];
360 }
361 
362 // Sets the most recently used bit for a cache block
363 void
365 {
366  AbstractCacheEntry* entry = lookup(makeLineAddress(address));
367  if (entry != nullptr) {
369  entry->setLastAccess(curTick());
370  }
371 }
372 
373 void
375 {
376  assert(entry != nullptr);
378  entry->setLastAccess(curTick());
379 }
380 
381 void
382 CacheMemory::setMRU(Addr address, int occupancy)
383 {
384  AbstractCacheEntry* entry = lookup(makeLineAddress(address));
385  if (entry != nullptr) {
386  // m_use_occupancy can decide whether we are using WeightedLRU
387  // replacement policy. Depending on different replacement policies,
388  // use different touch() function.
389  if (m_use_occupancy) {
390  static_cast<WeightedLRUPolicy*>(m_replacementPolicy_ptr)->touch(
391  entry->replacementData, occupancy);
392  } else {
394  }
395  entry->setLastAccess(curTick());
396  }
397 }
398 
399 int
400 CacheMemory::getReplacementWeight(int64_t set, int64_t loc)
401 {
402  assert(set < m_cache_num_sets);
403  assert(loc < m_cache_assoc);
404  int ret = 0;
405  if (m_cache[set][loc] != NULL) {
406  ret = m_cache[set][loc]->getNumValidBlocks();
407  assert(ret >= 0);
408  }
409 
410  return ret;
411 }
412 
413 void
415 {
416  uint64_t warmedUpBlocks = 0;
417  uint64_t totalBlocks M5_VAR_USED = (uint64_t)m_cache_num_sets *
418  (uint64_t)m_cache_assoc;
419 
420  for (int i = 0; i < m_cache_num_sets; i++) {
421  for (int j = 0; j < m_cache_assoc; j++) {
422  if (m_cache[i][j] != NULL) {
423  AccessPermission perm = m_cache[i][j]->m_Permission;
424  RubyRequestType request_type = RubyRequestType_NULL;
425  if (perm == AccessPermission_Read_Only) {
427  request_type = RubyRequestType_IFETCH;
428  } else {
429  request_type = RubyRequestType_LD;
430  }
431  } else if (perm == AccessPermission_Read_Write) {
432  request_type = RubyRequestType_ST;
433  }
434 
435  if (request_type != RubyRequestType_NULL) {
436  Tick lastAccessTick;
437  lastAccessTick = m_cache[i][j]->getLastAccess();
438  tr->addRecord(cntrl, m_cache[i][j]->m_Address,
439  0, request_type, lastAccessTick,
440  m_cache[i][j]->getDataBlk());
441  warmedUpBlocks++;
442  }
443  }
444  }
445  }
446 
447  DPRINTF(RubyCacheTrace, "%s: %lli blocks of %lli total blocks"
448  "recorded %.2f%% \n", name().c_str(), warmedUpBlocks,
449  totalBlocks, (float(warmedUpBlocks) / float(totalBlocks)) * 100.0);
450 }
451 
452 void
453 CacheMemory::print(ostream& out) const
454 {
455  out << "Cache dump: " << name() << endl;
456  for (int i = 0; i < m_cache_num_sets; i++) {
457  for (int j = 0; j < m_cache_assoc; j++) {
458  if (m_cache[i][j] != NULL) {
459  out << " Index: " << i
460  << " way: " << j
461  << " entry: " << *m_cache[i][j] << endl;
462  } else {
463  out << " Index: " << i
464  << " way: " << j
465  << " entry: NULL" << endl;
466  }
467  }
468  }
469 }
470 
471 void
472 CacheMemory::printData(ostream& out) const
473 {
474  out << "printData() not supported" << endl;
475 }
476 
477 void
478 CacheMemory::setLocked(Addr address, int context)
479 {
480  DPRINTF(RubyCache, "Setting Lock for addr: %#x to %d\n", address, context);
481  AbstractCacheEntry* entry = lookup(address);
482  assert(entry != nullptr);
483  entry->setLocked(context);
484 }
485 
486 void
488 {
489  DPRINTF(RubyCache, "Clear Lock for addr: %#x\n", address);
490  AbstractCacheEntry* entry = lookup(address);
491  assert(entry != nullptr);
492  entry->clearLocked();
493 }
494 
495 void
497 {
498  // iterate through every set and way to get a cache line
499  for (auto i = m_cache.begin(); i != m_cache.end(); ++i) {
501  for (auto j = set.begin(); j != set.end(); ++j) {
502  AbstractCacheEntry *line = *j;
503  if (line && line->isLocked(context)) {
504  DPRINTF(RubyCache, "Clear Lock for addr: %#x\n",
505  line->m_Address);
506  line->clearLocked();
507  }
508  }
509  }
510 }
511 
512 bool
513 CacheMemory::isLocked(Addr address, int context)
514 {
515  AbstractCacheEntry* entry = lookup(address);
516  assert(entry != nullptr);
517  DPRINTF(RubyCache, "Testing Lock for addr: %#llx cur %d con %d\n",
518  address, entry->m_locked, context);
519  return entry->isLocked(context);
520 }
521 
522 void
524 {
526 
528  .name(name() + ".demand_hits")
529  .desc("Number of cache demand hits")
530  ;
531 
533  .name(name() + ".demand_misses")
534  .desc("Number of cache demand misses")
535  ;
536 
538  .name(name() + ".demand_accesses")
539  .desc("Number of cache demand accesses")
540  ;
541 
543 
545  .name(name() + ".total_sw_prefetches")
546  .desc("Number of software prefetches")
548  ;
549 
551  .name(name() + ".total_hw_prefetches")
552  .desc("Number of hardware prefetches")
554  ;
555 
557  .name(name() + ".total_prefetches")
558  .desc("Number of prefetches")
560  ;
561 
563 
565  .init(RubyRequestType_NUM)
566  .name(name() + ".access_mode")
568  ;
569  for (int i = 0; i < RubyAccessMode_NUM; i++) {
571  .subname(i, RubyAccessMode_to_string(RubyAccessMode(i)))
573  ;
574  }
575 
577  .name(name() + ".num_data_array_reads")
578  .desc("number of data array reads")
580  ;
581 
583  .name(name() + ".num_data_array_writes")
584  .desc("number of data array writes")
586  ;
587 
589  .name(name() + ".num_tag_array_reads")
590  .desc("number of tag array reads")
592  ;
593 
595  .name(name() + ".num_tag_array_writes")
596  .desc("number of tag array writes")
598  ;
599 
601  .name(name() + ".num_tag_array_stalls")
602  .desc("number of stalls caused by tag array")
604  ;
605 
607  .name(name() + ".num_data_array_stalls")
608  .desc("number of stalls caused by data array")
610  ;
611 
613  .init(8)
614  .name(name() + ".htm_transaction_committed_read_set")
615  .desc("read set size of a committed transaction")
617  ;
618 
620  .init(8)
621  .name(name() + ".htm_transaction_committed_write_set")
622  .desc("write set size of a committed transaction")
624  ;
625 
627  .init(8)
628  .name(name() + ".htm_transaction_aborted_read_set")
629  .desc("read set size of a aborted transaction")
631  ;
632 
634  .init(8)
635  .name(name() + ".htm_transaction_aborted_write_set")
636  .desc("write set size of a aborted transaction")
638  ;
639 }
640 
641 // assumption: SLICC generated files will only call this function
642 // once **all** resources are granted
643 void
644 CacheMemory::recordRequestType(CacheRequestType requestType, Addr addr)
645 {
646  DPRINTF(RubyStats, "Recorded statistic: %s\n",
647  CacheRequestType_to_string(requestType));
648  switch(requestType) {
649  case CacheRequestType_DataArrayRead:
650  if (m_resource_stalls)
653  return;
654  case CacheRequestType_DataArrayWrite:
655  if (m_resource_stalls)
658  return;
659  case CacheRequestType_TagArrayRead:
660  if (m_resource_stalls)
663  return;
664  case CacheRequestType_TagArrayWrite:
665  if (m_resource_stalls)
668  return;
669  default:
670  warn("CacheMemory access_type not found: %s",
671  CacheRequestType_to_string(requestType));
672  }
673 }
674 
675 bool
677 {
678  if (!m_resource_stalls) {
679  return true;
680  }
681 
682  if (res == CacheResourceType_TagArray) {
683  if (tagArray.tryAccess(addressToCacheSet(addr))) return true;
684  else {
685  DPRINTF(RubyResourceStalls,
686  "Tag array stall on addr %#x in set %d\n",
689  return false;
690  }
691  } else if (res == CacheResourceType_DataArray) {
692  if (dataArray.tryAccess(addressToCacheSet(addr))) return true;
693  else {
694  DPRINTF(RubyResourceStalls,
695  "Data array stall on addr %#x in set %d\n",
698  return false;
699  }
700  } else {
701  panic("Unrecognized cache resource type.");
702  }
703 }
704 
705 bool
706 CacheMemory::isBlockInvalid(int64_t cache_set, int64_t loc)
707 {
708  return (m_cache[cache_set][loc]->m_Permission == AccessPermission_Invalid);
709 }
710 
711 bool
712 CacheMemory::isBlockNotBusy(int64_t cache_set, int64_t loc)
713 {
714  return (m_cache[cache_set][loc]->m_Permission != AccessPermission_Busy);
715 }
716 
717 /* hardware transactional memory */
718 
719 void
721 {
722  uint64_t htmReadSetSize = 0;
723  uint64_t htmWriteSetSize = 0;
724 
725  // iterate through every set and way to get a cache line
726  for (auto i = m_cache.begin(); i != m_cache.end(); ++i)
727  {
729 
730  for (auto j = set.begin(); j != set.end(); ++j)
731  {
732  AbstractCacheEntry *line = *j;
733 
734  if (line != nullptr) {
735  htmReadSetSize += (line->getInHtmReadSet() ? 1 : 0);
736  htmWriteSetSize += (line->getInHtmWriteSet() ? 1 : 0);
737  if (line->getInHtmWriteSet()) {
738  line->invalidateEntry();
739  }
740  line->setInHtmWriteSet(false);
741  line->setInHtmReadSet(false);
742  line->clearLocked();
743  }
744  }
745  }
746 
747  htmTransAbortReadSet.sample(htmReadSetSize);
748  htmTransAbortWriteSet.sample(htmWriteSetSize);
749  DPRINTF(HtmMem, "htmAbortTransaction: read set=%u write set=%u\n",
750  htmReadSetSize, htmWriteSetSize);
751 }
752 
753 void
755 {
756  uint64_t htmReadSetSize = 0;
757  uint64_t htmWriteSetSize = 0;
758 
759  // iterate through every set and way to get a cache line
760  for (auto i = m_cache.begin(); i != m_cache.end(); ++i)
761  {
763 
764  for (auto j = set.begin(); j != set.end(); ++j)
765  {
766  AbstractCacheEntry *line = *j;
767  if (line != nullptr) {
768  htmReadSetSize += (line->getInHtmReadSet() ? 1 : 0);
769  htmWriteSetSize += (line->getInHtmWriteSet() ? 1 : 0);
770  line->setInHtmWriteSet(false);
771  line->setInHtmReadSet(false);
772  line->clearLocked();
773  }
774  }
775  }
776 
777  htmTransCommitReadSet.sample(htmReadSetSize);
778  htmTransCommitWriteSet.sample(htmWriteSetSize);
779  DPRINTF(HtmMem, "htmCommitTransaction: read set=%u write set=%u\n",
780  htmReadSetSize, htmWriteSetSize);
781 }
weighted_lru_rp.hh
CacheMemory::recordCacheContents
void recordCacheContents(int cntrl, CacheRecorder *tr) const
Definition: CacheMemory.cc:414
AbstractCacheEntry
Definition: AbstractCacheEntry.hh:57
ReplaceableEntry
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
Definition: replaceable_entry.hh:53
Stats::Group::regStats
virtual void regStats()
Callback to set stat parameters.
Definition: group.cc:64
CacheMemory::findTagInSetIgnorePermissions
int findTagInSetIgnorePermissions(int64_t cacheSet, Addr tag) const
Definition: CacheMemory.cc:151
CacheMemory::m_cache_size
int m_cache_size
Definition: CacheMemory.hh:212
CacheMemory::Params
RubyCacheParams Params
Definition: CacheMemory.hh:66
CacheMemory::m_prefetches
Stats::Formula m_prefetches
Definition: CacheMemory.hh:158
AbstractCacheEntry::setInHtmWriteSet
void setInHtmWriteSet(bool val)
Definition: AbstractCacheEntry.cc:106
warn
#define warn(...)
Definition: logging.hh:239
CacheRecorder
Definition: CacheRecorder.hh:66
CacheMemory::m_hw_prefetches
Stats::Scalar m_hw_prefetches
Definition: CacheMemory.hh:157
CacheMemory::clearLocked
void clearLocked(Addr addr)
Definition: CacheMemory.cc:487
CacheMemory::lookup
AbstractCacheEntry * lookup(Addr address)
Definition: CacheMemory.cc:342
CacheMemory::tagArray
BankedArray tagArray
Definition: CacheMemory.hh:210
RubySystem::getBlockSizeBytes
static uint32_t getBlockSizeBytes()
Definition: RubySystem.hh:62
CacheMemory::isLocked
bool isLocked(Addr addr, int context)
Definition: CacheMemory.cc:513
makeLineAddress
Addr makeLineAddress(Addr addr)
Definition: Address.cc:54
AbstractCacheEntry::setLocked
void setLocked(int context)
Definition: AbstractCacheEntry.cc:78
AbstractCacheEntry::m_Permission
AccessPermission m_Permission
Definition: AbstractCacheEntry.hh:97
warn_once
#define warn_once(...)
Definition: logging.hh:243
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
CacheMemory::m_cache
std::vector< std::vector< AbstractCacheEntry * > > m_cache
Definition: CacheMemory.hh:201
CacheMemory::dataArray
BankedArray dataArray
Definition: CacheMemory.hh:209
BaseReplacementPolicy::invalidate
virtual void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) const =0
Invalidate replacement data to set it as the next probable victim.
CacheMemory::m_demand_misses
Stats::Scalar m_demand_misses
Definition: CacheMemory.hh:153
CacheMemory::cacheProbe
Addr cacheProbe(Addr address) const
Definition: CacheMemory.cc:325
type
uint8_t type
Definition: inet.hh:421
CacheMemory::regStats
void regStats()
Callback to set stat parameters.
Definition: CacheMemory.cc:523
CacheMemory::~CacheMemory
~CacheMemory()
Definition: CacheMemory.cc:113
ReplaceableEntry::getSet
uint32_t getSet() const
Get set number.
Definition: replaceable_entry.hh:94
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
CacheMemory::m_replacementPolicy_ptr
BaseReplacementPolicy * m_replacementPolicy_ptr
We use BaseReplacementPolicy from Classic system here, hence we can use different replacement policie...
Definition: CacheMemory.hh:207
AbstractCacheEntry::m_locked
int m_locked
Definition: AbstractCacheEntry.hh:95
AbstractCacheEntry::getInHtmWriteSet
bool getInHtmWriteSet() const
Definition: AbstractCacheEntry.cc:118
CacheMemory::htmTransCommitWriteSet
Stats::Histogram htmTransCommitWriteSet
Definition: CacheMemory.hh:172
AbstractCacheEntry::m_Address
Addr m_Address
Definition: AbstractCacheEntry.hh:92
AbstractCacheEntry::setInHtmReadSet
void setInHtmReadSet(bool val)
Definition: AbstractCacheEntry.cc:100
std::vector
STL vector class.
Definition: stl.hh:37
CacheMemory::m_tag_index
std::unordered_map< Addr, int > m_tag_index
Definition: CacheMemory.hh:200
CacheMemory::m_cache_num_set_bits
int m_cache_num_set_bits
Definition: CacheMemory.hh:214
AbstractCacheEntry::getInHtmReadSet
bool getInHtmReadSet() const
Definition: AbstractCacheEntry.cc:112
floorLog2
std::enable_if< std::is_integral< T >::value, int >::type floorLog2(T x)
Definition: intmath.hh:63
BankedArray::tryAccess
bool tryAccess(int64_t idx)
Definition: BankedArray.cc:53
BaseReplacementPolicy::instantiateEntry
virtual std::shared_ptr< ReplacementData > instantiateEntry()=0
Instantiate a replacement data entry.
CacheRecorder::addRecord
void addRecord(int cntrl, Addr data_addr, Addr pc_addr, RubyRequestType type, Tick time, DataBlock &data)
Definition: CacheRecorder.cc:154
CacheMemory::print
void print(std::ostream &out) const
Definition: CacheMemory.cc:453
CacheMemory::setMRU
void setMRU(Addr address)
Definition: CacheMemory.cc:364
CacheMemory::deallocate
void deallocate(Addr address)
Definition: CacheMemory.cc:310
CacheMemory::testCacheAccess
bool testCacheAccess(Addr address, RubyRequestType type, DataBlock *&data_ptr)
Definition: CacheMemory.cc:211
CacheMemory::m_use_occupancy
bool m_use_occupancy
Set to true when using WeightedLRU replacement policy, otherwise, set to false.
Definition: CacheMemory.hh:234
DataBlock
Definition: DataBlock.hh:40
Stats::DataWrap::flags
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
Definition: statistics.hh:331
AbstractCacheEntry::invalidateEntry
virtual void invalidateEntry()
Definition: AbstractCacheEntry.hh:111
ArmISA::j
Bitfield< 24 > j
Definition: miscregs_types.hh:54
CacheMemory::allocate
AbstractCacheEntry * allocate(Addr address, AbstractCacheEntry *new_entry)
Definition: CacheMemory.cc:269
CacheMemory::init
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: CacheMemory.cc:90
CacheMemory::m_demand_hits
Stats::Scalar m_demand_hits
Definition: CacheMemory.hh:152
CacheMemory::replacement_data
std::vector< std::vector< ReplData > > replacement_data
We store all the ReplacementData in a 2-dimensional array.
Definition: CacheMemory.hh:228
WeightedLRUPolicy
Definition: weighted_lru_rp.hh:44
CacheMemory.hh
CacheMemory::numTagArrayStalls
Stats::Scalar numTagArrayStalls
Definition: CacheMemory.hh:167
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
CacheMemory::printData
void printData(std::ostream &out) const
Definition: CacheMemory.cc:472
CacheMemory::cacheAvail
bool cacheAvail(Addr address) const
Definition: CacheMemory.cc:247
CacheMemory::CacheMemory
CacheMemory(const Params *p)
Definition: CacheMemory.cc:71
CacheMemory
Definition: CacheMemory.hh:63
bitSelect
Addr bitSelect(Addr addr, unsigned int small, unsigned int big)
Definition: Address.cc:35
CacheMemory::m_cache_assoc
int m_cache_assoc
Definition: CacheMemory.hh:215
RiscvISA::perm
Bitfield< 3, 1 > perm
Definition: pagetable.hh:68
AbstractCacheEntry::clearLocked
void clearLocked()
Definition: AbstractCacheEntry.cc:85
CacheMemory::isBlockInvalid
bool isBlockInvalid(int64_t cache_set, int64_t loc)
Definition: CacheMemory.cc:706
RubySystem.hh
CacheMemory::m_block_size
int m_block_size
Definition: CacheMemory.hh:218
CacheMemory::m_sw_prefetches
Stats::Scalar m_sw_prefetches
Definition: CacheMemory.hh:156
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
CacheMemory::findTagInSet
int findTagInSet(int64_t line, Addr tag) const
Definition: CacheMemory.cc:136
Stats::DataWrap::name
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
Definition: statistics.hh:274
Stats::dist
const FlagsType dist
Print the distribution.
Definition: info.hh:55
Stats::VectorBase::init
Derived & init(size_type size)
Set this vector to have the given size.
Definition: statistics.hh:1177
AbstractCacheEntry::isLocked
bool isLocked(int context) const
Definition: AbstractCacheEntry.cc:92
CacheMemory::clearLockedAll
void clearLockedAll(int context)
Definition: CacheMemory.cc:496
Stats::nozero
const FlagsType nozero
Don't print if this is zero.
Definition: info.hh:57
CacheMemory::m_start_index_bit
int m_start_index_bit
Definition: CacheMemory.hh:216
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
AbstractCacheEntry::setLastAccess
void setLastAccess(Tick tick)
Definition: AbstractCacheEntry.hh:104
CacheMemory::tryCacheAccess
bool tryCacheAccess(Addr address, RubyRequestType type, DataBlock *&data_ptr)
Definition: CacheMemory.cc:186
CacheMemory::htmCommitTransaction
void htmCommitTransaction()
Definition: CacheMemory.cc:754
CacheMemory::setLocked
void setLocked(Addr addr, int context)
Definition: CacheMemory.cc:478
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
CacheMemory::htmTransAbortWriteSet
Stats::Histogram htmTransAbortWriteSet
Definition: CacheMemory.hh:174
Stats::pdf
const FlagsType pdf
Print the percent of the total that this entry represents.
Definition: info.hh:51
CacheMemory::isTagPresent
bool isTagPresent(Addr address) const
Definition: CacheMemory.cc:231
BaseReplacementPolicy::touch
virtual void touch(const std::shared_ptr< ReplacementData > &replacement_data) const =0
Update replacement data.
CacheMemory::numDataArrayWrites
Stats::Scalar numDataArrayWrites
Definition: CacheMemory.hh:163
addr
ip6_addr_t addr
Definition: inet.hh:423
CacheMemory::getAddressAtIdx
Addr getAddressAtIdx(int idx) const
Definition: CacheMemory.cc:166
CacheMemory::numDataArrayReads
Stats::Scalar numDataArrayReads
Definition: CacheMemory.hh:162
Stats::DistBase::sample
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
Definition: statistics.hh:1924
logging.hh
ReplaceableEntry::replacementData
std::shared_ptr< ReplacementData > replacementData
Replacement data associated to this entry.
Definition: replaceable_entry.hh:74
CacheMemory::m_is_instruction_only_cache
bool m_is_instruction_only_cache
Definition: CacheMemory.hh:196
CacheMemory::addressToCacheSet
int64_t addressToCacheSet(Addr address) const
Definition: CacheMemory.cc:126
BaseReplacementPolicy::reset
virtual void reset(const std::shared_ptr< ReplacementData > &replacement_data) const =0
Reset replacement data.
Stats::DataWrapVec::subname
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.
Definition: statistics.hh:374
CacheMemory::htmTransCommitReadSet
Stats::Histogram htmTransCommitReadSet
Definition: CacheMemory.hh:171
Stats::Histogram::init
Histogram & init(size_type size)
Set the parameters of this histogram.
Definition: statistics.hh:2669
operator<<
ostream & operator<<(ostream &out, const CacheMemory &obj)
Definition: CacheMemory.cc:58
CacheMemory::checkResourceAvailable
bool checkResourceAvailable(CacheResourceType res, Addr addr)
Definition: CacheMemory.cc:676
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
intmath.hh
Stats::total
const FlagsType total
Print the total.
Definition: info.hh:49
BankedArray::reserve
void reserve(int64_t idx)
Definition: BankedArray.cc:69
Stats::DataWrap::desc
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
Definition: statistics.hh:307
CacheMemory::recordRequestType
void recordRequestType(CacheRequestType requestType, Addr addr)
Definition: CacheMemory.cc:644
CacheMemory::htmAbortTransaction
void htmAbortTransaction()
Definition: CacheMemory.cc:720
CacheMemory::getReplacementWeight
int getReplacementWeight(int64_t set, int64_t loc)
Definition: CacheMemory.cc:400
CacheMemory::m_cache_num_sets
int m_cache_num_sets
Definition: CacheMemory.hh:213
CacheMemory::numTagArrayWrites
Stats::Scalar numTagArrayWrites
Definition: CacheMemory.hh:165
CacheMemory::numTagArrayReads
Stats::Scalar numTagArrayReads
Definition: CacheMemory.hh:164
CacheMemory::m_demand_accesses
Stats::Formula m_demand_accesses
Definition: CacheMemory.hh:154
Stats::nonan
const FlagsType nonan
Don't print if this is NAN.
Definition: info.hh:59
CacheMemory::numDataArrayStalls
Stats::Scalar numDataArrayStalls
Definition: CacheMemory.hh:168
CacheMemory::htmTransAbortReadSet
Stats::Histogram htmTransAbortReadSet
Definition: CacheMemory.hh:173
AbstractCacheEntry::getDataBlk
virtual DataBlock & getDataBlk()
Definition: AbstractCacheEntry.hh:76
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
CacheMemory::m_resource_stalls
bool m_resource_stalls
Definition: CacheMemory.hh:217
CacheMemory::m_accessModeType
Stats::Vector m_accessModeType
Definition: CacheMemory.hh:160
curTick
Tick curTick()
The current simulated tick.
Definition: core.hh:45
CacheMemory::isBlockNotBusy
bool isBlockNotBusy(int64_t cache_set, int64_t loc)
Definition: CacheMemory.cc:712
ReplaceableEntry::getWay
uint32_t getWay() const
Get way number.
Definition: replaceable_entry.hh:101
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17