-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_scripts.py
117 lines (105 loc) · 3.27 KB
/
build_scripts.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import json
import os
def save_config(config, prefix):
config["caches"].sort(key=lambda x: x["layer"])
cache_descs: list[str] = []
for cache in config["caches"]:
size = cache["size"]
radix = ""
if size / 1024 >= 1:
size /= 1024
radix = "K"
if size / 1024 >= 1:
size /= 1024
radix = "M"
if size / 1024 >= 1:
size /= 1024
radix = "G"
layer = cache["layer"]
assc = cache["associativity"]
bs = cache["block_size"]
cache_desc = f"L{layer}s{int(size)}{radix}w{assc}bs{bs}"
cache_descs.append(cache_desc)
json_path = cache_descs.pop(0)
while True:
try:
path = cache_descs.pop(0)
except Exception:
break
json_path += '_'
json_path += path
json_path += '.json'
with open(file=f"{prefix}{json_path}", mode='w') as f:
json.dump(config, f, indent=4)
def generate_group_1():
config = {
"CPU_GHZ": 2.0,
"using_latency_as_cycles": True,
"memory": {
"hit_latency": 100,
"bus_latency": 0,
},
"caches": [
{
"layer": 1,
"hit_latency": 1,
"bus_latency": 0,
"write_hit_policy": "WriteThrough",
"write_miss_policy": "NonWriteAllocate",
"replacement_policy": "LRU",
"size": 32 * 1024,
"associativity": 8,
"block_size": 64,
}
]
}
CONFIGS_DIR_PREFIX = 'configs/group_1/'
for cache_size in [16, 32, 64, 128]:
cache_size *= 1024 # KiB
config["caches"][0]["size"] = cache_size
for bs in [16, 32, 64, 128]:
config["caches"][0]["block_size"] = bs
save_config(config, CONFIGS_DIR_PREFIX)
def generate_group_2():
config = {
"CPU_GHZ": 2.0,
"using_latency_as_cycles": True,
"memory": {
"hit_latency": 100,
"bus_latency": 0,
},
"caches": [
{
"layer": 1,
"hit_latency": 1,
"bus_latency": 0,
"write_hit_policy": "WriteThrough",
"write_miss_policy": "NonWriteAllocate",
"replacement_policy": "LRU",
"size": 64 * 1024,
"associativity": 8,
"block_size": 64,
},
{
"layer": 2,
"hit_latency": 1,
"bus_latency": 0,
"write_hit_policy": "WriteThrough",
"write_miss_policy": "NonWriteAllocate",
"replacement_policy": "LRU",
"size": 512 * 1024,
"associativity": 8,
"block_size": 64,
}
]
}
CONFIGS_DIR_PREFIX = 'configs/group_2/'
for ascc in [1, 2, 4, 8, 16]:
for bs in [16, 32, 64, 128]:
config["caches"][0]["associativity"] = ascc
config["caches"][1]["associativity"] = ascc
config["caches"][0]["block_size"] = bs
config["caches"][1]["block_size"] = bs
save_config(config, CONFIGS_DIR_PREFIX)
if __name__ == '__main__':
generate_group_2()