source: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/run@ f77f648d

ast-experimental
Last change on this file since f77f648d was f77f648d, checked in by caparsons <caparson@…>, 2 years ago

intermediate runscript to move to benchmarking on another machine

  • Property mode set to 100755
File size: 7.5 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
87# numtimes=5
88numtimes=1
89
90# num_threads='2 4 8 16 24 32'
91# side_chan_threads='6 12 18 24 30' # must be mults of 6
92num_threads='2'
93side_chan_threads='6'
94
95chan_size='10'
96future_time='10'
97
98# toggle benchmarks
99spin=${true}
100contend=${true}
101sidechan=${true}
102future=${true}
103spin=${false}
104contend=${false}
105sidechan=${false}
106# future=${false}
107
108runCFA=${true}
109runGO=${true}
110runUCPP=${true}
111# runCFA=${false}
112runGO=${false}
113# runUCPP=${false}
114
115cfa=~/cfa-cc/driver/cfa
116
117# Helpers to minimize code duplication
118
119# repeats a command ${numtimes}
120preprint=''
121repeat_command() {
122 t=1
123 while [ ${t} -le ${numtimes} ] ; do
124 echo -n -e ${preprint}
125 "${@}"
126 t=`expr ${t} + 1`
127 done
128}
129
130# prints the leading info for a given run of a variant
131print_header() {
132 echo ${1}':'
133 echo -e "cores\tthroughput (entries)"
134}
135
136# runs the current benchmark with provided args
137# only works for standard-run benchmarks (not Akka)
138# must split into pre and post args to be able to supply val of p
139pre_args=''
140post_args=''
141single_run() {
142 affinity ${1}
143 preprint="${1}\t"
144 repeat_command taskset -c ${taskset} ./a.${hostname} ${pre_args} ${1} ${post_args}
145}
146
147# runs the current bench for all processor vals
148# works for standard benchs that dont need to set a config file (not Akka or CAF)
149run_bench() {
150 for p in ${num_threads} ; do
151 single_run ${p}
152 done
153}
154
155run_side_chan() {
156 i=1
157 for p in ${side_chan_threads} ; do
158 affinity ${p}
159 preprint="${p}\t"
160 repeat_command taskset -c ${taskset} ./a.${hostname} ${pre_args} ${i} ${post_args}
161 i=`expr ${i} + 1`
162 done
163}
164
165run_future() {
166 for p in ${num_threads} ; do
167 pre_args=$(( ${p} - 1 ))
168 affinity ${p}
169 preprint="${p}\t"
170 repeat_command taskset -c ${taskset} ./a.${hostname} ${pre_args} ${post_args}
171 done
172}
173
174arch # get hostname
175
176# set up leading info for python script
177echo $numtimes
178echo $num_threads
179echo $side_chan_threads
180
181if [ ${runCFA} -eq ${true} ]; then
182 echo -n 'CFA '
183fi
184if [ ${runGO} -eq ${true} ]; then
185 echo -n 'Go '
186fi
187echo ""
188
189# done printing header info for output
190
191# cfa flags
192cfa_flags='-quiet -O3 -nodebug -DNDEBUG'
193
194# UCPP flags
195UCPPflags="-quiet -g -Wall -Wextra -O3 -nodebug -DNDEBUG -multi"
196UCPP=~/ucpp/u++-7.0.0/bin/u++
197
198# run the benchmarks
199
200run_contend() {
201 post_args=${1}
202
203 if [ ${runCFA} -eq ${true} ] ; then
204 cd cfa # CFA RUN
205 print_header 'CFA'
206 ${cfa} ${cfa_flags} '-DNUM_CHANS='${3} ${2}.cfa -o a.${hostname} > /dev/null 2>&1
207 run_bench
208 rm a.${hostname}
209 cd - > /dev/null
210 fi # done CFA
211
212 if [ ${runGO} -eq ${true} ] ; then
213 cd go/${2}${3} # Go RUN
214 print_header 'Go'
215 go build -o a.${hostname} > /dev/null 2>&1
216 run_bench
217 rm a.${hostname}
218 cd - > /dev/null
219 fi # done Go
220}
221
222# /usr/bin/time -f "%Uu %Ss %Er %Mkb"
223if [ ${contend} -eq ${true} ] ; then
224 echo "contend2: "
225 run_contend ${chan_size} 'contend' '2'
226 echo "contend4: "
227 run_contend ${chan_size} 'contend' '4'
228 echo "contend8: "
229 run_contend ${chan_size} 'contend' '8'
230fi
231
232if [ ${spin} -eq ${true} ] ; then
233 echo "spin2: "
234 run_contend ${chan_size} 'spin' '2'
235 echo "spin4: "
236 run_contend ${chan_size} 'spin' '4'
237 echo "spin8: "
238 run_contend ${chan_size} 'spin' '8'
239fi
240
241if [ ${sidechan} -eq ${true} ] ; then
242 echo "sidechan: "
243 post_args=${chan_size}
244 if [ ${runCFA} -eq ${true} ] ; then
245 cd cfa # CFA RUN
246 print_header 'CFA'
247 ${cfa} ${cfa_flags} sidechan.cfa -o a.${hostname} > /dev/null 2>&1
248 run_side_chan
249 rm a.${hostname}
250 cd - > /dev/null
251 fi # done CFA
252
253 if [ ${runGO} -eq ${true} ] ; then
254 cd go/sidechan
255 print_header 'Go'
256 go build -o a.${hostname} > /dev/null 2>&1
257 run_side_chan
258 rm a.${hostname}
259 cd - > /dev/null
260 fi # done Go
261fi
262
263if [ ${future} -eq ${true} ] ; then
264 echo "future: "
265 post_args=${future_time}
266 if [ ${runCFA} -eq ${true} ] ; then
267 cd cfa # CFA RUN
268 print_header 'CFA'
269 ${cfa} ${cfa_flags} future.cfa -o a.${hostname} > /dev/null 2>&1
270 run_future
271 rm a.${hostname}
272 cd - > /dev/null
273 fi # done CFA
274
275 if [ ${runUCPP} -eq ${true} ] ; then
276 cd ucpp
277 print_header 'uC++'
278 ${UCPP} ${UCPPflags} future.cc -o a.${hostname} > /dev/null 2>&1
279 run_future
280 rm a.${hostname}
281 cd - > /dev/null
282 fi # done Go
283fi
284
Note: See TracBrowser for help on using the repository browser.