[2f6a9391] | 1 | #!/bin/bash - |
---|
| 2 | |
---|
| 3 | false=0; true=1 |
---|
| 4 | |
---|
| 5 | # Usage: arch [ hostname ] returns hostname, cores, startcore |
---|
| 6 | # |
---|
| 7 | # Define machine architecture based on starting socket, CPUs (cores) per socket, number of |
---|
| 8 | # sockets, has hyperthreading. |
---|
| 9 | |
---|
| 10 | start=0 |
---|
| 11 | |
---|
| 12 | arch() { |
---|
| 13 | hostname=${1:-`hostname`} # return value |
---|
| 14 | hashyper=${true} # assume machine has hyperthreads |
---|
| 15 | if [ "${hostname}" = "plg2" ] ; then |
---|
| 16 | startsocket=${start} |
---|
| 17 | cps=16 # coresPerSocket |
---|
| 18 | sockets=2 |
---|
| 19 | hashyper=${false} # has no hyperthreads |
---|
| 20 | elif [ "${hostname}" = "nasus" ] ; then |
---|
| 21 | startsocket=${start} |
---|
| 22 | cps=64 # coresPerSocket |
---|
| 23 | sockets=2 |
---|
| 24 | elif [ "${hostname}" = "pyke" ] ; then |
---|
| 25 | startsocket=${start} |
---|
| 26 | cps=24 # coresPerSocket |
---|
| 27 | sockets=2 |
---|
| 28 | elif [ "${hostname}" = "jax" ] ; then |
---|
| 29 | startsocket=${start} |
---|
| 30 | cps=24 # coresPerSocket |
---|
| 31 | sockets=4 |
---|
| 32 | else |
---|
| 33 | echo "unsupported host" ${hostname} |
---|
| 34 | exit 1 |
---|
| 35 | fi |
---|
| 36 | cores=$(( ${cps} * ${sockets} )) |
---|
| 37 | startcore=$(( ${startsocket} * ${cps} )) |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | # Usage: affinity (global cps, sockets, startsocket, hashyper, cores, startcore, wrap) |
---|
| 41 | # returns taskset argument |
---|
| 42 | # |
---|
| 43 | # This routine assumes hyperthreading has only 2 hyperthreads per core. |
---|
| 44 | # |
---|
| 45 | # If hyperthread scanning is used: processor units are assigned across the low-number hyperthreads |
---|
| 46 | # of the socket's cores. When the low-number hyperthreads are filled, the high-number hyperhtreads |
---|
| 47 | # are assigned across the socket's cores. Then the next socket is assigned. |
---|
| 48 | # |
---|
| 49 | # If hyperthread wrapping is used: processor units are assigned in low/high-number pairs of |
---|
| 50 | # hyperthreads across the socket's cores. Then the next socket is assigned. |
---|
| 51 | |
---|
| 52 | wrap=${false} # set to control hyperthread assignment across socket cores |
---|
| 53 | |
---|
| 54 | affinity() { |
---|
| 55 | if [ ${wrap} -eq ${true} -a ${hashyper} -eq ${false} ] ; then |
---|
| 56 | echo "architecture does not support hyperthreading for wrapping" |
---|
| 57 | exit 1 |
---|
| 58 | fi |
---|
| 59 | taskset="" # return value |
---|
| 60 | set -- $(( ${1} - 1 )) # decrement $1 |
---|
| 61 | if [ ${1} -eq 0 ] ; then taskset="${startcore}-${startcore}"; return; fi |
---|
| 62 | if [ ${1} -ge $(( ${cps} * ( ${sockets} - ${startsocket} ) * ( ${hashyper} + 1 ) )) ] ; then # error |
---|
| 63 | echo "not enough cores $(( ${cores} * ${sockets} )) for $(( ${1} + 1 )) starting at ${startcore}" |
---|
| 64 | exit 1 |
---|
| 65 | fi |
---|
| 66 | if [ ${hashyper} -eq ${false} ] ; then taskset="${startcore}-$(( ${1} + ${startcore} ))"; return; fi # no hyperthreads |
---|
| 67 | start2=$(( ${startcore} + ${cores} )) |
---|
| 68 | if [ ${wrap} -eq ${true} ] ; then # hyperthread wrapping |
---|
| 69 | end1=$(( ${1} / 2 + ${startcore} )) |
---|
| 70 | end2=$(( ${end1} + ${cores} )) |
---|
| 71 | if [ $(( ${1} % 2 )) -eq 0 ] ; then |
---|
| 72 | end2=$(( ${end2} - 1 )) |
---|
| 73 | fi |
---|
| 74 | taskset="${startcore}-${end1},${start2}-${end2}" |
---|
| 75 | else # hyperthread scanning |
---|
| 76 | if [ ${1} -lt ${cps} ] ; then taskset="${startcore}-$(( ${1} + ${startcore} ))"; return; fi |
---|
| 77 | filled=$(( ${1} / ( ${cps} * 2 ) * ${cps} )) |
---|
| 78 | modulus=$(( ${1} % ( ${cps} * 2 ) )) # leftover cores added to saturated sockets |
---|
| 79 | if [ ${modulus} -gt ${cps} ] ; then |
---|
| 80 | taskset="${startcore}-$(( ${startcore} + ${filled} + ${cps} - 1 )),${start2}-$(( ${start2} + ${filled} + ${modulus} % ${cps} ))" |
---|
| 81 | else |
---|
| 82 | taskset="${startcore}-$(( ${startcore} + ${filled} + ${modulus} )),${start2}-$(( ${start2} + ${filled} - 1 ))" |
---|
| 83 | fi |
---|
| 84 | fi |
---|
| 85 | } |
---|
| 86 | |
---|
[d24b1985] | 87 | numtimes=5 |
---|
[2f6a9391] | 88 | |
---|
| 89 | num_threads='2 4 8 16 24 32' |
---|
[d24b1985] | 90 | # num_threads='2' |
---|
[2f6a9391] | 91 | |
---|
| 92 | # toggle benchmarks |
---|
[d24b1985] | 93 | zero=${false} |
---|
| 94 | contend=${true} |
---|
| 95 | barrier=${false} |
---|
| 96 | churn=${false} |
---|
| 97 | daisy_chain=${false} |
---|
| 98 | hot_potato=${false} |
---|
| 99 | pub_sub=${false} |
---|
[2f6a9391] | 100 | |
---|
| 101 | runCFA=${true} |
---|
[d24b1985] | 102 | runGO=${true} |
---|
[2f6a9391] | 103 | # runCFA=${false} |
---|
[d24b1985] | 104 | # runGO=${false} |
---|
[2f6a9391] | 105 | |
---|
| 106 | cfa=~/cfa-cc/driver/cfa |
---|
| 107 | |
---|
| 108 | # Helpers to minimize code duplication |
---|
| 109 | |
---|
| 110 | # repeats a command ${numtimes} |
---|
| 111 | preprint='' |
---|
| 112 | repeat_command() { |
---|
| 113 | t=1 |
---|
| 114 | while [ ${t} -le ${numtimes} ] ; do |
---|
| 115 | echo -n -e ${preprint} |
---|
| 116 | "${@}" |
---|
| 117 | t=`expr ${t} + 1` |
---|
| 118 | done |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | # prints the leading info for a given run of a variant |
---|
| 122 | print_header() { |
---|
| 123 | echo ${1}':' |
---|
| 124 | echo -e "cores\tthroughput (entries)" |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | # runs the current benchmark with provided args |
---|
| 128 | # only works for standard-run benchmarks (not Akka) |
---|
| 129 | # must split into pre and post args to be able to supply val of p |
---|
| 130 | pre_args='' |
---|
| 131 | post_args='' |
---|
| 132 | single_run() { |
---|
| 133 | affinity ${1} |
---|
| 134 | preprint="${1}\t" |
---|
| 135 | repeat_command taskset -c ${taskset} ./a.${hostname} ${pre_args} ${1} ${post_args} |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | # runs the current bench for all processor vals |
---|
| 139 | # works for standard benchs that dont need to set a config file (not Akka or CAF) |
---|
| 140 | run_bench() { |
---|
| 141 | for p in ${num_threads} ; do |
---|
| 142 | single_run ${p} |
---|
| 143 | done |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | arch # get hostname |
---|
| 147 | |
---|
| 148 | # set up leading info for python script |
---|
| 149 | echo $numtimes |
---|
| 150 | echo $num_threads |
---|
| 151 | |
---|
[d24b1985] | 152 | if [ ${runCFA} -eq ${true} ]; then |
---|
| 153 | echo -n 'CFA ' |
---|
[2f6a9391] | 154 | fi |
---|
[d24b1985] | 155 | if [ ${runGO} -eq ${true} ]; then |
---|
| 156 | echo -n 'Go ' |
---|
[2f6a9391] | 157 | fi |
---|
| 158 | echo "" |
---|
| 159 | |
---|
| 160 | # done printing header info for output |
---|
| 161 | |
---|
| 162 | # cfa flags |
---|
| 163 | cfa_flags='-quiet -O3 -nodebug -DNDEBUG' |
---|
| 164 | |
---|
| 165 | # run the benchmarks |
---|
| 166 | |
---|
[d24b1985] | 167 | run_contend() { |
---|
[2f6a9391] | 168 | post_args=${1} |
---|
| 169 | |
---|
| 170 | if [ ${runCFA} -eq ${true} ] ; then |
---|
| 171 | cd cfa # CFA RUN |
---|
[d24b1985] | 172 | print_header 'CFA' |
---|
| 173 | ${cfa} ${cfa_flags} ${2}.cfa -o a.${hostname} > /dev/null 2>&1 |
---|
[2f6a9391] | 174 | run_bench |
---|
| 175 | rm a.${hostname} |
---|
| 176 | cd - > /dev/null |
---|
| 177 | fi # done CFA |
---|
| 178 | |
---|
[d24b1985] | 179 | if [ ${runGO} -eq ${true} ] ; then |
---|
| 180 | cd go/${2} # Go RUN |
---|
| 181 | print_header 'Go' |
---|
| 182 | go build -o a.${hostname} > /dev/null 2>&1 |
---|
[2f6a9391] | 183 | run_bench |
---|
| 184 | rm a.${hostname} |
---|
| 185 | cd - > /dev/null |
---|
[d24b1985] | 186 | fi # done Go |
---|
[2f6a9391] | 187 | } |
---|
| 188 | |
---|
| 189 | # /usr/bin/time -f "%Uu %Ss %Er %Mkb" |
---|
[d24b1985] | 190 | if [ ${contend} -eq ${true} ] ; then |
---|
| 191 | echo "contend: " |
---|
| 192 | run_contend '128' 'contend' |
---|
| 193 | fi |
---|
[2f6a9391] | 194 | |
---|
[d24b1985] | 195 | if [ ${zero} -eq ${true} ] ; then |
---|
| 196 | echo "zero: " |
---|
| 197 | run_contend '0' 'contend' |
---|
| 198 | fi |
---|
[2f6a9391] | 199 | |
---|
[d24b1985] | 200 | if [ ${barrier} -eq ${true} ] ; then |
---|
| 201 | echo "barrier: " |
---|
| 202 | run_contend '' 'barrier' |
---|
| 203 | fi |
---|
[2f6a9391] | 204 | |
---|
[d24b1985] | 205 | if [ ${churn} -eq ${true} ] ; then |
---|
| 206 | echo "churn: " |
---|
| 207 | run_contend '' 'churn' |
---|
| 208 | fi |
---|
| 209 | |
---|
| 210 | if [ ${daisy_chain} -eq ${true} ] ; then |
---|
| 211 | echo "daisy_chain: " |
---|
| 212 | run_contend '' 'daisy_chain' |
---|
| 213 | fi |
---|
| 214 | |
---|
| 215 | if [ ${hot_potato} -eq ${true} ] ; then |
---|
| 216 | echo "hot_potato: " |
---|
| 217 | run_contend '' 'hot_potato' |
---|
| 218 | fi |
---|
| 219 | |
---|
| 220 | if [ ${pub_sub} -eq ${true} ] ; then |
---|
| 221 | echo "pub_sub: " |
---|
| 222 | run_contend '' 'pub_sub' |
---|
| 223 | fi |
---|