forked from open-mpi/ompi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathompi-time.sh
1245 lines (1042 loc) · 32.4 KB
/
ompi-time.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
#
# Copyright (c) 2015 Mellanox Technologies, Inc.
# All rights reserved.
# Copyright (c) 2022 Cisco Systems, Inc. All rights reserved
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# This script is used to measure PMIx performance.
#
# --exec: scenario to run as sync or "test1 test2"
# --mpidir: path to mpi installation (/usr default)
# --parse: path to collected results
# HOWTO:
# 1 .Set test matrix using variables $node_list, ppn_list, test_list
# 2. Allocate nodes:
# $salloc --nodelist=node[1-4]
# or
# $salloc -N4
# 3. Launch script:
# $./opmi-time.sh --exec="test1 test2" --mpidir=<open>
# $./opmi-time.sh --mpidir=<open>
#
# Output location is test name folder
# Output file formats
# ()_base.log
# timestamp (usec) hostnode label
# 1441715028369350 mir14 start
# 1441715030540656 mir14 end
#
# ()_out.log
# timestamp (usec) rank node
# 1441715030460727 0 mir9
# 1441715030460628 1 mir10
#
# ()_result.log
# time rank node
# 2.089 3 mir12
# 2.093 2 mir11
#
# report.log
# nodes ppn mintime maxtime
# 4 1 2.089 2.093
# Settings
###############################################################################
node_list=(2 4)
ppn_list=(1 2)
test_list="test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13"
# Declarations
###############################################################################
prefix=pmix
module=${BASH_SOURCE[0]}
# Command line parsing
###############################################################################
opt=""
while [ "$#" -gt 0 ]; do
case "$1" in
--parse=*) parse="${1#*=}"; shift 1;;
--exec=*) exec="${1#*=}"; shift 1;;
--mpidir=*) mpidir="${1#*=}"; shift 1;;
--parse|--exec|--mpidir) echo "$1 requires an argument" >&2; exit 1;;
-*) echo "unknown option: $1" >&2; exit 1;;
*) shift 1;;
esac
done
# The scenario of measurement
if [ -n "$exec" ]; then
test_list="$exec"
fi
# The mpi path
mpidir=${mpidir:=/usr}
# Functions
###############################################################################
# format text
function do_format() {
local is_format=true
if [[ $is_format == true ]] ; then
res=""
for ((i=2; i<=$#; i++)) ; do
case "${!i}" in
"bold" ) res="$res\e[1m" ;;
"underline" ) res="$res\e[4m" ;;
"reverse" ) res="$res\e[7m" ;;
"red" ) res="$res\e[91m" ;;
"green" ) res="$res\e[92m" ;;
"yellow" ) res="$res\e[93m" ;;
esac
done
echo -e "$res$1\e[0m"
else
echo "$1"
fi
}
# print message
function do_msg() {
echo -e "$*" 2>&1 | tee -a $logfile
}
# print error message and exit script
function do_err() {
echo -e $(do_format "$module failed. aborting. $*" "red" "bold") 2>&1 | tee -a $logfile
exit 1
}
# print the seconds and current microseconds.
function do_timestamp() {
do_msg "$(($(date +%s%N)/1000))\t$(hostname -s)" "$1"
}
# swap two files
function do_fswap() {
if (( $# == 2 )); then
mv "$1" /tmp/
mv "$2" "`dirname $1`"
mv "/tmp/`basename $1`" "`dirname $2`"
else
echo "Usage: swap <file1> <file2>"
return 1
fi
}
function do_cmd() {
cmd="$*"
do_msg "Doing:"
do_msg "=================================================="
do_msg "$*"
eval $cmd >> $logfile 2>&1
local status=$?
if test "$status" != "0"; then
echo "$module failed. Log:"
tail -20 $logfile
cat $logfile
exit $status
fi
do_msg "DONE"
do_msg ""
}
function do_export() {
do_msg "Exporting PATHs:"
do_msg "=================================================="
do_msg "$1"
export PATH="$1/bin:${PATH}"
export LD_LIBRARY_PATH="$1/lib:${LD_LIBRARY_PATH}"
export MANPATH="$1/share/man:${MANPATH}"
do_msg "DONE"
do_msg ""
}
function do_nodeinfo() {
do_msg "Node information:"
do_msg "=================================================="
do_msg $(hostname)
do_msg $(cat /etc/issue | grep We)
do_msg $(cat /proc/cpuinfo | grep 'model name' | sort -u | awk '{print $4, $5, $6, $7, $9}')
do_msg $(cat /proc/cpuinfo | grep proce | wc | awk '{print $1}')
do_msg $(uname -a | awk '{print $12}')
do_msg $(cat /proc/meminfo | grep [M,m]em)
do_msg $(uname -a | awk '{print $3}')
do_msg $(ibstat | grep -e "CA type" -e "Firmware version")
do_msg $(ibstatus | grep -e rate -e state | grep -v 'phys state')
do_msg $(ofed_info | head -6 | grep OFED)
do_msg "DONE"
do_msg ""
}
function do_validate() {
command -v mpiexec >/dev/null 2>&1 || { do_err "mpiexec is not found."; }
command -v srun >/dev/null 2>&1 || { do_err "srun is not found."; }
command -v salloc >/dev/null 2>&1 || { do_err "salloc is not found."; }
}
function do_check_pmix() {
eval "srun --mpi=list 2>&1 | grep pmix"
}
function do_checksync_mpisync() {
local status
local tooldir=${tempdir}/mpisync
local verbose=$1
local option=$*
do_msg "Checking synchronization using mpisync:"
if [ ! -e ${tooldir} ]; then
mkdir -p ${tooldir}
cd ${tooldir}
wget --no-check-certificate https://github.com/open-mpi/ompi/raw/main/ompi/tools/mpisync/mpigclock.c >> $logfile 2>&1
wget --no-check-certificate https://github.com/open-mpi/ompi/raw/main/ompi/tools/mpisync/mpigclock.h >> $logfile 2>&1
wget --no-check-certificate https://github.com/open-mpi/ompi/raw/main/ompi/tools/mpisync/hpctimer.c >> $logfile 2>&1
wget --no-check-certificate https://github.com/open-mpi/ompi/raw/main/ompi/tools/mpisync/hpctimer.h >> $logfile 2>&1
wget --no-check-certificate https://github.com/open-mpi/ompi/raw/main/ompi/tools/mpisync/sync.c >> $logfile 2>&1
mpicc hpctimer.c mpigclock.c sync.c -o mpisync >> $logfile 2>&1
fi
if [ ! -e "$tooldir" ] || [ ! -f "$tooldir/mpisync" ]; then
do_err "can not find $tooldir/mpisync"
fi
mpiexec -n $(($nodes)) -npernode 1 $mpioptions $tooldir/mpisync -o ${syncfile} ${option} 2>&1
do_msg "Analysing ${syncfile}"
cat ${syncfile} >> $logfile 2>&1
diff=$(grep -v '^#' ${syncfile} | cut -f3 -d' ' | sort -n | awk 'BEGIN {min=1000000; max=0;}; { if($1<min && $1 != "") min = $1; if($1>max && $1 != "") max = $1; } END { printf("%0.06f %0.06f %0.06f", min, max, max-min) }') >> $logfile 2>&1
do_msg "sync drift is equal: $diff"
diff=`echo $diff | cut -f3 -d' '`
status=$(if (( `bc <<< "$diff >= 0.001"` == 1 )); then echo "value $diff >= 0.001"; fi)
if [ -n "$status" ] && [ -n $verbose -a "$verbose" == "on" ]; then
do_err "mpisync reports issue with synchronization as $status"
else
do_msg "Warning: mpiperf reports issue with synchronization as $status"
fi
do_msg "DONE"
do_msg ""
}
function do_checksync_mpiperf() {
local status
local tooldir=${tempdir}/mpiperf-0.0.3
local verbose=$1
do_msg "Checking synchronization using mpiperf:"
if [ ! -f ${tempdir}/mpiperf-0.0.3.tar.gz ]; then
wget http://mpiperf.cpct.sibsutis.ru/uploads/Main/mpiperf-0.0.3.tar.gz >> $logfile 2>&1
tar zxvf mpiperf-0.0.3.tar.gz >> $logfile 2>&1
cd $tooldir
make >> $logfile 2>&1
fi
if [ ! -e "$tooldir" ] || [ ! -f "$tooldir/src/mpiperf" ]; then
do_err "can not find $tooldir/src/mpiperf"
fi
mpiexec -n 1 $mpioptions $tooldir/src/mpiperf -T >> $logfile 2>&1
if [ -z "$(mpiexec -n 1 $mpioptions $tooldir/src/mpiperf -j -t gettimeofday 2>&1 | tee -a $logfile | sed -n '/PASSED/p')" ]; then
do_err "mpiperf does not support gettimeofday"
fi
mpiexec -n $(($nodes)) -npernode 1 $mpioptions $tooldir/src/mpiperf -t gettimeofday WaitPatternNull >> ${syncfile} 2>&1
do_msg "Analysing ${syncfile}"
cat ${syncfile} >> $logfile 2>&1
status=$(grep -v '^#' ${syncfile} | awk -F ' ' '{ print $6 }' | while read i; do if (( `bc <<< "$i >= 1"` == 1 )); then echo "value $i >= 1.00"; break; fi; done)
if [ -n "$status" ] && [ -n $verbose -a "$verbose" == "on" ]; then
do_err "mpiperf reports issue with synchronization as $status"
else
do_msg "Warning: mpiperf reports issue with synchronization as $status"
fi
do_msg "DONE"
do_msg ""
}
# $1 - sync filename
# $2 - verbose mode: on - exit in case synchronization values exceed a threshold and off - silent mode (default: off)
# $3+ - application additional options
function do_checksync() {
if [ -z "$1" ]; then
syncfile=${tempdir}/mpisync.log
else
syncfile=$1
fi
do_checksync_mpisync $2 "-a 0"
# do_checksync_mpisync $2 "-a 1"
# do_checksync_mpiperf
do_msg "syncfile: $syncfile"
}
function do_analysis() {
local testdir=$1
local basefile=$2
local outfile=$3
local outfile1="${3}.1"
local resultfile=${testdir}/${nodes}x${ppn}_result.log
if [ ! -e $tesdir ]; then
do_err "can not find testdir: $testdir"
fi
if [ -z $basefile -o ! -f $basefile ]; then
do_err "can not find basefile: $basefile"
fi
if [ -z $outfile -o ! -f $outfile ]; then
do_err "can not find outfile: $outfile"
fi
if [ "$(cat $outfile | wc -l)" != "$(($nodes * $ppn))" ]; then
do_msg "Warning: number of lines in $outfile ($(cat $outfile | wc -l)) is not equal ($nodes * $ppn)."
fi
start_t=`awk -F $'\t' '{ if (NR == 1) print $1 }' $basefile`
# Add sync value in output file
while read line; do
if [[ ! $line =~ ^[0-9] ]]; then
do_msg "Warning: ignoring line: $line."
continue
fi
local n=$(echo $line | cut -f3 -d' ')
local v1=$(echo $line | cut -f1 -d' ')
local v2=0
if [ ! -z $syncfile -o -f $syncfile ]; then
v2=$(echo "scale=2; ($(grep $n $syncfile | cut -f3 -d' ') * 1000000)" | bc -l)
# Round float value to int
v2=$(echo ${v2%%.*})
v2=${v2:=0}
fi
echo -e "$(($v1 + $v2))\t${v2}\t${line}" >> $outfile1
done < $outfile
# Find maximum and minimum lines
min_line=`sort -n $outfile1 | head -n1`
max_line=`sort -n $outfile1 | tail -n1`
if [ -z "$min_line" -o -z "$max_line" ]; then
do_err "can not find max/min lines in : $outfile1"
fi
min_t=$( echo "$min_line" | cut -f1 -d$'\t')
max_t=$( echo "$max_line" | cut -f1 -d$'\t')
echo -e "`bc -l <<< "scale=3; (($min_t - $start_t) / 1000000)"`\t`echo "$min_line" | cut -f4 -d$'\t'`\t`echo "$min_line" | cut -f5 -d$'\t'`" >> $resultfile 2>&1
echo -e "`bc -l <<< "scale=3; (($max_t - $start_t) / 1000000)"`\t`echo "$max_line" | cut -f4 -d$'\t'`\t`echo "$max_line" | cut -f5 -d$'\t'`" >> $resultfile 2>&1
echo -e "\n# Used synchronization file: $syncfile" >> $outfile1
do_report $testdir $resultfile
}
function do_report() {
local testdir=$1
local resultfile=$2
local reportfile=${testdir}/report.log
if [ -z $resultfile -o ! -f $resultfile ]; then
do_err "can not find resultfile: $resultfile"
fi
min_t=`awk -F $'\t' '{ if (NR == 1) print $1 }' $resultfile`
max_t=`awk -F $'\t' '{ if (NR == 2) print $1 }' $resultfile`
echo -e "${nodes}\t${ppn}\t${min_t}\t${max_t}" >> $reportfile 2>&1
}
function do_postresult() {
cd $tempdir/..
tar -zcvf $PWD/pmix.$$.tar.gz $tempdir > /dev/null 2>&1
}
include_timestamp_func=$(cat <<END_MSG
#include <dlfcn.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/stat.h>
#include <time.h>
#include <sys/time.h>
static inline void timestamp(FILE *file)
{
struct timeval tv;
char name[256];
char *host_name = NULL;
char *domain = NULL;
int procid = -1;
char *str = NULL;
gettimeofday(&tv, NULL);
if (gethostname(name, sizeof(name)) != 0)
strcpy(name, "localhost");
host_name = strdup(name);
domain = strchr(host_name, '.');
if (domain)
*domain = '\0';
str = getenv("SLURM_PROCID");
procid = ( str ? strtol(str, NULL, 10) : -1);
fprintf(file, "%lld\t%d\t%s\n", tv.tv_sec * 1000000LL + tv.tv_usec, procid, host_name);
fflush(file);
}
END_MSG
)
function do_exec() {
# The number of nodes (see SLURM_NNODES)
nodes=${SLURM_NNODES}
nodes=${nodes:=2}
# The number of tasks per node (see SLURM_NTASKS_PER_NODE or SLURM_TASKS_PER_NODE)
ppn=${SLURM_NTASKS_PER_NODE}
ppn=${ppn:=1}
mpioptions=' -novm -mca btl_openib_warn_default_gid_prefix 0 -mca mpi_add_procs_cutoff 100000 '
slurmoptions=' OMPI_MCA_btl_openib_warn_default_gid_prefix=0 OMPI_MCA_mpi_add_procs_cutoff=100000 '
if [ -z "$(env | grep SLURM)" ]; then
do_err "Do not see allocated nodes by SLURM. Probably salloc -N option is not set"
fi
#if [ "${SLURM_NPROCS}" != "$(($nodes * $ppn))" ]; then
# do_err "SLURM_NPROCS=${SLURM_NPROCS} is not equal ($nodes * $ppn). Probably salloc -N option is not set"
#fi
do_msg ""
do_msg "Configuration:"
do_msg "=================================================="
do_msg "tempdir: $tempdir"
do_msg "logfile: $logfile"
do_msg "mpi: $mpidir"
do_msg "exec: $exec"
do_msg "nodes: $nodes"
do_msg "ppn: $ppn"
do_msg "mpioptions: $mpioptions"
do_msg "slurmoptions: $slurmoptions"
do_msg "node list: $node_list"
do_msg "ppn list: $ppn_list"
do_msg "test list: $test_list"
do_msg ""
do_export $mpidir
do_nodeinfo
do_validate
if [ -f "${tempdir}/mpisync.log" ]; then
syncfile=${tempdir}/mpisync.log
do_msg "found sync data at ${syncfile}"
elif [ -f "${tempdir}/mpiperf.log" ]; then
syncfile=${tempdir}/mpiperf.log
do_msg "found sync data at ${syncfile}"
else
do_msg "sync data is not found"
fi
# Launch scenario
node_list_len=${#node_list[*]}
ppn_list_len=${#ppn_list[*]}
for ((i=0; $i < $node_list_len; i=$((i=$i+1)))); do
for ((j=0; $j < $ppn_list_len; j=$((j=$j+1)))); do
for test in $test_list; do
nodes=${node_list[$i]}
ppn=${ppn_list[$j]}
if [ "$test" = "sync" ]; then
do_checksync "${tempdir}/${nodes}x${ppn}_mpisync00.log" "off"
else
do_checksync "${tempdir}/${nodes}x${ppn}_mpisync_before.log" "off"
eval "do_${test}"
do_checksync "${tempdir}/${nodes}x${ppn}_mpisyn_after.log" "off"
fi
done
done
done
do_postresult
}
# $1 - result location
function do_parse() {
local parsedir=$1
local result_list
local test_list
local parsefile
for result in `ls -1 $workdir`; do
if [ ! -d "${parsedir}/${result}" ]; then
continue
fi
for test in `ls -1 "${parsedir}/${result}" | grep -v mpisync`; do
if [ ! -d "${parsedir}/${result}/${test}" ]; then
continue
fi
result_list="${result_list} ${result}"
test_list="${test_list} ${test}"
done
done
result_list=`echo $result_list | tr " " "\n" | sort | uniq | tr "\n" " "`
test_list=`echo $test_list | tr " " "\n" | sort | uniq | tr "\n" " "`
do_msg "results: $result_list"
do_msg "tests: $test_list"
for test in $test_list; do
parsefile="${parsedir}/parse_${test}.log"
for result in $result_list; do
echo -e "\n${result}:" >> $parsefile 2>&1
echo -e "nodes\tppn\tmin\tmax" >> $parsefile 2>&1
cat "${parsedir}/${result}/${test}/report.log" >> $parsefile 2>&1
done
done
}
# Pure application srun launch
#####################################################
function do_test1
{
local status
local scenario=test1
local testdir=${tempdir}/$scenario
local outfile=${testdir}/${nodes}x${ppn}_out.log
local basefile=${testdir}/${nodes}x${ppn}_base.log
do_msg "Running $scenario ${nodes}x${ppn} :"
mkdir -p $testdir
cd $testdir
cat > $scenario.c <<END_MSG
$include_timestamp_func
int main()
{
timestamp(stdout);
return 0;
}
END_MSG
gcc $scenario.c -o $scenario.out >> $logfile 2>&1
# Do test
do_timestamp "start" 2>&1 | tee -a $basefile
srun -n$(($nodes * $ppn)) -N$nodes --ntasks-per-node=$ppn ./$scenario.out >> $outfile 2>&1
test $? -eq 0 && status=OK || status=FAIL
do_timestamp "end" 2>&1 | tee -a $basefile
if [ "$status" == "FAIL" ]; then
do_err "can not launch a test"
fi
echo -e "srun pure overhead" > ${testdir}/info.log 2>&1
do_analysis $testdir $basefile $outfile
do_msg "DONE"
}
# Pure application mpiexec launch
#####################################################
function do_test2
{
local status
local scenario=test2
local testdir=${tempdir}/$scenario
local outfile=${testdir}/${nodes}x${ppn}_out.log
local basefile=${testdir}/${nodes}x${ppn}_base.log
do_msg "Running $scenario ${nodes}x${ppn} :"
mkdir -p $testdir
cd $testdir
cat > $scenario.c <<END_MSG
$include_timestamp_func
int main()
{
timestamp(stdout);
return 0;
}
END_MSG
gcc $scenario.c -o $scenario.out >> $logfile 2>&1
# Do test
do_timestamp "start" 2>&1 | tee -a $basefile
mpiexec -n $(($nodes * $ppn)) -npernode $ppn $mpioptions ./$scenario.out >> $outfile 2>&1
test $? -eq 0 && status=OK || status=FAIL
do_timestamp "end" 2>&1 | tee -a $basefile
if [ "$status" == "FAIL" ]; then
do_err "can not launch a test"
fi
echo -e "mpiexec pure overhead" > ${testdir}/info.log 2>&1
do_analysis $testdir $basefile $outfile
do_msg "DONE"
}
# Pure application oshrun launch
#####################################################
function do_test3
{
local status
local scenario=test3
local testdir=${tempdir}/$scenario
local outfile=${testdir}/${nodes}x${ppn}_out.log
local basefile=${testdir}/${nodes}x${ppn}_base.log
do_msg "Running $scenario ${nodes}x${ppn} :"
mkdir -p $testdir
cd $testdir
cat > $scenario.c <<END_MSG
$include_timestamp_func
int main()
{
timestamp(stdout);
return 0;
}
END_MSG
gcc $scenario.c -o $scenario.out >> $logfile 2>&1
# Do test
do_timestamp "start" 2>&1 | tee -a $basefile
oshrun -n $(($nodes * $ppn)) -npernode $ppn $mpioptions ./$scenario.out >> $outfile 2>&1
test $? -eq 0 && status=OK || status=FAIL
do_timestamp "end" 2>&1 | tee -a $basefile
if [ "$status" == "FAIL" ]; then
do_err "can not launch a test"
fi
echo -e "osrun pure overhead" > ${testdir}/info.log 2>&1
do_analysis $testdir $basefile $outfile
do_msg "DONE"
}
# MPI_init application srun/pmi2 launch
#####################################################
function do_test4
{
local status
local scenario=test4
local testdir=${tempdir}/$scenario
local outfile=${testdir}/${nodes}x${ppn}_out.log
local basefile=${testdir}/${nodes}x${ppn}_base.log
do_msg "Running $scenario ${nodes}x${ppn} :"
mkdir -p $testdir
cd $testdir
cat > $scenario.c <<END_MSG
$include_timestamp_func
#include "mpi.h"
int main(int argc, char* argv[])
{
MPI_Init(&argc, &argv);
timestamp(stdout);
MPI_Finalize();
return 0;
}
END_MSG
mpicc $scenario.c -o $scenario.out >> $logfile 2>&1
# Do test
do_timestamp "start" 2>&1 | tee -a $basefile
env $slurmoptions srun -n$(($nodes * $ppn)) -N$nodes --ntasks-per-node=$ppn --mpi=pmi2 ./$scenario.out >> $outfile 2>&1
test $? -eq 0 && status=OK || status=FAIL
do_timestamp "end" 2>&1 | tee -a $basefile
if [ "$status" == "FAIL" ]; then
do_err "can not launch a test"
fi
echo -e "srun --mpi=pmi2:MPI_Init" > ${testdir}/info.log 2>&1
do_analysis $testdir $basefile $outfile
do_msg "DONE"
}
# start_pes application srun/pmi2 launch
#####################################################
function do_test5
{
local status
local scenario=test5
local testdir=${tempdir}/$scenario
local outfile=${testdir}/${nodes}x${ppn}_out.log
local basefile=${testdir}/${nodes}x${ppn}_base.log
do_msg "Running $scenario ${nodes}x${ppn} :"
mkdir -p $testdir
cd $testdir
cat > $scenario.c <<END_MSG
$include_timestamp_func
#include "shmem.h"
int main(int argc, char* argv[])
{
start_pes(0);
timestamp(stdout);
return 0;
}
END_MSG
oshcc $scenario.c -o $scenario.out >> $logfile 2>&1
# Do test
do_timestamp "start" 2>&1 | tee -a $basefile
env $slurmoptions srun -n$(($nodes * $ppn)) -N$nodes --ntasks-per-node=$ppn --mpi=pmi2 ./$scenario.out >> $outfile 2>&1
test $? -eq 0 && status=OK || status=FAIL
do_timestamp "end" 2>&1 | tee -a $basefile
if [ "$status" == "FAIL" ]; then
do_err "can not launch a test"
fi
echo -e "srun --mpi=pmi2:start_pes" > ${testdir}/info.log 2>&1
do_analysis $testdir $basefile $outfile
do_msg "DONE"
}
# MPI_Init application mpiexec launch
#####################################################
function do_test6
{
local status
local scenario=test6
local testdir=${tempdir}/$scenario
local outfile=${testdir}/${nodes}x${ppn}_out.log
local basefile=${testdir}/${nodes}x${ppn}_base.log
do_msg "Running $scenario ${nodes}x${ppn} :"
mkdir -p $testdir
cd $testdir
cat > $scenario.c <<END_MSG
$include_timestamp_func
#include "mpi.h"
int main(int argc, char* argv[])
{
MPI_Init(&argc, &argv);
timestamp(stdout);
MPI_Finalize();
return 0;
}
END_MSG
mpicc $scenario.c -o $scenario.out >> $logfile 2>&1
# Do test
do_timestamp "start" 2>&1 | tee -a $basefile
mpiexec -n $(($nodes * $ppn)) -npernode $ppn $mpioptions ./$scenario.out >> $outfile 2>&1
test $? -eq 0 && status=OK || status=FAIL
do_timestamp "end" 2>&1 | tee -a $basefile
if [ "$status" == "FAIL" ]; then
do_err "can not launch a test"
fi
echo -e "mpiexec:MPI_Init" > ${testdir}/info.log 2>&1
do_analysis $testdir $basefile $outfile
do_msg "DONE"
}
# start_pes application oshrun launch
#####################################################
function do_test7
{
local status
local scenario=test7
local testdir=${tempdir}/$scenario
local outfile=${testdir}/${nodes}x${ppn}_out.log
local basefile=${testdir}/${nodes}x${ppn}_base.log
do_msg "Running $scenario ${nodes}x${ppn} :"
mkdir -p $testdir
cd $testdir
cat > $scenario.c <<END_MSG
$include_timestamp_func
#include "shmem.h"
int main(int argc, char* argv[])
{
start_pes(0);
timestamp(stdout);
return 0;
}
END_MSG
oshcc $scenario.c -o $scenario.out >> $logfile 2>&1
# Do test
do_timestamp "start" 2>&1 | tee -a $basefile
oshrun -n $(($nodes * $ppn)) -npernode $ppn $mpioptions ./$scenario.out >> $outfile 2>&1
test $? -eq 0 && status=OK || status=FAIL
do_timestamp "end" 2>&1 | tee -a $basefile
if [ "$status" == "FAIL" ]; then
do_err "can not launch a test"
fi
echo -e "osrun:start_pes" > ${testdir}/info.log 2>&1
do_analysis $testdir $basefile $outfile
do_msg "DONE"
}
# pure application mpiexec:orte_daemon
#####################################################
function do_test8
{
local status
local scenario=test8
local testdir=${tempdir}/$scenario
local outfile=${testdir}/${nodes}x${ppn}_out.log
local basefile=${testdir}/${nodes}x${ppn}_base.log
do_msg "Running $scenario ${nodes}x${ppn} :"
mkdir -p $testdir
cd $testdir
cat > $scenario.c <<END_MSG
#include "mpi.h"
int main(int argc, char* argv[])
{
return 0;
}
END_MSG
cat > lib_$scenario.c <<END_MSG
#define _GNU_SOURCE
$include_timestamp_func
int orte_daemon(int argc, char *argv[])
{
static int (*_orte_daemon)(int argc, char *argv[]) = NULL;
if (!_orte_daemon) {
_orte_daemon=dlsym(RTLD_NEXT,"orte_daemon");
if (!_orte_daemon) {
fprintf(stderr, "Error in 'dlsym': %s\n", dlerror());
exit(1);
} else {
FILE *fd = NULL;
char filename[1024];
char *str = getenv("SLURM_PROCID");
if (str) {
sprintf(filename, "%s.%s", "$outfile", str);
fd = fopen(filename, "a");
if (fd) {
timestamp(fd);
fclose(fd);
}
}
}
}
return _orte_daemon(argc, argv);
}
END_MSG
mpicc $scenario.c -o $scenario.out >> $logfile 2>&1
gcc lib_$scenario.c -o $scenario.so -shared -fPIC -ldl >> $logfile 2>&1
# Do test
do_timestamp "start" 2>&1 | tee -a $basefile
LD_PRELOAD=$PWD/$scenario.so mpiexec -n $(($nodes * $ppn)) -npernode $ppn $mpioptions ./$scenario.out
test $? -eq 0 && status=OK || status=FAIL
do_timestamp "end" 2>&1 | tee -a $basefile
if [ "$status" == "FAIL" ]; then
do_err "can not launch a test"
fi
eval cat $outfile.* >> $outfile
rm $outfile.*
echo -e "mpiexec:orte_daemon" > ${testdir}/info.log 2>&1
do_analysis $testdir $basefile $outfile
do_msg "DONE"
}
# pure application oshrun:orte_daemon
#####################################################
function do_test9
{
local status
local scenario=test9
local testdir=${tempdir}/$scenario
local outfile=${testdir}/${nodes}x${ppn}_out.log
local basefile=${testdir}/${nodes}x${ppn}_base.log
do_msg "Running $scenario ${nodes}x${ppn} :"
mkdir -p $testdir
cd $testdir
cat > $scenario.c <<END_MSG
#include "mpi.h"
int main(int argc, char* argv[])
{
return 0;
}
END_MSG
cat > lib_$scenario.c <<END_MSG
#define _GNU_SOURCE
$include_timestamp_func
int orte_daemon(int argc, char *argv[])
{
static int (*_orte_daemon)(int argc, char *argv[]) = NULL;
if (!_orte_daemon) {
_orte_daemon=dlsym(RTLD_NEXT,"orte_daemon");
if (!_orte_daemon) {
fprintf(stderr, "Error in 'dlsym': %s\n", dlerror());
exit(1);
} else {
FILE *fd = NULL;
char filename[1024];
char *str = getenv("SLURM_PROCID");
if (str) {
sprintf(filename, "%s.%s", "$outfile", str);
fd = fopen(filename, "a");
if (fd) {
timestamp(fd);
fclose(fd);
}
}
}
}
return _orte_daemon(argc, argv);
}
END_MSG
mpicc $scenario.c -o $scenario.out >> $logfile 2>&1
gcc lib_$scenario.c -o $scenario.so -shared -fPIC -ldl >> $logfile 2>&1
# Do test
do_timestamp "start" 2>&1 | tee -a $basefile
LD_PRELOAD=$PWD/$scenario.so oshrun -n $(($nodes * $ppn)) -npernode $ppn $mpioptions ./$scenario.out
test $? -eq 0 && status=OK || status=FAIL
do_timestamp "end" 2>&1 | tee -a $basefile
if [ "$status" == "FAIL" ]; then
do_err "can not launch a test"
fi
eval cat $outfile.* >> $outfile
rm $outfile.*
echo -e "oshrun:orte_daemon" > ${testdir}/info.log 2>&1
do_analysis $testdir $basefile $outfile
do_msg "DONE"
}
# pure application mpiexec:orte_rml_base_update_contact_info
#####################################################
function do_test10
{
local status
local scenario=test10
local testdir=${tempdir}/$scenario
local outfile=${testdir}/${nodes}x${ppn}_out.log
local basefile=${testdir}/${nodes}x${ppn}_base.log
do_msg "Running $scenario ${nodes}x${ppn} :"
mkdir -p $testdir
cd $testdir
cat > $scenario.c <<END_MSG
#include "mpi.h"
int main(int argc, char* argv[])
{
return 0;
}
END_MSG
cat > lib_$scenario.c <<END_MSG
#define _GNU_SOURCE
$include_timestamp_func
int orte_rml_base_update_contact_info(void * data)
{
static int (*_real_func)(void* data) = NULL;
if (!_real_func) {
_real_func=dlsym(RTLD_NEXT,"orte_rml_base_update_contact_info");
if (!_real_func) {
fprintf(stderr, "Error in 'dlsym': %s\n", dlerror());
exit(1);
} else {
FILE *fd = NULL;
char filename[1024];
char *str = getenv("SLURM_PROCID");
if (str) {
sprintf(filename, "%s.%s", "$outfile", str);