1 | #!/bin/bash - |
---|
2 | |
---|
3 | false=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 | |
---|
10 | start=0 |
---|
11 | |
---|
12 | arch() { |
---|
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 | |
---|
52 | wrap=${false} # set to control hyperthread assignment across socket cores |
---|
53 | |
---|
54 | affinity() { |
---|
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 |
---|
88 | |
---|
89 | # bench_cores='1 2 4 8 16 24 32' |
---|
90 | bench_cores='8 16 24 32 48' |
---|
91 | # bench_cores='32' |
---|
92 | |
---|
93 | # toggle benchmarks |
---|
94 | executor=${true} |
---|
95 | matrix=${true} |
---|
96 | repeat=${true} |
---|
97 | balance=${true} |
---|
98 | static=${false} |
---|
99 | dynamic=${false} |
---|
100 | |
---|
101 | # executor config |
---|
102 | batch='1' |
---|
103 | nRounds='500' |
---|
104 | |
---|
105 | # matrix config |
---|
106 | size='3000' |
---|
107 | |
---|
108 | # repeat config |
---|
109 | messages='100000' |
---|
110 | n_repeats='100' |
---|
111 | |
---|
112 | # balance config |
---|
113 | nOneRounds='2000' |
---|
114 | nMultiRounds='800' |
---|
115 | |
---|
116 | # static config |
---|
117 | n_static_sends='10000000' |
---|
118 | |
---|
119 | # dynamic config |
---|
120 | n_dynamic_sends='10000000' |
---|
121 | |
---|
122 | # names=('NOSTEAL' 'CLOSE' 'SEARCH') |
---|
123 | # var_flags=('-D__STEAL=1 -DRAND=1' '-D__STEAL=1 -DCLOSE=1' '-D__STEAL=1 -DSEARCH=1') |
---|
124 | |
---|
125 | names=('SEARCH') |
---|
126 | var_flags=('-D__STEAL=1 -DSEARCH=1') |
---|
127 | |
---|
128 | |
---|
129 | # names=('NOSTEAL' 'SEARCH' 'RAND' 'SEARCHC' 'RANDC') |
---|
130 | # var_flags=('' '-D__STEAL=1 -DSEARCH=1' '-D__STEAL=1 -DRAND=1' '-D__STEAL=1 -DSEARCH=1 -DCYCLE' '-D__STEAL=1 -DRAND=1 -DCYCLE') |
---|
131 | |
---|
132 | # names=('NOSTEAL' 'RAND' 'CLOSE' 'SEARCH') |
---|
133 | # var_flags=('' '-D__STEAL=1 -DRAND=1' '-D__STEAL=1 -DCLOSE=1' '-D__STEAL=1 -DSEARCH=1') |
---|
134 | |
---|
135 | cfa_flags='-quiet -O3 -nodebug -DNDEBUG' |
---|
136 | |
---|
137 | cfa=~/cfa-cc/driver/cfa |
---|
138 | |
---|
139 | preprint='' |
---|
140 | repeat_command() { |
---|
141 | t=1 |
---|
142 | while [ ${t} -le ${numtimes} ] ; do |
---|
143 | echo -n -e ${preprint} |
---|
144 | "${@}" |
---|
145 | t=`expr ${t} + 1` |
---|
146 | done |
---|
147 | } |
---|
148 | |
---|
149 | arch nasus |
---|
150 | |
---|
151 | echo $numtimes |
---|
152 | echo $bench_cores |
---|
153 | |
---|
154 | for i in ${!names[@]}; do |
---|
155 | echo -n ${names[$i]}" " |
---|
156 | done |
---|
157 | echo "" |
---|
158 | |
---|
159 | # /usr/bin/time -f "%Uu %Ss %Er %Mkb" |
---|
160 | |
---|
161 | if [ ${executor} -eq ${true} ] ; then |
---|
162 | echo "executor" |
---|
163 | for i in ${!names[@]}; do |
---|
164 | echo ${names[$i]}':' |
---|
165 | echo -e "proc\ttime (s)" |
---|
166 | ${cfa} ${cfa_flags} ${var_flags[$i]} executor.cfa > /dev/null 2>&1 |
---|
167 | for p in ${bench_cores} ; do |
---|
168 | affinity ${p} |
---|
169 | # echo "taskset -c ${startcore}-`expr ${startcore} + ${p} - 1` ./a.out 40000 100 ${nRounds} ${p} ${batch}" |
---|
170 | preprint="${p}\t" |
---|
171 | repeat_command taskset -c ${taskset} ./a.out 40000 100 ${nRounds} ${p} ${batch} |
---|
172 | done |
---|
173 | rm a.out |
---|
174 | done |
---|
175 | echo "" |
---|
176 | fi |
---|
177 | |
---|
178 | if [ ${matrix} -eq ${true} ] ; then |
---|
179 | echo "matrix" |
---|
180 | for i in ${!names[@]}; do |
---|
181 | echo ${names[$i]} |
---|
182 | echo -e "proc\ttime (s)" |
---|
183 | ${cfa} ${cfa_flags} ${var_flags[$i]} matrix.cfa > /dev/null 2>&1 |
---|
184 | for p in ${bench_cores} ; do |
---|
185 | affinity ${p} |
---|
186 | preprint="${p}\t" |
---|
187 | repeat_command taskset -c ${taskset} ./a.out ${size} ${size} ${size} ${p} |
---|
188 | done |
---|
189 | rm a.out |
---|
190 | done |
---|
191 | echo "" |
---|
192 | fi |
---|
193 | |
---|
194 | if [ ${repeat} -eq ${true} ] ; then |
---|
195 | echo "repeat" |
---|
196 | echo -e "proc\ttime (s)" |
---|
197 | for i in ${!names[@]}; do |
---|
198 | echo ${names[$i]} |
---|
199 | ${cfa} ${cfa_flags} ${var_flags[$i]} repeat.cfa > /dev/null 2>&1 |
---|
200 | for p in ${bench_cores} ; do |
---|
201 | affinity ${p} |
---|
202 | preprint="${p}\t" |
---|
203 | repeat_command taskset -c ${taskset} ./a.out ${messages} ${p} 256 ${n_repeats} |
---|
204 | done |
---|
205 | rm a.out |
---|
206 | done |
---|
207 | echo "" |
---|
208 | fi |
---|
209 | |
---|
210 | |
---|
211 | if [ ${static} -eq ${true} ] ; then |
---|
212 | echo "static" |
---|
213 | for i in ${!names[@]}; do |
---|
214 | echo ${names[$i]} |
---|
215 | ${cfa} ${cfa_flags} ${var_flags[$i]} static.cfa > /dev/null 2>&1 |
---|
216 | repeat_command taskset -c ${startcore} ./a.out ${n_static_sends} |
---|
217 | rm a.out |
---|
218 | done |
---|
219 | echo "" |
---|
220 | fi |
---|
221 | |
---|
222 | if [ ${dynamic} -eq ${true} ] ; then |
---|
223 | echo "dynamic" |
---|
224 | for i in ${!names[@]}; do |
---|
225 | echo ${names[$i]} |
---|
226 | ${cfa} ${cfa_flags} ${var_flags[$i]} dynamic.cfa > /dev/null 2>&1 |
---|
227 | repeat_command taskset -c ${startcore} ./a.out ${n_dynamic_sends} |
---|
228 | done |
---|
229 | echo "" |
---|
230 | fi |
---|
231 | |
---|
232 | |
---|
233 | if [ ${balance} -eq ${true} ] ; then |
---|
234 | echo "balance_one" |
---|
235 | for i in ${!names[@]}; do |
---|
236 | echo ${names[$i]}':' |
---|
237 | echo -e "proc\ttime (s)" |
---|
238 | ${cfa} ${cfa_flags} ${var_flags[$i]} balance.cfa > /dev/null 2>&1 |
---|
239 | for p in ${bench_cores} ; do |
---|
240 | affinity ${p} |
---|
241 | preprint="${p}\t" |
---|
242 | repeat_command taskset -c ${taskset} ./a.out 32 32 ${nOneRounds} ${p} |
---|
243 | done |
---|
244 | rm a.out |
---|
245 | done |
---|
246 | echo "" |
---|
247 | echo "balance_multi" |
---|
248 | for i in ${!names[@]}; do |
---|
249 | echo ${names[$i]}':' |
---|
250 | echo -e "proc\ttime (s)" |
---|
251 | ${cfa} ${cfa_flags} ${var_flags[$i]} -DMULTI balance.cfa > /dev/null 2>&1 |
---|
252 | for p in ${bench_cores} ; do |
---|
253 | affinity ${p} |
---|
254 | preprint="${p}\t" |
---|
255 | repeat_command taskset -c ${taskset} ./a.out 32 32 ${nMultiRounds} ${p} |
---|
256 | done |
---|
257 | rm a.out |
---|
258 | done |
---|
259 | echo "" |
---|
260 | fi |
---|
261 | |
---|