-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cpu.cpp
More file actions
38 lines (28 loc) · 984 Bytes
/
test_cpu.cpp
File metadata and controls
38 lines (28 loc) · 984 Bytes
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
#include <iostream>
#include <string>
#include "SimpleCPU.h"
#include <libcachesim/CacheToolbox.h>
using namespace std;
/* Returns the L2 associativity needed in order for L2 to have the same number of sets
* than L1 */
unsigned compute_L2_associativity(unsigned L1_size, unsigned L1_assoc, unsigned L2_size)
{
const float ratio = L2_size / (float) L1_size;
return L1_assoc * ratio;
}
int main(int argc, char** argv)
{
if (argc != 5)
{
cerr << "Must provide two filenames and two cache sizes (L1 and L2) as arguments" << endl;
exit(1);
}
const unsigned L1_size = stoul(argv[3]);
const unsigned L2_size = stoul(argv[4]);
const unsigned L1_assoc = 64;
const unsigned L2_assoc = compute_L2_associativity(L1_size, L1_assoc, L2_size);
CacheConfig L1_config(L1_size, L1_assoc, 64);
CacheConfig L2_config(L2_size, L2_assoc, 64);
SimpleCPU cpu(argv[1], argv[2], L1_config, L2_config, 1, 1, 10, 130);
cpu.run();
}