aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/__init__.py0
-rwxr-xr-xutils/iqr.py32
-rw-r--r--utils/machines.py43
3 files changed, 75 insertions, 0 deletions
diff --git a/utils/__init__.py b/utils/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/utils/__init__.py
diff --git a/utils/iqr.py b/utils/iqr.py
new file mode 100755
index 0000000..bbecdfa
--- /dev/null
+++ b/utils/iqr.py
@@ -0,0 +1,32 @@
1import numpy as np
2from scipy.stats import scoreatpercentile
3import bisect
4
5def find_lt(a, x):
6 i = bisect.bisect_left(a,x)
7 if i:
8 return i - 1
9 else:
10 return None
11
12def find_gt(a, x):
13 i = bisect.bisect_right(a, x)
14 if i != len(a):
15 return i
16 else:
17 return None
18
19def apply_iqr(seq, extent = 1.5):
20 q1 = scoreatpercentile(seq, 25)
21 q3 = scoreatpercentile(seq, 75)
22 iqr = q3 - q1
23 start = 0
24 end = len(seq) - 1
25 l = find_lt(seq, q1 - extent*iqr)
26 if l is not None:
27 start = l + 1
28 r = find_gt(seq, q3 + extent*iqr)
29 if r is not None:
30 end = r - 1
31 seq = seq[start:end+1]
32 return (seq, q1 - extent*iqr, q3 + extent*iqr)
diff --git a/utils/machines.py b/utils/machines.py
new file mode 100644
index 0000000..37a3c2f
--- /dev/null
+++ b/utils/machines.py
@@ -0,0 +1,43 @@
1machines = {
2 'ludwig': {
3 'cpu': 2133.0, # mhz
4 'sockets': 4,
5 'cores_per_socket': 6,
6 'L1': 256, # kb
7 'nL1': 1, # private
8 'L2': 3*1024,
9 'nL2': 2, # shared by two L1 modules
10 'L3': 12*1024,
11 'nL3': 3, # shared by three L2 modules
12 'nMem': 4 # shared by four L3 modules
13 },
14 'bonham': {
15 'cpu': 2666.0, # mhz
16 'sockets': 2,
17 'cores_per_socket': 6,
18 'L1': 32, # kb
19 'nL1': 1, # private
20 'L2': 2*1024,
21 'nL2': 1, # private
22 'L3': 12*1024,
23 'nL3': 6, # shared by six L2 modules
24 'nMem': 1 # shared by one L3 module (per mem)
25 },
26 'ringo': {
27 'cpu': 1400.0, # mhz
28 'sockets': 1,
29 'cores_per_socket': 4,
30 'L1': 32, # kb (just d-cache)
31 'nL1': 1, # private
32 'L2': 1024,
33 'nL2': 4, # shared by four cpus
34 'L3': 0, # n/a
35 'nL3': 0, # n/a
36 'nMem': 1
37 }
38}
39
40def cycles_to_us(machine_name, ncycles):
41 mhz = machines[machine_name]['cpu']
42 us = ncycles / mhz
43 return us