-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_experiments.py
More file actions
36 lines (30 loc) · 1.48 KB
/
run_experiments.py
File metadata and controls
36 lines (30 loc) · 1.48 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
# Run experiments for cache simulator
import subprocess
import os
configs = [
(256, 1, 16, "write-allocate", "write-back", "lru"),
(256, 4, 16, "write-allocate", "write-back", "lru"),
(512, 4, 16, "write-allocate", "write-back", "lru"),
(128, 4, 32, "write-allocate", "write-back", "lru"),
(1024, 4, 16, "write-allocate", "write-back", "lru"),
(256, 4, 16, "no-write-allocate", "write-through", "lru"),
(256, 4, 16, "write-allocate", "write-back", "fifo"),
]
trace_file = "traces/gcc.trace"
print("Sets,Blocks,Bytes,WriteAlloc,WritePolicy,Eviction,LoadHits,LoadMisses,StoreHits,StoreMisses,TotalCycles")
for sets, blocks, bytes, wa, wp, ev in configs:
# Use direct stdin instead of cat to avoid platform issues
with open(trace_file, 'r') as f:
cmd = ["./csim.exe", str(sets), str(blocks), str(bytes), wa, wp, ev]
process = subprocess.Popen(cmd, stdin=f, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
stdout, stderr = process.communicate()
# Debug: print(stdout)
lines = stdout.strip().split('\n')
results = {}
for line in lines:
if ':' in line:
parts = line.split(':')
if len(parts) == 2:
key, val = parts
results[key.strip()] = val.strip()
print(f"{sets},{blocks},{bytes},{wa},{wp},{ev},{results.get('Load hits')},{results.get('Load misses')},{results.get('Store hits')},{results.get('Store misses')},{results.get('Total cycles')}")