source: doc/theses/colby_parsons_MMAth/benchmarks/actors/run @ f6afd84

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

merging together benchmark run files

  • Property mode set to 100755
File size: 18.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
87column_headers="proc\ttime (s)"
88
89# executor config
90batch='100'
91nRounds='400' #500
92
93# matrix config
94size='3072'
95
96# repeat config
97messages='100000'
98n_repeats='200' #200
99
100# balance config
101nOneRounds='2000'
102nMultiRounds='800'
103
104# static config
105n_static_sends='100000000'
106n_static_sends_slow='10000000'
107
108# dynamic config
109n_dynamic_sends='20000000'
110n_dynamic_sends_slow='2000000'
111
112numtimes=5
113
114# bench_cores='4 8'
115bench_cores='1 2 4 8 16 24 32 48'
116# bench_cores='48'
117
118# toggle mem collection instead of time (executor only)
119# mem=${true}
120mem=${false}
121
122# toggle benchmarks
123executor=${true}
124matrix=${true}
125repeat=${true}
126balance=${true}
127static=${true}
128dynamic=${true}
129# executor=${false}
130# matrix=${false}
131# repeat=${false}
132# balance=${false}
133# static=${false}
134# dynamic=${false}
135
136# names=('Longest-Victim' 'No-Stealing' 'Random')
137# var_flags=('-D__STEAL=1 -DSEARCH=1' '' '-D__STEAL=1 -DRAND=1')
138
139# names=('CFA' 'CFA-EMPTY')
140# var_flags=('' '-DEMPTY')
141
142# names=('CFA')
143# var_flags=('-D__STEAL=1 -DSEARCH=1')
144
145# names=('CFA' 'CFA-STAT')
146# var_flags=('-D__STEAL=1 -DSEARCH=1' '-D__STEAL=1 -DSTATS')
147
148# names=()
149# var_flags=()
150
151names=('CFA')
152var_flags=('')
153
154runCAF=${true}
155runUCPP=${true}
156runPROTO=${true}
157runAKKA=${true}
158runCAF=${false}
159runUCPP=${false}
160runPROTO=${false}
161runAKKA=${false}
162
163if [ ${missed_gulps} -eq ${true} ] ; then
164    bench_cores='2 4 8 16 24 32 48'
165    column_headers="proc\tmissed\ttime (s)"
166    names=('CFA')
167    var_flags=('-D__STEAL=1 -DSEARCH=1 -DACTOR_STATS_QUEUE_MISSED')
168    runCAF=${false}
169    runUCPP=${false}
170    runPROTO=${false}
171    runAKKA=${false}
172fi
173
174cfa=~/cfa-cc/driver/cfa
175
176# Helpers to minimize code duplication
177
178# repeats a command ${numtimes}
179preprint=''
180repeat_command() {
181    t=1
182    while [ ${t} -le ${numtimes} ] ; do
183        echo -n -e ${preprint}
184        "${@}"
185        t=`expr ${t} + 1`
186    done
187}
188
189# prints the leading info for a given run of a variant
190print_header() {
191    echo ${1}':'
192    if [ ${mem} -eq ${false} ] ; then
193        echo -e $column_headers
194    fi
195}
196
197# runs the current benchmark with provided args
198# only works for standard-run benchmarks (not Akka)
199# must split into pre and post args to be able to supply val of p
200pre_args=''
201post_args=''
202single_run() {
203    affinity ${1}
204    preprint="${1}\t"
205    if [ ${mem} -eq ${true} ] ; then
206        repeat_command /usr/bin/time -f "%M" taskset -c ${taskset} ./a.${hostname} ${pre_args} ${1} ${post_args} > /dev/null
207    else
208        repeat_command taskset -c ${taskset} ./a.${hostname} ${pre_args} ${1} ${post_args}
209    fi
210}
211
212# runs the current bench for all processor vals
213# works for standard benchs that dont need to set a config file (not Akka or CAF)
214run_bench() {
215    for p in ${bench_cores} ; do
216        single_run ${p}
217    done
218}
219
220set_akka_parallelism() {
221    sed -i "s/parallelism-min = .*/parallelism-min = ${1}/g" application.conf
222    sed -i "s/parallelism-max = .*/parallelism-max = ${1}/g" application.conf
223}
224
225arch # get hostname
226
227# set up leading info for python script
228echo $numtimes
229echo $bench_cores
230
231for i in ${!names[@]}; do
232        echo -n ${names[$i]}" "
233done
234if [ ${runCAF} -eq ${true} ] ; then
235    echo -n 'CAF '
236fi # done CAF
237if [ ${runAKKA} -eq ${true} ] ; then
238    echo -n 'Akka '
239fi # done AKKA
240if [ ${runUCPP} -eq ${true} ] ; then
241    echo -n 'uC++ '
242fi # done UCPP
243if [ ${runPROTO} -eq ${true} ] ; then
244    echo -n 'ProtoActor '
245fi
246echo ""
247
248# done printing header info for output
249
250# cfa flags
251cfa_flags='-quiet -O3 -nodebug -DNDEBUG'
252
253# CAF flags
254prefixCAF='-O3 -Wall -std=c++17 -I/home/pabuhr/software/nasus/Actors/experiments/CAF/actor-framework/libcaf_core -I/home/pabuhr/software/nasus/Actors/experiments/CAF/actor-framework/libcaf_core/caf -I/home/pabuhr/software/nasus/Actors/experiments/CAF/actor-framework/build/libcaf_core -L/home/pabuhr/software/nasus/Actors/experiments/CAF/actor-framework/build/libcaf_core -L/home/pabuhr/software/nasus/Actors/experiments/CAF/actor-framework/build/libcaf_io'
255suffixCAF='-lcaf_io -lcaf_core -Wl,-rpath=CAF/actor-framework/build/libcaf_core'
256
257# AKKA flags
258sbtflags="--warn -J-Xmx32g"
259
260# UCPP flags
261UCPPflags="-quiet -g -Wall -Wextra -O3 -nodebug -DNDEBUG -multi"
262UCPP=~/ucpp/u++-7.0.0/bin/u++
263
264# run the benchmarks
265
266# /usr/bin/time -f "%Uu %Ss %Er %Mkb"
267if [ ${executor} -eq ${true} ] ; then
268    if [ ${mem} -eq ${false} ] ; then
269        echo "executor"
270    else
271        echo "mem"
272    fi
273    pre_args="40000 100 ${nRounds}"
274    post_args="${batch}"
275    cd cfa # CFA RUN
276    for i in ${!names[@]}; do
277        print_header ${names[$i]}
278        ${cfa} ${cfa_flags} ${var_flags[$i]} executor.cfa -o a.${hostname} > /dev/null 2>&1
279        run_bench
280        rm a.${hostname}
281    done
282    cd - > /dev/null # done CFA
283    if [ ${runCAF} -eq ${true} ] ; then # CAF RUN
284        cd caf
285        print_header 'CAF'
286        g++ ${prefixCAF} CAFExecutor.cpp ${suffixCAF} -o a.${hostname} > /dev/null 2>&1
287        for p in ${bench_cores} ; do
288            sed -i "s/max-threads = .*/max-threads = ${p}/g" caf-application.conf # set CAF parallelism
289            single_run ${p}
290        done
291        rm a.${hostname}
292        # set back parallelism
293        sed -i "s/max-threads = .*/max-threads = 1/g" caf-application.conf
294        cd - > /dev/null
295    fi # done CAF
296    if [ ${runAKKA} -eq ${true} ] ; then # AKKA RUN
297        cd akka/Executor
298        rm -rf project target                           # random out of memory errors without this
299        print_header 'Akka'
300        for p in ${bench_cores} ; do
301            set_akka_parallelism ${p}
302            affinity ${p}
303            if [ ${mem} -eq ${true} ] ; then
304                t=1
305                while [ ${t} -le ${numtimes} ] ; do
306                    /usr/bin/time -f "%M" taskset -c ${taskset} sbt ${sbtflags} "run ${pre_args} ${p} ${post_args} 1" 2>&1 | grep -v "SLF4J:" | grep -v "Slf4jLogger started" | sed -e "s/\x1b\[0J//" | grep -v "\."
307                    t=`expr ${t} + 1`
308                done
309            else
310                taskset -c ${taskset} sbt ${sbtflags} "run ${pre_args} ${p} ${post_args} ${numtimes}" 2>&1 | grep -v "SLF4J:" | grep -v "Slf4jLogger started" | sed -e "s/\x1b\[0J//"
311            fi
312           
313            sbt clean > /dev/null
314        done
315        # set back parallelism
316        set_akka_parallelism 1
317        cd - > /dev/null
318    fi # done AKKA
319    if [ ${runUCPP} -eq ${true} ] ; then # UCPP RUN
320        cd ucpp
321        print_header 'uC++'
322        ${UCPP} ${UCPPflags} uC++Executor.cc -o a.${hostname} > /dev/null 2>&1
323        run_bench
324        rm a.${hostname}
325        cd - > /dev/null
326    fi # done UCPP
327    if [ ${runPROTO} -eq ${true} ] ; then # PROTO RUN
328        print_header 'ProtoActor'
329        cd proto/Executor
330        go build -o a.${hostname} > /dev/null 2>&1
331        run_bench
332        rm a.${hostname}
333        cd - > /dev/null
334    fi # done PROTO
335    echo ""
336fi
337
338if [ ${matrix} -eq ${true} ] ; then
339    echo "matrix"
340    pre_args="${size} ${size} ${size}"
341    post_args=""
342    cd cfa
343    for i in ${!names[@]}; do
344        print_header ${names[$i]}
345        ${cfa} ${cfa_flags} ${var_flags[$i]} matrix.cfa -o a.${hostname} > /dev/null 2>&1
346        run_bench
347        rm a.${hostname}
348    done
349    cd - > /dev/null
350    if [ ${runCAF} -eq ${true} ] ; then # CAF RUN
351        cd caf
352        print_header 'CAF'
353        g++ ${prefixCAF} CAFMatrix.cpp ${suffixCAF} -o a.${hostname} > /dev/null 2>&1
354        for p in ${bench_cores} ; do
355            sed -i "s/max-threads = .*/max-threads = ${p}/g" caf-application.conf # set CAF parallelism
356            single_run ${p}
357        done
358        rm a.${hostname}
359
360        # set back parallelism
361        sed -i "s/max-threads = .*/max-threads = 1/g" caf-application.conf
362        cd - > /dev/null
363    fi # done CAF
364    if [ ${runAKKA} -eq ${true} ] ; then # AKKA RUN
365        cd akka/Matrix
366        rm -rf project target                           # random out of memory errors without this
367        print_header 'Akka'
368        for p in ${bench_cores} ; do
369            set_akka_parallelism ${p}
370            affinity ${p}
371            repeat_command taskset -c ${taskset} sbt ${sbtflags} "run ${pre_args} ${p}" 2>&1 | grep -v "SLF4J:" | grep -v "Slf4jLogger started" | sed -e "s/\x1b\[0J//"
372            sbt clean > /dev/null
373        done
374        # set back parallelism
375        set_akka_parallelism 1
376        cd - > /dev/null
377    fi # done AKKA
378    if [ ${runUCPP} -eq ${true} ] ; then # UCPP RUN
379        cd ucpp
380        print_header 'uC++'
381        ${UCPP} ${UCPPflags} uC++Matrix.cc -o a.${hostname} > /dev/null 2>&1
382        run_bench
383        rm a.${hostname}
384        cd - > /dev/null
385    fi # done UCPP
386    if [ ${runPROTO} -eq ${true} ] ; then # PROTO RUN
387        cd proto/Matrix
388        print_header 'ProtoActor'
389        go build -o a.${hostname} > /dev/null 2>&1
390        run_bench
391        rm a.${hostname}
392        cd - > /dev/null
393    fi # done PROTO
394    echo ""
395fi
396
397if [ ${repeat} -eq ${true} ] ; then
398    echo "repeat"
399    pre_args="${messages}"
400    post_args="${n_repeats}"
401    cd cfa
402    for i in ${!names[@]}; do
403        print_header ${names[$i]}
404        ${cfa} ${cfa_flags} ${var_flags[$i]} repeat.cfa -o a.${hostname} > /dev/null 2>&1
405        run_bench
406        rm a.${hostname}
407    done
408    cd - > /dev/null
409    if [ ${runCAF} -eq ${true} ] ; then # CAF RUN
410        cd caf
411        print_header 'CAF'
412        g++ ${prefixCAF} CAFRepeat.cpp ${suffixCAF} -o a.${hostname} > /dev/null 2>&1
413        for p in ${bench_cores} ; do
414            sed -i "s/max-threads = .*/max-threads = ${p}/g" caf-application.conf # set CAF parallelism
415            single_run ${p}
416        done
417        rm a.${hostname}
418
419        # set back parallelism
420        sed -i "s/max-threads = .*/max-threads = 1/g" caf-application.conf
421        cd - > /dev/null
422    fi # done CAF
423    if [ ${runAKKA} -eq ${true} ] ; then # AKKA RUN
424        cd akka/Repeat
425        rm -rf project target                           # random out of memory errors without this
426        print_header 'Akka'
427        for p in ${bench_cores} ; do
428            set_akka_parallelism ${p}
429            affinity ${p}
430            repeat_command taskset -c ${taskset} sbt ${sbtflags} "run ${pre_args} ${p} ${post_args}" 2>&1 | grep -v "SLF4J:" | grep -v "Slf4jLogger started" | sed -e "s/\x1b\[0J//"
431            sbt clean > /dev/null
432        done
433        # set back parallelism
434        set_akka_parallelism 1
435        cd - > /dev/null
436    fi # done AKKA
437    if [ ${runUCPP} -eq ${true} ] ; then # UCPP RUN
438        cd ucpp
439        print_header 'uC++'
440        ${UCPP} ${UCPPflags} uC++Repeat.cc -o a.${hostname} > /dev/null 2>&1
441        run_bench
442        rm a.${hostname}
443        cd - > /dev/null
444    fi # done UCPP
445    if [ ${runPROTO} -eq ${true} ] ; then # PROTO RUN
446        print_header 'ProtoActor'
447        cd proto/Repeat
448        go build -o a.${hostname} > /dev/null 2>&1
449        run_bench
450        rm a.${hostname}
451        cd - > /dev/null
452    fi # done PROTO
453    echo ""
454fi
455
456
457if [ ${static} -eq ${true} ] ; then
458    echo "static"
459    preprint=''
460    cd cfa
461    for i in ${!names[@]}; do
462        echo ${names[$i]}
463        ${cfa} ${cfa_flags} ${var_flags[$i]} static.cfa -o a.${hostname} > /dev/null 2>&1
464        repeat_command taskset -c ${startcore} ./a.${hostname} ${n_static_sends}
465        rm a.${hostname}
466    done
467    cd - > /dev/null
468    if [ ${runCAF} -eq ${true} ] ; then # CAF RUN
469        cd caf
470        echo 'CAF:'
471        g++ ${prefixCAF} CAFSendStatic.cpp ${suffixCAF} -o a.${hostname} > /dev/null 2>&1
472        sed -i "s/max-threads = .*/max-threads = 1/g" caf-application.conf # set CAF parallelism
473        repeat_command taskset -c ${startcore} ./a.${hostname} ${n_static_sends_slow}
474        rm a.${hostname}
475        cd - > /dev/null
476    fi # done CAF
477    if [ ${runAKKA} -eq ${true} ] ; then # AKKA RUN
478        cd akka/SendStatic
479        rm -rf project target                           # random out of memory errors without this
480        echo 'Akka:'
481        set_akka_parallelism 1
482        taskset -c ${startcore} sbt ${sbtflags} "run ${n_static_sends} ${numtimes}" 2>&1 | grep -v "SLF4J:" | grep -v "Slf4jLogger started" | sed -e "s/\x1b\[0J//"
483        cd - > /dev/null
484    fi # done AKKA
485    if [ ${runUCPP} -eq ${true} ] ; then # UCPP RUN
486        cd ucpp
487        echo 'uC++:'
488        ${UCPP} ${UCPPflags} uC++SendStatic.cc -o a.${hostname} > /dev/null 2>&1
489        repeat_command taskset -c ${startcore} ./a.${hostname} ${n_static_sends}
490        rm a.${hostname}
491        cd - > /dev/null
492    fi # done UCPP
493    if [ ${runPROTO} -eq ${true} ] ; then # PROTO RUN
494        cd proto/SendStatic
495        echo 'ProtoActor:'
496        go build -o a.${hostname} > /dev/null 2>&1
497        repeat_command taskset -c ${startcore} ./a.${hostname} ${n_static_sends}
498        rm a.${hostname}
499        cd - > /dev/null
500    fi # done PROTO
501    echo ""
502fi
503
504if [ ${dynamic} -eq ${true} ] ; then
505    echo "dynamic"
506    cd cfa
507    for i in ${!names[@]}; do
508        echo ${names[$i]}
509        ${cfa} ${cfa_flags} ${var_flags[$i]} dynamic.cfa -o a.${hostname} > /dev/null 2>&1
510        repeat_command taskset -c ${startcore} ./a.${hostname} ${n_dynamic_sends}
511        rm a.${hostname}
512    done
513    cd - > /dev/null
514    if [ ${runCAF} -eq ${true} ] ; then # CAF RUN
515        cd caf
516        echo 'CAF:'
517        g++ ${prefixCAF} CAFSendDynamic.cpp ${suffixCAF} -o a.${hostname} > /dev/null 2>&1
518        sed -i "s/max-threads = .*/max-threads = 1/g" caf-application.conf # set CAF parallelism
519        repeat_command taskset -c ${startcore} ./a.${hostname} ${n_dynamic_sends_slow}
520        rm a.${hostname}
521        cd - > /dev/null
522    fi # done CAF
523    if [ ${runAKKA} -eq ${true} ] ; then # AKKA RUN
524        cd akka/SendDynamic
525        rm -rf project target                           # random out of memory errors without this
526        echo 'Akka:'
527        set_akka_parallelism 1
528        taskset -c ${startcore} sbt ${sbtflags} "run ${n_dynamic_sends_slow} ${numtimes}" 2>&1 | grep -v "SLF4J:" | grep -v "Slf4jLogger started" | sed -e "s/\x1b\[0J//"
529        cd - > /dev/null
530    fi # done AKKA
531    if [ ${runUCPP} -eq ${true} ] ; then # UCPP RUN
532        cd ucpp
533        echo 'uC++:'
534        ${UCPP} ${UCPPflags} uC++SendDynamic.cc -o a.${hostname} > /dev/null 2>&1
535        repeat_command taskset -c ${startcore} ./a.${hostname} ${n_dynamic_sends}
536        rm a.${hostname}
537        cd - > /dev/null
538    fi # done UCPP
539    if [ ${runPROTO} -eq ${true} ] ; then # PROTO RUN
540        cd proto/SendDynamic
541        echo 'ProtoActor:'
542        go build -o a.${hostname} > /dev/null 2>&1
543        repeat_command taskset -c ${startcore} ./a.${hostname} ${n_dynamic_sends_slow}
544        rm a.${hostname}
545        cd - > /dev/null
546    fi # done PROTO
547    echo ""
548fi
549
550
551if [ ${balance} -eq ${true} ] ; then
552    cd cfa
553    echo "balance_one"
554    for i in ${!names[@]}; do
555        echo ${names[$i]}':'
556        echo -e $column_headers
557        ${cfa} ${cfa_flags} ${var_flags[$i]} balance.cfa -o a.${hostname} > /dev/null 2>&1
558        for p in ${bench_cores} ; do 
559            affinity ${p}
560            preprint="${p}\t"
561            repeat_command taskset -c ${taskset} ./a.${hostname} 32 32 ${nOneRounds} ${p}
562        done
563        rm a.${hostname}
564    done
565    echo ""
566    echo "balance_multi"
567    for i in ${!names[@]}; do
568        echo ${names[$i]}':'
569        echo -e $column_headers
570        ${cfa} ${cfa_flags} ${var_flags[$i]} -DMULTI balance.cfa -o a.${hostname} > /dev/null 2>&1
571        for p in ${bench_cores} ; do 
572            affinity ${p}
573            preprint="${p}\t"
574            repeat_command taskset -c ${taskset} ./a.${hostname} 32 32 ${nMultiRounds} ${p}
575        done
576        rm a.${hostname}
577    done
578    echo ""
579    cd - > /dev/null
580fi
581
Note: See TracBrowser for help on using the repository browser.