forked from cache-sim/cache-sim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache.py
More file actions
executable file
·33 lines (26 loc) · 1.21 KB
/
cache.py
File metadata and controls
executable file
·33 lines (26 loc) · 1.21 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
#!/usr/bin/python3
import os # to execute the programs
import sys # for argv
if(len(sys.argv) < 6):
print("Usage: ./cache.py <replacement_policy> <block_size> <set_associativity> <number_of_sets> <input_trace>")
print(" -> <replacement_policy> can be:")
print(" * lru")
print(" * lfu")
print(" * nru")
print(" * plru")
print(" * srrip")
print(" -> cache specifications can be any powers of 2")
print(" -> <input_trace> is the trace generated by using the Intel® pin tool (pinatrace)")
else:
replacementPolicy = sys.argv[1]
blockSize = sys.argv[2]
setAssociativity = sys.argv[3]
numberOfSets = sys.argv[4]
inputTrace = sys.argv[5]
if not os.path.isdir("exe"):
os.system("mkdir exe")
if any(replacementPolicy+".cpp" in file for file in os.listdir("src/")) and replacementPolicy != "cache":
os.system("g++ src/" + replacementPolicy + ".cpp src/cache.cpp -o exe/" + replacementPolicy)
os.system("gzip -dc " + inputTrace + " | exe/" + replacementPolicy + " " + numberOfSets + " " + blockSize + " " + setAssociativity)
else:
print("That replacement policy is not supported")