1AC_PREREQ([2.69]) 2 3# The version is set in elpa.spec, to have a single point of reference 4AC_INIT([elpa],m4_esyscmd_s([awk '/^ *Version:/ {print $2;}' elpa.spec]), [elpa-library@mpcdf.mpg.de]) 5AC_SUBST([PACKAGE_VERSION]) 6 7AC_CONFIG_SRCDIR([src/elpa.F90]) 8 9AM_INIT_AUTOMAKE([foreign -Wall subdir-objects]) 10 11AC_CONFIG_MACRO_DIR([m4]) 12AC_CONFIG_HEADERS([config.h]) 13AM_SILENT_RULES([yes]) 14 15# ABI version 16# 17# Set the libtool library version, see LIBRARY_INTERFACE 18# 19# See http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html 20# 21# [c:r:a] 22# 23# c: The currently implement interface 24# r: The revision number of the current interface, that is the number 25# of released source-code changes for the current interface 26# a: The "age" is the number of interfaces prior to c that are also supported 27# by the current interface, as they are ABI compatible (e.g. only new symbols 28# were added by the new interface) 29# 30AC_SUBST([ELPA_SO_VERSION], [14:0:0]) 31 32# AC_DEFINE_SUBST(NAME, VALUE, DESCRIPTION) 33# ----------------------------------------- 34AC_DEFUN([AC_DEFINE_SUBST], [ 35AC_DEFINE([$1], [$2], [$3]) 36AC_SUBST([$1], ['$2']) 37]) 38 39# API Version 40AC_DEFINE([EARLIEST_API_VERSION], [20170403], [Earliest supported ELPA API version]) 41 42AC_DEFINE_SUBST(CURRENT_API_VERSION, 20190524, "Current ELPA API version") 43# Autotune Version 44AC_DEFINE([EARLIEST_AUTOTUNE_VERSION], [20171201], [Earliest ELPA API version, which supports autotuning]) 45AC_DEFINE([CURRENT_AUTOTUNE_VERSION], [20190524], [Current ELPA autotune version]) 46AC_DEFINE_SUBST(CURRENT_AUTOTUNE_VERSION, 20190524, "Current ELPA autotune version") 47 48AX_CHECK_GNU_MAKE() 49if test x$_cv_gnu_make_command = x ; then 50 AC_MSG_ERROR([Need GNU Make]) 51fi 52 53enable_legacy=no 54 55AC_MSG_CHECKING(whether legacy interface should be provided) 56AC_ARG_ENABLE([legacy-interface], 57 AS_HELP_STRING([--enable-legacy-interface], 58 [build legacy API, default no]), 59 [ 60 if test x"$enableval" = x"yes"; then 61 enable_legacy=yes 62 else 63 enable_legacy=no 64 fi 65 ], 66 [enable_legacy=no]) 67AC_MSG_RESULT([${enable_legacy}]) 68AM_CONDITIONAL([ENABLE_LEGACY],[test x"$enable_legacy" = x"yes"]) 69if test x"${enable_legacy}" = x"yes"; then 70 AC_DEFINE([ENABLE_LEGACY], [1], [enable legacy interface]) 71fi 72 73AC_MSG_CHECKING(whether in C interface the error argument should be optional) 74AC_ARG_ENABLE([optional-argument-in-C-API], 75 AS_HELP_STRING([--enable-optional-argument-in-C-API], 76 [do not build C API with error argument as optional, default no]), 77 [ 78 if test x"$enableval" = x"yes"; then 79 optional_c_error_argument=yes 80 else 81 optional_c_error_argument=no 82 fi 83 ], 84 [optional_c_error_argument=no]) 85AC_MSG_RESULT([${optional_c_error_argument}]) 86AM_CONDITIONAL([OPTIONAL_C_ERROR_ARGUMENT],[test x"$enable_legacy" = x"yes"]) 87if test x"${optional_c_error_argument}" = x"yes"; then 88 AC_DEFINE([OPTIONAL_C_ERROR_ARGUMENT], [1], [enable error argument in C-API to be optional]) 89fi 90 91 92# gnu-make fortran module dependencies 93m4_include([fdep/fortran_dependencies.m4]) 94FDEP_F90_GNU_MAKE_DEPS 95 96 97dnl OpenMP 98m4_include([m4/ax_elpa_openmp.m4]) 99AC_MSG_CHECKING(whether --enable-openmp is specified) 100AC_ARG_ENABLE([openmp], 101 AS_HELP_STRING([--enable-openmp], 102 [use OpenMP threading, default no.]), 103 [ 104 if test x"$enableval" = x"yes"; then 105 enable_openmp=yes 106 else 107 enable_openmp=no 108 fi 109 ], 110 [enable_openmp=no]) 111AC_MSG_RESULT([${enable_openmp}]) 112AM_CONDITIONAL([WITH_OPENMP],[test x"$enable_openmp" = x"yes"]) 113if test x"${enable_openmp}" = x"yes"; then 114 AC_DEFINE([WITH_OPENMP], [1], [use OpenMP threading]) 115fi 116 117 118dnl mpi 119AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi=[[yes|no]]], [compile with MPI. Default: yes])],,[with_mpi=yes]) 120AM_CONDITIONAL([WITH_MPI],[test x"$with_mpi" = x"yes"]) 121if test x"${with_mpi}" = x"yes"; then 122 AC_DEFINE([WITH_MPI], [1], [use MPI]) 123fi 124 125 126dnl Scalapack tests 127AC_MSG_CHECKING(whether --enable-scalapack-tests is specified) 128AC_ARG_ENABLE([scalapack-tests], 129 AS_HELP_STRING([--enable-scalapack-tests], 130 [build SCALAPACK test cases for performance comparison, needs MPI, default no.]), 131 [ 132 if test x"$enableval" = x"yes"; then 133 enable_scalapack_tests=yes 134 else 135 enable_scalapack_tests=no 136 fi 137 ], 138 [enable_scalapack_tests="no"]) 139AC_MSG_RESULT([$enable_scalapack_tests]) 140if test x"${enable_scalapack_tests}" = x"yes"; then 141 if test x"$with_mpi" = x"no"; then 142 AC_MSG_ERROR([You cannot build the SCALAPCK test cases without MPI]) 143 fi 144 AC_DEFINE([WITH_SCALAPACK_TESTS], [1], [build SCALAPACK test cases]) 145fi 146AM_CONDITIONAL([WITH_SCALAPACK_TESTS], [test x"$enable_scalapack_tests" = x"yes"]) 147 148 149dnl C 150AC_LANG_PUSH([C]) 151 152AX_PROG_CC_MPI([test x"$with_mpi" = x"yes"],[found_mpi_c=yes],[found_mpi_c=no]) 153if test x"$with_mpi" = x"yes"; then 154 if test x"$found_mpi_c" = x"no"; then 155 AC_MSG_ERROR([Could not compile an MPI C program]) 156 fi 157fi 158 159if test x"${enable_openmp}" = x"yes"; then 160 AX_ELPA_OPENMP 161 if test "$ac_cv_prog_cc_openmp" = unsupported; then 162 AC_MSG_ERROR([Could not compile a C program with OpenMP, adjust CFLAGS]) 163 fi 164 CFLAGS="$OPENMP_CFLAGS $CFLAGS" 165fi 166 167 168AX_CHECK_COMPILE_FLAG([-std=c11], [ 169 CFLAGS+=" -std=c11" 170], [ 171 echo "C compiler cannot compile C11 code" 172 exit -1 173]) 174 175AC_MSG_CHECKING(whether C compiler can use _Generic ) 176AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 177int main(int argc, char **argv) { 178#define elpa_set(e, name, value, error) _Generic((value), \ 179 int: \ 180 elpa_set_integer, \ 181 \ 182 double: \ 183 elpa_set_double \ 184 )(e, name, value, error) 185 186 return 0; 187} 188 ])], 189 [can_compile_generic=yes], 190 [can_compile_generic=no] 191 ) 192AC_MSG_RESULT([${can_compile_generic}]) 193if test x"$can_compile_generic" != x"yes"; then 194 AC_MSG_ERROR([C compiler cannot handle _Generic statement! Upgrade or change C compiler]) 195fi 196AC_DEFINE([HAVE_VSX_SSE],[1],[Altivec VSX intrinsics are supported on this CPU]) 197 198AC_PROG_INSTALL 199AM_PROG_AR 200AM_PROG_AS 201AC_PROG_CC_C99 202AM_PROG_CC_C_O 203AC_LANG_POP([C]) 204 205# Fortran 206AC_LANG_PUSH([Fortran]) 207m4_include([m4/ax_prog_fc_mpi.m4]) 208AX_PROG_FC_MPI([test x"$with_mpi" = x"yes"],[found_mpi_f=yes],[found_mpi_f=no]) 209if test x"$with_mpi" = x"yes"; then 210 if test x"$found_mpi_f" = x"no"; then 211 AC_MSG_ERROR([Could not compile an MPI Fortran program]) 212 fi 213fi 214 215AC_FC_SRCEXT([F90]) 216AC_FC_FREEFORM 217AC_FC_MODULE_FLAG 218AC_FC_MODULE_OUTPUT_FLAG 219AC_FC_LIBRARY_LDFLAGS 220 221 222if test x"${enable_openmp}" = x"yes"; then 223 AX_ELPA_OPENMP 224 if test "$ac_cv_prog_fc_openmp" = unsupported; then 225 AC_MSG_ERROR([Could not compile a Fortran program with OpenMP, adjust FCFLAGS]) 226 fi 227 FCFLAGS="$OPENMP_FCFLAGS $FCFLAGS" 228fi 229 230dnl check which MPI binray invokes a MPI job 231if test x"$with_mpi" = x"yes"; then 232 AC_CHECK_PROGS([MPI_BINARY], [mpiexec.hydra mpiexec mpirun poe runjob srun aprun], [no]) 233 if test x"$MPI_BINARY" = x"no"; then 234 AC_MSG_ERROR([Could not find either of the MPI binaries: mpiexec.hydra, mpiexec, mpirun, poe, runjob, srun, aprun]) 235 fi 236fi 237 238dnl build with the possibilty to redirect stdout and stderr 239dnl per MPI task in a file 240AC_MSG_CHECKING(whether stdout/stderr file redirect should be enabled) 241AC_ARG_ENABLE([redirect], 242 [AS_HELP_STRING([--enable-redirect], 243 [for test programs, allow redirection of stdout/stderr per MPI taks in a file (useful for timing), default no.])], 244 [ 245 if test x"$enableval" = x"yes"; then 246 enable_redirect=yes 247 else 248 enable_redirect=no 249 fi 250 ], 251 [enable_redirect=no]) 252AC_MSG_RESULT([${enable_redirect}]) 253 254dnl check whether single precision is requested 255AC_MSG_CHECKING(whether ELPA library should contain also single precision functions) 256AC_ARG_ENABLE(single-precision, 257 [AS_HELP_STRING([--enable-single-precision], 258 [build with single precision])], 259 [want_single_precision="$enableval"], 260 [want_single_precision="no"]) 261AC_MSG_RESULT([${want_single_precision}]) 262 263 264dnl redirect 265if test x"${enable_redirect}" = x"yes"; then 266 AC_DEFINE([HAVE_REDIRECT], [1], [Redirect stdout and stderr of test programs per MPI tasks to a file]) 267fi 268AM_CONDITIONAL([HAVE_REDIRECT],[test x"$enable_redirect" = x"yes"]) 269 270dnl build with ftimings support 271 272AC_ARG_ENABLE([timings], 273 [AS_HELP_STRING([--disable-timings], 274 [more detailed timing, default yes])], 275 [ 276 if test x"$enableval" = x"yes"; then 277 enable_timings=yes 278 else 279 enable_timings=no 280 fi 281 ], 282 [enable_timings=yes]) 283 284if test x"${enable_timings}" = x"yes"; then 285 AC_DEFINE([HAVE_DETAILED_TIMINGS], [1], [Enable more timing]) 286fi 287AM_CONDITIONAL([HAVE_DETAILED_TIMINGS], [test x"$enable_timings" = x"yes"]) 288 289dnl PAPI for ftimings 290AC_LANG_PUSH([C]) 291AC_ARG_WITH([papi], 292 [AS_HELP_STRING([--with-papi], 293 [Use PAPI to also measure flop count in the detailed timing (--enable-timing), disabled by default])], 294 [ 295 if test x"$enableval" = x"yes"; then 296 with_papi=yes 297 else 298 with_papi=no 299 fi 300 ], 301 [with_papi="no"]) 302if test x"${enable_timings}" = x"yes"; then 303 if test x"$with_papi" = x"yes" ; then 304 AC_SEARCH_LIBS([PAPI_library_init], [papi], [papi_found=yes], [papi_found=no]) 305 if test x"$papi_found" = x"no" ; then 306 AC_MSG_ERROR(["Could not find usable PAPI installation, please install or adjust CFLAGS, LDFLAGS"]) 307 fi 308 AC_DEFINE([HAVE_LIBPAPI], [1], [Use the PAPI library]) 309 fi 310fi 311AC_LANG_POP([C]) 312 313dnl Likwid 314AC_LANG_PUSH([Fortran]) 315AC_ARG_WITH([likwid], 316 [AS_HELP_STRING([--with-likwid=[[yes|no(default)|PATH]]], 317 [Use Likwid to measure performance in some parts of the library])], 318 [with_likwid="$withval"], 319 [with_likwid="no"]) 320 321if test x"$with_likwid" != x"no" ; then 322 if test -d $with_likwid/lib ; then 323 LDFLAGS="-L$with_likwid/lib $LDFLAGS" 324 fi 325 if test -d $with_likwid/lib64 ; then 326 LDFLAGS="-L$with_likwid/lib64 $LDFLAGS" 327 fi 328 if test -d $with_likwid/include ; then 329 FCFLAGS="-I$with_likwid/include $FCFLAGS" 330 fi 331 AC_SEARCH_LIBS([likwid_markerInit], [likwid], [liblikwid_found="yes"], [liblikwid_found="no"]) 332 if test x"$liblikwid_found" = x"no" ; then 333 AC_MSG_ERROR([Could not find a usable likwid library, please adjust LDFLAGS]) 334 fi 335 AC_MSG_CHECKING([whether we can use the likwid module in a Fortran program]) 336 AC_COMPILE_IFELSE([ 337 program foo 338 use likwid 339 340 implicit none 341 342 call likwid_markerInit() 343 call likwid_markerThreadInit() 344 345 call likwid_markerStartRegion("foobar") 346 call likwid_markerStopRegion("foobar") 347 348 call likwid_markerClose() 349 end 350 ], 351 [AC_MSG_RESULT([yes])], 352 [AC_MSG_RESULT([no]) 353 AC_MSG_ERROR([Could not compile a Fortran program using the likwid module, adjust FCFLAGS])]) 354 AC_DEFINE([HAVE_LIKWID], [1], [Use likwid]) 355fi 356AC_LANG_POP([Fortran]) 357 358save_FCFLAGS=$FCFLAGS 359save_LDFLAGS=$LDFLAGS 360 361AC_ARG_VAR([SCALAPACK_LDFLAGS],[Extra LDFLAGS necessary to link a program with Scalapack]) 362AC_ARG_VAR([SCALAPACK_FCFLAGS],[Extra FCFLAGS necessary to compile a Fortran program with Scalapack]) 363 364FCFLAGS="$FCFLAGS $SCALAPACK_FCFLAGS" 365LDFLAGS="$LDFLAGS $SCALAPACK_LDFLAGS" 366 367dnl check whether fortran error_unit is defined 368AC_MSG_CHECKING([whether Fortran module iso_fortran_env is available]) 369AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 370 program test_error_unit 371 use iso_fortran_env, only : error_unit 372 implicit none 373 374 write(error_unit,*) "error_unit is defined" 375 end program 376])], 377 [can_use_iso_fortran_env=yes], 378 [can_use_iso_fortran_env=no] 379) 380AC_MSG_RESULT([${can_use_iso_fortran_env}]) 381if test x"${can_use_iso_fortran_env}" = x"yes" ; then 382 AC_DEFINE([HAVE_ISO_FORTRAN_ENV],[1],[can use module iso_fortran_env]) 383fi 384 385 386dnl check whether one can link with specified MKL (desired method) 387AC_MSG_CHECKING([whether we can compile a Fortran program using MKL]) 388AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 389 program test_mkl 390 use mkl_service 391 character*198 :: string 392 call mkl_get_version_string(string) 393 write(*,'(a)') string 394 end program 395])], 396 [can_compile_with_mkl=yes], 397 [can_compile_with_mkl=no] 398) 399AC_MSG_RESULT([${can_compile_with_mkl}]) 400 401if test x"$can_compile_with_mkl" = x"yes" ; then 402 AC_MSG_CHECKING([whether we can link a Fortran program with MKL]) 403 AC_LINK_IFELSE([AC_LANG_SOURCE([ 404 program test_mkl 405 use mkl_service 406 character*198 :: string 407 call mkl_get_version_string(string) 408 write(*,'(a)') string 409 end program 410 ])], 411 [have_mkl=yes], 412 [have_mkl=no] 413 ) 414 AC_MSG_RESULT([${have_mkl}]) 415fi 416 417dnl if not mkl, check all the necessary individually 418if test x"${have_mkl}" = x"yes" ; then 419 WITH_MKL=1 420else 421 422 dnl first check blas 423 AC_SEARCH_LIBS([dgemm],[openblas satlas blas],[have_blas=yes],[have_blas=no]) 424 AC_MSG_CHECKING([whether we can link a program with a blas lib]) 425 AC_MSG_RESULT([${have_blas}]) 426 427 if test x"${have_blas}" = x"no" ; then 428 AC_MSG_ERROR([could not link with blas: specify path]) 429 fi 430 dnl now lapack 431 AC_SEARCH_LIBS([dlarrv],[lapack],[have_lapack=yes],[have_lapack=no]) 432 AC_MSG_CHECKING([whether we can link a program with a lapack lib]) 433 AC_MSG_RESULT([${have_lapack}]) 434 435 if test x"${have_lapack}" = x"no" ; then 436 AC_MSG_ERROR([could not link with lapack: specify path]) 437 fi 438 439 if test x"${with_mpi}" = x"yes"; then 440 dnl test whether scalapack already contains blacs 441 scalapack_libs="mpiscalapack scalapack scalapack-openmpi" 442 old_LIBS="$LIBS" 443 for lib in ${scalapack_libs}; do 444 LIBS="-l${lib} ${old_LIBS}" 445 AC_MSG_CHECKING([whether -l${lib} already contains a BLACS implementation]) 446 AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([blacs_gridinit])],[blacs_in_scalapack=yes],[blacs_in_scalapack=no]) 447 448 AC_MSG_RESULT([${blacs_in_scalapack}]) 449 if test x"${blacs_in_scalapack}" = x"yes"; then 450 break 451 fi 452 done 453 454 if test x"${blacs_in_scalapack}" = x"no"; then 455 LIBS="${old_LIBS}" 456 457 dnl Test for stand-alone blacs 458 AC_SEARCH_LIBS([bi_f77_init],[mpiblacsF77init],[],[],[-lmpiblacs]) 459 460 dnl for debian 461 AC_SEARCH_LIBS([blacs_gridinit],[blacs-openmpi],[have_blacs=yes],[have_blacs=no],[-lblacsCinit-openmpi -lscalapack-openmpi]) 462 if test x"${have_blacs}" = x"no"; then 463 unset ac_cv_search_blacs_gridinit 464 fi 465 AC_SEARCH_LIBS([blacs_gridinit],[mpiblacs blacs],[have_blacs=yes],[have_blacs=no]) 466 467 if test x"${have_blacs}" = x"no"; then 468 AC_MSG_ERROR([No usable BLACS found. If installed in a non-standard place, please specify suitable LDFLAGS and FCFLAGS as arguments to configure]) 469 fi 470 fi 471 472 AC_SEARCH_LIBS([pdtran],[$scalapack_libs],[have_scalapack=yes],[have_scalapack=no]) 473 474 if test x"${have_scalapack}" = x"no" ; then 475 AC_MSG_ERROR([could not link with scalapack: specify path]) 476 fi 477 fi 478 479 dnl check whether we can link alltogehter 480 AC_MSG_CHECKING([whether we can link a Fortran program with all blacs/scalapack]) 481 AC_LINK_IFELSE([AC_LANG_SOURCE([ 482 program dgemm_test 483 484 integer , parameter:: M = 4, N = 3, K = 2 485 real :: A(M,K), B(K,N), C(M,N) 486 487 call dgemm('N','N',M,N,K,1.0,A,M,B,K,0.0,C,M) 488 489 end program dgemm_test 490 ])], 491 [can_link_with_blacs_scalapack=yes], 492 [can_link_with_blacs_scalapack=no] 493 ) 494 AC_MSG_RESULT([${can_link_with_blacs_scalapack}]) 495 496 if test x"${can_link_with_blacs_scalapack}" = x"yes" ; then 497 WITH_BLACS=1 498 else 499 AC_MSG_ERROR([We can neither link with MKL or another Scalpack. Please specify SCALAPACK_LDFLAGS and SCALAPACK_FCFLAGS!]) 500 fi 501fi 502 503dnl important: reset them again! 504FCFLAGS=$save_FCFLAGS 505LDFLAGS=$save_LDFLAGS 506 507 508dnl check for intrinsic fortran function of 2003 standard 509AC_MSG_CHECKING([whether we can use the intrinsic Fortran function "get_environment_variable"]) 510 511 512AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 513 program test_get_environment 514 character(len=256) :: homedir 515 call get_environment_variable("HOME",homedir) 516 end program 517])], 518 [fortran_can_check_environment=yes], 519 [fortran_can_check_environment=no] 520) 521AC_MSG_RESULT([${fortran_can_check_environment}]) 522if test x"${fortran_can_check_environment}" = x"yes" ; then 523 AC_DEFINE([HAVE_ENVIRONMENT_CHECKING],[1],[Fortran can query environment variables]) 524fi 525 526 527dnl check whether BAND_TO_FULL_BLOCKING is set 528AC_MSG_CHECKING(whether BAND_TO_FLULL_BLOCKING is requested) 529AC_ARG_ENABLE(band-to-full-blocking,[AS_HELP_STRING([--disable-band-to-full-blocking], 530 [build ELPA2 with blocking in band_to_full (default: enabled)])], 531 [ 532 if test x"$enableval" = x"yes"; then 533 enable_band_to_full_blocking=yes 534 else 535 enable_band_to_full_blocking=no 536 fi 537 ], 538 [enable_band_to_full_blocking="yes"]) 539AC_MSG_RESULT([${enable_band_to_full_blocking}]) 540 541AM_CONDITIONAL([BAND_TO_FULL_BLOCKING],[test x"$enable_band_to_full_blocking" = x"yes"]) 542if test x"${enable_band_to_full_blocking}" = x"yes"; then 543 AC_DEFINE([BAND_TO_FULL_BLOCKING], [1], [use blocking in trans_ev_band_to_full]) 544fi 545 546 547AC_ARG_WITH([cuda-path],[AS_HELP_STRING([--with-cuda-path=PATH],[prefix where CUDA is installed @<:@default=auto@:>@])], 548 [CUDA_INSTALL_PATH=$withval], [with_cuda=auto]) 549 550AC_ARG_WITH([cuda-sdk-path],[AS_HELP_STRING([--with-cuda-sdk-path=PATH],[prefix where CUDA SDK is installed @<:@default=auto@:>@])], 551 [CUDA_SDK_INSTALL_PATH=$withval],[with_cuda_sdk=auto]) 552 553 554dnl setup nvcc flags and use them in later tests 555user_sets_gpu_compute_capability="no" 556AC_MSG_CHECKING(whether a GPU compute capability is specified) 557AC_ARG_WITH([GPU-compute-capability], 558 [AS_HELP_STRING([--with-GPU-compute-capability=VALUE], 559 [use compute capability VALUE for GPU version, default: "sm_35"])], 560 [user_sets_gpu_compute_capability="yes"],[cuda_compute_capability="sm_35"]) 561AC_MSG_RESULT([${user_sets_gpu_compute_capability}]) 562 563 564dnl sanity check whether compute capability setting by user is reasonable 565if test x"${user_sets_gpu_compute_capability}" = x"yes" ; then 566 dnl the user must set a value which starts with "sm_" 567 value=$(echo $withval | cut -c1-3) 568 if test x"${value}" = x"sm_" ; then 569 cuda_compute_capability=$withval 570 else 571 AC_MSG_ERROR([Unknown GPU compute capability set: ${withval}]) 572 fi 573fi 574 575 576dnl Test possibility of 'use mpi', if requested 577if test x"${with_mpi}" = x"yes" ; then 578 AC_ARG_ENABLE([mpi-module], 579 AS_HELP_STRING([--disable-mpi-module], 580 [do not use the Fortran MPI module, get interfaces by 'include "mpif.h']), 581 [ 582 if test x"$enableval" = x"yes"; then 583 enable_mpi_module=yes 584 else 585 enable_mpi_module=no 586 fi 587 ], 588 [enable_mpi_module=yes]) 589 if test x"${enable_mpi_module}" = x"yes" ; then 590 AC_MSG_CHECKING(whether Fortran mpi module can be used) 591 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 592 program test_mpi_module 593 use mpi 594 real :: time 595 time = MPI_WTime() 596 end program 597 ])], 598 [can_use_fortran_mpi_module=yes], 599 [can_use_fortran_mpi_module=no] 600 ) 601 AC_MSG_RESULT([${can_use_fortran_mpi_module}]) 602 if test x"${can_use_fortran_mpi_module}" = x"yes" ; then 603 AC_DEFINE([HAVE_MPI_MODULE],[1],[can use the Fortran mpi module]) 604 else 605 AC_MSG_ERROR([Could not compile a Fortran program with an 'use mpi' statement. You can try again with --disable-mpi-module]) 606 fi 607 fi 608fi 609AC_LANG_POP([Fortran]) 610 611dnl Assemble the list of kernels to build 612m4_pattern_forbid([elpa_m4]) 613 614m4_define(elpa_m4_generic_kernels, [ 615 real_generic 616 real_generic_simple 617 real_generic_simple_block4 618 real_generic_simple_block6 619 complex_generic 620 complex_generic_simple 621]) 622 623m4_define(elpa_m4_sse_assembly_kernels, [ 624 real_sse_assembly 625 complex_sse_assembly 626]) 627 628m4_define(elpa_m4_sse_kernels, [ 629 real_sse_block2 630 real_sse_block4 631 real_sse_block6 632 complex_sse_block1 633 complex_sse_block2 634]) 635 636m4_define(elpa_m4_sparc64_kernels, [ 637 real_sparc64_block2 638 real_sparc64_block4 639 real_sparc64_block6 640]) 641 642m4_define(elpa_m4_neon_arch64_kernels, [ 643 real_neon_arch64_block2 644 real_neon_arch64_block4 645 real_neon_arch64_block6 646]) 647 648m4_define(elpa_m4_vsx_kernels, [ 649 real_vsx_block2 650 real_vsx_block4 651 real_vsx_block6 652]) 653 654m4_define(elpa_m4_avx_kernels, [ 655 real_avx_block2 656 real_avx_block4 657 real_avx_block6 658 complex_avx_block1 659 complex_avx_block2 660]) 661 662m4_define(elpa_m4_avx2_kernels, [ 663 real_avx2_block2 664 real_avx2_block4 665 real_avx2_block6 666 complex_avx2_block1 667 complex_avx2_block2 668]) 669 670m4_define(elpa_m4_avx512_kernels, [ 671 real_avx512_block2 672 real_avx512_block4 673 real_avx512_block6 674 complex_avx512_block1 675 complex_avx512_block2 676]) 677 678m4_define(elpa_m4_bgp_kernels, [ 679 real_bgp 680 complex_bgp 681]) 682 683m4_define(elpa_m4_bgq_kernels, [ 684 real_bgq 685 complex_bgq 686]) 687 688m4_define(elpa_m4_gpu_kernels, [ 689 real_gpu 690 complex_gpu 691]) 692 693m4_define(elpa_m4_kernel_types, [generic sparc64 neon_arch64 vsx sse sse_assembly avx avx2 avx512 bgp bgq gpu]) 694 695m4_define(elpa_m4_all_kernels, 696 m4_foreach_w([elpa_m4_type], 697 elpa_m4_kernel_types, 698 [m4_foreach_w([elpa_m4_kernel],[elpa_m4_]elpa_m4_type[_kernels],elpa_m4_kernel )])) 699 700m4_define(elpa_m4_real_kernels, 701 m4_foreach_w(elpa_m4_kernel, 702 elpa_m4_all_kernels, 703 [m4_bmatch(elpa_m4_kernel,real,elpa_m4_kernel) ])) 704 705m4_define(elpa_m4_complex_kernels, 706 m4_foreach_w(elpa_m4_kernel, 707 elpa_m4_all_kernels, 708 [m4_bmatch(elpa_m4_kernel,complex,elpa_m4_kernel) ])) 709 710dnl 711dnl ELPA_SELECT_KERNELS([flagname],[default]) 712dnl 713dnl default should be one of `enable' or `disable' 714dnl 715AC_DEFUN([ELPA_SELECT_KERNELS], [ 716 AC_ARG_ENABLE(m4_bpatsubst($1,[_],[-]),[AS_HELP_STRING([--]m4_case([$2],[enable],[disable],[disable],[enable])[-]m4_bpatsubst($1,[_],[-]), 717 m4_case([$2],[enable],[do not build],[disable],[build])[ ]m4_toupper($1)[ kernels, default: $2d])], 718 [],[enable_$1=]m4_case([$2],[enable],[yes],[disable],[no])) 719 m4_foreach_w(elpa_m4_kernel,elpa_m4_$1_kernels,[ 720 use_[]elpa_m4_kernel[=$enable_$1] 721 ]) 722]) 723 724dnl Modify list of kernels with configure arguments 725ELPA_SELECT_KERNELS([generic],[enable]) 726ELPA_SELECT_KERNELS([sparc64],[disable]) 727ELPA_SELECT_KERNELS([neon_arch64],[disable]) 728ELPA_SELECT_KERNELS([vsx],[disable]) 729ELPA_SELECT_KERNELS([sse],[enable]) 730ELPA_SELECT_KERNELS([sse_assembly],[enable]) 731ELPA_SELECT_KERNELS([avx],[enable]) 732ELPA_SELECT_KERNELS([avx2],[enable]) 733ELPA_SELECT_KERNELS([avx512],[disable]) 734ELPA_SELECT_KERNELS([gpu],[disable]) 735ELPA_SELECT_KERNELS([bgp],[disable]) 736ELPA_SELECT_KERNELS([bgq],[disable]) 737 738m4_foreach_w([elpa_m4_kind],[real complex],[ 739 default_[]elpa_m4_kind[]_kernel="" 740]) 741 742if test x"${enable_bgp}" = x"yes" -o x"$enable_bgq" = x"yes"; then 743 m4_foreach_w([elpa_m4_kernel], elpa_m4_sparc64_kernels elpa_m4_neon_arch64_kernels elpa_m4_vsx_kernels elpa_m4_sse_kernels elpa_m4_avx_kernels elpa_m4_avx2_kernels elpa_m4_avx512_kernels, [ 744 if x"$use_[]elpa_m4_kernel[]" = x"yes" ; then 745 echo "Disabling elpa_m4_kernel due to BGP/BGQ option" 746 fi 747 use_[]elpa_m4_kernel[]=no 748 ]) 749fi 750 751 752dnl Deal with --with-fixed-[real|complex]-kernel arguments 753m4_foreach_w([elpa_m4_kind],[real complex],[ 754 AC_ARG_WITH([fixed-]elpa_m4_kind[-kernel], m4_expand([AS_HELP_STRING([--with-fixed-]elpa_m4_kind[-kernel]=KERNEL, 755 [compile with only a single specific ]elpa_m4_kind[ kernel. Available kernels are:] 756 m4_foreach_w([elpa_m4_kernel],m4_expand(elpa_m4_[]elpa_m4_kind[]_kernels),[m4_bpatsubst(elpa_m4_kernel,elpa_m4_kind[]_,[]) ]))]), 757 [fixed_]elpa_m4_kind[_kernel="]elpa_m4_kind[_$withval"],[fixed_]elpa_m4_kind[_kernel=""]) 758 if test -n "$fixed_[]elpa_m4_kind[]_kernel" ; then 759 found="no" 760 m4_foreach_w([elpa_m4_otherkernel],m4_expand(elpa_m4_[]elpa_m4_kind[]_kernels),[ 761 if test "$fixed_]elpa_m4_kind[_kernel" = "]elpa_m4_otherkernel[" ; then 762 use_[]elpa_m4_otherkernel[]=yes 763 found="yes" 764 else 765 use_[]elpa_m4_otherkernel[]=no 766 fi 767 ]) 768 if test x"$found" = x"no" ; then 769 AC_MSG_ERROR([Invalid kernel "$fixed_]elpa_m4_kind[_kernel" specified for --with-fixed-]elpa_m4_kind[-kernel]) 770 fi 771 default_[]elpa_m4_kind[]_kernel="$fixed_[]elpa_m4_kind[]_kernel" 772 AC_DEFINE([WITH_FIXED_]m4_toupper(elpa_m4_kind)[_KERNEL],[1],[use only one specific ]elpa_m4_kind[ kernel (set at compile time)]) 773 fi 774]) 775 776AC_ARG_WITH(gpu-support-only, [AS_HELP_STRING([--with-gpu-support-only], 777 [Compile and always use the GPU version])], 778 [],[with_gpu_support_only=no]) 779if test x"$with_gpu_support_only" = x"yes" ; then 780 m4_foreach_w([elpa_m4_kernel],elpa_m4_all_kernels,[ 781 use_[]elpa_m4_kernel[]=no 782 ]) 783 use_real_gpu=yes 784 use_complex_gpu=yes 785fi 786 787 788dnl 789dnl ELPA_KERNEL_DEPENDS([kernel],[other kernels]) 790dnl 791dnl Switch on each of the other kernels if the given kernel is selected 792dnl 793AC_DEFUN([ELPA_KERNEL_DEPENDS],[ 794 if test x"$use_$1" = x"yes"; then 795 m4_foreach_w([elpa_m4_requiredkernel],[$2],[ 796 if test x"$use_[]elpa_m4_requiredkernel[]" = x"no" ; then 797 echo "Enabling elpa_m4_requiredkernel kernel, is a prerequisite for $1" 798 fi 799 use_[]elpa_m4_requiredkernel[]=yes 800 ]) 801 fi 802]) 803m4_foreach_w([elpa_m4_arch],[sparc64 neon_arch64 vsx sse avx avx2 avx512],[ 804 ELPA_KERNEL_DEPENDS([real_]elpa_m4_arch[_block6], [real_]elpa_m4_arch[_block4 real_]elpa_m4_arch[_block2]) 805 ELPA_KERNEL_DEPENDS([real_]elpa_m4_arch[_block4], [real_]elpa_m4_arch[_block2]) 806 ELPA_KERNEL_DEPENDS([complex_]elpa_m4_arch[_block2], [complex_]elpa_m4_arch[_block1]) 807]) 808 809m4_foreach_w([elpa_m4_type],elpa_m4_kernel_types,[ 810 need_[]elpa_m4_type=no 811 need_[]elpa_m4_type[]_kernels="" 812 m4_foreach_w([elpa_m4_kernel],m4_expand([elpa_m4_]elpa_m4_type[_kernels]),[ 813 if test x"$use_[]elpa_m4_kernel" = x"yes" ; then 814 need_[]elpa_m4_type=yes 815 need_[]elpa_m4_type[]_kernels="$need_[]elpa_m4_type[]_kernels elpa_m4_kernel" 816 fi 817 ]) 818]) 819m4_foreach_w([elpa_m4_type],elpa_m4_kernel_types,[ 820 if test x"$need_[]elpa_m4_type[]" = x"yes" ; then 821 echo "Using m4_toupper(elpa_m4_type) for kernels$need_[]elpa_m4_type[]_kernels" 822 fi 823]) 824m4_foreach_w([elpa_m4_type],elpa_m4_kernel_types,[ 825 if test x"$need_[]elpa_m4_type[]" != x"yes" ; then 826 echo "Not using m4_toupper(elpa_m4_type) as no selected kernel needs it" 827 fi 828]) 829 830 831dnl the list of kernels is now assembled 832dnl choosing a default kernel 833 834m4_foreach_w([elpa_m4_kind],[real complex],[ 835 AC_ARG_WITH([default-]elpa_m4_kind[-kernel], m4_expand([AS_HELP_STRING([--with-default-]elpa_m4_kind[-kernel]=KERNEL, 836 [set a specific ]elpa_m4_kind[ kernel as default kernel. Available kernels are:] 837 m4_foreach_w([elpa_m4_kernel],m4_expand(elpa_m4_[]elpa_m4_kind[]_kernels),[m4_bpatsubst(elpa_m4_kernel,elpa_m4_kind[]_,[]) ]))]), 838 [default_]elpa_m4_kind[_kernel="]elpa_m4_kind[_$withval"],[default_]elpa_m4_kind[_kernel=""]) 839 #if test -n "$default_[]elpa_m4_kind[]_kernel" ; then 840 # found="no" 841 # m4_foreach_w([elpa_m4_otherkernel],m4_expand(elpa_m4_[]elpa_m4_kind[]_kernels),[ 842 # if test "$default_]elpa_m4_kind[_kernel" = "]elpa_m4_otherkernel[" ; then 843 # use_[]elpa_m4_otherkernel[]=yes 844 # found="yes" 845 # else 846 # use_[]elpa_m4_otherkernel[]=no 847 # fi 848 # ]) 849 # if test x"$found" = x"no" ; then 850 # AC_MSG_ERROR([Invalid kernel "$default_]elpa_m4_kind[_kernel" specified for --with-default-]elpa_m4_kind[-kernel]) 851 # fi 852 # AC_DEFINE([WITH_DEFAULT_]m4_toupper(elpa_m4_kind)[_KERNEL],[1],[use specific ]elpa_m4_kind[ default kernel (set at compile time)]) 853 #fi 854]) 855 856 857 858m4_foreach_w([elpa_m4_kind],[real complex],[ 859 m4_foreach_w([elpa_m4_kernel], 860 m4_foreach_w([elpa_m4_cand_kernel], 861 elpa_m4_avx512_kernels elpa_m4_avx2_kernels elpa_m4_avx_kernels elpa_m4_sse_kernels elpa_m4_sse_assembly_kernels elpa_m4_sparc64_kernels elpa_m4_neon_arch64_kernels elpa_m4_vsx_kernels elpa_m4_generic_kernels, 862 [m4_bmatch(elpa_m4_cand_kernel,elpa_m4_kind,elpa_m4_cand_kernel)] ), 863 [ 864 if test -z "$default_[]elpa_m4_kind[]_kernel"; then 865 if test x"$use_[]elpa_m4_kernel" = x"yes"; then 866 default_[]elpa_m4_kind[]_kernel="elpa_m4_kernel" 867 fi 868 fi 869 ]) 870 if test -z "$default_[]elpa_m4_kind[]_kernel"; then 871 AC_MSG_ERROR([Internal error, could not determine a default kernel]) 872 fi 873 # find the number of this kernel 874 ELPA_2STAGE_[]m4_toupper(elpa_m4_kind)[]_DEFAULT=`grep -i '^ *X(ELPA_2STAGE_'$default_[]elpa_m4_kind[]_kernel'\>' $srcdir/elpa/elpa_constants.h.in | \ 875 perl -pe 's/^[[^,]]*, *//; s/,.*//;'` 876 AC_SUBST([ELPA_2STAGE_]m4_toupper(elpa_m4_kind)[_DEFAULT]) 877]) 878 879dnl #include <fjmfunc.h> 880dnl #include <emmintrin.h> 881dnl int main(int argc, char **argv) { 882dnl __m128d q; 883dnl __m128d h1 = _fjsp_neg_v2r8(q); 884dnl return 0; 885dnl } 886AC_LANG_PUSH([C]) 887 888if test x"${need_vsx}" = x"yes"; then 889 AC_MSG_CHECKING(whether we can compile Altivec VSX with intrinsics in C) 890 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 891#include <altivec.h> 892int main(int argc, char **argv) { 893 __vector double a, b, c; 894 c = vec_add(a,b); 895 return 0; 896} 897 ])], 898 [can_compile_vsx=yes], 899 [can_compile_vsx=no] 900 ) 901 AC_MSG_RESULT([${can_compile_vsx}]) 902 if test x"$can_compile_vsx" != x"yes"; then 903 AC_MSG_ERROR([Could not compile test program, try with --disable-vsx, or adjust the C compiler or CFLAGS]) 904 fi 905 AC_DEFINE([HAVE_VSX_SSE],[1],[Altivec VSX intrinsics are supported on this CPU]) 906fi 907 908if test x"${need_sparc64}" = x"yes"; then 909 AC_MSG_CHECKING(whether we can compile SPARC64 with intrinsics in C) 910 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 911#include <fjmfunc.h> 912#include <emmintrin.h> 913int main(int argc, char **argv) { 914 __m128d tau1; 915 __m128d h1 = _fjsp_neg_v2r8(tau1); 916 return 0; 917} 918 ])], 919 [can_compile_sparc64=yes], 920 [can_compile_sparc64=no] 921 ) 922 AC_MSG_RESULT([${can_compile_sparc64}]) 923 if test x"$can_compile_sparc64" != x"yes"; then 924 AC_MSG_ERROR([Could not compile test program, try with --disable-sparc64, or adjust the C compiler or CFLAGS]) 925 fi 926 AC_DEFINE([HAVE_SPARC64_SSE],[1],[SPARC64 intrinsics are supported on this CPU]) 927fi 928 929if test x"${need_neon_arch64}" = x"yes"; then 930 AC_MSG_CHECKING(whether we can compile NEON ARCH64 with intrinsics in C) 931 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 932#include <arm_neon.h> 933int main(int argc, char **argv) { 934 __Float64x2_t x1, x2, x3, x4; 935 x4 = vfmaq_f64(x1, x2, x3); 936 return 0; 937} 938 ])], 939 [can_compile_neon_arch64=yes], 940 [can_compile_neon_arch64=no] 941 ) 942 AC_MSG_RESULT([${can_compile_neon_arch64}]) 943 if test x"$can_compile_neon_arch64" != x"yes"; then 944 AC_MSG_ERROR([Could not compile test program, try with --disable-neon_arch64, or adjust the C compiler or CFLAGS]) 945 fi 946 AC_DEFINE([HAVE_NEON_ARCH64_SSE],[1],[NEON_ARCH64 intrinsics are supported on this CPU]) 947fi 948 949 950if test x"${need_sse}" = x"yes"; then 951 AC_MSG_CHECKING(whether we can compile SSE3 with gcc intrinsics in C) 952 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 953#include <x86intrin.h> 954int main(int argc, char **argv) { 955 double* q; 956 __m128d h1 = _mm_loaddup_pd(q); 957 return 0; 958} 959 ])], 960 [can_compile_sse=yes], 961 [can_compile_sse=no] 962 ) 963 AC_MSG_RESULT([${can_compile_sse}]) 964 if test x"$can_compile_sse" != x"yes"; then 965 AC_MSG_ERROR([Could not compile test program, try with --disable-sse, or adjust the C compiler or CFLAGS]) 966 fi 967 AC_DEFINE([HAVE_SSE_INTRINSICS],[1],[gcc intrinsics SSE is supported on this CPU]) 968fi 969 970 971if test x"${need_sse_assembly}" = x"yes"; then 972 AC_MSG_CHECKING(whether double-precision SSE assembly kernels can be compiled) 973 974 $CC $CFLAGS -c $srcdir/src/elpa2/kernels/asm_x86_64_double_precision.s -o conftest.o 2>&5 975 976 if test "$?" == 0; then 977 can_compile_sse_asm_double=yes 978 else 979 can_compile_sse_asm_double=no 980 fi 981 rm -f ./conftest.o 982 AC_MSG_RESULT([${can_compile_sse_asm_double}]) 983 if test x"$can_compile_sse_asm_double" != x"yes"; then 984 AC_MSG_ERROR([Could not compile test program, try with --disable-sse-assembly, or adjust the C compiler or CFLAGS]) 985 fi 986 987 if test x"${want_single_precision}" = x"yes" ; then 988 AC_MSG_CHECKING(whether single-precision SSE assembly kernels can be compiled) 989 990 $CC $CFLAGS -c $srcdir/src/elpa2/kernels/asm_x86_64_single_precision.s -o conftest.o 2>&5 991 992 if test "$?" == 0; then 993 can_compile_sse_asm_single=yes 994 else 995 can_compile_sse_asm_single=no 996 fi 997 rm -f ./conftest.o 998 AC_MSG_RESULT([${can_compile_sse_asm_single}]) 999 if test x"$can_compile_sse_asm_single" != x"yes"; then 1000 AC_MSG_ERROR([Could not compile test program, try with --disable-sse-assembly, or adjust the C compiler or CFLAGS]) 1001 fi 1002 fi 1003fi 1004 1005 1006 1007if test x"${need_avx}" = x"yes"; then 1008 dnl check whether one can compile AVX gcc intrinsics 1009 AC_MSG_CHECKING([whether we can compile AVX gcc intrinsics in C]) 1010 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 1011 #include <x86intrin.h> 1012 int main(int argc, char **argv){ 1013 double* q; 1014 __m256d a1_1 = _mm256_load_pd(q); 1015 return 0; 1016 } 1017 ])], 1018 [can_compile_avx=yes], 1019 [can_compile_avx=no] 1020 ) 1021 AC_MSG_RESULT([${can_compile_avx}]) 1022 if test x"$can_compile_avx" != x"yes"; then 1023 AC_MSG_ERROR([Could not compile a test program with AVX, try with --disable-avx, or adjust the C compiler or CFLAGS]) 1024 fi 1025 AC_DEFINE([HAVE_AVX],[1],[AVX is supported on this CPU]) 1026fi 1027 1028 1029if test x"${need_avx2}" = x"yes"; then 1030 AC_MSG_CHECKING([whether we can compile AVX2 gcc intrinsics in C]) 1031 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 1032 #include <x86intrin.h> 1033 int main(int argc, char **argv){ 1034 double* q; 1035 __m256d q1 = _mm256_load_pd(q); 1036 __m256d y1 = _mm256_fmadd_pd(q1, q1, q1); 1037 return 0; 1038 } 1039 ])], 1040 [can_compile_avx2=yes], 1041 [can_compile_avx2=no] 1042 ) 1043 AC_MSG_RESULT([${can_compile_avx2}]) 1044 if test x"$can_compile_avx2" != x"yes"; then 1045 AC_MSG_ERROR([Could not compile a test program with AVX2, try with --disable-avx2, or adjust the C compiler or CFLAGS]) 1046 fi 1047 AC_DEFINE([HAVE_AVX2],[1],[AVX2 is supported on this CPU]) 1048fi 1049 1050 1051if test x"${need_avx512}" = x"yes"; then 1052 AC_MSG_CHECKING([whether we can compile AVX512 gcc intrinsics in C]) 1053 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 1054 #include <x86intrin.h> 1055 int main(int argc, char **argv){ 1056 double* q; 1057 __m512d q1 = _mm512_load_pd(q); 1058 __m512d y1 = _mm512_fmadd_pd(q1, q1, q1); 1059 return 0; 1060 } 1061 ])], 1062 [can_compile_avx512=yes], 1063 [can_compile_avx512=no] 1064 ) 1065 AC_MSG_RESULT([${can_compile_avx512}]) 1066 if test x"$can_compile_avx512" != x"yes"; then 1067 AC_MSG_ERROR([Could not compile a test program with AVX512, adjust the C compiler or CFLAGS]) 1068 fi 1069 AC_DEFINE([HAVE_AVX512],[1],[AVX512 is supported on this CPU]) 1070 1071 if test x"$can_compile_avx512" = x"yes"; then 1072 AC_MSG_CHECKING([whether we compile for Xeon]) 1073 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 1074 #include <x86intrin.h> 1075 int main(int argc, char **argv){ 1076 __m512d sign; 1077 __m512d h1_real; 1078 1079 __m512d x1 = _mm512_xor_pd(h1_real, sign); 1080 return 0; 1081 } 1082 ])], 1083 [can_compile_avx512_xeon=yes], 1084 [can_compile_avx512_xeon=no] 1085 ) 1086 AC_MSG_RESULT([${can_compile_avx512_xeon}]) 1087 1088 AC_MSG_CHECKING([whether we compile for Xeon PHI]) 1089 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 1090 #include <x86intrin.h> 1091 int main(int argc, char **argv){ 1092 __m512d sign; 1093 __m512d h1; 1094 __m512d h2_real; 1095 1096 __m512d x1 = (__m512d) _mm512_xor_epi64((__m512i) h2_real, (__m512i) sign); 1097 return 0; 1098 } 1099 ])], 1100 [can_compile_avx512_xeon_phi=yes], 1101 [can_compile_avx512_xeon_phi=no] 1102 ) 1103 AC_MSG_RESULT([${can_compile_avx512_xeon_phi}]) 1104 1105 # this is needed for the intel compiler 1106 if test x"$can_compile_avx512_xeon" = x"yes" ; then 1107 if test x"$can_compile_avx512_xeon_phi" = x"yes" ; then 1108 # we want only one to be true; this is ugly but could not come up with a better way 1109 grep Phi /proc/cpuinfo > /dev/null 1110 if test x"$?" = x"0" ; then 1111 echo "Xeon PHI found ... disabling AVX512 Xeon" 1112 can_compile_avx512_xeon=no 1113 fi 1114 fi 1115 fi 1116 1117 if test x"$can_compile_avx512_xeon" = x"yes"; then 1118 AC_DEFINE([HAVE_AVX512_XEON],[1],[AVX512 for Xeon is supported on this CPU]) 1119 else 1120 if test x"$can_compile_avx512_xeon_phi" = x"yes"; then 1121 AC_DEFINE([HAVE_AVX512_XEON_PHI],[1],[AVX512 for Xeon-PHI is supported on this CPU]) 1122 else 1123 AC_MSG_ERROR([Oho! We can neither compile AVX512 intrinsics for Xeon nor Xeon Phi. This should not happen!]) 1124 fi 1125 fi 1126 fi 1127fi 1128AC_LANG_POP([C]) 1129 1130 1131AC_LANG_PUSH([Fortran]) 1132if test x"${need_bgp}" = x"yes"; then 1133 AC_MSG_CHECKING([whether we can compile with BGP intrinsics]) 1134 AC_LINK_IFELSE([AC_LANG_SOURCE([ 1135 program test_bgp 1136 complex*16 :: y3,q3,h2 1137 y3 = fxcpmadd(y3,q3,h2) 1138 1139 end program 1140 ])], 1141 [can_compile_bgp=yes], 1142 [can_compile_bgp=no] 1143 ) 1144 AC_MSG_RESULT([${can_compile_bgp}]) 1145 if test x"$can_compile_bgp" != x"yes"; then 1146 AC_MSG_ERROR([Could not compile a test program with BGP intrinsics, adjust the FC compiler or FCFLAGS]) 1147 fi 1148fi 1149 1150 1151if test x"${need_bgq}" = x"yes"; then 1152 AC_MSG_CHECKING([whether we can compile with BGQ intrinsics]) 1153 AC_LINK_IFELSE([AC_LANG_SOURCE([ 1154 program test_bgq 1155 VECTOR(REAL(8))::QPX_h2 1156 real*8 :: hh(10,2) 1157 QPX_h2 = VEC_SPLATS(hh(2,2)) 1158 1159 end program 1160 ])], 1161 [can_compile_bgq=yes], 1162 [can_compile_bgq=no] 1163 ) 1164 AC_MSG_RESULT([${can_compile_bgq}]) 1165 if test x"$can_compile_bgq" != x"yes"; then 1166 AC_MSG_ERROR([Could not compile a test program with BGQ intrinsics, adjust the FC compiler or FCFLAGS]) 1167 fi 1168fi 1169AC_LANG_POP([Fortran]) 1170 1171if test x"${need_gpu}" = x"yes" ; then 1172 AC_LANG_PUSH([C]) 1173 CUDA_CFLAGS="$CUDA_CFLAGS -arch $cuda_compute_capability -O2 -I$CUDA_INSTALL_PATH/include" 1174 LDFLAGS="$LDFLAGS -L$CUDA_INSTALL_PATH/lib64" 1175 NVCCFLAGS="$NVCCFLAGS $CUDA_CFLAGS $CUDA_LDFLAGS" 1176 NVCC="nvcc" 1177 AC_SUBST(NVCC) 1178 AC_SUBST(NVCCFLAGS) 1179 1180 dnl check whether nvcc compiler is found 1181 AC_CHECK_PROG(nvcc_found,nvcc,yes,no) 1182 if test x"${nvcc_found}" = x"no" ; then 1183 AC_MSG_ERROR([nvcc not found; try to set the cuda-path or disable GPU support]) 1184 fi 1185 1186 dnl check whether we find cublas 1187 AC_SEARCH_LIBS([cublasDgemm],[cublas],[have_cublas=yes],[have_cublas=no]) 1188 if test x"${have_cublas}" = x"no"; then 1189 AC_MSG_ERROR([Could not link cublas; try to set the cuda-path or disable GPU support]) 1190 fi 1191 AC_SEARCH_LIBS([cudaMemcpy],[cudart],[have_cudart=yes],[have_cudart=no]) 1192 if test x"${have_cudart}" = x"no"; then 1193 AC_MSG_ERROR([Could not link cudart; try to set the cuda-path or disable GPU support]) 1194 fi 1195 AC_LANG_POP([C]) 1196fi 1197 1198 1199m4_foreach_w([elpa_m4_kernel],elpa_m4_all_kernels,[ 1200 AM_CONDITIONAL([WITH_]m4_toupper(elpa_m4_kernel)[_KERNEL],[test x"$use_[]elpa_m4_kernel[]" = x"yes"]) 1201 if test x"$use_[]elpa_m4_kernel[]" = x"yes" ; then 1202 AC_DEFINE([WITH_]m4_toupper(elpa_m4_kernel)[_KERNEL],[1],[Build elpa_m4_kernel kernel]) 1203 kernel_defined=1 1204 else 1205 kernel_defined=0 1206 fi 1207 [ELPA_2STAGE_]m4_toupper(elpa_m4_kernel)[_COMPILED]=$kernel_defined 1208 AC_SUBST([ELPA_2STAGE_]m4_toupper(elpa_m4_kernel)[_COMPILED]) 1209]) 1210 1211 1212AM_CONDITIONAL([WITH_GPU_VERSION],[test x"$use_real_gpu" = x"yes" -o x"$use_complex_gpu" = x"yes"]) 1213if test x"$use_real_gpu" = x"yes" -o x"$use_complex_gpu" = x"yes" ; then 1214 AC_DEFINE([WITH_GPU_VERSION],[1],[enable GPU support]) 1215 AC_DEFINE([WITH_GPU_KERNEL],[1],[GPU kernel should be build]) 1216 ELPA_2STAGE_COMPLEX_GPU_COMPILED=1 1217 ELPA_2STAGE_REAL_GPU_COMPILED=1 1218else 1219 ELPA_2STAGE_COMPLEX_GPU_COMPILED=0 1220 ELPA_2STAGE_REAL_GPU_COMPILED=0 1221fi 1222AC_SUBST([ELPA_2STAGE_COMPLEX_GPU_COMPILED]) 1223AC_SUBST([ELPA_2STAGE_REAL_GPU_COMPILED]) 1224 1225LT_INIT 1226 1227DX_PDF_FEATURE(OFF) 1228DX_PS_FEATURE(OFF) 1229DX_MAN_FEATURE(ON) 1230DX_HTML_FEATURE(ON) 1231DX_INIT_DOXYGEN([ELPA], [Doxyfile], [docs]) 1232 1233AC_MSG_CHECKING(whether assumed size Fortran arrays should be used) 1234AC_ARG_ENABLE([assumed-size], 1235 AS_HELP_STRING([--disable-assumed-size], 1236 [do NOT use assumed-size Fortran arrays]), 1237 [if test x"$enableval" = x"yes"; then 1238 USE_ASSUMED_SIZE=yes 1239 else 1240 USE_ASSUMED_SIZE=no 1241 fi], 1242 [USE_ASSUMED_SIZE=yes]) 1243AC_MSG_RESULT([${USE_ASSUMED_SIZE}]) 1244AM_CONDITIONAL([WITH_USE_ASSUMED_SIZE],[test x"$USE_ASSUMED_SIZE" = x"yes"]) 1245if test x"${USE_ASSUMED_SIZE}" = x"yes" ; then 1246 AC_DEFINE([USE_ASSUMED_SIZE],[1],[for performance reasons use assumed size Fortran arrays, even if not debuggable]) 1247fi 1248 1249AC_MSG_CHECKING(whether Fortran2008 features should be enabled) 1250AC_ARG_ENABLE([Fortran2008-features], 1251 AS_HELP_STRING([--enable-Fortran2008-features], 1252 [enables some Fortran 2008 features, default yes.]), 1253 [ 1254 if test x"$enableval" = x"yes"; then 1255 enable_fortran2008_features=yes 1256 else 1257 enable_fortran2008_features=no 1258 fi 1259 ], 1260 [enable_fortran2008_features=yes]) 1261AC_MSG_RESULT([${enable_fortran2008_features}]) 1262AM_CONDITIONAL([USE_FORTRAN2008],[test x"$enable_fortran2008_features" = x"yes"]) 1263if test x"${enable_fortran2008_features}" = x"yes"; then 1264 AC_DEFINE([USE_FORTRAN2008], [1], [use some Fortran 2008 features]) 1265fi 1266 1267AC_MSG_CHECKING(whether autotuning functionality should be enabled) 1268AC_ARG_ENABLE([autotuning], 1269 AS_HELP_STRING([--enable-autotuning], 1270 [enables autotuning functionality, default yes.]), 1271 [ 1272 if test x"$enableval" = x"yes"; then 1273 enable_autotuning=yes 1274 else 1275 enable_autotuning=no 1276 fi 1277 ], 1278 [enable_autotuning=yes]) 1279AC_MSG_RESULT([${enable_autotuning}]) 1280AM_CONDITIONAL([ENABLE_AUTOTUNING],[test x"$enable_autotuning" = x"yes"]) 1281if test x"${enable_autotuning}" = x"yes"; then 1282 AC_DEFINE([ENABLE_AUTOTUNING], [1], [enable autotuning functionality]) 1283fi 1284 1285AC_MSG_CHECKING(whether C tests should be provided) 1286AC_ARG_ENABLE([c-tests], 1287 AS_HELP_STRING([--enable-c-tests], 1288 [enables the C tests for elpa, default yes.]), 1289 [ 1290 if test x"$enableval" = x"yes"; then 1291 enable_c_tests=yes 1292 else 1293 enable_c_tests=no 1294 fi 1295 ], 1296 [enable_c_tests=yes]) 1297AC_MSG_RESULT([${enable_c_tests}]) 1298AM_CONDITIONAL([ENABLE_C_TESTS],[test x"$enable_c_tests" = x"yes"]) 1299if test x"${enable_c_tests}" = x"yes"; then 1300 AC_DEFINE([ENABLE_C_TESTS], [1], [enable C tests]) 1301fi 1302 1303AC_MSG_CHECKING(whether we build for K-computer) 1304AC_ARG_ENABLE([K-computer], 1305 AS_HELP_STRING([--enable-K-computer], 1306 [enable builds on K-Computer, default no.]), 1307 [if test x"$enableval"=x"yes"; then 1308 enable_kcomputer=yes 1309 else 1310 enable_kcomputer=no 1311 fi], 1312 [enable_kcomputer=no]) 1313AC_MSG_RESULT([${enable_kcomputer}]) 1314AM_CONDITIONAL([BUILD_KCOMPUTER],[test x"$enable_kcomputer" = x"yes"]) 1315if test x"${enable_kcomputer}" = x"yes"; then 1316 AC_DEFINE([BUILD_KCOMPUTER], [1], [build for K-Computer]) 1317 FC_MODINC="-I" 1318 if test x"${USE_ASSUMED_SIZE}" = x"yes" ; then 1319 AC_MSG_ERROR(on K-computer you have to switch off assumed-size arrays!) 1320 fi 1321 if test x"${enable_fortran2008_features}" = x"yes" ; then 1322 AC_MSG_ERROR(on K-computer you have to switch off Fortran 2008 features!) 1323 fi 1324fi 1325 1326if test x"${want_single_precision}" = x"yes" ; then 1327 AC_DEFINE([WANT_SINGLE_PRECISION_REAL],[1],[build also single-precision for real calculation]) 1328 AC_DEFINE([WANT_SINGLE_PRECISION_COMPLEX],[1],[build also single-precision for complex calculation]) 1329fi 1330AM_CONDITIONAL([WANT_SINGLE_PRECISION_REAL],[test x"$want_single_precision" = x"yes"]) 1331AM_CONDITIONAL([WANT_SINGLE_PRECISION_COMPLEX],[test x"$want_single_precision" = x"yes"]) 1332 1333AC_SUBST([MPI_BINARY]) 1334AC_SUBST([WITH_MKL]) 1335AC_SUBST([WITH_BLACS]) 1336AC_SUBST([FC_MODINC]) 1337AC_SUBST([FC_MODOUT]) 1338AC_SUBST([OPENMP_CFLAGS]) 1339AC_SUBST([OPENMP_FCFLAGS]) 1340AC_SUBST([OPENMP_LDFLAGS]) 1341AC_SUBST([DOXYGEN_OUTPUT_DIR], [docs]) 1342 1343mkdir -p modules private_modules test_modules 1344 1345 1346#gl_VISIBILITY 1347#AH_BOTTOM([#if HAVE_VISIBILITY 1348#define EXPORTED __attribute__((__visibility__("default"))) 1349#define HIDDEN __attribute__((__visibility__("hidden"))) 1350#else 1351#define EXPORTED 1352#define HIDDEN 1353#endif]) 1354 1355 1356# Some part of libtool is too smart and tries to parse the output of 1357# gfortran -v 1358# and catches anything that resembles a -l library link specification. 1359# Unfortunately, recent versions of gfortran emit 1360# -l gfortran 1361# with a space between -l and gfortran. The empty -l is then included 1362# into "postdeps_FC" and causes linking errors later on. 1363postdeps_FC=$(echo $postdeps_FC | sed 's/-l //g') 1364 1365if test x"${with_mpi}" = x"yes"; then 1366 if test x"${enable_openmp}" = x"yes"; then 1367 SUFFIX="_openmp" 1368 else 1369 SUFFIX="" 1370 fi 1371else 1372 if test x"${enable_openmp}" = x"yes"; then 1373 SUFFIX="_onenode_openmp" 1374 else 1375 SUFFIX="_onenode" 1376 fi 1377fi 1378 1379AC_SUBST([SUFFIX]) 1380AC_SUBST([PKG_CONFIG_FILE],[elpa${SUFFIX}-${PACKAGE_VERSION}.pc]) 1381 1382AC_CONFIG_FILES([ 1383 Makefile 1384 Doxyfile 1385 ${PKG_CONFIG_FILE}:elpa.pc.in 1386 elpa/elpa_constants.h 1387 elpa/elpa_version.h 1388]) 1389 1390m4_include([m4/ax_fc_check_define.m4]) 1391AC_MSG_CHECKING([if workaround for broken preprocessor is needed]) 1392 1393need_manual_cpp=no 1394AX_FC_CHECK_DEFINE([__INTEL_COMPILER],[is_intel=yes],[]) 1395AX_FC_CHECK_DEFINE([__PGI],[is_pgi=yes],[]) 1396ACTUAL_FC="$FC" 1397AC_SUBST([ACTUAL_FC]) 1398 1399if test x"$is_intel" = x"yes" ; then 1400 need_manual_cpp=yes 1401fi 1402if test x"$is_pgi" = x"yes" ; then 1403 need_manual_cpp=yes 1404fi 1405 1406if test x"$need_manual_cpp" = x"yes" ; then 1407 AC_MSG_RESULT([yes]) 1408 FC="\$(top_srcdir)/manual_cpp $FC" 1409else 1410 AC_MSG_RESULT([no]) 1411fi 1412 1413if test x"$is_pgi" = x"yes" ; then 1414 AC_DEFINE([PGI_VARIABLE_STRING_BUG], [1], [Work around a PGI bug with variable-length string results]) 1415fi 1416 1417 1418dnl PGI compiler uses -module to specify module output 1419dnl directory. This clashes with libtools -module link option 1420dnl => escape it for libtool with -Xcompiler -module 1421AC_MSG_CHECKING([whether we have to escape '-module' for libtool]) 1422if test x"$FC_MODOUT" = x'-module ' ; then 1423 FC_MODOUT="-Xcompiler $FC_MODOUT -Xcompiler \$(ac_empty)" 1424 FC="\$(top_srcdir)/remove_xcompiler $FC" 1425 AC_MSG_RESULT([yes]) 1426else 1427 AC_MSG_RESULT([no]) 1428fi 1429 1430AC_MSG_CHECKING(whether --enable-python is specified) 1431AC_ARG_ENABLE([python], 1432 AS_HELP_STRING([--enable-python], 1433 [build and install python wrapper, default no.]), 1434 [ 1435 if test x"$enableval" = x"yes"; then 1436 enable_python=yes 1437 else 1438 enable_python=no 1439 fi 1440 ], 1441 [enable_python=no]) 1442AC_MSG_RESULT([${enable_python}]) 1443AM_CONDITIONAL([WITH_PYTHON],[test x"$enable_python" = x"yes"]) 1444if test x"${enable_python}" = x"yes"; then 1445 AC_DEFINE([WITH_PYTHON], [1], [build and install python wrapper]) 1446 # check for python and dependencies 1447 AM_PATH_PYTHON([3.6]) 1448 AC_ARG_VAR([PYTHON_INCLUDE], [Include flags for python, bypassing python-config]) 1449 AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config]) 1450 AS_IF([test -z "$PYTHON_INCLUDE"], [ 1451 AS_IF([test -z "$PYTHON_CONFIG"], [ 1452 AC_PATH_PROGS([PYTHON_CONFIG], 1453 [python$PYTHON_VERSION-config python-config], 1454 [no], 1455 [`dirname $PYTHON`]) 1456 AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON.])]) 1457 ]) 1458 AC_MSG_CHECKING([python include flags]) 1459 PYTHON_INCLUDE=`$PYTHON_CONFIG --includes` 1460 AC_MSG_RESULT([$PYTHON_INCLUDE]) 1461 ]) 1462 AC_MSG_CHECKING([numpy module]) 1463 AS_IF([$PYTHON -c "import numpy"], [AC_MSG_RESULT([found.])], 1464 [AC_MSG_ERROR([cannot find numpy.])]) 1465 AC_MSG_CHECKING([mpi4py module]) 1466 AS_IF([$PYTHON -c "import mpi4py"], [AC_MSG_RESULT([found.])], 1467 [AC_MSG_ERROR([cannot find mpi4py.])]) 1468 AC_MSG_CHECKING([cython module]) 1469 AS_IF([$PYTHON -c "import cython"], [AC_MSG_RESULT([found.])], 1470 [AC_MSG_ERROR([cannot find cython.])]) 1471 AC_CHECK_PROG([cython_found], [cython], [yes], [no]) 1472 if test x"$cython_found" != x"yes" ; then 1473 AC_MSG_ERROR([cython not found.]) 1474 fi 1475 AC_ARG_VAR([NUMPY_INCLUDE], [Include flags for numpy]) 1476 AC_MSG_CHECKING([numpy include flags]) 1477 NUMPY_INCLUDE=-I`$PYTHON -c "import numpy; print(numpy.get_include())"` 1478 AS_IF([test "$NUMPY_INCLUDE" = "-I"], [AC_MSG_ERROR([cannot get numpy include path.])]) 1479 AC_MSG_RESULT([$NUMPY_INCLUDE]) 1480fi 1481AC_MSG_CHECKING(whether --enable-python-tests is specified) 1482AC_ARG_ENABLE([python-tests], 1483 AS_HELP_STRING([--enable-python-tests], 1484 [enable python tests, default no.]), 1485 [ 1486 if test x"$enableval" = x"yes"; then 1487 enable_python_tests=yes 1488 else 1489 enable_python_tests=no 1490 fi 1491 ], 1492 [enable_python_tests=no]) 1493AC_MSG_RESULT([${enable_python_tests}]) 1494AM_CONDITIONAL([WITH_PYTHON_TESTS],[test x"$enable_python_tests" = x"yes"]) 1495if test x"${enable_python_tests}" = x"yes"; then 1496 if test x"${enable_python}" = x"no"; then 1497 AC_MSG_ERROR([Python tests can only be enabled it python is enabled.]) 1498 fi 1499 AC_CHECK_PROG([pytest_found], [pytest], [yes], [no]) 1500 if test x"$pytest_found" != x"yes" ; then 1501 AC_MSG_ERROR([pytest not found.]) 1502 fi 1503fi 1504 1505 1506AC_OUTPUT 1507 1508echo "" 1509echo "The following ELPA2 kernels will be build:" 1510echo "" 1511m4_foreach_w([elpa_m4_kind],[real complex],[ 1512 m4_foreach_w([elpa_m4_kernel],m4_expand(elpa_m4_[]elpa_m4_kind[]_kernels),[ 1513 if test x"$use_[]elpa_m4_kernel" = x"yes" ; then 1514 echo -n " elpa_m4_kernel" 1515 if test "$fixed_]elpa_m4_kind[_kernel" = "]elpa_m4_kernel[" ; then 1516 echo -n " (selected as fixed kernel)" 1517 fi 1518 if test "$default_]elpa_m4_kind[_kernel" = "]elpa_m4_kernel[" ; then 1519 echo -n " (default)" 1520 fi 1521 echo "" 1522 fi 1523 ]) 1524]) 1525 1526#echo " " 1527#echo "***********************************************************************" 1528#echo "* ELPA 2018.11.001 will be the last release where the old, obsolete, *" 1529#echo "* legacy API is enabled by default! In the 2019.05.001 release *" 1530#echo "* the legacy API will be still available (but as default switched *" 1531#echo "* off). With the 2019.11.001 release it will be abolished! *" 1532#echo "***********************************************************************" 1533#echo " " 1534#echo " " 1535#echo "***********************************************************************" 1536#echo "* This is a the first release candidate of ELPA 2019.05.001.rc2 *" 1537#echo "* There might be still some changes until the final release of *" 1538#echo "* ELPA 2019.05.001 *" 1539#echo "***********************************************************************" 1540#echo " " 1541 1542if test x"$enable_kcomputer" = x"yes" ; then 1543 echo " " 1544 echo "Important message:" 1545 echo "On K-computer (at the moment) the automatic creation of the generated" 1546 echo "headers does not work." 1547 echo "call: make -f ../generated_headers.am generated-headers top_srcdir=.." 1548 echo "BEFORE triggering the build with make!" 1549else 1550 if test x"$optional_c_error_argument" = x"yes" ; then 1551 echo "#define OPTIONAL_C_ERROR_ARGUMENT" > elpa/elpa_generated_c_api.h 1552 else 1553 echo "#undef OPTIONAL_C_ERROR_ARGUMENT" > elpa/elpa_generated_c_api.h 1554 fi 1555 make -f $srcdir/generated_headers.am generated-headers top_srcdir="$srcdir" CPP="$CPP" 1556fi 1557 1558