-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfigure.ac
1692 lines (1324 loc) · 45.7 KB
/
configure.ac
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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.71])
AC_INIT([genesis],[2.1.0beta_cgdyn],[genesis@riken.jp])
AC_CONFIG_SRCDIR([src/spdyn/spdyn.fpp])
AC_CONFIG_HEADERS([src/config.h])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_PREFIX_DEFAULT([$PWD/])
m4_ifdef([AM_EXTRA_RECURSIVE_TARGETS], [AM_EXTRA_RECURSIVE_TARGETS([depend])], [])
## make set
AC_PROG_MAKE_SET
## ranlib
AC_PROG_RANLIB
AC_LANG_PUSH(Fortran)
## real precision
#
DEFINED_VARIABLES=""
AC_ARG_ENABLE([double],
[AS_HELP_STRING(
[--enable-double],
[enable double precision (default = yes)])],
[],[enable_double=yes])
AC_ARG_ENABLE([mixed],
[AS_HELP_STRING(
[--enable-mixed],
[enable mixed precision (default = no)])],
[],[enable_mixed=no])
AC_ARG_ENABLE([single],
[AS_HELP_STRING(
[--enable-single],
[enable single precision (default = no)])],
[],[enable_single=no])
if test x"${enable_mixed}" = x"yes"; then
enable_double=no
fi
if test x"${enable_single}" = x"yes"; then
enable_double=no
enable_mixed=no
fi
mainly_single=no
if test x"${enable_single}" = x"yes"; then
AC_DEFINE(_SINGLE, 1, [defined if _SINGLE is used.])
DEFINED_VARIABLES+=" -D_SINGLE"
mainly_single=yes
elif test x"${enable_mixed}" = x"yes"; then
AC_DEFINE(_MIXED, 1, [defined if _MIXED is used.])
DEFINED_VARIABLES+=" -D_MIXED"
mainly_single=yes
fi
## integer precision for degree of freedom
#
DEFINED_VARIABLES=""
AC_ARG_ENABLE([large_int],
[AS_HELP_STRING(
[--enable-large_int],
[enable 8byte integer precision (default = no)])],
[],[enable_large_int=no])
mainly_large_int=no
if test x"${enable_large_int}" = x"yes"; then
AC_DEFINE(_LARGE_INT, 1, [defined if _LARGE_INT is used.])
DEFINED_VARIABLES+=" -D_LARGE_INT"
mainly_large_int=yes
fi
DEFINED_VARIABLES=""
## Debug
#
AC_ARG_ENABLE([debug],
[AS_HELP_STRING(
[--enable-debug@<:@=ARG@:>@],
[set Debug level (from 1 to 4, default = 1)])],
[
if test x"${enableval}" = x"yes"; then
enable_debug=1
elif test x"${enableval}" = x"1" -o \
x"${enableval}" = x"2" -o \
x"${enableval}" = x"3" -o \
x"${enableval}" = x"4"; then
enable_debug=${enableval}
else
AC_MSG_ERROR([Not supported Debug level ${enableval}.])
fi
],
[
enable_debug=0
])
## MPI
#
AC_ARG_ENABLE([mpi],
[AS_HELP_STRING([--disable-mpi], [disable MPI parallel])],
[], [enable_mpi=yes])
if test x"${enable_mpi}" = x"yes"; then
AC_DEFINE(HAVE_MPI_GENESIS, 1, [defined if MPI is used.])
DEFINED_VARIABLES+=" -DHAVE_MPI_GENESIS"
fi
AM_CONDITIONAL(SPDYN, test x"${enable_mpi}" = x"yes")
AM_CONDITIONAL(CGDYN, test x"${enable_mpi}" = x"yes")
AC_ARG_WITH([msmpi],
[AS_HELP_STRING([--with-msmpi],
[use MSMPI (default: does not use MSMPI)])],
[], [with_msmpi=no])
## fortran compiler
#
if test x"${enable_mpi}" = x"yes"; then
genesis_default_fc="mpiifort mpifrtpx mpifrt mpif90"
else
genesis_default_fc="ifort frtpx frt ifort gfortran"
fi
# check usablility
AC_PROG_FC($genesis_default_fc)
AC_PROG_F77($genesis_default_fc)
## C++ compiler
qsimulate_default_cxx="mpicxx mpic++"
AC_PROG_CXX($qsimulate_default_cxx)
# check actual compiler
AC_MSG_CHECKING([for actual compiler])
if test x"${FC}" = x"mpifrtpx"; then
VER_OPT="-V"
else
VER_OPT="--version"
fi
fc_ver_info=$(${FC} -E ${VER_OPT})
for vtok in ${fc_ver_info} ; do
if test x"${vtok}" = x"ifort"; then
FC_ACT="ifort"
break
elif test x"${vtok}" = x"GNU"; then
FC_ACT="gfortran"
break
elif test x"${vtok}" = x"pgfortran"; then
FC_ACT="pgf90"
break
elif test x"${vtok}" = x"pgf90"; then
FC_ACT="pgf90"
break
elif test x"${vtok}" = x"pgf95"; then
FC_ACT="pgf90"
break
fi
done
if test -z "${FC_ACT}"; then
FC_ACT=${FC}
fi
F77_ACT=FC_ACT
AC_MSG_RESULT([$FC_ACT])
AC_MSG_CHECKING([for MPI type])
mpitype="no"
if test x"${with_msmpi}" = x"yes"; then
mpitype="MS"
elif test x"${enable_mpi}"=x"yes" ; then
mpi_ver_info=$(${FC} --showme:version)
prev=""
for vtok in ${mpi_ver_info} ; do
if echo ${vtok} | egrep -q "MPI"; then
mpitype=${prev}
fi
prev=${vtok}
done
fi
version_warning=yes
# check gfortran & intel version
if test x"${FC_ACT}" = x"frtpx" ; then
if test x"${enable_mpi}" != x"yes"; then
AC_MSG_ERROR([disable_mpi is not available on Fugaku])
fi
elif test x"${FC_ACT}" = x"ifort" ; then
AC_MSG_CHECKING([for fortran version])
version=""
build=""
fc_ver_info=$(${FC} -E ${VER_OPT})
for vtok in ${fc_ver_info} ; do
if echo ${vtok} | egrep -q "^@<:@0-9@:>@+\.@<:@0-9@:>@+\.@<:@0-9@:>@+"; then
version=${vtok}
fi
if echo ${vtok} | egrep -q "^@<:@0-9@:>@{8}"; then
build=${vtok}
fi
done
if test x"${mpitype}" = x"no" -a x"${with_msmpi}" = x"no" ; then
fc_ver_info=$(${FC} -E -v)
prev=""
for vtok in ${fc_ver_info} ; do
if echo ${vtok} | egrep -q "MPI"; then
mpitype=${prev}
fi
prev=${vtok}
done
fi
AC_MSG_RESULT([$version])
FC_GNU_VER=`echo ${version}\
| awk -F'[.]' '{printf "%02d%02d%02d",$1,$2,$3}'`
if test ${FC_GNU_VER} -eq 120100 -a ${build} -eq 20110811 ; then
AC_MSG_ERROR([ifort version 12.1.0 (20110811) has a serious problem in GENESIS])
elif test ${FC_GNU_VER} -eq 150001 -a ${build} -eq 20141023 ; then
AC_MSG_ERROR([ifort version 15.0.1 (20141023) has a serious problem in GENESIS])
fi
elif test x"${FC_ACT}" = x"gfortran"; then
FC_GNU_VER=`echo "__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"\
| ${FC_ACT} -E -P - | xargs printf "%02d%02d%02d"`
if test ${FC_GNU_VER} -lt 040407; then
AC_MSG_ERROR([Gfortran version must be >= 4.4.7])
fi
elif test x"${FC_ACT}" = x"pgf90"; then
version=""
build=""
fc_ver_info=$(${FC} -E ${VER_OPT} )
for vtok in ${fc_ver_info} ; do
if echo ${vtok} | egrep -q "^@<:@0-9@:>@+\.@<:@0-9@:>@+\-@<:@0-9@:>@+$"; then
version=${vtok}
fi
done
FC_GNU_VER=`echo ${version}\
| sed -e 's/\(@<:@0-9@:>@*\).\(@<:@0-9@:>@*\)-/\1 \2/'\
| xargs printf "%02d%02d"`
if test ${FC_GNU_VER} -lt 1610 ; then
AC_MSG_ERROR([pgi version must be >= 16.1])
fi
fi
AC_MSG_RESULT([${mpitype} MPI])
## C compiler
#
if test x"${enable_mpi}" = x"yes"; then
genesis_default_cc="mpiicc mpifccpx mpifcc mpicc"
else
genesis_default_cc="icc fccpx fcc gcc"
fi
# check usablility
AC_PROG_CC($genesis_default_cc)
# check actual compiler
AC_MSG_CHECKING([for actual compiler])
cc_ver_info=$(${CC} -E ${VER_OPT})
for vtok in ${cc_ver_info} ; do
if test x"${vtok}" = x"icc"; then
CC_ACT="icc"
break
elif test x"${vtok}" = x"fccpx"; then
CC_ACT="fccpx"
if test x"${enable_mpi}" = x"yes"; then
CC_ACT="mpifccpx"
fi
break
elif test x"${vtok}" = x"gcc"; then
CC_ACT="gcc"
break
elif test x"${vtok}" = x"pgcc"; then
CC_ACT="pgcc"
break
fi
done
if test -z "${CC_ACT}"; then
CC_ACT=${CC}
fi
AC_MSG_RESULT([$CC_ACT])
## preprocessor
#
if test -n "${FPP}"; then
if test ` echo ${FPP} | grep / ` ; then
AC_CHECK_FILES([${FPP}], check_fpp=${FPP})
else
AC_CHECK_PROGS(check_fpp, [${FPP}])
fi
if test -z "${check_fpp}"; then
AC_MSG_ERROR([Preprocessor ${FPP} is not found.])
fi
else
if test x"${FC_ACT}" = x"frtpx" -o x"${FC_ACT}" = x"mpifrtpx"; then
AC_CHECK_PROGS(FPP, frtpx fpp cpp)
elif test x"${FC_ACT}" = x"frt" -o x"${FC_ACT}" = x"mpifrt"; then
AC_CHECK_PROGS(FPP, frt fpp cpp)
else
AC_CHECK_PROGS(FPP, fpp cpp)
fi
if test -z "${FPP}"; then
AC_MSG_ERROR([There is no any Preprocessor for Fortran])
fi
fi
## OpenMP
#
AC_ARG_ENABLE([openmp],
[AS_HELP_STRING([--disable-openmp], [disable OpenMP])],
[], [enable_openmp=yes])
if test x"${enable_openmp}" = x"yes"; then
AC_DEFINE(OMP, 1, [defined if OpenMP is used.])
DEFINED_VARIABLES+=" -DOMP"
if test x"${FC_ACT}" = x"ifort"; then
OPT_OPENMP="-openmp"
if test ${FC_GNU_VER} -gt 160000; then
OPT_OPENMP="-qopenmp"
fi
if test ${FC_GNU_VER} -gt 190000; then
AC_DEFINE(IFORT19, 1, [defined if ifort version (>19) is used.])
DEFINED_VARIABLES+=" -DIFORT19"
fi
elif test x"${FC_ACT}" = x"gfortran"; then
OPT_OPENMP="-fopenmp"
elif test x"${FC_ACT}" = x"pgf90"; then
OPT_OPENMP="-mp"
elif test x"${FC_ACT}" = x"frtpx"; then
OPT_OPENMP="-Kopenmp"
elif test x"${FC_ACT}" = x"mpifrtpx"; then
OPT_OPENMP="-Kopenmp"
elif test x"${FC_ACT}" = x"frt"; then
OPT_OPENMP="-Kopenmp"
elif test x"${FC_ACT}" = x"mpifrt"; then
OPT_OPENMP="-Kopenmp"
fi
if test x"${with_msmpi}" = x"yes"; then
AC_MSG_ERROR([OpenMP is not available with MSMPI])
fi
fi
## ffte
#
AC_DEFINE(FFTE, 1, [defined if FFTE is used.])
DEFINED_VARIABLES+=" -DFFTE"
## lapack
#
AC_ARG_WITH([lapack],
[AS_HELP_STRING([--without-lapack],
[do not use LAPACK (default: uses LAPACK)])],
[], [with_lapack=yes])
AC_ARG_VAR([LAPACK_PATH],
[LAPACK library path (linker flags, e.g. -L<lapack dir>)])
AC_ARG_VAR([LAPACK_LIBS],
[LAPACK library files (libraries, e.g. -l<lapack library>)])
if test x"${with_lapack}" == x"yes"; then
AC_DEFINE(LAPACK, 1, [defined if LAPACK is used.])
DEFINED_VARIABLES+=" -DLAPACK"
blaslink="-lblas"
lapacklib=""
if test -n "${LAPACK_PATH}"; then
lapack_path_string=${LAPACK_PATH}
if test x"${FC_ACT}" = x"gfortran" -o \
x"${FC_ACT}" = x"pgf90" ; then
lapack_lib_path=""
blas_lib_path=""
for vtok in ${lapack_path_string} ; do
if test -z "${lapack_lib_path}"; then
AC_CHECK_FILE([${vtok}/liblapack.a],[lapack_lib_path=${vtok} ; lapacklib="lapack"],[])
if test -z "${lapack_lib_path}"; then
AC_CHECK_FILE([${vtok}/liblapack.so],[lapack_lib_path=${vtok} ; lapacklib="lapack"],[])
fi
fi
if test -z "${blas_lib_path}"; then
AC_CHECK_FILE([${vtok}/libblas.a],[blas_lib_path=${vtok} ; blaslink="-lblas"],[])
if test -z "${blas_lib_path}"; then
AC_CHECK_FILE([${vtok}/libblas.so],[blas_lib_path=${vtok} ; blaslink="-lblas"],[])
fi
if test -z "${blas_lib_path}"; then
AC_CHECK_FILE([${vtok}/librefblas.a],[blas_lib_path=${vtok} ; blaslink="-lrefblas"],[])
fi
if test -z "${blas_lib_path}"; then
AC_CHECK_FILE([${vtok}/librefblas.so],[blas_lib_path=${vtok} ; blaslink="-lrefblas" ],[])
fi
fi
done
if test -z "${lapack_lib_path}"; then
AC_MSG_ERROR([Lapack is not found.])
fi
if test -z "${blas_lib_path}"; then
AC_MSG_ERROR([BLAS is not found])
fi
if test x"${lapack_lib_path}" == x"${blas_lib_path}"; then
OPT_LD_LAPACK+=" -L${lapack_lib_path}"
else
OPT_LD_LAPACK+=" -L${lapack_lib_path} -L${blas_lib_path}"
fi
else
for vtok in ${lapack_path_string} ; do
OPT_LD_LAPACK+=" -L${vtok}"
done
fi
fi
if test -n "${LAPACK_LIBS}"; then
OPT_LD_LAPACK+="${LAPACK_LIBS}"
elif test x"${FC_ACT}" = x"ifort"; then
OPT_LD_LAPACK+=" -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lmkl_lapack95_lp64"
lapacklib="mkl_lapack95_lp64"
LDFLAGS=${OPT_LD_LAPACK}
AC_CHECK_LIB([${lapacklib}], [dsyev],
[], [AC_MSG_ERROR([lapack is not correct])],[-lmkl_intel_lp64 -lmkl_sequential -lmkl_core])
LDFLAGS=""
elif test x"${FC_ACT}" = x"pgf90"; then
# OPT_LD_LAPACK+=" -llapack ${blaslink}"
lapacklib="lapack"
LDFLAGS=${OPT_LD_LAPACK}
AC_CHECK_LIB([${lapacklib}], [dsyev],
[OPT_LD_LAPACK+=" -llapack ${blaslink}"], [AC_MSG_ERROR([lapack is not correct])],["${blaslink} ${OPT_LD_LAPACK}"])
LDFLAGS=""
elif test x"${FC_ACT}" = x"gfortran"; then
# OPT_LD_LAPACK+=" -llapack ${blaslink}"
lapacklib="lapack"
LDFLAGS=${OPT_LD_LAPACK}
AC_CHECK_LIB([${lapacklib}], [dsyev],
[OPT_LD_LAPACK+=" -llapack ${blaslink}"], [AC_MSG_ERROR([lapack is not correct])],["${blaslink}"])
LDFLAGS=""
fi
fi
with_internallapack=no
AM_CONDITIONAL(INTERNAL_LAPACK, test x"${with_internallapack}" = x"yes")
AM_CONDITIONAL(INTERNAL_SCALAPACK, test x"${with_internallapack}" = x"yes" -a x"${enable_mpi}" = x"yes")
## GPU precision
#
AC_ARG_ENABLE([gpu],
[AS_HELP_STRING(
[--enable-gpu],
[enable gpu (default = no)])],
[],[enable_gpu=no])
if test x"${enable_gpu}" = x"yes"; then
AC_DEFINE(USE_GPU, 1, [defined if gpu is used.])
DEFINED_VARIABLES+=" -DUSE_GPU"
fi
## parallel I/O
#
AC_ARG_ENABLE([parallel_IO],
[AS_HELP_STRING([--enable-parallel_IO], [enable parallel_IO (defalt: no)])],
[], [enable_parallel_IO=no])
if test x"${FC_ACT}" = x"frtpx" -o x"${FC_ACT}" = x"mpifrtpx"; then
enable_parallel_IO=no
fi
if test x"${FC_ACT}" = x"frt" -o x"${FC_ACT}" = x"mpifrt"; then
enable_parallel_IO=no
fi
if test x"${enable_single}" = x"yes"; then
enable_parallel_IO=no
fi
if test x"${enable_mixed}" = x"yes"; then
enable_parallel_IO=no
fi
if test x"${enable_gpu}" = x"yes"; then
enable_parallel_IO=no
fi
AM_CONDITIONAL(PARALLEL_IO, test x"${enable_parallel_IO}" = x"yes")
## huge molecule on hard disk
#
AC_ARG_ENABLE([hmdisk],
[AS_HELP_STRING(
[--enable-hmdisk],
[enable huge molecule on hard disk (default = no)])],
[],[enable_hmdisk=no])
if test x"${enable_hmdisk}" = x"yes"; then
AC_DEFINE(HM_DISK, 1, [defined if HM_DISK is used.])
fi
## CUDA
#
OPT_FC_CUDA=""
AC_ARG_WITH([cuda],
[AS_HELP_STRING([--with-cuda@<:@=PATH@:>@],
[use cuda (default: no)])],
[], [with_cuda=no])
#AC_ARG_VAR([CUDA_LIB_PATH],
# [CUDA library path (linker flags, e.g. -L<cuda lib>)])
if test x"${enable_gpu}" = x"yes"; then
if test x"${with_cuda}" = x"no"; then
with_cuda=yes
fi
fi
if test x"${with_cuda}" != x"no"; then
cuda_lib_path=""
cuda_path=""
if test x"${with_msmpi}" = x"yes"; then
AC_MSG_ERROR([GPU is not available with MSMPI])
fi
if test x"${with_cuda}" != x"yes"; then
cuda_path=${with_cuda}
AC_CHECK_FILE([${cuda_path}/libcudart.so],
[cuda_lib_path=${cuda_path}],[])
AC_CHECK_FILE([${cuda_path}/lib64/libcudart.so],
[cuda_lib_path=${cuda_path}/lib64],[])
fi
NVCC=no
if test x"${with_cuda}" != x"yes"; then
AC_CHECK_FILE([${cuda_path}/bin/nvcc],
[NVCC=${cuda_path}/bin/nvcc],[])
fi
AC_PATH_PROG(NVCC, nvcc ,no)
if test x"${NVCC}" = x"no"; then
AC_MSG_ERROR([nvcc is not found])
fi
if test -z "${cuda_lib_path}"; then
lib_dirs=$(echo ${LIBRARY_PATH} ${LD_LIBRARY_PATH} |tr ':' ' ')
for dir in ${lib_dirs}; do
if echo ${dir} | egrep -q "cuda"; then
AC_CHECK_FILE([${dir}/libcudart.so], [cuda_lib_path=${dir}], [])
if test x"${cuda_lib_path}" != x""; then
break
fi
fi
done
fi
if test -z "${cuda_lib_path}"; then
# for debian & ubuntsu (non nvidia-package)
AC_CHECK_FILE([/usr/lib/x86_64-linux-gnu/libcudart.so],
[cuda_lib_path=/usr/lib/x86_64-linux-gnu], [])
fi
if test -z "${cuda_lib_path}"; then
# for fedora
AC_CHECK_FILE([/usr/local/cuda/lib64/libcudart.so],
[cuda_lib_path=/usr/local/cuda/lib64], [])
fi
if test -z "${cuda_lib_path}"; then
AC_CHECK_FILE([/usr/lib64/libcudart.so],
[cuda_lib_path=/usr/lib64], [])
fi
if test -z ${cuda_lib_path}; then
AC_MSG_ERROR([CUDA is not found, set --with-cuda or CUDA_LIB_PATH])
fi
# AC_CHECK_PROG(NVCC, nvcc)
version=""
nvcc_ver_info=$(${NVCC} -V)
for vtok in ${nvcc_ver_info} ; do
if test x"${vtok}" = x"(NVCC)"; then
check_ver=yes
elif echo ${vtok} | egrep -q "V@<:@0-9@:>@*\.@<:@0-9@:>@*\.@<:@0-9@:>@*"; then
version=${vtok}
fi
done
AC_MSG_RESULT([$version])
NVCC_VER=`echo ${version}\
| sed -e 's/\V\(@<:@0-9@:>@*\).\(@<:@0-9@:>@*\).\(@<:@0-9@:>@*\)/\1 \2 \3/'\
| xargs printf "%02d%02d%02d"`
AC_DEFINE(CUDAGPU, 1, [defined if cuda_gpu is used.])
DEFINED_VARIABLES+=" -DCUDAGPU"
if test x"${FC_ACT}" = x"pgf90"; then
OPT_LD_CUDA+="-Mcuda -L${cuda_lib_path} -lcudart -lstdc++"
OPT_FC_CUDA+="-Mcuda "
AC_DEFINE(PGICUDA, 1, [defined if pgi and cuda are used.])
DEFINED_VARIABLES+=" -DPGICUDA"
elif test x"${FC_ACT}" = x"ifort"; then
OPT_LD_CUDA+="-L${cuda_lib_path} -lcudart -lstdc++"
elif test x"${FC_ACT}" = x"gfortran"; then
OPT_LD_CUDA+="-L${cuda_lib_path} -lcudart -lstdc++"
else
AC_MSG_ERROR([CUDA is not allowed])
fi
# CUDA VERSION and compile option
if test ${NVCC_VER} -lt 080000; then
AC_MSG_ERROR([CUDA version must be >= 8.0.0 for GENESIS])
fi
GENCODEFLAG='--generate-code=arch=compute_35,code=\"sm_35,compute_35\"'
if test ${NVCC_VER} -gt 065000; then
GENCODEFLAG+=' --generate-code=arch=compute_37,code=\"sm_37,compute_37\"' #K80
fi
if test ${NVCC_VER} -gt 080000; then
GENCODEFLAG+=' --generate-code=arch=compute_60,code=\"sm_60,compute_60\"' #P100
GENCODEFLAG+=' --generate-code=arch=compute_61,code=\"sm_61,compute_61\"' #GTX1080
GENCODEFLAG+=' --generate-code=arch=compute_62,code=\"sm_62,compute_62\"'
fi
# NVCCFLAG
NVCCFLAG="-c -g -O3 ${GENCODEFLAG} --ftz=false --prec-div=true --prec-sqrt=true --fmad=true"
AC_SUBST(NVCCFLAG)
fi
AM_CONDITIONAL(CUDAGPU, test x"${with_cuda}" != x"no")
AC_ARG_ENABLE([package],
[AS_HELP_STRING(
[--enable-package],
[enable package (default = no)])],
[],[enable_package=no])
## ATDYN calculation
#
enable_atdyn=yes
if test x"${FC_ACT}" = x"pgif90" -o \
x"${FC_ACT}" = x"pgf90" -o \
x"${FC_ACT}" = x"pgfortran"; then
enable_atdyn=no
fi
if test x"${enable_single}" = x"yes"; then
enable_atdyn=no
fi
if test x"${enable_mixed}" = x"yes"; then
enable_atdyn=no
fi
if test x"${enable_gpu}" = x"yes"; then
enable_atdyn=no
fi
AM_CONDITIONAL(ATDYN, test x"${enable_atdyn}" = x"yes")
## ANALSIS calculation
#
enable_analysis=yes
if test x"${enable_single}" = x"yes"; then
enable_analysis=no
fi
if test x"${enable_mixed}" = x"yes"; then
enable_analysis=no
fi
if test x"${enable_gpu}" = x"yes"; then
enable_analysis=no
fi
if test x"${FC_ACT}" = x"pgif90" -o \
x"${FC_ACT}" = x"pgf90" -o \
x"${FC_ACT}" = x"pgfortran"; then
enable_analysis=no
fi
AM_CONDITIONAL(ANALYSIS, test x"${enable_analysis}" = x"yes")
## gprof
#
AC_ARG_ENABLE([gprof],
[AS_HELP_STRING(
[--enable-gprof],
[enable gprof profiler (default = no)])],
[],[enable_gprof=no])
OPT_GPROF=""
if test x"${enable_gprof}" = x"yes"; then
OPT_GPROF="-pg -g"
fi
## dSFMT settings
#
AC_DEFINE(DSFMT_MEXP, 19937, [defined always.])
DEFINED_VARIABLES+=" -DDSFMT_MEXP=19937"
# architecture check
#
cpuinfo=`grep "^flags.*" /proc/cpuinfo | head -1 `
have_avx512f=no
have_avx512er=no
have_avx512cd=no
have_avx512pf=no
have_avx512dq=no
have_avx512bw=no
have_avx512vl=no
have_avx2=no
have_avx=no
have_sse4_2=no
have_rtm=no
have_rdseed=no
have_mmxext=no
have_fxsr_opt=no
have_3dnowprefetch=no
for vtok in ${cpuinfo} ; do
if test x"${vtok}" = x"avx512f"; then
have_avx512f=yes
elif test x"${vtok}" = x"avx512er"; then
have_avx512er=yes
elif test x"${vtok}" = x"avx512cd"; then
have_avx512cd=yes
elif test x"${vtok}" = x"avx512pf"; then
have_avx512pf=yes
elif test x"${vtok}" = x"avx512dq"; then
have_avx512dq=yes
elif test x"${vtok}" = x"avx512bw"; then
have_avx512bw=yes
elif test x"${vtok}" = x"avx512vl"; then
have_avx512vl=yes
elif test x"${vtok}" = x"avx2"; then
have_avx2=yes
elif test x"${vtok}" = x"avx"; then
have_avx=yes
elif test x"${vtok}" = x"sse4_2"; then
have_sse4_2=yes
elif test x"${vtok}" = x"rtm"; then
have_rtm=yes
elif test x"${vtok}" = x"rdseed"; then
have_rdseed=yes
elif test x"${vtok}" = x"mmxext"; then
have_mmxext=yes
elif test x"${vtok}" = x"3dnowprefetch"; then
have_3dnowprefetch=yes
elif test x"${vtok}" = x"fxsr_opt"; then
have_fxsr_opt=yes
fi
done
## compile flags
#
AC_ARG_WITH([simd],
[AS_HELP_STRING([--with-simd=@<:@auto/MIC-AVX512/CORE-AVX512/CORE-AVX2@:>@],
[SIMD instruction (default: auto)])],
[], [with_simd=auto])
if test x"${FC_ACT}" != x"ifort" -a x"${with_simd}" != x"auto" ; then
AC_MSG_ERROR([with-simd is only used in intel fortran])
fi
if test x"${FC_ACT}" = x"ifort" ; then
if test ${FC_GNU_VER} -lt 152000; then
if test x"${with_simd}" = x"CORE-AVX512"; then
AC_MSG_ERROR([ifort > 15.2 is required for CORE-AVX512])
fi
if test x"${with_simd}" = x"MIC-AVX512"; then
AC_MSG_ERROR([ifort > 15.2 is required for MIC-AVX512])
fi
fi
fi
FARCFLAGS=""
FARCFLAGS_NOOPT=""
FARCFLAGS_KERNELS=""
FARCFLAGS_KERNELS_PAIRLIST=""
FARCFLAGS_DIHEDRAL=""
# FFLAGS
if test x"${ac_test_FFLAGS}" = x"set"; then
FCFLAGS=${ac_save_FFLAGS}
else
if test x"${enable_debug}" == x"0"; then
# no-debug no report
if test x"${FC_ACT}" = x"ifort"; then
if test x"${have_fxsr_opt}" = x"yes" -o \
x"${have_mmxext}" = x"yes" -o \
x"${have_3dnowprefetch}" = x"yes"; then
#AMD
FARCFLAGS=""
FARCFLAGS_NOOPT=""
FCFLAGS+=" -O3 "
else
FARCFLAGS=" -xHost "
FARCFLAGS_NOOPT=" -axCORE-AVX2 -xHost "
FCFLAGS+=" -O3 -ip "
fi
if test x"${with_simd}" != x"auto"; then
FARCFLAGS+=" -ax${with_simd}"
elif test ${FC_GNU_VER} -ge 152000 ; then
if test x"${have_avx512f}" = x"yes" -a \
x"${have_avx512er}" = x"yes" -a \
x"${have_avx512cd}" = x"yes" -a \
x"${have_avx512pf}" = x"yes"; then
with_simd="MIC-AVX512"
FARCFLAGS+=" -ax${with_simd}"
elif test x"${have_avx512f}" = x"yes" -a \
x"${have_avx512dq}" = x"yes" -a \
x"${have_avx512cd}" = x"yes" -a \
x"${have_avx512vl}" = x"yes" -a \
x"${have_avx512bw}" = x"yes"; then
with_simd="CORE-AVX512"
FARCFLAGS+=" -ax${with_simd}"
elif test x"${have_avx2}" = x"yes" -a \
x"${have_rdseed}" = x"yes" -a \
x"${have_rtm}" = x"yes" ; then
with_simd="CORE-AVX512"
FARCFLAGS+=" -ax${with_simd}"
elif test x"${have_avx2}" = x"yes" ; then
with_simd="CORE-AVX2"
FARCFLAGS+=" -ax${with_simd}"
fi
fi
if test ${FC_GNU_VER} -ge 20210000; then
FCFLAGS+=" -qmkl=parallel "
else
FCFLAGS+=" -mkl=parallel "
fi
elif test x"${FC_ACT}" = x"gfortran"; then
FCFLAGS="-O3 -ffast-math -march=native -ffree-line-length-none"
echo ${FC_GNU_VER}
if test ${FC_GNU_VER} -gt 100000; then
if test x"${with_msmpi}" = x"no"; then
FCFLAGS+=" -fallow-argument-mismatch"
else
FCFLAGS+=" -Wno-argument-mismatch"
fi
fi
elif test x"${FC_ACT}" = x"pgf90"; then
FCFLAGS="-O2 -fastsse -Mipa=fast,inline -m64 -Mflushz -pc 64 -mcmodel=medium -Msmartalloc=huge"
elif test x"${FC_ACT}" = x"frtpx"; then
FCFLAGS="-m -Kocl -Kfast,openmp,parallel,simd=2,noalias -Nlst=t -Koptmsg=2"
elif test x"${FC_ACT}" = x"mpifrtpx"; then
FCFLAGS="-m -Kocl -Kfast,openmp,parallel,simd=2,noalias -Nlst=t -Koptmsg=2"
FCFLAGS_FFTE_KERNEL_FPP__PGI__SP=" -m -Kocl -Kfast,openmp,parallel,simd=2,noalias -Nlst=t -Koptmsg=2"
FCFLAGS_FPP__PGI_NOOPT="-m -Kocl -Kfast,openmp,parallel,simd=2,noalias -Nlst=t -Koptmsg=2"
FCFLAGS_KERNELS_PAIRLIST="-m -Kocl -Kfast,openmp,parallel,simd=2,nounroll,swp_strong,noalias=s -Nlst=t -Koptmsg=2"
FCFLAGS_DIHEDRAL="-m -xsp_energy_dihedrals_mod.calculate_dihedral_2 -Kocl -Kfast,openmp,parallel,simd=2,noalias -Nlst=t -Koptmsg=2"
FCFLAGS_KERNELS=" -m -Kocl -Kfast,openmp,parallel,simd=2,swp_strong,noalias=s -Nlst=t -Koptmsg=2"
elif test x"${FC_ACT}" = x"frt"; then
FCFLAGS="-m -Am -Kfast"
elif test x"${FC_ACT}" = x"mpifrt"; then
FCFLAGS="-m -Am -Kfast"
fi
elif test x"${enable_debug}" == x"1"; then
# debug level 1 (without higher optmization ) (default)
if test x"${FC_ACT}" = x"ifort"; then
FCFLAGS=" -axCORE-AVX2 -vec-report"
if test ${FC_GNU_VER} -ge 20210000; then
FCFLAGS+=" -qmkl=parallel "
else
FCFLAGS+=" -mkl=parallel "
fi
elif test x"${FC_ACT}" = x"gfortran"; then
FCFLAGS="-Wall -ffree-line-length-none"
if test ${FC_GNU_VER} -gt 100000; then
if test x"${with_msmpi}" = x"no"; then
FCFLAGS+=" -fallow-argument-mismatch"
else
FCFLAGS+=" -O2 -march=x86-64 -Wno-argument-mismatch"
fi
fi
elif test x"${FC_ACT}" = x"pgf90"; then
FCFLAGS="-m64 -Mflushz -pc 64 -mcmodel=medium -Msmartalloc=huge -Mbackslash"
elif test x"${FC_ACT}" = x"frtpx"; then
FCFLAGS="-m -Kocl -Kopenmp -Nlst=t -Koptmsg=2"
elif test x"${FC_ACT}" = x"mpifrtpx"; then
FCFLAGS="-m -Kocl -Kopenmp -Nlst=t -Koptmsg=2"
elif test x"${FC_ACT}" = x"frt"; then
FCFLAGS="-m "
elif test x"${FC_ACT}" = x"mpifrt"; then
FCFLAGS="-m "
fi
elif test x"${enable_debug}" == x"2"; then