diff options
| author | Joshua Bakita <jbakita@cs.unc.edu> | 2020-06-11 21:32:55 -0400 |
|---|---|---|
| committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-06-11 21:32:55 -0400 |
| commit | a100a322fe414021a1e5878b910a84e9df37df61 (patch) | |
| tree | fe6f9e51c1c90683ba53838838f496b45a7a3422 /dis | |
| parent | 3d7bc39109895130d7de703893dd5aa7448b01cd (diff) | |
Add inital testing infrastructure
Works for three-way WSS/cache size/execution time comparisons
Diffstat (limited to 'dis')
| -rw-r--r-- | dis/original/WSS_DOCS.md | 83 | ||||
| -rwxr-xr-x | dis/original/clean.sh | 1 | ||||
| -rwxr-xr-x | dis/original/gen_input.py | 113 | ||||
| -rw-r--r-- | dis/original/inputs/WSSS | 12 | ||||
| -rw-r--r-- | dis/original/inputs/WSSS_maxstride4mb | 16 | ||||
| -rw-r--r-- | dis/original/inputs/caches | 7 | ||||
| -rw-r--r-- | dis/original/inputs/caches_maxstride2ways | 11 | ||||
| -rwxr-xr-x | dis/original/postproc.sh | 3 | ||||
| -rwxr-xr-x | dis/original/run_dis.sh | 81 | ||||
| -rwxr-xr-x | dis/original/setup_mem_and_global.sh | 13 |
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 | ||
| 4 | 1 allocation in main() | ||
| 5 | f = 1st input param | ||
| 6 | |||
| 7 | sizeof(unsigned char) * f | ||
| 8 | |||
| 9 | ## Matrix | ||
| 10 | 6 allocations in main(), 7 allocations in biConjugateGradient() | ||
| 11 | |||
| 12 | *Allocations in main()* | ||
| 13 | dim = 2nd input param | ||
| 14 | numberNonzero = 3nd input param | ||
| 15 | |||
| 16 | sizeof(double) * (dim^2+3dim+numberNonzero) + sizeof(int) * (2dim+1+numberNonzero) | ||
| 17 | |||
| 18 | *Allocations in biConjugateGradient()* | ||
| 19 | sizeof(double) * 7dim | ||
| 20 | |||
| 21 | ## Neighborhood | ||
| 22 | 1 allocation in createImage, 2 allocations in neighborhoodCalculation | ||
| 23 | |||
| 24 | *Allocations in createImage()* | ||
| 25 | dimension = 3rd input param | ||
| 26 | |||
| 27 | sizeof(short int) * dimension^2 | ||
| 28 | |||
| 29 | *Allocations in neighborhoodCalculation()* | ||
| 30 | bitDepth = 2nd param | ||
| 31 | |||
| 32 | sizeof(int) * (2^(bitDepth + 1) - 1) | ||
| 33 | |||
| 34 | ## Pointer | ||
| 35 | n = 5th input param | ||
| 36 | f = 1st input param | ||
| 37 | |||
| 38 | sizeof(unsigned int) * 4n + sizeof(int) * f | ||
| 39 | |||
| 40 | ## Transitive | ||
| 41 | n = 1st input param | ||
| 42 | |||
| 43 | sizeof(unsigned int) * 2n^2 | ||
| 44 | |||
| 45 | ## Update | ||
| 46 | f = 1st input param | ||
| 47 | |||
| 48 | sizeof(int) * f | ||
| 49 | |||
| 50 | ## Testplan | ||
| 51 | *Problem!* Larger WSS = more computations | ||
| 52 | Use testcase #1 for non-specified parameters | ||
| 53 | Below 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 | ||
| 58 | Just vary first param | ||
| 59 | |||
| 60 | f = WSS | ||
| 61 | |||
| 62 | ### Matrix | ||
| 63 | 0.3 - 16% number nonzero | ||
| 64 | - Fixed at 8% | ||
| 65 | Just vary dim (matrix size) | ||
| 66 | |||
| 67 | sizeof(double) * (dim^2+10dim+numberNonzero) + sizeof(int) * (2dim+1+numberNonzero) = WSS | ||
| 68 | |||
| 69 | |||
| 70 | ### Neighborhood | ||
| 71 | 8 or 15 bit depth | ||
| 72 | - Fix at 12? | ||
| 73 | Just vary dim (image size) | ||
| 74 | |||
| 75 | ### Pointer | ||
| 76 | 10 for n | ||
| 77 | Just vary f | ||
| 78 | |||
| 79 | ### Transitive | ||
| 80 | Just vary n | ||
| 81 | |||
| 82 | ### Update | ||
| 83 | Just 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 | |||
| 10 | from ctypes import sizeof, c_double, c_int, c_short | ||
| 11 | from math import sqrt, floor | ||
| 12 | import sys # For argv and stderr | ||
| 13 | |||
| 14 | USAGE = """Usage: {} <benchmark> <template> <WSS in bytes>""" | ||
| 15 | |||
| 16 | # Check input | ||
| 17 | if (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 | ||
| 22 | def setup_field(params, wss): | ||
| 23 | params[0] = wss | ||
| 24 | return params | ||
| 25 | |||
| 26 | def 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 | |||
| 38 | def 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 | |||
| 53 | def 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 | |||
| 62 | def 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 | |||
| 71 | def 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 | |||
| 84 | def setup_random_walk(params, wss): | ||
| 85 | params[0] = wss | ||
| 86 | return params | ||
| 87 | |||
| 88 | BENCH_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 | ||
| 91 | benchmark_name = sys.argv[1] | ||
| 92 | if benchmark_name not in BENCH_TO_PARAMS.keys(): | ||
| 93 | print("Invalid benchmark name.", file=sys.stderr) | ||
| 94 | exit(2) | ||
| 95 | |||
| 96 | wss = int(sys.argv[3]) | ||
| 97 | if wss <= 0: | ||
| 98 | print("Invalid working set size", file=sys.stderr) | ||
| 99 | exit(3) | ||
| 100 | |||
| 101 | with 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 @@ | |||
| 1 | 16384 | ||
| 2 | 32768 | ||
| 3 | 65536 | ||
| 4 | 131072 | ||
| 5 | 262144 | ||
| 6 | 524288 | ||
| 7 | 1048576 | ||
| 8 | 2097152 | ||
| 9 | 4194304 | ||
| 10 | 8388608 | ||
| 11 | 16777216 | ||
| 12 | 33554432 | ||
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 @@ | |||
| 1 | 16384 | ||
| 2 | 32768 | ||
| 3 | 65536 | ||
| 4 | 131072 | ||
| 5 | 262144 | ||
| 6 | 524288 | ||
| 7 | 1048576 | ||
| 8 | 2097152 | ||
| 9 | 4194304 | ||
| 10 | 8388608 | ||
| 11 | 12582912 | ||
| 12 | 16777216 | ||
| 13 | 20971520 | ||
| 14 | 25165824 | ||
| 15 | 29360120 | ||
| 16 | 33554432 | ||
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 @@ | |||
| 1 | L3:0=0000;1=0000;2=0000;3=0000 | ||
| 2 | L3:0=0000;1=0000;2=0000;3=0001 | ||
| 3 | L3:0=0000;1=0000;2=0000;3=0003 | ||
| 4 | L3:0=0000;1=0000;2=0000;3=0007 | ||
| 5 | L3:0=0000;1=0000;2=0000;3=000f | ||
| 6 | L3:0=0000;1=0000;2=0000;3=00ff | ||
| 7 | L3: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 @@ | |||
| 1 | L3:0=0000;1=0000;2=0000;3=0000 | ||
| 2 | L3:0=0000;1=0000;2=0000;3=0001 | ||
| 3 | L3:0=0000;1=0000;2=0000;3=0003 | ||
| 4 | L3:0=0000;1=0000;2=0000;3=0007 | ||
| 5 | L3:0=0000;1=0000;2=0000;3=000f | ||
| 6 | L3:0=0000;1=0000;2=0000;3=003f | ||
| 7 | L3:0=0000;1=0000;2=0000;3=00ff | ||
| 8 | L3:0=0000;1=0000;2=0000;3=03ff | ||
| 9 | L3:0=0000;1=0000;2=0000;3=0fff | ||
| 10 | L3:0=0000;1=0000;2=0000;3=3fff | ||
| 11 | L3: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 | |||
| 3 | core=$1 | ||
| 4 | maxJobs=$2 | ||
| 5 | runID=$3 | ||
| 6 | benchmark=${4,} | ||
| 7 | template_input=inputs/$4/in1 | ||
| 8 | wss_settings=inputs/WSSS | ||
| 9 | cache_settings=inputs/caches | ||
| 10 | |||
| 11 | if [ $# -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 | ||
| 14 | fi | ||
| 15 | |||
| 16 | if [ $# -gt 4 ]; then | ||
| 17 | echo "Using alternate input template from $5" | ||
| 18 | template_input=$5 | ||
| 19 | fi | ||
| 20 | |||
| 21 | if [ $# -gt 5 ]; then | ||
| 22 | echo "Using alternate WSS settings from $6" | ||
| 23 | wss_settings=$6 | ||
| 24 | fi | ||
| 25 | |||
| 26 | if [ $# -gt 6 ]; then | ||
| 27 | echo "Using alternate cache settings from $7" | ||
| 28 | cache_settings=$7 | ||
| 29 | fi | ||
| 30 | |||
| 31 | echo "Making sure that binary is up to date..." | ||
| 32 | make $benchmark | ||
| 33 | echo "Done. Disabling real-time throttling..." | ||
| 34 | |||
| 35 | # Turn off rt throttling | ||
| 36 | echo -1 > /proc/sys/kernel/sched_rt_runtime_us | ||
| 37 | echo "Done. Redirecting all interrupts to core 0..." | ||
| 38 | |||
| 39 | # TODO: Make this cleaner | ||
| 40 | # Redirect all interrupts to core 0 | ||
| 41 | i=0 | ||
| 42 | for IRQ in /proc/irq/* | ||
| 43 | do | ||
| 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 )) | ||
| 50 | done | ||
| 51 | echo "Done. Beginning benchmarks..." | ||
| 52 | |||
| 53 | # Setup cache control group | ||
| 54 | mount -t resctrl resctrl /sys/fs/resctrl | ||
| 55 | mkdir /sys/fs/resctrl/benchmarks | ||
| 56 | sleep 1 # Wait a second for the group to initialize | ||
| 57 | echo $core > /sys/fs/resctrl/benchmarks/cpus_list | ||
| 58 | |||
| 59 | # Execute the benchmark for each WSS and cache config | ||
| 60 | while 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 | ||
| 70 | done < $cache_settings | ||
| 71 | |||
| 72 | # Put IRQs back as they were | ||
| 73 | i=0 | ||
| 74 | for IRQ in /proc/irq/* | ||
| 75 | do | ||
| 76 | if [ -d $IRQ ]; then | ||
| 77 | echo ${irqList[$i]} > $IRQ/smp_affinity_list | ||
| 78 | fi | ||
| 79 | i=$(( $i + 1 )) | ||
| 80 | done | ||
| 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 | ||
| 2 | mkdir -p /sys/fs/resctrl/benchmarks | ||
| 3 | echo 15 > /sys/fs/resctrl/benchmarks/cpus_list | ||
| 4 | # Remove mem from global domain | ||
| 5 | echo "L3:0=ffff;1=ffff;2=ffff;3=0000" > /sys/fs/resctrl/schemata | ||
| 6 | # Remove bandwidth from global domain | ||
| 7 | echo "MB:0=2;1=2;2=2;3=2" > /sys/fs/resctrl/schemata | ||
| 8 | echo "MB:0=2048;1=2048;2=2048;3=2048" > /sys/fs/resctrl/benchmarks/schemata | ||
| 9 | echo "=== Global Config ===" | ||
| 10 | cat /sys/fs/resctrl/schemata | ||
| 11 | echo "=== Core 15 Config ===" | ||
| 12 | cat /sys/fs/resctrl/benchmarks/schemata | ||
| 13 | |||
