-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun_multiple_memtier_bench.py
executable file
·76 lines (65 loc) · 2.35 KB
/
run_multiple_memtier_bench.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
#!/usr/bin/python
# this script is used to run memtier_counter_bench multiple times with different thresholds
import numpy as np
import subprocess
import re
import os
from matplotlib import pyplot as plt
class Policy:
STATIC_RATIO='-s'
DATA_HOTNESS='-p'
def compile_command(runs: int, iterations: int, policy: Policy):
return ['./utils/memtier_counter_bench/memtier_counter_bench', policy, '-i', f'{iterations}', '-r', f'{runs}', '-t', '1']
def collect_data_multiple_runs(runs: [int], iterations: int, policy: Policy):
ratios=[]
menv = os.environ.copy()
menv['LD_LIBRARY_PATH'] = '.libs:' + menv['LD_LIBRARY_PATH'] if 'LD_LIBRARY_PATH' in menv else ''
for cruns in runs:
command = compile_command(cruns, iterations, policy)
out = subprocess.run(command, stdout=subprocess.PIPE)
sout = out.stdout.decode()
ratio = None
for line in sout.split('\n'):
mo = re.findall('actual\|desired DRAM/TOTAL ratio: ([0-9\.]*) ', line)
if mo:
ratio = float(mo[0])
if ratio is not None:
ratios.append(ratio)
else:
raise Exception('Ratio not found!')
return ratios
def collect_data_multiple_iters(runs: int, iters: int, policy: Policy):
ratios=[]
menv = os.environ.copy()
menv['LD_LIBRARY_PATH'] = '.libs:' + menv['LD_LIBRARY_PATH'] if 'LD_LIBRARY_PATH' in menv else ''
for citers in iters:
command = compile_command(runs, citers, policy)
out = subprocess.run(command, stdout=subprocess.PIPE)
sout = out.stdout.decode()
ratio = None
for line in sout.split('\n'):
mo = re.findall('actual\|desired DRAM/TOTAL ratio: ([0-9\.]*) ', line)
if mo:
ratio = float(mo[0])
if ratio is not None:
ratios.append(ratio)
else:
raise Exception('Ratio not found!')
return ratios
#runs=np.logspace(1, 3.5, 10)
runs=np.logspace(2, 5.5, 8)
results = collect_data_multiple_runs(runs, 10, Policy.DATA_HOTNESS)
plt.plot(runs, results, '*')
plt.xscale('log')
plt.grid()
plt.xlabel('runs')
plt.ylabel('ratio')
plt.show()
iterations=np.logspace(2, 5.5, 8)
results = collect_data_multiple_iters(10, iterations, Policy.DATA_HOTNESS)
plt.plot(iterations, results, '*')
plt.xscale('log')
plt.grid()
plt.xlabel('iterations')
plt.ylabel('ratio')
plt.show()