aboutsummaryrefslogtreecommitdiffstats
path: root/cache_cost.py
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2013-10-15 20:19:57 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2013-10-15 20:19:57 -0400
commit311f3384882847edd83d688a1a2dcc12bdc59d23 (patch)
treef4a75065c57bfc29796c2eef349a02a97c6912d7 /cache_cost.py
parente15736509ab36e33bc71a0fe1120f2974e389725 (diff)
CPMD and producer/consumer overhead scripts.
Diffstat (limited to 'cache_cost.py')
-rwxr-xr-xcache_cost.py181
1 files changed, 181 insertions, 0 deletions
diff --git a/cache_cost.py b/cache_cost.py
new file mode 100755
index 0000000..9f4e54a
--- /dev/null
+++ b/cache_cost.py
@@ -0,0 +1,181 @@
1#!/usr/bin/python
2
3import os
4import copy
5import sys
6import string
7import smtplib
8import socket
9import time
10import itertools
11import multiprocessing
12
13from run.executable.executable import Executable
14
15test_mode = False
16email_notification = True
17
18def run_exp(nsamples, ncpu, numa_args, wss, wcycle, sleep_range_ms, walk, do_pollute, do_huge_pages, do_uncache_pages):
19
20 fstub = 'pmo'
21 fstub += '_host='+socket.gethostname().split('.')[0]
22 fstub += '_ncpu='+str(ncpu)
23 fstub += '_wss='+str(wss)
24 fstub += '_wcycle='+str(wcycle)
25 fstub += '_smin='+str(sleep_range_ms[0]*1000)
26 fstub += '_smax='+str(sleep_range_ms[1]*1000)
27 fstub += '_polluters='+str(do_pollute)
28 fstub += '_hpages='+str(do_huge_pages)
29 fstub += '_upages='+str(do_uncache_pages)
30 fstub += '_walk='+walk
31
32 filename = fstub + '.csv'
33
34 if os.path.exists(filename):
35 return
36
37 polluters = []
38 if do_pollute:
39 for i in range(multiprocessing.cpu_count()):
40 if numa_args:
41 # number of CPUs in one of two NUMA nodes
42 if ncpu == 6:
43 if i < 6:
44 numa_hack = ['--cpunodebind=0', '--interleave=0']
45 else:
46 numa_hack = ['--cpunodebind=1', '--interleave=1']
47 else:
48 numa_hack = ['--cpunodebind=0,1', '--interleave=0,1']
49 args = copy.deepcopy(numa_hack)
50 args.append('memthrash')
51 else:
52 args = []
53 args.append('-m')
54 args.append(str(i))
55 if numa_args:
56 polluters.append(Executable('numactl', args))
57 else:
58 polluters.append(Executable('memthrash', args))
59
60 if numa_args:
61 args = copy.deepcopy(numa_args)
62 args.append('cache_cost')
63 else:
64 args = []
65 args.append('-m')
66 args.append(str(ncpu))
67 args.append('-c')
68 args.append(str(nsamples))
69 args.append('-s')
70 args.append(str(wss))
71 args.append('-w')
72 args.append(str(wcycle))
73
74 if do_huge_pages:
75 args.append('-h')
76
77 if do_uncache_pages:
78 args.append('-u')
79
80 # cache_cost wants time in microseconds
81 args.append('-x')
82 args.append(str(sleep_range_ms[0]*1000))
83 args.append('-y')
84 args.append(str(sleep_range_ms[1]*1000))
85
86 if walk == 'rand':
87 args.append('-r')
88
89 args.append('-o')
90 args.append(filename)
91
92 if numa_args:
93 probe = Executable('numactl', args)
94 else:
95 probe = Executable('cache_cost', args)
96
97 if not test_mode:
98 if do_pollute:
99 for p in polluters:
100 p.execute()
101 time.sleep(10)
102
103 probe.execute()
104 probe.wait()
105
106 for p in polluters:
107 p.kill()
108 for p in polluters:
109 p.wait(False)
110 else:
111 print 'Process commands and arguments: '
112 if do_pollute:
113 for p in polluters:
114 print str(p)
115 print str(probe)
116
117def main(argv):
118 nsamples = 5000
119
120 # We may need to test different NUMA node configurations
121 # according to memory interleaving across the NUMA topology.
122 #
123 # For non-numa systems, do "<#cpu>: []"
124 # Ex., for a 4-CPU non-numa system: "4: []"
125 #
126 # NOTE: Must update NUMA hack in run_exp() for memthrash
127 # for your configuration.
128 #
129 # todo: configure numa args for system automatically
130 ncpu_and_numa_args = {
131 6: ['--cpunodebind=0', '--interleave=0']
132# 12: ['--cpunodebind=0,1', '--interleave=0,1']
133 }
134
135 wss_kb = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 3072, 4096, 8192, 12288, 16384]
136 write_cycle = [0, 64, 16, 4, 2, 1]
137
138 sleep_range_ms = [0,50]
139
140# uncache = [False, True]
141 uncache = [False]
142 huge_pages = [False]
143
144 pollute = [False, True]
145 walk = ['seq', 'rand']
146# walk = ['seq']
147
148 for ncpu, numa_args in ncpu_and_numa_args.iteritems():
149 for u in uncache:
150 for h in huge_pages:
151 if u == True and h == True:
152 # skip invalid combo
153 continue
154 for wcycle in write_cycle:
155 for w in walk:
156 for p in pollute:
157 for wss in wss_kb:
158 run_exp(nsamples, ncpu, numa_args, wss, wcycle, sleep_range_ms, w, p, h, u)
159
160 if email_notification:
161 _subject = "Cache Ovh Collection Complete!"
162 _to = "gelliott@cs.unc.edu"
163 _from = "gelliott@bonham.cs.unc.edu"
164 _text = "Cache Ovh Collection Complete!"
165 _body = string.join(("From: %s" % _from, "To: %s" % _to, "Subject: %s" % _subject, "", _text), "\r\n")
166 s = smtplib.SMTP("localhost")
167 s.sendmail(_from, [_to], _body)
168 s.quit()
169
170
171
172if __name__ == "__main__":
173
174 os.environ['PATH'] += ':../liblitmus'
175 os.environ['PATH'] += ':../cache-ovh'
176
177 if 'LD_LIBRARY_PATH' not in os.environ:
178 os.environ['LD_LIBRARY_PATH'] = ''
179 os.environ['LD_LIBRARY_PATH'] += ':../liblitmus'
180
181 main(sys.argv[1:])