Version 1.4.0 introduces optional L3 (Last Level Cache) support to the Cache Simulator. The L3 cache serves as a shared cache in multi-core systems and provides an additional level of the memory hierarchy between L2 caches and main memory.
{
"memory_hierarchy": {
"l1": {
"size": 32768,
"associativity": 4,
"block_size": 64
},
"l2": {
"size": 262144,
"associativity": 8,
"block_size": 64
},
"l3": {
"size": 8388608,
"associativity": 16,
"block_size": 64
},
"l3_inclusive": true
}
}| Parameter | Type | Description |
|---|---|---|
size |
int | L3 cache size in bytes (typical: 4MB-32MB) |
associativity |
int | Set associativity (typical: 8-16 ways) |
block_size |
int | Cache line size (must match L1/L2) |
l3_inclusive |
bool | Whether L3 is inclusive of L1/L2 |
When l3_inclusive is true, the L3 cache maintains a superset of all data in L1 and L2 caches:
- Benefit: Simplifies coherence in multi-core systems
- Trade-off: Evictions from L3 require back-invalidation of L1/L2
When l3_inclusive is false:
- L3 acts as a victim cache for L2 misses
- No back-invalidation required on L3 eviction
- More efficient use of total cache capacity
L1 Access
├── HIT → Return data
└── MISS → L2 Access
├── HIT → Return data, update L1
└── MISS → L3 Access
├── HIT → Return data, update L1, L2
└── MISS → Memory Access
The following L3 statistics are available:
| Method | Description |
|---|---|
getL3Misses() |
Total L3 cache misses |
getL3HitRate() |
L3 hit rate (0.0 to 1.0) |
getL3MissRate() |
L3 miss rate (0.0 to 1.0) |
hasL3() |
Whether L3 is configured |
getL3Cache() |
Optional pointer to L3 cache |
{
"l3": {
"size": 8388608,
"associativity": 16,
"block_size": 64
},
"l3_inclusive": true
}{
"l3": {
"size": 33554432,
"associativity": 16,
"block_size": 64
},
"l3_inclusive": false
}The L3 cache is implemented as an std::optional<Cache> member in MemoryHierarchy:
std::optional<Cache> l3;
bool l3Inclusive_ = true;if (!l1Hit) {
if (l2 && !l2->access(address, isWrite)) {
if (l3) {
l3Accesses++;
if (!l3->access(address, isWrite)) {
l3Misses++;
// Memory access
}
}
}
}- L3 Size: Should be significantly larger than total L2 capacity
- Associativity: Higher associativity reduces conflict misses
- Inclusivity: Inclusive is simpler but wastes capacity duplicating L1/L2 data