source: doc/theses/colby_parsons_MMAth/benchmarks/mutex_stmt/run @ 0e398ad

ADTast-experimental
Last change on this file since 0e398ad was 4eebbcc, checked in by caparsons <caparson@…>, 15 months ago

some mutex stmt benchmark cleanup

  • Property mode set to 100755
File size: 6.3 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=11
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# num_threads='2 4 8'
96
97# toggle benchmarks
98order=${true}
99rand=${true}
100baseline=${true}
101
102runCFA=${true}
103runCPP=${true}
104# runCFA=${false}
105# runCPP=${false}
106
107cfa=~/cfa-cc/driver/cfa
108cpp=g++
109
110# Helpers to minimize code duplication
111
112# repeats a command ${numtimes}
113preprint=''
114repeat_command() {
115    t=1
116    while [ ${t} -le ${numtimes} ] ; do
117        echo -n -e ${preprint}
118        "${@}"
119        t=`expr ${t} + 1`
120    done
121}
122
123# prints the leading info for a given run of a variant
124print_header() {
125    echo ${1}':'
126    echo -e "cores\tthroughput (entries)"
127}
128
129# runs the current benchmark with provided args
130# only works for standard-run benchmarks (not Akka)
131# must split into pre and post args to be able to supply val of p
132pre_args=''
133post_args=''
134single_run() {
135    affinity ${1}
136    preprint="${1}\t"
137    repeat_command taskset -c ${taskset} ./a.${hostname} ${pre_args} ${1} ${post_args}
138}
139
140# runs the current bench for all processor vals
141# works for standard benchs that dont need to set a config file (not Akka or CAF)
142run_bench() {
143    for p in ${num_threads} ; do
144        single_run ${p}
145    done
146}
147
148arch # get hostname
149
150# set up leading info for python script
151echo $numtimes
152echo $num_threads
153
154for i in ${!locks[@]}; do
155        echo -n ${locks[$i]}' '
156done
157echo ""
158
159if [ ${runCFA} -eq ${true} ] && [ ${order} -eq ${true} ]; then
160    echo -n 'CFA-order '
161fi
162if [ ${runCPP} -eq ${true} ] && [ ${order} -eq ${true} ]; then
163    echo -n 'CPP-order '
164fi
165if [ ${runCFA} -eq ${true} ] && [ ${baseline} -eq ${true} ]; then
166    echo -n 'CFA-baseline '
167fi
168if [ ${runCPP} -eq ${true} ] && [ ${baseline} -eq ${true} ]; then
169    echo -n 'CPP-baseline '
170fi
171if [ ${runCFA} -eq ${true} ] && [ ${rand} -eq ${true} ]; then
172    echo -n 'CFA-rand '
173fi
174if [ ${runCPP} -eq ${true} ] && [ ${rand} -eq ${true} ]; then
175    echo -n 'CPP-rand '
176fi
177echo ""
178
179# done printing header info for output
180
181# cfa flags
182cfa_flags='-quiet -O3 -nodebug -DNDEBUG'
183
184# cpp flagse
185cpp_flags='-O3 -std=c++17 -lpthread -pthread -DNDEBUG'
186
187# run the benchmarks
188
189run_order() {
190    post_args=${1}
191
192    if [ ${runCFA} -eq ${true} ] ; then
193        cd cfa # CFA RUN
194        print_header 'CFA-'${3}
195        ${cfa} ${cfa_flags} ${2} ${3}.cfa -o a.${hostname} > /dev/null 2>&1
196        run_bench
197        rm a.${hostname}
198        cd - > /dev/null
199    fi # done CFA
200
201    if [ ${runCPP} -eq ${true} ] ; then
202        cd cpp # CPP RUN
203        print_header 'CPP-'${3}
204        ${cpp} ${cpp_flags} ${2} ${3}.cc -o a.${hostname} > /dev/null 2>&1
205        run_bench
206        rm a.${hostname}
207        cd - > /dev/null
208    fi # done CPP
209}
210
211# /usr/bin/time -f "%Uu %Ss %Er %Mkb"
212
213for i in ${!locks[@]}; do
214    echo "locks: "${locks[$i]}
215    if [ ${order} -eq ${true} ] ; then
216        run_order ${locks[$i]} ${lock_flags[$i]} 'order'
217    fi
218    if [ ${baseline} -eq ${true} ] ; then
219        run_order ${locks[$i]} ${lock_flags[$i]} 'baseline'
220    fi
221    if [ ${rand} -eq ${true} ] ; then
222        run_order ${locks[$i]} '-DLOCKS=L8' 'rand'
223    fi
224done
225
226
Note: See TracBrowser for help on using the repository browser.