forked from cyclops-community/ctf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·1411 lines (1312 loc) · 42.6 KB
/
configure
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
#!/usr/bin/env bash
#configure script adapted from Aquarius software (https://github.cxxom/devinamatthews/aquarius)
function usage
{
echo -e 'Usage: configure [options]'
echo
echo -e '\t--install-dir=dir Specify where to install header and lib files (default is /usr/local,'
echo -e '\t so headers will be installed to /usr/local/include and libs to /usr/local/lib)'
echo
echo -e '\t--build-dir=dir Specify where to build object files, library, and executable (default is .)'
echo
echo -e '\t--with-lapack Tells CTF build to enable LAPACK functionality regardless of whether LAPACK libs have been given.'
echo
echo -e '\t--with-scalapack Tells CTF build to enable ScaLAPACK functionality regardless of whether ScaLAPACK libs have been given.'
echo
echo -e '\t--build-scalapack Tells CTF to download and build ScaLAPACK library.'
echo
echo -e '\t--with-hptt Tells CTF build to enable HPTT functionality.'
echo
echo -e '\t--build-hptt Tells CTF to download and build HPTT library.'
echo
echo -e '\t--with-cuda Tells CTF to setup and use NVCC, NVCCFLAGS, and CUBLAS libs'
echo
echo -e '\t--no-dynamic Turns off configuration and build of dynamic (shared) libraries (these are needed for Python codes and some C++ codes)'
echo
echo -e '\t--no-static Turns off configuration and build of static libraries (these are needed for C++ codes)'
echo
echo -e '\t--verbose Does not suppress tests of compile/link commands'
echo
echo -e '\tLIB_PATH=-Ldir Specify paths to static libraries, e.g. -L/usr/local/lib to be used for test executables'
echo
echo -e '\tLD_LIB_PATH=-Ldir Specify paths to dynamic libraries to be used for test executables as part of LD_LIBRARY_PATH'
echo
echo -e '\tLIBS=-llibname Specify list of static libraries to link to, by default "-lblas -llapack -lscalapack" or a subset'
echo -e '\t (for each -l<name> ensure lib<name>.a is found in LIBRARY_PATH or LIB_PATH)'
echo
echo -e '\tLD_LIBS=-llibname Specify list of dynamic libraries to link to, by default "-lblas -llapack -lscalapack" or a subset'
echo -e '\t (for each -l<name> ensure lib<name>.a is found in LD_LIBRARY_PATH or LD_LIB_PATH)'
echo
echo -e '\tCXX=compiler Specify the C++ compiler (e.g. mpicxx)'
echo
echo -e '\tCXXFLAGS=flags Specify the compiler flags (e.g. "-g -O0" for a lightweight debug build),'
echo -e '\t can also be used to specify macros like -DOMP_OFF (turn off OpenMP) -DPROFILE -DPMPI (turn on performance profiling)'
echo -e '\t -DVERBOSE=1 -DDEBUG, see docs and generated config.mk for details)'
echo
echo -e '\tLINKFLAGS=flags Specify flags for creating the static library'
echo
echo -e '\tLDFLAGS=flags Specify flags for creating the dynamic library'
echo
echo -e '\tINCLUDES=-Idir Specify directories and header files to include (e.g. -I/path/to/mpi/header/file/)'
echo
echo -e 'Additionally, the variables AR, NVCC, NVCCFLAGS, and WARNFLAGS'
echo -e 'can be set on the command line, e.g. ./configure CXX=g++ CXXFLAGS="-fopenmp -O2 -g".'
echo
}
PARAMS=$0
for PARAM in "$@"
do
PARAMS="${PARAMS} '${PARAM}'"
done
#Usage: 'testlink $1 $2 $3' where
# $1 - library link line
# $2 - symbol (function)
# $3 - 0 if no printouts, 1 if verbose
function testlink
{
rm -f a.out
status=1
cat > .test.cxx <<EOF
#if __cplusplus
extern "C"
#endif
void $2();
int main(){ $2(); return 0; }
EOF
if [ $3 -eq 1 ]; then
( set -x; $CXX $DEFS $WARNFLAGS $CXXFLAGS $INCLUDES .test.cxx $1 $LINKFLAGS 2>&1 )
else
$CXX $DEFS $WARNFLAGS $CXXFLAGS $INCLUDES .test.cxx $1 $LINKFLAGS > /dev/null 2>&1
fi
if [ -x a.out ]; then
status=0
fi
rm -f .test.cxx a.out
return $status
}
#Usage: 'testldlink $1 $2 $3' for checking symbol with dynamic library where
# $1 - shared library link path
# $2 - shared library libs
# $3 - symbol (function)
# $4 - 0 if no printouts, 1 if verbose
function testldlink
{
rm -f a.out
status=1
cat > .test.cxx <<EOF
#if __cplusplus
extern "C"
#endif
void $3();
void func(){ $3(); }
int main(){ return 0; }
EOF
if [ $IS_APPLE_CLANG -eq 0 ]; then
TMP_LD_LIB_PATH=${1//"-L"/"-Wl,-rpath="}
fi
TMP_LD_LIB_PATH="$1 $TMP_LD_LIB_PATH"
TMP_LD_LIBS="$2"
if [ $4 -eq 1 ]; then
( set -x; $CXX $DEFS $WARNFLAGS $CXXFLAGS $INCLUDES .test.cxx $TMP_LD_LIB_PATH $TMP_LD_LIBS $LDFLAGS 2>&1 )
else
$CXX $DEFS $WARNFLAGS $CXXFLAGS $INCLUDES .test.cxx $TMP_LD_LIB_PATH $TMP_LD_LIBS $LDFLAGS > /dev/null 2>&1
fi
if [ -x a.out ]; then
status=0
TMP_RAW_LD_LIB_PATH=${TMP_LD_LIB_PATH//" -L"/":"}
TMP_RAW_LD_LIB_PATH=${RAW_LD_LIB_PATH//"-L"/""}
TMP_RAW_LD_LIB_PATH=${RAW_LD_LIB_PATH//" "/""}
if [ $4 -eq 1 ]; then
( set -x; LD_LIBRARY_PATH="$TMP_RAW_LD_LIB_PATH:$LD_LIBRARY_PATH" ./a.out 2>&1 )
else
LD_LIBRARY_PATH="$TMP_RAW_LD_LIB_PATH:$LD_LIBRARY_PATH" ./a.out > /dev/null 2>&1
fi
# Check if symbol is not yet defined, to ensure we really linked to dynamic and not static
# Disabled because it seems this is not always a reliable check, things often work despite it failing
#if [ $IS_APPLE_CLANG -eq 0 ]; then
# if [ $? -eq 0 ]; then
# UDEFSYMB=$(nm ./a.out | grep "$3" | grep -c "U")
# if [ $UDEFSYMB -eq 0 ]; then
# status=1
# if [ $4 -eq 1 ]; then
# echo "Undefined symbol not found, so we did not really link to dynamic library (but rather static)"
# ( set -x; nm ./a.out; )
# fi
# fi
# else
# status=0
# fi
#fi
fi
rm -f .test.cxx a.out
return $status
}
#Usage: 'testcompiler $1' where
# $1 - 0 if no printouts, 1 if verbose
function testcompiler
{
status=1
cat > .test.cxx <<EOF
int main(){ return 0; }
EOF
if [ $1 -eq 1 ]; then
( set -x; $CXX $DEFS $WARNFLAGS $INCLUDES .test.cxx 2>&1 )
else
$CXX $DEFS $WARNFLAGS $INCLUDES .test.cxx > /dev/null 2>&1
fi
if [ -x a.out ]; then
status=0
fi
rm -f .test.cxx a.out
return $status
}
#Usage: 'testcpp11 $1' where
# $1 - 0 if no printouts, 1 if verbose
function testcpp11
{
status=1
cat > .test.cxx <<EOF
#include <type_traits>
template <typename a>
class b {
public:
a s;
b(a s_){ s=s_; }
};
template <typename a>
using tb = b<a>;
int f(int k){
tb<int> r = b<int>(k);
return r.s;
}
template <typename a, bool b>
inline typename std::enable_if<b, a>::type testmin(a x, a y){
return x>y ? y : x;
}
template <typename a, bool b>
inline typename std::enable_if<!b, a>::type testmin(a x, a y){
return x;
}
int main(){ return testmin<int,1>(f(7),3)-testmin<int,0>(3,4); }
EOF
if [ $1 -eq 1 ]; then
( set -x; $CXX $DEFS $WARNFLAGS $INCLUDES .test.cxx $LINKFLAGS 2>&1 )
else
$CXX $DEFS $WARNFLAGS $INCLUDES .test.cxx $LINKFLAGS > /dev/null 2>&1
fi
if [ -x a.out ]; then
status=0
fi
rm -f .test.cxx a.out
return $status
}
#Usage: 'testopenmp'
function testopenmp
{
status=1
cat > .test.cxx <<EOF
#include "omp.h"
int main(){
int i;
int j = 0;
omp_set_num_threads(1);
#pragma omp for
for (i=0; i<10; i++){
j+=i;
}
return j;
}
EOF
$CXX $CXXFLAGS $DEFS $WARNFLAGS $INCLUDES .test.cxx $LINKFLAGS > /dev/null 2>&1
if [ -x a.out ]; then
status=0
fi
rm -f .test.cxx a.out
return $status
}
#Usage: 'testmpi $1 $2' where
# $1 is MPI_Datatype to test
# $2 - 0 if no printouts, 1 if verbose
function testmpi
{
status=1
cat > .test.cxx <<EOF
#include "mpi.h"
int main(){
MPI_Init(NULL,NULL);
MPI_Datatype a = $1;
MPI_Finalize();
return 0;
}
EOF
if [ $2 -eq 1 ]; then
( set -x; $CXX $CXXFLAGS $DEFS $WARNFLAGS $INCLUDES .test.cxx $LINKFLAGS 2>&1 )
else
$CXX $CXXFLAGS $DEFS $WARNFLAGS $INCLUDES .test.cxx $LINKFLAGS > /dev/null 2>&1
fi
if [ -x a.out ]; then
status=0
fi
rm -f .test.cxx a.out
return $status
}
#Usage: 'testhptt $1' where
# $1 - 0 if no printouts, 1 if verbose
function testhptt
{
status=1
cat > .test.cxx <<EOF
#include <hptt.h>
int main(){
int i = sizeof(hptt::DoubleComplex);
auto plan = hptt::create_plan( NULL, 0,
hptt::DoubleComplex(1.0), NULL, 0, NULL,
hptt::DoubleComplex(0.0), NULL, NULL,
hptt::ESTIMATE, 1 );
return 1;
}
EOF
if [ $1 -eq 1 ]; then
(set -x; $CXX $CXXFLAGS $DEFS $WARNFLAGS $INCLUDES .test.cxx $LIB_PATH $LIBS $LINKFLAGS 2>&1 )
else
$CXX $CXXFLAGS $DEFS $WARNFLAGS $INCLUDES .test.cxx $LIB_PATH $LIBS $LINKFLAGS > /dev/null 2>&1
fi
if [ -x a.out ]; then
status=0
fi
rm -f .test.cxx a.out
return $status
}
#Usage: 'testcompiler $1' where
# $1 - 0 if no printouts, 1 if verbose
function testnvcc
{
status=1
cat > .test.cu <<EOF
#include <cuda_runtime.h>
int main(){
int ndev=0;
cudaGetDeviceCount(&ndev);
return 0;
}
EOF
if [ $1 -eq 1 ]; then
( set -x; $NVCC $NVCCFLAGS $DEFS $INCLUDES .test.cu -c .test.o 2>&1 )
( set -x; $CXX $DEFS $WARNFLAGS $INCLUDES .test.o $LINKFLAGS 2>&1 )
else
$NVCC $NVCCFLAGS $DEFS $INCLUDES .test.cu -c .test.o > /dev/null 2>&1
$CXX $DEFS $WARNFLAGS $INCLUDES .test.o $LINKFLAGS > /dev/null 2>&1
fi
if [ -x a.out ]; then
status=0
fi
rm -f .test.cu .test.o a.out
return $status
}
function testcublas
{
status=1
cat > .test.cu <<EOF
#include <cuda_runtime.h>
#include <cublas_v2.h>
cublasHandle_t cuhandle;
int main(){
cublasStatus_t status = cublasCreate(&cuhandle);
return 0;
}
EOF
if [ $1 -eq 1 ]; then
( set -x; $NVCC $NVCCFLAGS $DEFS $INCLUDES .test.cu -c .test.o 2>&1 )
( set -x; $CXX $DEFS $WARNFLAGS $INCLUDES .test.o $LINKFLAGS 2>&1 )
else
$NVCC $NVCCFLAGS $DEFS $INCLUDES .test.cu -c .test.o > /dev/null 2>&1
$CXX $DEFS $WARNFLAGS $INCLUDES .test.o $LINKFLAGS > /dev/null 2>&1
fi
if [ -x a.out ]; then
status=0
fi
rm -f .test.cu a.out
return $status
}
#Usage: 'testcompiler $1' where
# $1 - 0 if no printouts, 1 if verbose
function testlambda
{
status=1
cat > .test.cxx <<EOF
#include <functional>
void a(std::function<void(int)>){}
void a(std::function<void(int,int)>){}
void f(int){};
int main(){
a(&f);
return 0;
}
EOF
if [ $1 -eq 1 ]; then
( set -x; $CXX $DEFS $WARNFLAGS $INCLUDES .test.cxx $LINKFLAGS 2>&1 )
else
$CXX $DEFS $WARNFLAGS $INCLUDES .test.cxx $LINKFLAGS > /dev/null 2>&1
fi
if [ -x a.out ]; then
status=0
fi
rm -f .test.cxx a.out
return $status
}
function realcompiler
{
echo -n 'Checking compiler type/version... '
if $CXX --version > /dev/null 2>&1; then
version=`$CXX --version 2>&1 | tr '\n' ' '`
elif $CXX -V > /dev/null 2>&1; then
version=`$CXX -V 2>&1 | tr '\n' ' '`
else
$CXX --version
$CXX -V
echo 'Could not determine underlying C/C++ compilers. Specify MPI compiler via CXX=...'
exit 1
fi
case $version in
*Intel*)
echo 'Using Intel compilers.'
compiler=intel
;;
*Portland*)
echo 'Portland Group compilers are not supported. Specify MPI compiler via CXX=...'
exit 1
compiler=pgi
;;
*Free\ Software*)
echo 'Using GNU compilers.'
compiler=gnu
;;
*Cray*)
echo 'Cray compilers are not supported.'
exit 1
compiler=cray
;;
*clang*)
#CLANG_VERSION=$(clang++ --version | grep -o "[0-9]\.[0-9]" | sort | head -n 1)
#echo 'Using Clang/LLVM compiler, version '$CLANG_VERSION'.'
echo 'Using Clang/LLVM compiler.'
compiler=clang
;;
*)
echo 'Could not determine underlying C/C++ compilers. Specify MPI compiler via CXX=...'
exit 1
;;
esac
}
function defaultflags
{
#
# Set default compiler flags
#
case $compiler in
intel)
if [ "x$AR" = "x" ]; then AR='xiar'; fi
if [ "x$CXXFLAGS" = "x" ]; then CXXFLAGS='-qopenmp -O3 -ipo'; fi
if [ "x$NVCCFLAGS" = "x" ]; then NVCCLAGS=''; fi
if [ "x$DEFS" = "x" ]; then DEFS='-D_POSIX_C_SOURCE=200112L -D__STDC_LIMIT_MACROS'; fi
if [ "x$WARNFLAGS" = "x" ]; then WARNFLAGS='-Wall'; fi
PASS_TO_LINKER='-Wl,'
;;
gnu | clang)
if [ "x$AR" = "x" ]; then AR='ar'; fi
if [ "x$CXXFLAGS" = "x" ]; then CXXFLAGS='-O3'; fi
if [ "x$NVCCFLAGS" = "x" ]; then NVCCLAGS=''; fi
if [ "x$DEFS" = "x" ]; then DEFS='-D_POSIX_C_SOURCE=200112L -D__STDC_LIMIT_MACROS'; fi
if [ "x$WARNFLAGS" = "x" ]; then WARNFLAGS='-Wall'; fi
PASS_TO_LINKER='-Wl,'
;;
*)
echo 'No default flags known for given compilers. Make sure that you have set the'
echo 'appropriate compiler flags manually.'
if [ "x$AR" = "x" ]; then AR='ar'; fi
if [ "x$CXXFLAGS" = "x" ]; then CXXFLAGS='-O3'; fi
if [ "x$NVCCFLAGS" = "x" ]; then NVCCLAGS=''; fi
if [ "x$DEFS" = "x" ]; then DEFS='-D_POSIX_C_SOURCE=200112L -D__STDC_LIMIT_MACROS'; fi
if [ "x$WARNFLAGS" = "x" ]; then WARNFLAGS='-Wall'; fi
PASS_TO_LINKER='-Wl,'
;;
esac
case $compiler in
intel)
if [ "x$SEQCXX" = "x" ]; then SEQCXX='icpc'; fi
;;
gnu )
if [ "x$SEQCXX" = "x" ]; then SEQCXX='g++'; fi
;;
clang)
if [ "x$SEQCXX" = "x" ]; then SEQCXX='clang++'; fi
;;
*)
if [ "x$SEQCXX" = "x" ]; then SEQCXX=$CXX; fi
;;
esac
}
function check_if_apple
{
status=1
cat > .test.cxx <<EOF
#if defined(__APPLE__)
#error
#endif
int main(){ return 0; }
EOF
$CXX $DEFS $WARNFLAGS $CXXFLAGS $INCLUDES .test.cxx $LINKFLAGS > /dev/null 2>&1
if [ -x a.out ]; then
status=0
fi
rm -f .test.cxx a.out
return $status
}
#
# Parse command-line arguments
#
depstype=normal
WITH_CUDA=0
WITH_LAPACK=0
WITH_SCALAPACK=0
WITH_STATIC=1
WITH_DYNAMIC=1
BUILD_SCALAPACK=0
WITH_HPTT=0
BUILD_HPTT=0
VERBOSE=0
while [ "x$1" != "x" ]; do
case $1 in
--build-dir=*)
eval BUILDDIR="$(printf "%q" "${1#--build-dir=}")"
;;
--install-dir=*)
eval INSTALLDIR="$(printf "%q" "${1#--install-dir=}")"
;;
--with-lapack)
WITH_LAPACK=1
;;
--with-scalapack)
WITH_SCALAPACK=1
;;
--build-scalapack)
BUILD_SCALAPACK=1
;;
--with-hptt)
WITH_HPTT=1
;;
--build-hptt)
BUILD_HPTT=1
;;
--with-cuda)
WITH_CUDA=1
;;
--no-dynamic)
WITH_DYNAMIC=0
;;
--no-static)
WITH_STATIC=0
;;
--verbose)
VERBOSE=1
;;
--help)
usage
exit 0
;;
LIB_PATH=*|\
LD_LIB_PATH=*|\
LIBS=*|\
LD_LIBS=*|\
CXX=*|\
NVCC=*|\
AR=*|\
CXXFLAGS=*|\
NVCCFLAGS=*|\
LINKFLAGS=*|\
LDFLAGS=*|\
WARNFLAGS=*|\
INCLUDES=*)
eval "${1%%=*}=\"${1#*=}\""
;;
*)
echo " WARNING: Unknown option \"$1\"."
usage
exit 1
;;
esac
shift
done
CTFDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ "x$BUILDDIR" = "x" ]; then
if [ "x$CTFDIR" = `pwd` ]; then
BUILDDIR='.'
else
BUILDDIR=`pwd`
fi
fi
if [ "x$INSTALLDIR" = "x" ]; then
INSTALLDIR='/usr/local'
fi
if [ "x$LIB_PATH" = "x" ]; then
LIB_PATH=""
elif [ "x$LD_LIB_PATH" = "x" ]; then
echo "LD_LIB_PATH was unspecified but LIB_PATH was, setting LD_LIB_PATH=$LIB_PATH."
LD_LIB_PATH=$LIB_PATH
fi
if [ "x$LIBS" = "x" ]; then
LIBS=""
elif [ "x$LD_LIBS" = "x" ]; then
echo "LD_LIBS was unspecified but LIBS was, setting LD_LIBS=$LIBS."
LD_LIBS=$LIBS
fi
if [ "x$CXX" = "x" ]; then
CXX=mpicxx
fi
realcompiler
defaultflags
if [ $WITH_STATIC = 0 ]; then
if [ $WITH_DYNAMIC = 0 ]; then
echo
echo -n 'Specifying --no-dynamic and --no-static does not make sense, what do you want to build?'
echo
exit 1
fi
fi
echo -n 'Checking whether __APPLE__ is defined... '
IS_APPLE_CLANG=0
BDYNAMIC="-Wl,-Bdynamic"
BSTATIC="-Wl,-Bstatic"
check_if_apple;
status=$?
if [ $status = 1 ]; then
echo -n 'yes, tacking on -D_DARWIN_C_SOURCE to DEFS and -std=c++0x to CXXFLAGS.'
echo
DEFS="$DEFS -D_DARWIN_C_SOURCE"
CXXFLAGS="$CXXFLAGS -std=c++0x"
if [ "$compiler" = "clang" ]; then
echo -n 'Detected Apple + Clang, disabling use of rpath, Bdynamic, and Bstatic'
echo
IS_APPLE_CLANG=1
BDYNAMIC=""
BSTATIC=""
fi
else
echo -n 'no.'
echo
fi
#
# Check that compiler works without error
#
echo -n 'Checking compiler (CXX)... '
if testcompiler 0; then
echo 'successful.'
else
echo 'FAILED! error below:'
echo
testcompiler 1
echo
exit 1
fi
#
# Check that CXXFLAGS works without error
#
echo -n 'Checking flags (CXXFLAGS)... '
ODEFS="$DEFS"
DEFS="$DEFS $CXXFLAGS"
if testcompiler 0; then
echo 'successful.'
else
echo 'FAILED! error below:'
echo
testcompiler 1
echo
exit 1
fi
DEFS="$ODEFS"
#
# Check that compiler works without error
#
echo -n 'Checking availability of C++11... '
if testcpp11 0; then
echo 'successful.'
else
ODEFS="$DEFS"
DEFS="$DEFS $CXXFLAGS"
if testcpp11 0; then
echo 'successful.'
else
if [ "$NERSC_HOST" = "edison" ]; then
echo 'FAILED! error below, try using module load gcc/4.8.2:'
echo
testcpp11 1
echo
exit 1
else
CXXFLAGS="$CXXFLAGS -std=c++0x"
DEFS="$ODEFS $CXXFLAGS"
if testcpp11 0; then
echo 'successful (tacking on -std=c++0x to CXXFLAGS).'
else
echo 'FAILED! error below:'
echo
testcpp11 1
echo
exit 1
fi
fi
DEFS="$ODEFS"
fi
fi
#
# Check if MPI is provided
#
echo -n 'Checking for MPI... '
if testmpi MPI_CXX_DOUBLE_COMPLEX $VERBOSE; then
echo 'MPI works.'
else
if testmpi MPI::DOUBLE_COMPLEX $VERBOSE; then
echo 'detected limited MPI type-naming convention, e.g. MPI_C_DOUBLE_COMPLEX, adapting to use MPI::... instead of MPI_CXX_... for some types.'
DEFS="$DEFS -DUSE_MPI_CPP"
else
echo ' ERROR: unable to compile MPI test program, provide appropriate compiler, e.g. CXX=mpicxx or specify INCLUDES=-I/path/to/mpi.h/ as well as appropriate static/dynamic paths/libraries, see ./configure --help.'
echo
testmpi MPI_CXX_DOUBLE_COMPLEX 1;
echo
exit 1
fi
fi
#
# Check if OpenMP is provided
#
echo -n 'Checking for OpenMP... '
if testopenmp; then
echo 'OpenMP works.'
else
OCXXFLAGS=$CXXFLAGS
if [ "$compiler" = "clang" ]; then
echo
echo ' WARNING: not attempting usage of -fopenmp for Clang, reconfigure with appropriate flags to use OpenMP with Clang... '
echo -n ' ... '
else
CXXFLAGS="$CXXFLAGS -fopenmp"
fi
if testopenmp; then
echo 'using OpenMP via -fopenmp flag.'
else
echo 'unable to compile OpenMP test program, will build without OpenMP, to enable OpenMP please provide e.g. CXXFLAGS=-fopenmp.'
CXXFLAGS="$OCXXFLAGS -DOMP_OFF"
fi
fi
USE_BATCH_GEMM=-1
USE_MKL=0
#
# Check for BLAS/LAPACK/SCALAPACK libraries and determine BLAS/LAPACK naming convention (underscores)
#
if [ $WITH_STATIC = 1 ]; then
echo -n 'Checking for static BLAS library... '
if testlink "$LIB_PATH $LIBS" dgemm_ $VERBOSE; then
UNDERSCORE=1
echo 'static BLAS library found, with underscores.'
else
if testlink "$LIB_PATH $LIBS" dgemm $VERBOSE; then
UNDERSCORE= 0
echo 'static BLAS library found, without underscores.'
else
if [ "$compiler" = "intel" ] && testlink "$LIB_PATH -mkl $LIBS" dgemm_ 0 ; then
UNDERSCORE=1
echo 'detected that -mkl works, speculatively using -mkl.'
LIBS="-mkl $LIBS"
USE_MKL=1
elif testlink "$LIB_PATH $LIBS $BSTATIC -lblas $BDYNAMIC" dgemm_ $VERBOSE; then
UNDERSCORE=1
echo 'detected that -lblas works, speculatively using -lblas (with underscores).'
LIBS="$LIBS -lblas"
elif testlink "$LIB_PATH $LIBS $BSTATIC -lblas $BDYNAMIC" dgemm $VERBOSE; then
UNDERSCORE=0
echo 'detected that -lblas works, speculatively using -lblas (without underscores).'
LIBS="$LIBS -lblas"
else
UNDERSCORE=1
echo
echo ' WARNING: static BLAS libirary did not work, executables will not build (errors for a few configurations below),'
testlink "$LIB_PATH $LIBS" dgemm_ 1
testlink "$LIB_PATH $LIBS" dgemm 1
testlink "$LIB_PATH $LIBS $BSTATIC -lblas $BDYNAMIC" dgemm_ 1
testlink "$LIB_PATH $LIBS $BSTATIC -lblas $BDYNAMIC" dgemm 1
echo ' please specify correct LIB_PATH and LIBS (run ./configure --help to see all options),'
echo ' CTF library can still build (via make), but executables will not!'
echo
fi
fi
fi
echo -n 'Checking for availability of static batched gemm... '
if [ $UNDERSCORE = 1 ]; then
if testlink "$LIB_PATH $LIBS" dgemm_batch_ $VERBOSE; then
echo 'available, will build with -DUSE_BATCH_GEMM.'
USE_BATCH_GEMM=1
else
echo 'unavailable, will build without -DUSE_BATCH_GEMM.'
USE_BATCH_GEMM=0
fi
else
if testlink "$LIB_PATH $LIBS" dgemm_batch $VERBOSE; then
echo 'available, will build with -DUSE_BATCH_GEMM.'
USE_BATCH_GEMM=1
else
echo 'unavailable, will build without -DUSE_BATCH_GEMM.'
USE_BATCH_GEMM=0
fi
fi
fi
if [ $WITH_DYNAMIC = 1 ]; then
echo -n 'Checking for dynamic BLAS library... '
if testldlink "$LD_LIB_PATH" "$LD_LIBS" dgemm_ $VERBOSE; then
UNDERSCORE=1
echo 'dynamic BLAS library found, with underscores.'
else
if testldlink "$LD_LIB_PATH" "$LD_LIBS" dgemm $VERBOSE; then
UNDERSCORE= 0
echo 'dynamic BLAS library found, without underscores.'
else
if [ "$compiler" = "intel" ] && testldlink "$LD_LIB_PATH" "$LD_LIBS -mkl" dgemm_ $VERBOSE ; then
UNDERSCORE=1
echo 'detected that -mkl works, speculatively using -mkl.'
LD_LIBS="$LD_LIBS -mkl"
USE_MKL=1
elif testldlink "$LD_LIB_PATH $LD_LIBS $BDYNAMIC -lblas" "$LD_LIBS" dgemm_ $VERBOSE; then
UNDERSCORE=1
echo "detected that $BDYNAMIC -lblas works, speculatively using (-Wl,-Bdynamic) -lblas (with underscores)."
LD_LIBS="$LD_LIBS $BDYNAMIC -lblas"
elif testldlink "$LD_LIB_PATH $LD_LIBS $BDYNAMIC -lblas" "$LD_LIBS" dgemm $VERBOSE; then
UNDERSCORE=0
echo "detected that $BDYNAMIC -lblas works, speculatively using $BDYNAMIC -lblas (without underscores)."
LD_LIBS="$LD_LIBS $BDYNAMIC -lblas"
else
UNDERSCORE=1
echo
echo ' WARNING: dynamic BLAS libirary did not work, python executables will not run (errors for a few configurations below),'
testldlink "$LD_LIB_PATH" "$LD_LIBS" dgemm_ 1
testldlink "$LD_LIB_PATH" "$LD_LIBS" dgemm 1
testldlink "$LD_LIB_PATH $LD_LIBS $BDYNAMIC -lblas" "$LD_LIBS" dgemm_ 1
testldlink "$LD_LIB_PATH $LD_LIBS $BDYNAMIC -lblas" "$LD_LIBS" dgemm 1
echo ' please specify correct LD_LIB_PATH and LD_LIBS (run ./configure --help to see all options),'
echo ' CTF library can still build (via make), but executables will not!'
echo
exit 1
fi
fi
fi
echo -n 'Checking for availability of dynamic batched gemm... '
if [ $USE_BATCH_GEMM = -1 ]; then
if [ $UNDERSCORE = 1 ]; then
if testldlink "$LD_LIB_PATH" "$LD_LIBS" dgemm_batch_ $VERBOSE; then
echo 'available, will build with -DUSE_BATCH_GEMM.'
USE_BATCH_GEMM=1
else
echo 'unavailable, will build without -DUSE_BATCH_GEMM.'
USE_BATCH_GEMM=0
fi
else
if testldlink "$LD_LIB_PATH" "$LD_LIBS" dgemm_batch $VERBOSE; then
echo 'available, will build with -DUSE_BATCH_GEMM.'
USE_BATCH_GEMM=1
else
echo 'unavailable, will build without -DUSE_BATCH_GEMM.'
USE_BATCH_GEMM=0
fi
fi
fi
fi
DEFS="$DEFS -DFTN_UNDERSCORE=$UNDERSCORE"
if [ $USE_BATCH_GEMM = 1 ]; then
DEFS="$DEFS -DUSE_BATCH_GEMM"
fi
if [ $UNDERSCORE = 1 ] ; then
DGEMM=dgemm_
DGEQRF=dgeqrf_
PDGEMM=pdgemm_
else
DGEMM=dgemm
DGEQRF=dgeqrf
PDGEMM=pdgemm
fi
USING_LAPACK=0
if [ $WITH_STATIC = 1 ]; then
echo -n 'Checking for static LAPACK library... '
if testlink "$LIB_PATH $LIBS" $DGEQRF $VERBOSE; then
echo 'static LAPACK found.'
DEFS="$DEFS -DUSE_LAPACK"
USING_LAPACK=1
else
if testlink "$LIB_PATH $BSTATIC -llapack $BDYNAMIC $LIBS" $DGEQRF $VERBOSE; then
echo 'static LAPACK library found (-llapack).'
LIBS="$BSTATIC -llapack $BDYNAMIC $LIBS"
DEFS="$DEFS -DUSE_LAPACK"
USING_LAPACK=1
else
OLINKFLAGS=$LINKFLAGS
LINKFLAGS="$LINKFLAGS -lgfortran"
if testlink "$LIB_PATH $BSTATIC -llapack $BDYNAMIC $LIBS" $DGEQRF $VERBOSE; then
echo 'static LAPACK library found (-llapack -lgfortran).'
LIBS="$BSTATIC -llapack $BDYNAMIC $LIBS"
DEFS="$DEFS -DUSE_LAPACK"
USING_LAPACK=1
else
LINKFLAGS="$OLINKFLAGS"
if [ $WITH_LAPACK = 1 ]; then
echo ' LAPACK not found, will build with LAPACK-dependent functionality anyway, since --with-lapackwas specified.'
echo ' WARNING: you may not be able to build CTF tests and benchmarks in this configuration (but you can build the library and use in conjunction with a lapack library)'
echo ' WARNING: executables will not build until you provide a BLAS library (error below),'
testlink "$LIB_PATH $LIBS" $DGEQRF 1
echo ' please specify correct LIB_PATH and LIBS (run ./configure --help to see all options),'
echo ' CTF library can still build (via make), but executables will not!'
DEFS="$DEFS -DUSE_LAPACK"
USING_LAPACK=1
else
echo ' LAPACK not found, some functionality and tests will be unavailable,'
echo ' to fix reconfigure and add --with-lapack and the appropriate library path'
echo ' (LIB_PATH/LIBS for static, LD_LIB_PATH/LD_LIBS for dynamic)'
fi
fi
fi
fi
fi
if [ $WITH_DYNAMIC = 1 ]; then
echo -n 'Checking for dynamic LAPACK library... '
if testldlink "$LD_LIB_PATH" "$LD_LIBS" $DGEQRF $VERBOSE; then
echo 'dynamic LAPACK found.'
if [ $USING_LAPACK = 0 ]; then
DEFS="$DEFS -DUSE_LAPACK"
fi
else
if testldlink "$LD_LIB_PATH $BDYNAMIC -llapack" "$LD_LIBS" $DGEQRF $VERBOSE; then
echo 'dynamic LAPACK library found ($BDYNAMIC -llapack).'
LD_LIBS="$LD_LIBS $BDYNAMIC -llapack"
if [ $USING_LAPACK = 0 ]; then
DEFS="$DEFS -DUSE_LAPACK"
fi
else
if [ $WITH_LAPACK = 1 ]; then
echo ' LAPACK not found, will build with LAPACK-dependent functionality anyway, since --with-lapackwas specified.'
echo ' WARNING: you may not be able to build CTF tests and benchmarks in this configuration (but you can build the library and use in conjunction with a lapack library)'
echo ' WARNING: executables will not build until you provide a BLAS library (error below),'
testldlink "$LD_LIB_PATH" "$LD_LIBS" $DGEQRF 1
echo ' please specify correct LD_LIB_PATH and LD_LIBS (run ./configure --help to see all options),'
echo ' CTF library can still build (via make), but executables will not!'
if [ $USING_LAPACK = 0 ]; then
DEFS="$DEFS -DUSE_LAPACK"
fi
else
echo ' LAPACK not found, some functionality and tests will be unavailable,'
echo ' to fix reconfigure and add --with-lapack and the appropriate library path'
echo ' (LIB_PATH/LIBS for static, LD_LIB_PATH/LD_LIBS for dynamic)'
fi
fi
fi
fi
echo -n 'Checking for sparse MKL routines... '
if [ $WITH_STATIC = 1 ]; then
if testlink "$LIB_PATH $LIBS" mkl_dcsrmultcsr $VERBOSE; then
echo 'sparse MKL found.'
USE_MKL=1
elif testlink "$LIB_PATH $LIBS" mkl_dcsrmultcsr_ $VERBOSE; then
echo 'sparse MKL found.'
USE_MKL=1
else
echo 'MKL symbol not detected, assuming sparse MKL routines are unavailable (affects sparse BLAS performance).'
USE_MKL=0
fi
else
if testldlink "$LD_LIB_PATH" "$LD_LIBS" mkl_dcsrmultcsr $VERBOSE; then
echo 'sparse MKL found.'
USE_MKL=1
elif testldlink "$LD_LIB_PATH" "$LD_LIBS" mkl_dcsrmultcsr_ $VERBOSE; then
echo 'sparse MKL found.'
USE_MKL=1
else
echo 'MKL symbol not detected, assuming sparse MKL routines are unavailable (affects sparse BLAS performance).'
USE_MKL=0
fi
fi
if [ $USE_MKL = 1 ]; then
DEFS="$DEFS -DUSE_MKL"
fi
if [ $BUILD_SCALAPACK = 1 ]; then
echo -n 'Building ScaLAPACK using cmake (no options passed along)... '
cd $BUILDDIR
if [ -d scalapack ]; then
read -p "found existing scalapack subdirectory,"$'\n'""$'\n'" overwrite? (Y/N)? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
rm -rf scalapack