aboutsummaryrefslogtreecommitdiff
path: root/bench-malloc-threadgun.sh
blob: 5ba4d042e02ff38bb7dede28482d156b0c818a6c (plain)
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
#!/bin/bash
#Simple example running on ls
set -o pipefail
set -u

#Typically one would adjust these things at the top
GDBSCRIPT=bench-malloc-thread.gdb
BINARIES='/home/bernie.ogden/build/toolchain-upstream_sysroot/builds/x86_64-unknown-linux-gnu/aarch64-linux-gnu/glibc.git/benchtests/bench-malloc-thread /home/bernie.ogden/build/toolchain-bernie_sysroot/builds/x86_64-unknown-linux-gnu/aarch64-linux-gnu/glibc.git/benchtests/bench-malloc-thread /home/bernie.ogden/build/toolchain-unatomic_sysroot/builds/x86_64-unknown-linux-gnu/aarch64-linux-gnu/glibc.git/benchtests/bench-malloc-thread'
BINARY_ARGS='1'
OFFLOAD_MASK=0x1 #Core to run all non-profiled tasks on
declare -A CORE_COUNTER
#All perf events in A53 TRM, associated with taskset mask for an A53 on Juno
CORE_COUNTER[0x02]=A53_COUNTERS[@]
A53_COUNTERS=(\'\' \
              \'r00 r01 r02 r03 r04 r05\' \
              \'r06 r07 r08 r09 r0A r0B\' \
              \'r0C r0D r0E r0F r10 r11\' \
              \'r12 r13 r14 r15 r16 r17\' \
              \'r18 r19 r1A r1D r1E r60\' \
              \'r61 r7A r86 r87 rC0 rC1\' \
              \'rC2 rC3 rC4 rC5 rC6 rC7\' \
              \'rC8 rC9 rCA rCB rCC rD0\' \
              \'rD1 rD2 rE0 rE1 rE2 rE3\' \
              \'rE4 rE5 rE6 rE7 rE8\')
#All perf events in A57 TRM, associated with taskset mask for an A57 on Juno
CORE_COUNTER[0x10]=A57_COUNTERS[@]
A57_COUNTERS=(\'\' \
              \'r00 r01 r02 r03 r04 r05\' \
              \'r08 r09 r0A r0B r10 r11\' \
              \'r12 r13 r14 r15 r16 r17\' \
              \'r18 r19 r1A r1B r1C r1D\' \
              \'r1E r40 r41 r42 r43 r46\' \
              \'r47 r48 r4C r4D r50 r51\' \
              \'r52 r53 r56 r57 r58 r60\' \
              \'r61 r62 r63 r64 r65 r66\' \
              \'r67 r68 r69 r6A r6C r6D\' \
              \'r6E r70 r71 r72 r73 r74\' \
              \'r75 r76 r77 r78 r79 r7A\' \
              \'r7C r7D r7E r81 r82 r83\' \
              \'r84 r86 r87 r88 r8A r8B\' \
              \'r8C r8D r8E r8F r90 r91\')
function doit
{
  for i in {1..30}; do #Number of times to run each condition. 30 in some vague hope of statistical validity.
    echo : $binary $binary_args $i | tee -a ~/output.$$.${cpu}
    taskset $cpu gdb -q -x ${GDBSCRIPT} --args $binary $binary_args 2>&1 >/dev/null | tee -a ~/output.$$.${cpu}
  done
}

for cpu in "${!CORE_COUNTER[@]}"; do #This is the outer loop so that we stay on a single CPU for as long as possible
  for x in `ps -e | awk '{print $1}' | sed 1d`; do sudo taskset -p ${OFFLOAD_MASK} $x; done #Shunt as much as we can off the CPU of interest (i.e. onto a CPU that isn't in any mask that we are using)
  rm -f ${HOME}/output.$$.${cpu} #Delete output from old run, should it exist
  for binary in $BINARIES; do
    for binary_args in $BINARY_ARGS; do
      eval for PERF_COUNTERS in ${!CORE_COUNTER[${cpu}]}\; do export PERF_COUNTERS\; doit\; done
    done
  done
done