-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
53 lines (42 loc) · 1.39 KB
/
main.cpp
File metadata and controls
53 lines (42 loc) · 1.39 KB
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 <fstream>
#include "cache.h"
u64 clk = 0;
int main(int argc, char** argv) {
if( argc < 2 ) {
std::cout << "Usage: " << __FILE__ << " <memory trace file path>\n";
exit(0);
}
Cache* L1 = (Cache*) malloc(sizeof(Cache) * MAX_POLICY);
Cache* L2 = (Cache*) malloc(sizeof(Cache) * MAX_POLICY);
for ( int i = 0; i < MAX_POLICY; i++ ) {
L1[i] = Cache(8, 64, 64, Replace_Policy[LRU]);
L2[i] = Cache(16, 64, 1024, Replace_Policy[i]);
}
std::ifstream trace;
trace.open(argv[1]);
if ( trace.rdstate() & std::ifstream::failbit ) {
std::cerr << "Error opening " << argv[1] << std::endl;
return 0;
}
char buff[128];
long unsigned int addr;
int opsize;
trace.getline(buff, 128);
while ( !(trace.rdstate() & std::ifstream::eofbit) ) {
sscanf(buff, "%lu %d\n", &addr, &opsize);
for ( int i = 0; i < MAX_POLICY; i++ ) {
Inclusion_Policy(&L1[i], &L2[i], addr, opsize, clk);
}
clk++;
trace.getline(buff, 128);
}
for ( int i = 0; i < MAX_POLICY; i++ ) {
std::cout << policy_name[i] << "---------------------------------\n";
std::cout << "------L1------\n";
Print_Stats(&L1[i]);
std::cout << "------L2------\n";
Print_Stats(&L2[i]);
std::cout << "--------------------------------------\n";
}
return 0;
}