source: doc/theses/colby_parsons_MMAth/benchmarks/channels/run @ 21f4dff

Last change on this file since 21f4dff was d24b1985, checked in by caparson <caparson@…>, 20 months ago

updated plotting and run scripts for channel benchmarks

  • Property mode set to 100755
File size: 5.8 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=5
88
89num_threads='2 4 8 16 24 32'
90# num_threads='2'
91
92# toggle benchmarks
93zero=${false}
94contend=${true}
95barrier=${false}
96churn=${false}
97daisy_chain=${false}
98hot_potato=${false}
99pub_sub=${false}
100
101runCFA=${true}
102runGO=${true}
103# runCFA=${false}
104# runGO=${false}
105
106cfa=~/cfa-cc/driver/cfa
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
152if [ ${runCFA} -eq ${true} ]; then
153    echo -n 'CFA '
154fi
155if [ ${runGO} -eq ${true} ]; then
156    echo -n 'Go '
157fi
158echo ""
159
160# done printing header info for output
161
162# cfa flags
163cfa_flags='-quiet -O3 -nodebug -DNDEBUG'
164
165# run the benchmarks
166
167run_contend() {
168    post_args=${1}
169
170    if [ ${runCFA} -eq ${true} ] ; then
171        cd cfa # CFA RUN
172        print_header 'CFA'
173        ${cfa} ${cfa_flags} ${2}.cfa -o a.${hostname} > /dev/null 2>&1
174        run_bench
175        rm a.${hostname}
176        cd - > /dev/null
177    fi # done CFA
178
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
183        run_bench
184        rm a.${hostname}
185        cd - > /dev/null
186    fi # done Go
187}
188
189# /usr/bin/time -f "%Uu %Ss %Er %Mkb"
190if [ ${contend} -eq ${true} ] ; then
191    echo "contend: "
192    run_contend '128' 'contend'
193fi
194
195if [ ${zero} -eq ${true} ] ; then
196    echo "zero: "
197    run_contend '0' 'contend'
198fi
199
200if [ ${barrier} -eq ${true} ] ; then
201    echo "barrier: "
202    run_contend '' 'barrier'
203fi
204
205if [ ${churn} -eq ${true} ] ; then
206    echo "churn: "
207    run_contend '' 'churn'
208fi
209
210if [ ${daisy_chain} -eq ${true} ] ; then
211    echo "daisy_chain: "
212    run_contend '' 'daisy_chain'
213fi
214
215if [ ${hot_potato} -eq ${true} ] ; then
216    echo "hot_potato: "
217    run_contend '' 'hot_potato'
218fi
219
220if [ ${pub_sub} -eq ${true} ] ; then
221    echo "pub_sub: "
222    run_contend '' 'pub_sub'
223fi
Note: See TracBrowser for help on using the repository browser.