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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
#!/usr/bin/python
import os
import copy
import sys
import string
import pwd
import smtplib
import socket
import time
import itertools
import multiprocessing
from run.executable.executable import Executable
test_mode = False
email_notification = True
def run_exp(nsamples, ncpu, numa_args, wss, wcycle, sleep_range_ms, walk, do_pollute, do_huge_pages, do_uncache_pages):
fstub = 'pmo'
fstub += '_host='+socket.gethostname().split('.')[0]
fstub += '_ncpu='+str(ncpu)
fstub += '_wss='+str(wss)
fstub += '_wcycle='+str(wcycle)
fstub += '_smin='+str(sleep_range_ms[0]*1000)
fstub += '_smax='+str(sleep_range_ms[1]*1000)
fstub += '_polluters='+str(do_pollute)
fstub += '_hpages='+str(do_huge_pages)
fstub += '_upages='+str(do_uncache_pages)
fstub += '_walk='+walk
filename = fstub + '.csv'
if os.path.exists(filename):
return
polluters = []
if do_pollute:
for i in range(multiprocessing.cpu_count()):
if numa_args:
# number of CPUs in one of two NUMA nodes
if ncpu == 6:
if i < 6:
numa_hack = ['--cpunodebind=0', '--interleave=0']
else:
numa_hack = ['--cpunodebind=1', '--interleave=1']
else:
numa_hack = ['--cpunodebind=0,1', '--interleave=0,1']
args = copy.deepcopy(numa_hack)
args.append('memthrash')
else:
args = []
args.append('-m')
args.append(str(i))
if numa_args:
polluters.append(Executable('numactl', args))
else:
polluters.append(Executable('memthrash', args))
if numa_args:
args = copy.deepcopy(numa_args)
args.append('cache_cost')
else:
args = []
args.append('-m')
args.append(str(ncpu))
args.append('-c')
args.append(str(nsamples))
args.append('-s')
args.append(str(wss))
args.append('-w')
args.append(str(wcycle))
if do_huge_pages:
args.append('-h')
if do_uncache_pages:
args.append('-u')
# cache_cost wants time in microseconds
args.append('-x')
args.append(str(sleep_range_ms[0]*1000))
args.append('-y')
args.append(str(sleep_range_ms[1]*1000))
if walk == 'rand':
args.append('-r')
args.append('-o')
args.append(filename)
if numa_args:
probe = Executable('numactl', args)
else:
probe = Executable('cache_cost', args)
if not test_mode:
if do_pollute:
for p in polluters:
p.execute()
time.sleep(10)
probe.execute()
probe.wait()
for p in polluters:
p.kill()
for p in polluters:
p.wait(False)
else:
print 'Process commands and arguments: '
if do_pollute:
for p in polluters:
print str(p)
print str(probe)
def send_email(_to, _msg):
user = pwd.getpwuid(os.getuid())[0]
host = socket.gethostname()
_from = "%s@%s" % (user, host)
_body = "\r\n".join(["From: %s" % _from, "To: %s" % _to, "Subject: Test Completed!", "", "{}"])
mail = smtplib.SMTP("localhost")
mail.sendmail(_from, [_to], _body.format(_msg))
mail.quit()
def main(argv):
nsamples = 5000
# We may need to test different NUMA node configurations
# according to memory interleaving across the NUMA topology.
#
# For non-numa systems, do "<#cpu>: []"
# Ex., for a 4-CPU non-numa system: "4: []"
#
# NOTE: Must update NUMA hack in run_exp() for memthrash
# for your configuration.
#
# todo: configure numa args for system automatically
ncpu_and_numa_args = {
24: []
}
wss_kb = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 3072, 4096, 8192, 12288, 16384]
write_cycle = [16, 4, 2]
# write_cycle = [0]
sleep_range_ms = [0,50]
# uncache = [False, True]
uncache = [False]
huge_pages = [False]
pollute = [False, True]
# walk = ['seq', 'rand']
walk = ['seq']
# disable rt throttling in linux scheduler
os.system("echo -1 > /proc/sys/kernel/sched_rt_runtime_us")
for ncpu, numa_args in ncpu_and_numa_args.iteritems():
for u in uncache:
for h in huge_pages:
if u == True and h == True:
# skip invalid combo
continue
for wcycle in write_cycle:
for w in walk:
for p in pollute:
for wss in wss_kb:
run_exp(nsamples, ncpu, numa_args, wss, wcycle, sleep_range_ms, w, p, h, u)
if email_notification:
to = "gelliott@cs.unc.edu"
msg = "Cache Ovh Collection Complete!"
send_email(to, msg)
if __name__ == "__main__":
os.environ['PATH'] += ':../liblitmus'
os.environ['PATH'] += ':../cache-ovh'
if 'LD_LIBRARY_PATH' not in os.environ:
os.environ['LD_LIBRARY_PATH'] = ''
os.environ['LD_LIBRARY_PATH'] += ':../liblitmus'
main(sys.argv[1:])
|