summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Bakita <jbakita@cs.unc.edu>2020-06-11 21:32:55 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2020-06-11 21:32:55 -0400
commita100a322fe414021a1e5878b910a84e9df37df61 (patch)
treefe6f9e51c1c90683ba53838838f496b45a7a3422
parent3d7bc39109895130d7de703893dd5aa7448b01cd (diff)
Add inital testing infrastructure
Works for three-way WSS/cache size/execution time comparisons
-rw-r--r--dis/original/WSS_DOCS.md83
-rwxr-xr-xdis/original/clean.sh1
-rwxr-xr-xdis/original/gen_input.py113
-rw-r--r--dis/original/inputs/WSSS12
-rw-r--r--dis/original/inputs/WSSS_maxstride4mb16
-rw-r--r--dis/original/inputs/caches7
-rw-r--r--dis/original/inputs/caches_maxstride2ways11
-rwxr-xr-xdis/original/postproc.sh3
-rwxr-xr-xdis/original/run_dis.sh81
-rwxr-xr-xdis/original/setup_mem_and_global.sh13
10 files changed, 340 insertions, 0 deletions
diff --git a/dis/original/WSS_DOCS.md b/dis/original/WSS_DOCS.md
new file mode 100644
index 0000000..da5e066
--- /dev/null
+++ b/dis/original/WSS_DOCS.md
@@ -0,0 +1,83 @@
1# Documentation Mapping DIS Stressmark Parameters to WSS
2
3## Field
41 allocation in main()
5f = 1st input param
6
7sizeof(unsigned char) * f
8
9## Matrix
106 allocations in main(), 7 allocations in biConjugateGradient()
11
12*Allocations in main()*
13dim = 2nd input param
14numberNonzero = 3nd input param
15
16sizeof(double) * (dim^2+3dim+numberNonzero) + sizeof(int) * (2dim+1+numberNonzero)
17
18*Allocations in biConjugateGradient()*
19sizeof(double) * 7dim
20
21## Neighborhood
221 allocation in createImage, 2 allocations in neighborhoodCalculation
23
24*Allocations in createImage()*
25dimension = 3rd input param
26
27sizeof(short int) * dimension^2
28
29*Allocations in neighborhoodCalculation()*
30bitDepth = 2nd param
31
32sizeof(int) * (2^(bitDepth + 1) - 1)
33
34## Pointer
35n = 5th input param
36f = 1st input param
37
38sizeof(unsigned int) * 4n + sizeof(int) * f
39
40## Transitive
41n = 1st input param
42
43sizeof(unsigned int) * 2n^2
44
45## Update
46f = 1st input param
47
48sizeof(int) * f
49
50## Testplan
51*Problem!* Larger WSS = more computations
52Use testcase #1 for non-specified parameters
53Below math computed for x86_64
54- Test WSS at powers of 2: 16 KiB, 32, 64, 128, 256, 512, 1MiB, 2, 4, 8, 16, 32
55- For each WSS, measure cache allocation of 0, 1, 2, 4, 8, 16
56
57### Field
58Just vary first param
59
60f = WSS
61
62### Matrix
630.3 - 16% number nonzero
64- Fixed at 8%
65Just vary dim (matrix size)
66
67sizeof(double) * (dim^2+10dim+numberNonzero) + sizeof(int) * (2dim+1+numberNonzero) = WSS
68
69
70### Neighborhood
718 or 15 bit depth
72- Fix at 12?
73Just vary dim (image size)
74
75### Pointer
7610 for n
77Just vary f
78
79### Transitive
80Just vary n
81
82### Update
83Just vary f
diff --git a/dis/original/clean.sh b/dis/original/clean.sh
new file mode 100755
index 0000000..7c58295
--- /dev/null
+++ b/dis/original/clean.sh
@@ -0,0 +1 @@
tail -n +2 $1 | tr "-" " " | sed "s/L3:0=0000;1=0000;2=0000;3=0000/0/" | sed "s/L3:0=0000;1=0000;2=0000;3=0001/1/" | sed "s/L3:0=0000;1=0000;2=0000;3=0003/2/" | sed "s/L3:0=0000;1=0000;2=0000;3=0007/3/" | sed "s/L3:0=0000;1=0000;2=0000;3=000f/4/" | sed "s/L3:0=0000;1=0000;2=0000;3=003f/6/" | sed "s/L3:0=0000;1=0000;2=0000;3=00ff/8/" | sed "s/L3:0=0000;1=0000;2=0000;3=03ff/10/" | sed "s/L3:0=0000;1=0000;2=0000;3=0fff/12/" | sed "s/L3:0=0000;1=0000;2=0000;3=3fff/14/" | sed "s/L3:0=0000;1=0000;2=0000;3=ffff/16/" > $1.clean
diff --git a/dis/original/gen_input.py b/dis/original/gen_input.py
new file mode 100755
index 0000000..c7821b0
--- /dev/null
+++ b/dis/original/gen_input.py
@@ -0,0 +1,113 @@
1#!/usr/bin/python3
2#####
3# Copyright 2020 Joshua Bakita
4#
5# This program generates input data for the DIS benchmark suite on stdout
6# given a requested working set size.
7#####
8
9
10from ctypes import sizeof, c_double, c_int, c_short
11from math import sqrt, floor
12import sys # For argv and stderr
13
14USAGE = """Usage: {} <benchmark> <template> <WSS in bytes>"""
15
16# Check input
17if (len(sys.argv) < 4):
18 print(USAGE.format(sys.argv[0]), file=sys.stderr)
19 exit(1);
20
21# Don't try to understand the logic in these functions, see WSS_DOCS.md
22def setup_field(params, wss):
23 params[0] = wss
24 return params
25
26def setup_matrix(params, wss):
27 nnZR = 0.08 # 8% seems average
28 # This formula is out of a solver
29 si = sizeof(c_int)
30 sd = sizeof(c_double)
31 d = (sqrt((si**2) * (-(nnZR-1)) - si*sd*(nnZR-9) + si*wss*nnZR + sd*(25*sd+wss*nnZR+wss)) - si - 5*sd) / (si*nnZR + sd*nnZR + sd)
32 params[1] = floor(d);
33 params[2] = floor(d*d*nnZR);
34 if params[1] <= 0 or params[2] <= 0:
35 raise Exception("WSS too small for matrix benchmark!")
36 return params
37
38def setup_neighborhood(params, wss):
39 bitDepth = 8
40 bitDepthAlloc = sizeof(c_int) * (2**(bitDepth + 1) - 1)
41 dim = sqrt((wss - bitDepthAlloc) / sizeof(c_short))
42 params[1] = bitDepth
43 params[2] = floor(dim)
44 if params[1] <= 0 or params[2] <= 0:
45 raise Exception("WSS too small for neighborhood benchmark!")
46 # Cap maximum line thinkness to the image size
47 params[5] = min(params[2]-1, int(params[5]))
48 # Cap line lengths to the image size
49 params[6] = min(params[2]-1, int(params[6]))
50 params[7] = min(params[2]-1, int(params[7]))
51 return params
52
53def setup_pointer(params, wss):
54 n = 10;
55 f = (wss - sizeof(c_int) * 4 * n) / sizeof(c_int)
56 params[0] = floor(f)
57 params[4] = floor(n)
58 if params[0] <= 0 or params[4] <= 0:
59 raise Exception("WSS too small for pointer benchmark!")
60 return params
61
62def setup_transitive(params, wss):
63 n = sqrt(wss / (sizeof(c_int) * 2))
64 params[0] = floor(n)
65 # Fix edges at 50%
66 params[1] = floor(params[0] * 0.5)
67 if params[0] <= 0:
68 raise Exception("WSS too small for transitive benchmark!")
69 return params
70
71def setup_update(params, wss):
72 f = wss / sizeof(c_int)
73 params[0] = floor(f)
74 if params[0] <= 0:
75 raise Exception("WSS too small for update benchmark!")
76 # Don't do more than 100M hops (keeps time array feasible)
77 params[2] = min(100000000, int(params[2]))
78 # Enforce size requirements
79 params[4] = min(params[0]-1, int(params[4]))
80 params[5] = min(params[0]-1, int(params[5]))
81 params[6] = min(params[0]-1, int(params[6]))
82 return params
83
84def setup_random_walk(params, wss):
85 params[0] = wss
86 return params
87
88BENCH_TO_PARAMS = {"field":setup_field, "matrix":setup_matrix, "neighborhood":setup_neighborhood, "pointer":setup_pointer, "transitive":setup_transitive, "update":setup_update, "random_walk":setup_random_walk}
89
90# Main logic
91benchmark_name = sys.argv[1]
92if benchmark_name not in BENCH_TO_PARAMS.keys():
93 print("Invalid benchmark name.", file=sys.stderr)
94 exit(2)
95
96wss = int(sys.argv[3])
97if wss <= 0:
98 print("Invalid working set size", file=sys.stderr)
99 exit(3)
100
101with open(sys.argv[2], "r") as template:
102 # We expect the initialization params to all be on the first line
103 params = template.readline().split()
104 mutated_params = BENCH_TO_PARAMS[benchmark_name](params, wss);
105 print(" ".join(map(lambda x: str(x), mutated_params)))
106 print(" ".join(map(lambda x: str(x), mutated_params)), file=sys.stderr)
107 if benchmark_name == "pointer":
108 # Clone the data format used in the template
109 for i in range(0,10):
110 print("10 " + str(mutated_params[0]-10) + " " + str(mutated_params[0]-10))
111 else:
112 print(template.read())
113
diff --git a/dis/original/inputs/WSSS b/dis/original/inputs/WSSS
new file mode 100644
index 0000000..8836023
--- /dev/null
+++ b/dis/original/inputs/WSSS
@@ -0,0 +1,12 @@
116384
232768
365536
4131072
5262144
6524288
71048576
82097152
94194304
108388608
1116777216
1233554432
diff --git a/dis/original/inputs/WSSS_maxstride4mb b/dis/original/inputs/WSSS_maxstride4mb
new file mode 100644
index 0000000..f402c01
--- /dev/null
+++ b/dis/original/inputs/WSSS_maxstride4mb
@@ -0,0 +1,16 @@
116384
232768
365536
4131072
5262144
6524288
71048576
82097152
94194304
108388608
1112582912
1216777216
1320971520
1425165824
1529360120
1633554432
diff --git a/dis/original/inputs/caches b/dis/original/inputs/caches
new file mode 100644
index 0000000..f2293da
--- /dev/null
+++ b/dis/original/inputs/caches
@@ -0,0 +1,7 @@
1L3:0=0000;1=0000;2=0000;3=0000
2L3:0=0000;1=0000;2=0000;3=0001
3L3:0=0000;1=0000;2=0000;3=0003
4L3:0=0000;1=0000;2=0000;3=0007
5L3:0=0000;1=0000;2=0000;3=000f
6L3:0=0000;1=0000;2=0000;3=00ff
7L3:0=0000;1=0000;2=0000;3=ffff
diff --git a/dis/original/inputs/caches_maxstride2ways b/dis/original/inputs/caches_maxstride2ways
new file mode 100644
index 0000000..d5346b1
--- /dev/null
+++ b/dis/original/inputs/caches_maxstride2ways
@@ -0,0 +1,11 @@
1L3:0=0000;1=0000;2=0000;3=0000
2L3:0=0000;1=0000;2=0000;3=0001
3L3:0=0000;1=0000;2=0000;3=0003
4L3:0=0000;1=0000;2=0000;3=0007
5L3:0=0000;1=0000;2=0000;3=000f
6L3:0=0000;1=0000;2=0000;3=003f
7L3:0=0000;1=0000;2=0000;3=00ff
8L3:0=0000;1=0000;2=0000;3=03ff
9L3:0=0000;1=0000;2=0000;3=0fff
10L3:0=0000;1=0000;2=0000;3=3fff
11L3:0=0000;1=0000;2=0000;3=ffff
diff --git a/dis/original/postproc.sh b/dis/original/postproc.sh
new file mode 100755
index 0000000..c5dd1c9
--- /dev/null
+++ b/dis/original/postproc.sh
@@ -0,0 +1,3 @@
1#!/bin/bash
2./summarize.py $1.txt > $1-pp.txt
3./clean.sh $1-pp.txt
diff --git a/dis/original/run_dis.sh b/dis/original/run_dis.sh
new file mode 100755
index 0000000..3e82bfb
--- /dev/null
+++ b/dis/original/run_dis.sh
@@ -0,0 +1,81 @@
1#!/bin/bash
2
3core=$1
4maxJobs=$2
5runID=$3
6benchmark=${4,}
7template_input=inputs/$4/in1
8wss_settings=inputs/WSSS
9cache_settings=inputs/caches
10
11if [ $# -lt 4 ]; then
12 echo "Usage $0 <core ID> <number of iterations> <run ID> <benchmark> [template input] [DIS WSS file] [DIS cache file]"
13 exit
14fi
15
16if [ $# -gt 4 ]; then
17 echo "Using alternate input template from $5"
18 template_input=$5
19fi
20
21if [ $# -gt 5 ]; then
22 echo "Using alternate WSS settings from $6"
23 wss_settings=$6
24fi
25
26if [ $# -gt 6 ]; then
27 echo "Using alternate cache settings from $7"
28 cache_settings=$7
29fi
30
31echo "Making sure that binary is up to date..."
32make $benchmark
33echo "Done. Disabling real-time throttling..."
34
35# Turn off rt throttling
36echo -1 > /proc/sys/kernel/sched_rt_runtime_us
37echo "Done. Redirecting all interrupts to core 0..."
38
39# TODO: Make this cleaner
40# Redirect all interrupts to core 0
41i=0
42for IRQ in /proc/irq/*
43do
44 # Skip default_smp_affinity
45 if [ -d $IRQ ]; then
46 irqList[$i]=$(cat $IRQ/smp_affinity_list)
47 echo 0 > $IRQ/smp_affinity_list
48 fi
49 i=$(( $i + 1 ))
50done
51echo "Done. Beginning benchmarks..."
52
53# Setup cache control group
54mount -t resctrl resctrl /sys/fs/resctrl
55mkdir /sys/fs/resctrl/benchmarks
56sleep 1 # Wait a second for the group to initialize
57echo $core > /sys/fs/resctrl/benchmarks/cpus_list
58
59# Execute the benchmark for each WSS and cache config
60while read j; do
61 echo $j > /sys/fs/resctrl/benchmarks/schemata
62 while read i; do
63 if grep -q "#define LITMUS 1" ../../baseline/source/extra.h; then
64 echo "Using LITMUS-RT!"
65 ./gen_input.py $benchmark $template_input $i | ./$benchmark $benchmark-$i-$j $maxJobs $core $runID 1
66 else
67 ./gen_input.py $benchmark $template_input $i | chrt -r 97 taskset -c $core ./$benchmark $benchmark-$i-$j $maxJobs $core $runID 1
68 fi
69 done < $wss_settings
70done < $cache_settings
71
72# Put IRQs back as they were
73i=0
74for IRQ in /proc/irq/*
75do
76 if [ -d $IRQ ]; then
77 echo ${irqList[$i]} > $IRQ/smp_affinity_list
78 fi
79 i=$(( $i + 1 ))
80done
81
diff --git a/dis/original/setup_mem_and_global.sh b/dis/original/setup_mem_and_global.sh
new file mode 100755
index 0000000..56d6219
--- /dev/null
+++ b/dis/original/setup_mem_and_global.sh
@@ -0,0 +1,13 @@
1# Setup group
2mkdir -p /sys/fs/resctrl/benchmarks
3echo 15 > /sys/fs/resctrl/benchmarks/cpus_list
4# Remove mem from global domain
5echo "L3:0=ffff;1=ffff;2=ffff;3=0000" > /sys/fs/resctrl/schemata
6# Remove bandwidth from global domain
7echo "MB:0=2;1=2;2=2;3=2" > /sys/fs/resctrl/schemata
8echo "MB:0=2048;1=2048;2=2048;3=2048" > /sys/fs/resctrl/benchmarks/schemata
9echo "=== Global Config ==="
10cat /sys/fs/resctrl/schemata
11echo "=== Core 15 Config ==="
12cat /sys/fs/resctrl/benchmarks/schemata
13