-
Notifications
You must be signed in to change notification settings - Fork 2
/
lru.llc_repl
53 lines (42 loc) · 1.53 KB
/
lru.llc_repl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "cache.h"
// initialize replacement state
void CACHE::llc_initialize_replacement()
{
}
// find replacement victim
uint32_t CACHE::llc_find_victim(uint32_t cpu, uint64_t instr_id, uint32_t set, const BLOCK *current_set, uint64_t ip, uint64_t full_addr, uint32_t type)
{
// baseline LRU
return lru_victim(cpu, instr_id, set, current_set, ip, full_addr, type);
}
// called on every cache hit and cache fill
void CACHE::llc_update_replacement_state(uint32_t cpu, uint32_t set, uint32_t way, uint64_t full_addr, uint64_t ip, uint64_t victim_addr, uint32_t type, uint8_t hit)
{
string TYPE_NAME;
if (type == LOAD)
TYPE_NAME = "LOAD";
else if (type == RFO)
TYPE_NAME = "RFO";
else if (type == PREFETCH)
TYPE_NAME = "PF";
else if (type == WRITEBACK)
TYPE_NAME = "WB";
else
assert(0);
if (hit)
TYPE_NAME += "_HIT";
else
TYPE_NAME += "_MISS";
if ((type == WRITEBACK) && ip)
assert(0);
// uncomment this line to see the LLC accesses
// cout << "CPU: " << cpu << " LLC " << setw(9) << TYPE_NAME << " set: " << setw(5) << set << " way: " << setw(2) << way;
// cout << hex << " paddr: " << setw(12) << paddr << " ip: " << setw(8) << ip << " victim_addr: " << victim_addr << dec << endl;
// baseline LRU
if (hit && (type == WRITEBACK)) // writeback hit does not update LRU state
return;
return lru_update(set, way,cpu);
}
void CACHE::llc_replacement_final_stats()
{
}