forked from oneapi-src/oneDNN
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·1105 lines (1079 loc) · 46.5 KB
/
build.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/bash
# vim: et ts=4 sw=4 ai
ORIGINAL_CMD="$0 $*"
DOTEST=0
DODEBUG=0
DODOC="y"
DOJUSTDOC=0
DOWARN=""
BUILDOK="y"
SIZE_T=64 # or 64, for -s or -S SX compile
_cpus=`cat /proc/cpuinfo | grep '^processor' | wc -l` || _cpus=16
_cpus=$((_cpus/2+1))
_cpus=$((_cpus < 20 ? _cpus : 20 ))
JOBS="-j${_cpus}" # SIGSEGV in ccom now handle with incr ulimit -s
CMAKETRACE=""
USE_MKL=0
USE_CBLAS=0
USE_CACHE=0 # enable primitive cache?
QUICK=0
DOGCC_VER=0
NEC_FTRACE=0
DOTARGET="x"
BFLOAT16="x"
PRIMITIVES=""
RNN="x"
OMP=-1
#ULIMIT=16384 # ulimit is in 1024-byte blocks
#ULIMIT=32768
ULIMIT=65536 # cpu-tutorials-matmul-matmul-quantization-cpp like this ulimit
#ULIMIT=131072
#ULIMIT=262144
#ULIMIT=unlimited
NODE=0
if [ "$VE_NODE_NUMBER" ]; then NODE="$VE_NODE_NUMBER"; fi
ENV=`which env`
# see dnnl_config.h ... (historical?) CPU and ISA approach was not accepted.
CPU_X86=1
CPU_VE=2
CPU_SX=3
#
CPU=-1
ISA="ALL"
usage() {
echo "$0 usage:"
#head -n 30 "$0" | grep "^[^#]*.)\ #"
awk '/getopts/{flag=1;next} /^done/{flag=0} flag&&/^[^#]+) #/; flag&&/^ *# /' $0
echo ""
echo "Platform/Compiler: -v (vanilla) -j (x86 jit) -a (Aurora,ncc) -S (SX,sxcc)"
echo "Example: time a full test run for a debug compilation --- time $0 -dtt"
echo " SX debug compile, quick (no doxygen) --- time $0 -Sdq"
echo " *just* run cmake, for SX debug compile --- $0 -SdQ"
echo " *just* create doxygen docs --- $0 -D"
echo "Aurora : quick Aurora Ftrace Trace-Cmake) --- $0 -qaFT"
echo " quick, quick: no cmake, just make --- $0 -qqa"
echo " see what cmake is doing, and create build.log"
echo " CMAKEOPT='--trace -LAH' ./build.sh -q >&/dev/null"
echo " NEW: ./build.sh -aj for Aurora + vednn/jit compile (binary Aurora libvednn distro)"
echo "Debug: Individual tests can be run like build-sx/tests/gtests/test_relu"
echo " We look at CC and CXX to try to guess -S or -a (SX or Aurora)"
exit 0
}
while getopts ":m:u:N:hvjatTdDqQP:FbBrRowW1567iMrcC" arg; do
#echo "arg = ${arg}, OPTIND = ${OPTIND}, OPTARG=${OPTARG}"
case $arg in
m) # -mISA "machine", ISA=[ALL] | VANILLA | ANY? ... (prefer j|a|gj|ga)
ISA="${OPTARG}"
# check for valid ISA string values XXX
;;
u) # soft ulimit (kB) [32768] (avoid nc++ ccom errors)
ULIMIT="${OPTARG}"
;;
N) # [0, or from environment] VE_NODE_NUMBER
NODE="${OPTARG}"
;;
v) # force Intel x86 compile for VANILLA generic architecture
ISA=VANILLA
;;
V) # force x86 compile for VANILLA generic architecture, but with TARGET_VE
ISA=VE_SIM
;;
j) # force Intel x86 compile JIT (default FULL x86 build)
if [ ! "${DOTARGET}" == "x" ]; then echo "-j no good: already have -${DOTARGET}"; usage; fi
DOTARGET="j"; USE_CACHE=1
;;
a) # NEC Aurora VE, full features
if [ ! "${DOTARGET}" == "x" ]; then echo "-a no good: already have -${DOTARGET}"; usage; fi
DOTARGET="a"; SIZE_T=64;
_cpus=`cat /proc/cpuinfo | grep '^processor' | wc -l` || _cpus=16
JOBS="-j$((_cpus/2+1))" # SIGSEGV in ccom now handle with incr ulimit -s
if [ `uname -n` = "zoro" ]; then JOBS="-j8"; fi
;;
t) # [0] increment test level: (1) examples, (2) tests (longer), ...
# Apr-14-2017 build timings:
# >=1 : build ~ ?? min (jit), 1 min (vanilla) | examples/primitives-*
# >=2 : examples ~ 1 min (jit), 13-16 mins (vanilla) | other examples
# >=3 : test_* ~ 10 mins (jit), 108 mins (vanilla) | gtests
# >=4 : benchdnn quick performance/correctness tests | demo
# >=5 : benchdnn default build targets (very long) | very long
# Warning: -t>=1 with reduced omp (-o or -oo) can take a VERY long time
DOTEST=$(( DOTEST + 1 ))
;;
T) # cmake --trace
CMAKETRACE="--trace --debug-trycompile"
;;
d) # cmake build mode: [0] : cmake Release build.
# None : Release
# -d : ReleaseWithAssert
# -dd : RelWithDebInfo
# -ddd : Debug
# more : Debug and -O0
DODEBUG=$(( DODEBUG + 1 ))
;;
D) # [no] Doxygen-only : make doc (or doc-full with -DD) and stop. -q will reuse build/
DOJUSTDOC=$(( DOJUSTDOC + 1 )); DOTARGET="invalid"
;;
q) # quick: once, skip doxygen on OK build; twice, cd BUILDDIR && make
QUICK=$((QUICK+1))
;;
Q) # really quick: skip build and doxygen docs [JUST run cmake and stop]
BUILDOK="n"; DODOC="n"
;;
P) # all-caps primitives to enable (see end of cmake/option.cmake)
#VERBOSE_EXTRA="y"
PRIMITIVES="${PRIMITIVES} -DDNNLPRIM_${OPTARG}=1"
;;
F) # NEC Aurora VE or SX : add ftrace support (generate ftrace.out)
NEC_FTRACE=1
;;
b) # no bfloat16 support or tests (not supported for x86 jit builds)
BFLOAT16="n"
;;
B) # add bfloat16 support and tests
BFLOAT16="y"
;;
r) # no rnn support or tests
RNN="n"
;;
R) # add rnn support and tests
RNN="y"
;;
o) # OpenMp support [default -ooo]:
# once | 0 | build SEQ (no omp support) (run
# twice | 1 | omp support, but test with OMP_NUM_THREADS=1
# thrice | 2 | [default] omp, test without specifying OMP_NUM_THREADS
OMP=$(( OMP + 1 ));
;;
w) # reduce compiler warnings
DOWARN=0
;;
W) # lots of compiler warnings (default)
DOWARN=1
;;
1) # make -j1 (default is usually -j8)
JOBS="-j1"
;;
5) # gcc-5, if found
DOGCC_VER=5
;;
6) # gcc-6, if found
DOGCC_VER=6
;;
7) # gcc-7, if found
DOGCC_VER=7
;;
i) # try using icc
DOGCC_VER=icc
;;
M) # try MKL [at own risk] option
USE_MKL=1; USE_CBLAS=0
;;
r) # reference impls only: no -DUSE_CBLAS compile flag (->no im2col gemm)
USE_CBLAS=0; USE_MKL=0
;;
c) # cache: support primitive caching
USE_CACHE=1
;;
C) # force -DUSE_CBLAS compile flag (extended_sgemm will use libcblas
# instead of the OneDNN built-in gemm.
# x86: expect errors if not very careful about omp libs
# (or set OMP_NUM_THREADS=1)
# non-x86: this *may* provide a speed boost if your platform has an
# optimized cblas library
USE_CBLAS=1; USE_MKL=0
# Note: ve.cmake always LINKs with cblas (-ooo default)
;;
h | *) # help
usage
;;
esac
done
if [ $OMP -lt 0 -o $OMP -gt 2 ]; then OMP=2; fi
if [ ${OMP} -eq 1 ]; then TEST_ENV+=(OMP_NUM_THREADS=1); fi
#if [ $VERBOSE -lt 0 -o $VERBOSE -gt 2 ]; then VERBOSE=2; fi
#TEST_ENV+=(DNNL_VERBOSE=$VERBOSE)
# if unspecified, autodetect target via $CC compiler variable
if [ "${DOTARGET}" == "x" ]; then
if [ "${CC:0:3}" == "ncc" -a "${CXX:0:4}" == "nc++" ]; then
echo "auto-detected '-a' Aurora compiler (ncc, nc++)"
DOTARGET="a"; SIZE_T=64
if [ -f vejit/include/vednn.h ]; then
echo "auto-detected libvednn" # ISA=FULL
else
ISA=VANILLA
fi
else
DOTARGET="j" # j for JIT (Intel assembler)
fi
fi
if [ "${DOTARGET}" == "x" ]; then
usage
fi
if [ ! "x${CC}" == "x" ]; then
if [ ! "`which ${CC}`" ]; then
if [ -x ${CC} ]; then
echo "Using specific compiler version: ${CC}";
else
echo "./build.sh: CC=${CC} , but did not find that compiler."
exit -1
fi
fi
fi
if [ ${DOJUSTDOC} -gt 0 ]; then
echo " JUST building doxygen docs"
fi
INSTALLDIR=install
BUILDDIR=build
#
# I have not yet tried icc.
# we MUST avoid the full MKL (omp issues) (mkldnn uses the mkl subset in external/)
#
#if [ "${MKLROOT}" != "" ]; then
# module unload icc >& /dev/null || echo "module icc unloaded"
# if [ "${MKLROOT}" != "" ]; then
# echo "Please compile in an environment without MKLROOT"
# exit -1;
# fi
# # export -n MKLROOT
# # export MKL_THREADING_LAYER=INTEL # maybe ???
#fi
# Now Ubuntu can install libmkl "somewhere" in your /opt/intel, and the FOOvar.sh script will set MKLROOT
#
#
#
if [ "$DOTARGET" == "s" ]; then DODOC="n"; DOTEST=0; INSTALLDIR='install-sx'; BUILDDIR='build-sx';
elif [ "$DOTARGET" == "a" ]; then
if [ "$ISA" == "VANILLA" ]; then BUILDDIR="${BUILDDIR}-ve"; INSTALLDIR="${INSTALLDIR}-ve";
else BUILDDIR="${BUILDDIR}-vej"; INSTALLDIR="${INSTALLDIR}-vej";
fi
else #if [ "$DOTARGET" != "a" ]; then
if [ "$DOGCC_VER" == "icc" ]; then
echo "LOOKING for icc ... which icc = `which icc`"
set -x
if [ "x`which icc`" == "x" ]; then
if true; then
module load icc
MKLROOT=""
LD_LIBRARY_PATH=""
else
for d in \
/opt/intel/composer_xe_2015/bin \
/opt/intel/composer_xe_2015.3.187/bin \
/opt/intel/compilers_and_libraries/linux/bin/intel64/ \
; \
do
if [ -x "${d}/icc" ]; then
export PATH="${d}:${PATH}"
break;
fi
done
fi
fi
set +x
export CXX=icpc; export CC=icc; export FC=ifort;
BUILDDIR="${BUILDDIR}-icc"; INSTALLDIR="${INSTALLDIR}-icc"
elif [ "$DOGCC_VER" -gt 0 ]; then
if $(gcc-${DOGCC_VER} -v); then export CXX=g++-${DOGCC_VER}; export CC=gcc-${DOGCC_VER}; fi
fi
if [ "$DOTARGET" == "j" ]; then
if [ "$ISA" == "VANILLA" ]; then BUILDDIR="${BUILDDIR}-gen"; INSTALLDIR="${INSTALLDIR}-gen";
elif [ "$ISA" == "FULL" ]; then BUILDDIR="${BUILDDIR}-jit"; INSTALLDIR="${INSTALLDIR}-jit";
else BUILDDIR="${BUILDDIR}-jit-${ISA}"; INSTALLDIR="${INSTALLDIR}-jit-${ISA}";
fi
fi
fi
if [ $DODEBUG -eq 1 ]; then BUILDDIR="${BUILDDIR}d"; INSTALLDIR="${INSTALLDIR}d"; fi
if [ $DODEBUG -gt 1 ]; then BUILDDIR="${BUILDDIR}d${DODEBUG}"; INSTALLDIR="${INSTALLDIR}d${DODEBUG}"; fi
if [ $NEC_FTRACE -gt 0 ]; then BUILDDIR="${BUILDDIR}F"; fi
if [ $USE_CBLAS -gt 0 ]; then BUILDDIR="${BUILDDIR}C"; INSTALLDIR="${INSTALLDIR}C";fi
if [ "$BUILDDIR_SUFFIX" ]; then BUILDDIR="${BUILDDIR}${BUILDDIR_SUFFIX}"; fi
if [ "$BFLOAT16" = "y" ]; then BUILDDIR="${BUILDDIR}-bf16"; fi
if [ "$BFLOAT16" = "n" ]; then BUILDDIR="${BUILDDIR}-nobf16"; fi
if [ "$RNN" = "y" ]; then BUILDDIR="${BUILDDIR}-rnn"; fi
if [ "$RNN" = "n" ]; then BUILDDIR="${BUILDDIR}-nornn"; fi
if [ "${OMP}" -eq 0 ]; then BUILDDIR="${BUILDDIR}-seq"; INSTALLDIR="${INSTALLDIR}-seq"; fi
if [ $DOJUSTDOC -gt 0 ]; then
echo " JUST building doxygen docs"
echo "DOJUSTDOC = ${DOJUSTDOC}"
echo "QUICK = ${QUICK}"
if [ $DOJUSTDOC -eq 1 ]; then # old way Doxyfile
(
if [ ! -d build ]; then mkdir build; fi
if [ ! -f build/Doxyfile ]; then
# doxygen does not much care HOW to build, just WHERE
(cd build && cmake -DCMAKE_INSTALL_PREFIX=../${INSTALLDIR} -DFAIL_WITHOUT_MKL=OFF ..)
fi
echo "Doxygen (please be patient) logging to doxygen.log"
rm -f build/doc*stamp
if [ $QUICK -le 0 ]; then
rm -rf build/reference "${INSTALLDIR}/share/doc"
fi
#cd build \
#&& make VERBOSE=1 doc \
#&& cmake -DCOMPONENT=doc -P cmake_install.cmake
(cd build && make VERBOSE=1 doc) # Doxygen.cmake custom target (not always available!)
echo " Documentation built in build/reference/"
echo " doxygen.log ends up in gen-dnn project root,"
# ... install-doc target was remove in dnnl-v1.1 (or maybe earlier)
# can the cmake doc-full get additional docs from sub-cmakes ?
#(cd build && make VERBOSE=1 install-doc) # Doxygen.cmake custom target
#echo "Documentation installed under ${INSTALLDIR}/share/doc/"
# ... so just copy manually ...
if [ -d build/reference ]; then
echo " copying to INSTALLDIR..."
mkdir --parents ${INSTALLDIR}/share/doc
cp -uar build/reference ${INSTALLDIR}/share/doc/
echo " You may browse API docs at"
echo " ${INSTALLDIR}/share/doc/reference/html/index.html"
fi
) 2>&1 | tee doxygen.log
else # full docs Doxyfile-cpu, via 'make doc-full' also documents internals
(
if [ ! -d build ]; then mkdir build; fi
if [ ! -f build/Doxyfile ]; then
# doxygen does not much care HOW to build, just WHERE
(cd build && cmake -DCMAKE_INSTALL_PREFIX=../${INSTALLDIR} -DFAIL_WITHOUT_MKL=OFF ..)
fi
echo "Doxygen (please be patient) logging to doxygen-full.log"
rm -f build/doc*stamp-full
if [ $QUICK -le 0 ]; then
rm -rf build/reference-full "${INSTALLDIR}/share/doc"
fi
#cd build \
#&& make VERBOSE=1 doc \
#&& cmake -DCOMPONENT=doc -P cmake_install.cmake
(cd build && make VERBOSE=1 doc-full) # Doxygen.cmake custom target
echo " Documentation built in build/reference-full/"
echo " doxygen-full.log ends up in gen-dnn project root"
if [ -d build/reference-full ]; then
echo " copying to INSTALLDIR..."
mkdir --parents ${INSTALLDIR}/share/doc
cp -uar build/reference-full ${INSTALLDIR}/share/doc/
echo " You may browse API docs at"
echo " ${INSTALLDIR}/share/doc/reference-full/html/index.html"
fi
) 2>&1 | tee ../doxygen-full.log
fi
exit 0
fi
if [ $QUICK -gt 0 ]; then DODOC="n"; fi
if [ $QUICK -gt 1 ]; then
if [ ! -f "${BUILDDIR}/Makefile" ]; then # running cmake is absolutely required
QUICK=1
fi
fi
timeoutPID() { # unused
PID="$1"
timeout="$2"
interval=1
delay=1
(
((t = timeout))
while ((t > 0)); do
sleep $interval
kill -0 $$ || exit 0
((t -= interval))
done
# Be nice, post SIGTERM first.
# The exit 0 below will be executed if any preceeding command fails.
kill -s SIGTERM $$ && kill -0 $$ || exit 0
sleep $delay
kill -s SIGKILL $$
) 2> /dev/null &
}
if [ -d "${BUILDDIR}" -a $QUICK -lt 2 ]; then
rm -rf "${BUILDDIR}".bak && mv -v "${BUILDDIR}" "${BUILDDIR}".bak
if [ -f "${BUILDDIR}.log" ]; then
mv "${BUILDDIR}.log" "${BUILDDIR}".bak/
fi
fi
if [ -d "$INSTALLDIR}" -a $QUICK -lt 2 ]; then
rm -rf "$INSTALLDIR}".bak && mv -v "$INSTALLDIR}" "$INSTALLDIR}".bak
fi
# Obtain INITIAL guesses for TESTRUNNER and VE_EXEC
if [ "" ]; then # old way (now we do not need ve_exec anymore)
VE_EXEC=''
TESTRUNNER=''
if [ "$DOTARGET" = "a" ]; then
#export OMP_NUM_THREADS=1; # for now XXX
if { ve_exec --version 2> /dev/null; } then
# oops, this will not work for "${TESTRUNNER} make test"
#TESTRUNNER="${TESTRUNNER} ve_exec"
#echo "ve_exec! TESTRUNNER ${TESTRUNNER}"
VE_EXEC=ve_exec
else
TESTRUNNER="echo Not-Running "
echo "Aurora: ve_exec not found"
fi
fi
if { /usr/bin/time -v echo Hello >& /dev/null; } then
TESTRUNNER='/usr/bin/time -v'
fi
echo "TESTRUNNER ${TESTRUNNER}"
echo "VE_EXEC ${VE_EXEC}"
fi
#if [ "$NEC_FTRACE" -gt 0 ]; then
if [ "$DOTARGET" = "a" -o "$DOTARGET" = "s" ]; then
#TESTRUNNER="VE_PROGINF=YES ${TESTRUNNER}" #works if used as bash -c ${TESTRUNNER}
#export VE_PROGINF=YES;
export VE_PROGINF=DETAIL;
export C_PROGINF=YES;
#ulimit -Hs unlimited # no perms
ulimit -s $ULIMIT
echo 'ulimit : '`ulimit -s`
echo "NODE : ${NODE}"
unset VE_LIMIT_OPT
# above default 32768 is not possible???
#export VE_LIMIT_OPT='--softs 1000000 --hards=unlimited'
else
unset VE_PROGINF
unset C_PROGINF
unset VE_LIMIT_OPT
fi
if [ "$DOTARGET" = "aXXX" ]; then
echo "Warning: setting OMP_NUM_THREADS=1 for now"
export OMP_NUM_THREADS=1; # for now XXX
else
: #unset OMP_NUM_THREADS; # typically 1 thread per cpu
fi
export PATH
echo "PATH $PATH"
# ULIMIT (inherited by VE, since VE_LIMIT_OPT with spaces poses difficulty)
#ulimit -Hs unlimited # no perms
ulimit -Ss $ULIMIT
echo 'ulimit hard : '`ulimit -Hs`
echo 'ulimit soft : '`ulimit -Ss`
(
echo "# vim: set ro ft=log:"
echo "DOTARGET $DOTARGET"
echo "ISA $ISA"
echo "USE_MKL $USE_MKL"
echo "USE_CBLAS $USE_CBLAS"
echo "DOTEST $DOTEST"
echo "DODEBUG $DODEBUG"
echo "DODOC $DODOC"
echo "QUICK $QUICK"
#echo "VERBOSE_EXTRA $VERBOSE_EXTRA"
echo "NODE $NODE"
echo "PRIMITIVES $PRIMITIVES"
echo "BUILDDIR ${BUILDDIR}"
echo "INSTALLDIR ${INSTALLDIR}"
echo "JOBS ${JOBS}"
#ulimit -Hs unlimited # operation not permitted
#ulimit -Ss $ULIMIT # 10.1.18 "When compiling a program which code size is large, the compiler aborts by SIGSEGV."
echo 'ulimit : '`ulimit -s`
if [ "${DOTARGET}" = "a" ]; then
ve_exec --show-limit 2>&1 | tee "r{$LOG}"
fi
if [ $QUICK -lt 2 ]; then
mkdir "${BUILDDIR}"
fi
cd "${BUILDDIR}"
function ccxx_flags {
export CFLAGS="${CFLAGS} $*"
export CXXFLAGS="${CXXFLAGS} $*"
echo "ccxx_flags CFLAGS --> ${CFLAGS}"
}
#
# Show how to run a subset of tests (see cmake/option.config, end of file)
#CMAKEOPT="${CMAKEOPT} -DDNNLPRIM_ALL=0"
#CMAKEOPT="${CMAKEOPT} -DDNNLPRIM_CONVOLUTION=1"
if [ ! "${PRIMITIVES}" = "" ]; then
CMAKEOPT="${CMAKEOPT} -DDNNLPRIM_ALL=0"
CMAKEOPT="${CMAKEOPT} ${PRIMITIVES}"
fi
if [ "${DOWARN}" = "1" ]; then
DOWARNFLAGS=""
if [ "$DOTARGET" = "s" ]; then DOWARNFLAGS="-wall"
else DOWARNFLAGS="-Wall"; fi
ccxx_flags "${DOWARNFLAGS}"
fi
OPT_FLAGS=
CMAKEOPT="${CMAKEOPT} -DCMAKE_INSTALL_PREFIX=../${INSTALLDIR}"
if [ $DODEBUG -eq 0 ]; then
CMAKEOPT="${CMAKEOPT} -DCMAKE_BUILD_TYPE=Release"
elif [ $DODEBUG -eq 1 ]; then
CMAKEOPT="${CMAKEOPT} -DCMAKE_BUILD_TYPE=ReleaseWithAssert"
elif [ $DODEBUG -eq 2 ]; then
CMAKEOPT="${CMAKEOPT} -DCMAKE_BUILD_TYPE=RelWithDebInfo"
elif [ $DODEBUG -eq 3 ]; then
CMAKEOPT="${CMAKEOPT} -DCMAKE_BUILD_TYPE=Debug"
else
CMAKEOPT="${CMAKEOPT} -DCMAKE_BUILD_TYPE=Debug"
OPT_FLAGS="-O0"
fi
if [ ! x"${OPT_FLAGS}" = x"" ]; then ccxx_flags ${OPT_FLAGS}; fi
if [ "${DOTARGET}" = "a" ]; then
# The following works around a -std=c++11 issue (not needed if -std=gnu++11)
ccxx_flags -include stdint.h
ccxx_flags -minit-stack=zero
ccxx_flags -Wunknown-pragma
ccxx_flags -fdiag-inline=2
ccxx_flags -fdiag-vector=2
ccxx_flags -report-all
# -O4 early... when -O4 (or -O3) comes later, sometimes inlining does not happen
ccxx_flags -O3 -finline -finline-functions
# nc++-3.0.30 WILL NOT compile some files when -finline is specified:
#ccxx_flags -O3 -finline-functions
# nc++-3.0.30 has an ICE ** DO NOT USE IT **
ccxx_flags -finline-max-function-size=300
ccxx_flags -finline-max-depth=10
ccxx_flags -finline-max-times=20
if [ $DODEBUG -gt 0 ]; then
# in nc++-3.0.28 manual (but apparently not in nc++-3.0.27!)
: #ccxx_flags -traceback=verbose
# add this code to get backtrace
# __builtin_traceback((unsigned long *)__builtin_frame_address(0));
# when env VE_TRACEBACK=VERBOSE
fi
#ccxx_flags -finline-abort-at-error
#ccxx_flags -finline-suppress-diagnostics # 3.0.28?
# src/common/tag_traits.hpp uses one_of(31 possibilities)
ccxx_flags -ftemplate-depth=50
#ccxx_flags -mno-parallel # does this OVERRIDE (disable) -fopenmp?
#ccxx_flags -D_FORTIFY_SOURCE=1
#ccxx_flags -D_FORTIFY_SOURCE=2 -Wl,-z,-muldefs
if [ $DODEBUG -gt 0 ]; then
# VE can give some wrong math results for +/-0, inf, NaN or ovflw
# default is -mno-vector-intrinsic-check
#
# In optimized mode, we are OK with failing some tests for
# limit cases of some math functions, to speed execution.
# (Although many ve/ math ops may add such VE_SPECIFIC checks
# to handle some limit cases tested in benchdnn)
#
: #ccxx_flags -mvector-intrinsic-check
#
# In debug modes, check for benchdnn NaN,0,inf limit cases,
# In debug mode, this can be very verbose during benchdnn tests
# Not sure wether it makes any return values more correct!
fi
fi
# Show build commands
CMAKETRACE="${CMAKETRACE} -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
CMAKEOPT="${CMAKEOPT} -DDNNL_VERBOSE=1" # enable env DNNL_VERBOSE=0|1|2
CMAKEOPT="${CMAKEOPT} -DDNNL_ISA=${ISA}" # deprecate?
# avoid global scratchpad (thread local storage)
CMAKEOPT="${CMAKEOPT} -DDNNL_ENABLE_CONCURRENT_EXEC=ON"
#if [ "$VERBOSE_EXTRA" == "y" -o "${DODEBUG}" == "y" ]; then
# # iterator print skipped impls if dnnl_get_verbose=3|4
# #CMAKEOPT="${CMAKEOPT} -DDNNL_VERBOSE=EXTRA"
# CMAKEOPT="${CMAKEOPT} -DDNNL_VERBOSE=1"
#fi
#
# -b or -B : BFLOAT16 support override
#
if [ "${BFLOAT16}" = "n" ]; then
CMAKEOPT="${CMAKEOPT} -DDNNL_ENABLE_BFLOAT16=0"
echo "BFLOAT16 support OFF"
elif [ "${BFLOAT16}" = "y" ]; then
CMAKEOPT="${CMAKEOPT} -DDNNL_ENABLE_BFLOAT16=1"
echo "BFLOAT16 support ON"
else
echo "BFLOAT16 support = default"
fi
#
# -r or -R : RNN support override
#
if [ "${RNN}" = "n" ]; then
CMAKEOPT="${CMAKEOPT} -DDNNL_ENABLE_RNN=0"
echo "RNN support OFF"
elif [ "${RNN}" = "y" ]; then
CMAKEOPT="${CMAKEOPT} -DDNNL_ENABLE_RNN=1"
echo "RNN support ON"
else
echo "RNN support = default"
fi
#
# -c : enable primitive cache
#
if [ ${USE_CACHE} -eq 0 ]; then
CMAKEOPT="${CMAKEOPT} -DDNNL_ENABLE_PRIMITIVE_CACHE=0"
echo "Primitive cache OFF"
else
CMAKEOPT="${CMAKEOPT} -DDNNL_ENABLE_PRIMITIVE_CACHE=1"
echo "Primitive cache ON"
fi
if [ "$DOTARGET" = "j" -a "$ISA" = "VANILLA" ]; then
# x86 non-jit by setting bogus DNNL_TARGET_ARCH
CMAKEOPT="${CMAKEOPT} -DDNNL_TARGET_ARCH=ARCH_GENERIC"
# src/cpu/platform.hpp will define DNNL_X64|DNNL_AAARCH64|DNNL_ARCH_GENERIC
fi
if [ "$DOTARGET" = "j" -a "$ISA" = "VE_SIM" ]; then
# x86 non-jit by setting bogus DNNL_TARGET_ARCH
CMAKEOPT="${CMAKEOPT} -DDNNL_TARGET_ARCH=ARCH_GENERIC -DNEC_VE -DTARGET_VE"
# src/cpu/platform.hpp will define DNNL_X64|DNNL_AAARCH64|DNNL_ARCH_GENERIC
ccxx_flags -DDNNL_ARCH_VE
fi
#
# CMAKEOPT="" # allow user to pass flag, ex. CMAKEOPT='--trace -LAH' ./build.sh
#CMAKEOPT="${CMAKEOPT} -DCMAKE_SRC_CCXX_FLAGS"
#CMAKEOPT="${CMAKEOPT} -DCMAKE_EXAMPLE_CCXX_FLAGS"
#CMAKEOPT="${CMAKEOPT} -DCMAKE_TEST_CCXX_FLAGS"
#CMAKEOPT="${CMAKEOPT} -DDNNL_CPU_RUNTIME=OMP" # def [OMP] TBB
#CMAKEOPT="${CMAKEOPT} -DDNNL_GPU_RUNTIME=OCL" # def [] OCL
#CMAKEOPT="${CMAKEOPT} -DMKLDNN_WERROR=ON" # default OFF
# REMOVED:
#CMAKEOPT="${CMAKEOPT} -DDNNL_JIT_SUPPORT=${CPU}" # default max jit for target cpu
if [ $USE_CBLAS -ne 0 ]; then
# This way of configuring external gemm was NOT ACCEPTED.
# so we continue using a compile flag instead
#CMAKEOPT="${CMAKEOPT} -DDNNL_CPU_EXTERNAL_GEMM=CBLAS" # default NONE
# upstream will use something like this for "system default":
CMAKEOPT="${CMAKEOPT} -DDNNL_BLAS_VENDOR=ANY" # default NONE
fi
if [ $USE_MKL -ne 0 ]; then
CMAKEOPT="${CMAKEOPT} -D_DNNL_USE_MKL=1" # older way
#CMAKEOPT="${CMAKEOPT} -DDNNL_CPU_EXTERNAL_GEMM=MKL" # default NONE
CMAKEOPT="${CMAKEOPT} -DDNNL_BLAS_VENDOR=MKL" # newer way
fi
if [ "$DOTARGET" == "a" ]; then
TOOLCHAIN=../cmake/ve.cmake
if [ ! -f "${TOOLCHAIN}" ]; then echo "Ohoh. ${TOOLCHAIN} not found?"; BUILDOK="n"; fi
CMAKEOPT="${CMAKEOPT} -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}"
# adjust here for VE shared library and Openmp use
#CMAKEOPT="${CMAKEOPT} -DUSE_SHAREDLIB=OFF" # deprecated
#CMAKEOPT="${CMAKEOPT} -DDNNL_LIBRARY_TYPE=STATIC"
#CMAKEOPT="${CMAKEOPT} -DDNNL_LIBRARY_TYPE=SHARED" # default
# USE_OPENMP defaults to off, so force it on (VE openmp has improved)
echo " build.sh : OMP = ${OMP}"
if [ "${OMP}" -eq 0 ]; then
# CMAKEOPT="${CMAKEOPT} -DUSE_OPENMP=OFF"
CMAKEOPT="-DVE_SEQ=1 ${CMAKEOPT} -DDNNL_CPU_RUNTIME=SEQ"
# VE_SEQ=1 [default] is for the ve.cmake TOOLKIT file
else
# CMAKEOPT="${CMAKEOPT} -DUSE_OPENMP=ON"
CMAKEOPT="-DVE_SEQ=1 ${CMAKEOPT} -DDNNL_CPU_RUNTIME=OMP"
# NB: ve.cmake is instructed by VE_SEQ to use single-threaded libcblas_sequential,
# since OneDNN uses all threads.
#ccxx_flags -fopenmp # ?? -mparallel and -fopenmp both => -pthread
fi
# TODO proginf is not working automatically any more?
# -proginf : Run with 'export VE_PROGINF=YES' to get some stats output
# ccxx_flags -proginf
ccxx_flags -DCBLAS_LAYOUT=CBLAS_ORDER
ccxx_flags -DDNNL_VALUE_INITIALIZATION_BUG # VE branch should test and set in dnnl_config.h
ccxx_flags -pthread # for <atomic>, <mutex> headers
if [ "$NEC_FTRACE" -eq 1 ]; then
#ccxx_flags -ftrace
# at some point above was sufficent (ve.cmake) set things
# TODO have ve.cmake etc do this NICELY with a cmake option...
#VEPERF_DIR="/usr/uhome/aurora/mpc/pub/veperf/180218-ELF"
VEPERF_DIR="/usr/uhome/aurora/mpc/pub/veperf/latest"
VEPERF_INC_DIR="${VEPERF_DIR}/include"
VEPERF_LIB_DIR="${VEPERF_DIR}/lib"
ccxx_flags "-I${VEPERF_INC_DIR} -DFTRACE -ftrace"
export LDFLAGS="${LDFLAGS} -L${VEPERF_LIB_DIR} -lveperf"
#export LDFLAGS="${LDLIBS} -Wl,-rpath,${VEPERF_LIB_DIR}"
fi
# deprecated: use CMAKEOPT -DDNNL_ISA=VEJIT instead
#CMAKEOPT="${CMAKEOPT} -DVEJIT=${VEJIT}"
#ccxx_flags "-DVEJIT=${VEJIT}" # deprecated
echo "Aurora CMAKEOPT = ${CMAKEOPT}"
fi
if [ "$DOTARGET" == "s" ]; then
TOOLCHAIN=../cmake/sx.cmake
if [ ! -f "${TOOLCHAIN}" ]; then echo "Ohoh. ${TOOLCHAIN} not found?"; BUILDOK="n"; fi
CMAKEOPT="${CMAKEOPT} -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}"
CMAKEOPT="${CMAKEOPT} --debug-trycompile --trace -LAH" # long debug of cmake
# ... ohoh no easy way to include the spaces and expand variable properly ...
# Solution: do these changes within CMakeLists.txt
#CMAKEOPT="${CMAKEOPT} -DCMAKE_C_FLAGS=-g\ -ftrace\ -Cdebug" # override Cvopt
#SXOPT="${SXOPT} -DTARGET_VANILLA"
SXOPT="${SXOPT} -D__STDC_LIMIT_MACROS"
# __STDC_LIMIT_MACROS is a way to force definitions like INT8_MIN in stdint.h (cstdint)
# (it **should** be autmatic in C++11, imho)
SXOPT="${SXOPT} -woff=1097 -woff=4038" # turn off warnings about not using attributes
SXOPT="${SXOPT} -woff=1901" # turn off sxcc warning defining arr[len0] for constant len0
SXOPT="${SXOPT} -wnolongjmp" # turn off warnings about setjmp/longjmp (and tracing)
SXOPT="${SXOPT} -Pauto -acct" # enable parallelization (and run with C_PROGINF=YES)
#SXOPT="${SXOPT} -Pstack" # disable parallelization
# Generate 'ftrace.out' profiling that can be displayed with ftrace++
# BUT not compatible with POSIX threads
if [ "$NEC_FTRACE" -eq 1 ]; then ccxx_flags -ftrace demangled; fi
# REMOVE WHEN FINISHED SX DEBUGGING
SXOPT="${SXOPT} -g -traceback" # enable source code tracing ALWAYS
export CFLAGS="${CFLAGS} -size_t${SIZE_T} -Kc99,gcc ${SXOPT}"
# An object file that is generated with -Kexceptions and an object file
# that is generated with -Knoexceptions must not be linked together. In
# such conditions the exception may not be thrown correctly Therefore, do
# not specify -Kexceptions if the program does not use the try, catch
# and throw keywords.
#export CXXFLAGS="${CXXFLAGS} -size_t${SIZE_T} -Kcpp11,gcc,rtti,exceptions ${SXOPT}"
export CXXFLAGS="${CXXFLAGS} -size_t${SIZE_T} -Kcpp11,gcc,exceptions ${SXOPT}"
#export CXXFLAGS="${CXXFLAGS} -size_t${SIZE_T} -Kcpp11,gcc,rtti"
fi
# Remove leading whitespace from CMAKEENV (bash magic)
shopt -s extglob; CMAKEENV=\""${CMAKEENV##*([[:space:]])}"\"; shopt -u extglob
echo " CMAKEOPT ${CMAKEOPT}"
echo " CXXFLAGS ${CXXFLAGS}"
echo " CFLAGS ${CFLAGS}"
if [ "$BUILDOK" == "y" ]; then
BUILDOK="n"
if [ "" ]; then # original, just use 'make' to build
BUILD_CMD="make VERBOSE=1 ${JOBS}"
BUILD_CMD_AGAIN="make VERBOSE=1"
else # using cmake to build will propagate parallelism to sub-makes
BUILD_CMD="cmake --build . -- ${JOBS}"
BUILD_CMD_AGAIN="cmake --build . -- -j1"
# could also use '-j 8' as a 'cmake --build' arg (oops, not supported in older cmake)
# note also 'cmake --build' has '--clean-first' and '--target <tgt>' options
fi
if [ $QUICK -gt 1 ]; then
rm -f ./stamp-BUILDOK
echo '# rebuild in existing directory, WITHOUT rerunning cmake'
echo "# `pwd`"
echo "# BUILD_CMD = ${BUILD_CMD}"
{ { ${BUILD_CMD} || ${BUILD_CMD_AGAIN}; } \
&& BUILDOK="y" || echo "build failed: ret code $?"; }
else
BUILD_CMD="${BUILD_CMD} VERBOSE=1"
BUILD_CMD_AGAIN="${BUILD_CMD_AGAIN} VERBOSE=1"
echo "# BUILD_CMD = ${BUILD_CMD}"
rm -f ./stamp-BUILDOK ./CMakeCache.txt
echo "CMAKEENV: ${CMAKEENV}"
echo "CMAKEOPT: ${CMAKEOPT}"
echo "CMAKETRACE: ${CMAKETRACE}"
echo "${CMAKEENV}; cmake ${CMAKEOPT} ${CMAKETRACE} .."
set -x
# { if [ -nz "${CMAKEENV}" ]; then ${CMAKEENV}; fi; \
{ if [[ -n "${CMAKEENV}" && "${CMAKEENV}" != "\"\"" ]]; then ${CMAKEENV}; fi; \
cmake ${CMAKEOPT} ${CMAKETRACE} .. \
&& make help \
&& { ${BUILD_CMD} || ${BUILD_CMD_AGAIN}; } \
&& BUILDOK="y" || echo "build failed: ret code $?"; }
set +x
fi
if [ "$BUILDOK" == "y" ]; then
# If you have some test convolutions in special-named files
# make some assembly-source translations automatically...
cxxfiles=`(cd ../tests/benchdnn && ls -1 conv/*conv?.cpp conv/*.cxx)` || true
if [ "$cxxfiles" ]; then (
cd tests/benchdnn && { for f in $cxxfiles; do
if [ -f "${f}" ]; then
g=`basename "${f}" .cpp`; echo $f.s; make -j1 VERBOSE=1 conv/$f.s;
fi; done; }
) || true
else
echo "No .s files to generate from test code in tests/benchdnn/conv"
fi
# maybe copy them into ../asm, for perusal?
#pwd
#ls -l ../asm || true
fi
else # skip the build, just run cmake ...
echo "CMAKEENV <${CMAKEENV}>"
echo "CMAKEOPT <${CMAKEOPT}>"
echo "CMAKETRACE <${CMAKETRACE}>"
echo "pwd `pwd`"
echo "PATH $PATH"
echo "CC $CC"
if [ ! "x${CC}" == "x" ]; then ${CC} -V; fi
set -x
{ if [ ! "${CMAKEENV}" == '""' ]; then ${CMAKEENV}; fi; \
cmake ${CMAKEOPT} ${CMAKETRACE} .. ; }
set +x
fi
set -x
#if [ "$BUILDOK" == "y" -a "$DOTARGET" == "a" ]; then
# for d in src examples tests tests/gtests tests/gtests tests/benchdnn; do
# echo "ve_validate_binary in ${BUILDDIR}/${d} ..."
# ve_validate_binary -d "${BUILDDIR}/${d}"
# done
#fi
if [ "$BUILDOK" == "y" -a ! "$DOTARGET" == "s" ]; then
echo "DOTARGET $DOTARGET"
echo "ISA $ISA"
echo "DOTEST $DOTEST"
echo "DODEBUG $DODEBUG"
echo "DODOC $DODOC"
if [ -f ./bash_help.inc ]; then # note: file was removed from Intel master
source "./bash_help.inc" # we are already in ${BUILDDIR}
fi
if [ "${CMAKE_CROSSCOMPILING_EMULATOR}" ]; then
VE_EXEC="${CMAKE_CROSSCOMPILING_EMULATOR}"
# Use TESTRUNNER VE_EXEC for explicit targets,
# But leave out VE_EXEC if executing 'make' within $BUILDDIR,
# because 'make' tragets already supply VE_EXEC if needed.
fi
# Put one test here (maybe one you are currently debugging)
TEST_ENV=(DNNL_VERBOSE=2)
TEST_ENV+=(VE_INIT_HEAP=ZERO)
TEST_ENV+=(VE_ERRCTL_DEALLOCATE=MSG)
TEST_ENV+=(VE_TRACEBACK=VERBOSE)
TEST_ENV+=(VE_INIT_HEAP=ZERO)
TEST_ENV+=(VE_PROGINF=DETAIL)
#TEST_ENV+=(VE_ADVANCEOFF=YES)
TEST_ENV+=(VE_OMP_STACKSIZE=128M)
#TEST_ENV+=(OMP_PROC_BIND=true)
TEST_ENV+=(--unset=OMP_PROC_BIND)
TEST_ENV+=(--unset=OMP_DYNAMIC) # really want false
TEST_ENV+=(--unset=VE_OMP_DYNAMIC) # really want false
TEST_ENV+=(OMP_WAIT_POLICY=active)
if [ ${OMP} -eq 1 ]; then TEST_ENV+=(OMP_NUM_THREADS=1); fi
#TEST_ENV+=(OMP_WAIT_POLICY=active)
TEST_ENV+=(VE_NODE_NUMBER=${NODE})
{ echo "api-c ...";
sync # sometimes fails in full build, but rerun with -qq is OK ?
sleep 1 # so let's give it 2 chances now...
${ENV} ${TEST_ENV[@]} ${TESTRUNNER} ${VE_EXEC} tests/api-c || \
${ENV} ${TEST_ENV[@]} ${TESTRUNNER} ${VE_EXEC} tests/api-c \
|| BUILDOK="n"; # BUILDOK="n" will stop tests on failure
}
if [ $DOTEST -eq 13 ]; then # another short test, this one can fail too
{ echo "cpu-cnn-training-f32-c"
sync;
${ENV} ${TEST_ENV[@]} ${TESTRUNNER} ${VE_EXEC} examples/cpu-cnn-training-f32-c || \
${ENV} ${TEST_ENV[@]} ${TESTRUNNER} ${VE_EXEC} examples/cpu-cnn-training-f32-c \
|| BUILDOK="n";
}
fi
fi
if [ "$BUILDOK" == "y" -a "$DOTARGET" == "s" ]; then
# not much to do for testing on sx (need to log in to run?)
# make SX build dirs all-writable so SX runs can store logs etc.
#find "${BUILDDIR}" -type d -exec chmod o+w {} \;
{ cd ..; find "${BUILDDIR}" -type d -exec chmod o+w {} \; ; }
fi
if [ "$BUILDOK" == "y" ]; then # communicate this to build.sh script
touch ./stamp-BUILDOK
sync ./stamp-BUILDOK
if [ "$DODOC" == "y" ]; then
echo "Build OK... Doxygen (please be patient)"
make VERBOSE=1 doc >& ../doxygen.log
fi
else
rm -f ./stamp-BUILDOK
fi
set +x
) 2>&1 | tee "${BUILDDIR}".log
ls -l "${BUILDDIR}"
BUILDOK="n"; if [ -f "${BUILDDIR}/stamp-BUILDOK" ]; then BUILDOK="y"; fi
echo 'ulimit hard : '`ulimit -Hs`
echo 'ulimit soft : '`ulimit -Ss`
set +x
# after cmake we might have a better idea about ve_exec (esp. if PATH is not set properly)
if [ -f "${BUILDDIR}/bash_help.inc" ]; then # file was removed from mkl-dnnl ~ v1.x
# snarf some CMAKE variables
source "${BUILDDIR}/bash_help.inc"
TESTRUNNER=''
if [ "${CMAKE_CROSSCOMPILING_EMULATOR}" ]; then
VE_EXEC="${CMAKE_CROSSCOMPILING_EMULATOR}"
if [ ! -x "${VE_EXEC}" ]; then
TESTRUNNER="echo Not-Running "
echo "cmake crosscompiling emulator, such as ve_exec, not available?"
fi
fi
fi
if { /usr/bin/time -v echo Hello >& /dev/null; } then
TESTRUNNER='/usr/bin/time -v'
fi
# next is optional, for verbose primitive creation and run messages
TESTRUNNER="${TESTRUNNER}"
set -x
echo "TESTRUNNER ${TESTRUNNER}"
echo "VE_EXEC ${VE_EXEC}"
echo "BUILDDIR ${BUILDDIR}"
echo "INSTALLDIR ${INSTALLDIR}"
echo "DOTARGET=${DOTARGET}, ISA=${ISA}, DODEBUG=${DODEBUG}, DOTEST=${DOTEST}, DODOC=${DODOC}"
LOGDIR="log-${DOTARGET}${ISA}-d${DODEBUG}t${DOTEST}${DODOC}"
if [ "$BUILDOK" == "y" ]; then # Install? Test?
set -x
echo "BUILDOK ! QUICK=$QUICK"
if [ $QUICK -lt 2 ]; then # make install ?
(
cd "${BUILDDIR}"
# trouble with cmake COMPONENTs ...
echo "Installing :"; make install;
#if [ "$DODOC" == "y" ]; then { echo "Installing docs ..."; make install-doc; } fi
) 2>&1 >> "${BUILDDIR}".log || { echo "'make install' in ${BUILDDIR} had issues, ignored"; }
fi
echo "Testing ?"
if [ ! "$DOTARGET" == "s" ]; then # non-SX: -t might run some tests
TEST_ENV=(DNNL_VERBOSE=2)
TEST_ENV+=(VE_INIT_HEAP=ZERO)
TEST_ENV+=(VE_ERRCTL_DEALLOCATE=MSG)
TEST_ENV+=(VE_TRACEBACK=VERBOSE)
TEST_ENV+=(VE_INIT_HEAP=ZERO)
TEST_ENV+=(VE_PROGINF=DETAIL)
#TEST_ENV+=(VE_ADVANCEOFF=YES)
TEST_ENV+=(OMP_STACKSIZE=128M)
#TEST_ENV+=(OMP_DYNAMIC=false)
TEST_ENV+=(--unset=OMP_DYNAMIC)
TEST_ENV+=(--unset=VE_OMP_DYNAMIC)
#TEST_ENV+=(OMP_PROC_BIND=true)
TEST_ENV+=(--unset=OMP_PROC_BIND)
TEST_ENV+=(OMP_WAIT_POLICY=active)
if [ ${OMP} -eq 1 ]; then TEST_ENV+=(OMP_NUM_THREADS=1); fi
#TEST_ENV+=(OMP_WAIT_POLICY=active)
TEST_ENV+=(VE_NODE_NUMBER=${NODE})
rm -f ${BUILDDIR}/test[0123].log
# 'make test` uses ctest, which recognizes -R (require) and -E (exclude) options
if [ $DOTEST -ge 1 ]; then # some short sanity-check examples
echo "Testing> ${BUILDDIR}/test0.log"
( export;
echo "${ENV} ${TEST_ENV[@]} ${TESTRUNNER} examples/primitives*"; \
${ENV} ${TEST_ENV[@]} ARGS="-VV -R 'primitives-'" \
${TESTRUNNER} make VERBOSE=1 -C "${BUILDDIR}" test \
) 2>&1 | tee "${BUILDDIR}/test0.log" || true
fi
if [ $DOTEST -ge 2 ]; then
if [ "" ]; then
# these usually run fine under 'make test'
echo "Testing> ${BUILDDIR}/test2.log"
( export;
echo "${ENV} ${TEST_ENV[@]} other examples"; \
${ENV} ${TEST_ENV[@]} ARGS="-VV -E '(test_)|(primitives-)'" \
${TESTRUNNER} make VERBOSE=1 -C "${BUILDDIR}" test \
) 2>&1 | tee "${BUILDDIR}/test2.log" || true
else
echo "Testing> xtest2-${BUILDDIR}.log"
{
set +x
ARGS="-E '(test_)|(primitives-)' -N" make -C "${BUILDDIR}" test | awk '/Test #/{print $3}'
tests=`ARGS="-E '(test_)|(primitives-)' -N" make -C "${BUILDDIR}" test | awk '/Test +#/{print $3}' | sort`
echo 'test1.log alternate, via vetest.sh'
echo "tests ="
echo "${tests}" | sed 's/ /\n /g'
Targs=''
for t in ${tests}; do
Targs="${Targs} -T ${t}"
done
echo "Targs = ${Targs}"
echo "Running tests via vetests.sh ..."
echo "Command : ./vetest.sh -B ${BUILDDIR} \${Targs} -L xtest1-${BUILDDIR}.log"
# note: vetest.sh will recognize cpu-FOO and search for FOO if nec.
./vetest.sh -B ${BUILDDIR} -L xtest2-${BUILDDIR}.log -N ${NODE} ${Targs} || true
cat xtest2-${BUILDDIR}.log
set -x
} 2>&1 | tee "${BUILDDIR}/test2.log" || true
echo "cat..."
cat xtest2-${BUILDDIR}.log || true
fi
fi
if [ $DOTEST -ge 3 ]; then
if [ "" ]; then
echo "Testing> ${BUILDDIR}/test3.log"
( export;
echo "${ENV} ${TEST_ENV[@]} ARGS='-VV -R 'test_' ${TESTRUNNER} <commnad>";
${ENV} ${TEST_ENV[@]} ARGS="-VV -R 'test_'" \
${TESTRUNNER} make VERBOSE=1 -C "${BUILDDIR}" test \
) 2>&1 | tee "${BUILDDIR}/test3.log" || true
else # do not run via ctest, run via vetest.sh
echo "Testing> xtest3-${BUILDDIR}.log"
if [ "" ]; then
tests=`ARGS="-R 'test_' -N" make -C "${BUILDDIR}" test | awk '/Test +#/{print $3}' | sort`
echo 'test3.log alternate, via vetest.sh'
echo "tests = "
echo "${tests}" | sed 's/ /\n /g'
for t in ${tests}; do
./vetest.sh -B ${BUILDDIR} -N ${NODE} -T ${t} || true
cat f.log
done
else
{
set +x
tests=`ARGS="-R test_ -N" make -C "${BUILDDIR}" test | awk '/Test +#/{print $3}' | sort`