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

Last change on this file since fa5e1aa5 was b5e3a80, checked in by caparson <caparson@…>, 15 months ago

refactored waituntil future benchmarks and updated runscript

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