source: doc/theses/colby_parsons_MMAth/benchmarks/mutex_stmt/run@ 6e6989c

ADT ast-experimental
Last change on this file since 6e6989c was 6e6989c, checked in by caparsons <caparson@…>, 3 years ago

added mutex stmt benchmarking

  • Property mode set to 100755
File size: 5.6 KB
Line 
1#!/bin/bash -
2
3false=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
10start=0
11
12arch() {
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
52wrap=${false} # set to control hyperthread assignment across socket cores
53
54affinity() {
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
87numtimes=1
88
89# locks=('-DLOCKS=L1' '-DLOCKS=L2' '-DLOCKS=L3' '-DLOCKS=L4' '-DLOCKS=L5' '-DLOCKS=L6' '-DLOCKS=L7' '-DLOCKS=L8')
90# locks='1 2 3 4 5 6 7 8'
91lock_flags=('-DLOCKS=L2' '-DLOCKS=L4' '-DLOCKS=L8')
92locks=('2' '4' '8')
93
94num_threads='2 4 8 16 24 32'
95
96# toggle benchmarks
97rand=${false} # prolly not needed
98order=${true}
99
100runCFA=${true}
101runCPP=${true}
102# runCFA=${false}
103# runCPP=${false}
104
105cfa=~/cfa-cc/driver/cfa
106cpp=g++
107
108# Helpers to minimize code duplication
109
110# repeats a command ${numtimes}
111preprint=''
112repeat_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
122print_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
130pre_args=''
131post_args=''
132single_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)
140run_bench() {
141 for p in ${num_threads} ; do
142 single_run ${p}
143 done
144}
145
146arch # get hostname
147
148# set up leading info for python script
149echo $numtimes
150echo $num_threads
151
152for i in ${!locks[@]}; do
153 echo -n ${locks[$i]}' '
154done
155echo ""
156
157if [ ${runCFA} -eq ${true} ] ; then
158 echo -n 'CFA '
159fi # done CFA
160if [ ${runCPP} -eq ${true} ] ; then
161 echo -n 'CPP '
162fi # done CPP
163echo ""
164
165# done printing header info for output
166
167# cfa flags
168cfa_flags='-quiet -O3 -nodebug -DNDEBUG'
169
170# cpp flagse
171cpp_flags='-O3 -std=c++17 -lpthread -pthread -DNDEBUG'
172
173# run the benchmarks
174
175run_order() {
176 echo "order locks: "${1}
177
178 if [ ${runCFA} -eq ${true} ] ; then
179 cd cfa # CFA RUN
180 print_header 'CFA'
181 ${cfa} ${cfa_flags} ${2} order.cfa -o a.${hostname} > /dev/null 2>&1
182 run_bench
183 rm a.${hostname}
184 cd - > /dev/null
185 fi # done CFA
186
187 if [ ${runCPP} -eq ${true} ] ; then
188 cd cpp # CPP RUN
189 print_header 'CPP'
190 ${cpp} ${cpp_flags} ${2} order.cc -o a.${hostname} > /dev/null 2>&1
191 run_bench
192 rm a.${hostname}
193 cd - > /dev/null
194 fi # done CPP
195}
196
197# /usr/bin/time -f "%Uu %Ss %Er %Mkb"
198if [ ${order} -eq ${true} ] ; then
199 for i in ${!locks[@]}; do
200 run_order ${locks[$i]} ${lock_flags[$i]}
201 done
202fi
203
Note: See TracBrowser for help on using the repository browser.