Configure for GPUs much simplified

Important note: I don't know when CUSOLVER started to exist and to work.
I have assumed Eigensolver for NVHPC v. 19, CUSOLVER for v.2  and later.
This commit is contained in:
Paolo Giannozzi 2022-01-16 11:38:04 +01:00
parent b1244725c8
commit f36362edda
3 changed files with 104 additions and 673 deletions

599
install/configure vendored
View File

@ -676,16 +676,12 @@ FFLAGS
F77
f90rule
SET_MAKE
cuda_path
cuda_extlibs
cuda_libs
cuda_fflags
gpu_runtime
cuda_cflags
cuda_runtime
gpu_arch
CUDA_LDLIBS
CUDA_CFLAGS
NVCCFLAGS
NVCC
ldflags
ld
cppflags
@ -773,7 +769,6 @@ with_cuda
with_cuda_cc
with_cuda_runtime
enable_openacc
enable_cuda_env_check
with_libxc
with_libxc_prefix
with_libxc_include
@ -797,7 +792,6 @@ LIBS
CC
CFLAGS
CPPFLAGS
NVCCFLAGS
F77
FFLAGS'
@ -1434,8 +1428,6 @@ Optional Features:
(default: no)
--enable-static build static executables if possible (default: no)
--enable-openacc Enable compilation with OPENACC [default=yes]
--enable-cuda-env-check The configure script will check CUDA installation
and report problems [default=no]
--enable-signals enable signal trapping (default: no)
Optional Packages:
@ -1490,8 +1482,6 @@ Some influential environment variables:
CFLAGS C compiler flags
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
NVCCFLAGS Additional nvcc flags (example: NVCCFLAGS="-arch=compute_30
-code=sm_30")
F77 Fortran 77 compiler command
FFLAGS Fortran 77 compiler flags
@ -1651,52 +1641,6 @@ fi
} # ac_fn_c_try_compile
# ac_fn_c_try_link LINENO
# -----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_link ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext conftest$ac_exeext
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
test -x conftest$ac_exeext
}; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
# Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
# created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
# interfere with the next link command; also delete a directory that is
# left behind by Apple's compiler. We do this before executing the actions.
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_link
# ac_fn_f77_try_compile LINENO
# ----------------------------
# Try to compile conftest.$ac_ext, and return whether this succeeded.
@ -1826,6 +1770,52 @@ fi
as_fn_set_status $ac_retval
} # ac_fn_fc_try_link
# ac_fn_c_try_link LINENO
# -----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_link ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext conftest$ac_exeext
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
test -x conftest$ac_exeext
}; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
# Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
# created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
# interfere with the next link command; also delete a directory that is
# left behind by Apple's compiler. We do this before executing the actions.
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_link
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
@ -4163,15 +4153,14 @@ test_ldflags="`echo $ldflags | sed 's/\$([^)]*)//g'`"
# Checking CUDA...
# Variables
NVCC=no
CUDA_CFLAGS=
CUDA_LDLIBS=
cuda_path=
gpu_arch=
cuda_runtime=
cuda_cflags=
cuda_fflags=
cuda_libs=
cuda_extlibs=
# FIXME: currently devxlib is needed also for non-CUDA compilation
cuda_extlibs=devxlib
# Provide your CUDA path with this
@ -4209,18 +4198,12 @@ else
fi
# Check whether --enable-cuda-env-check was given.
if test "${enable_cuda_env_check+set}" = set; then :
enableval=$enable_cuda_env_check;
else
enable_cuda_env_check=no
fi
if test "$f90_major_version" -gt 20 || (test "$f90_major_version" -eq 20 && test "$f90_minor_version" -ge 7); then
# NVHPC v. 20.7 and later
mMcuda="-cuda -gpu"
mMcudalib="-cudalib"
else
# NVHPC previous to v. 20.7
mMcuda="-Mcuda"
mMcudalib="-Mcudalib"
fi
@ -4228,7 +4211,7 @@ fi
if test "x$with_cuda" != "xno"
then
# -----------------------------------------
# Check compiler is PGI
# Check compiler
# -----------------------------------------
ac_ext=${ac_fc_srcext-f}
ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
@ -4326,461 +4309,23 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test "x$have_cudafor" != "xyes"
then
as_fn_error $? "You do not have the cudafor module. Are you using a PGI compiler?" "$LINENO" 5
as_fn_error $? "You do not have the cudafor module. Are you using NVHPC compiler?" "$LINENO" 5
fi
# -----------------------------------------
# Setup CUDA paths
# Headers and libraries
# -----------------------------------------
if test "x$with_cuda" != "xyes"
then
#AX_NORMALIZE_PATH([with_cuda], ["/"])
CUDAPATH="$with_cuda"
CUDA_CFLAGS+=" -I$with_cuda/include"
CUDA_LDLIBS+=" -L$with_cuda/lib64"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for /usr/local/cuda/" >&5
$as_echo_n "checking for /usr/local/cuda/... " >&6; }
if ${ac_cv_file__usr_local_cuda_+:} false; then :
$as_echo_n "(cached) " >&6
else
test "$cross_compiling" = yes &&
as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5
if test -r "/usr/local/cuda/"; then
ac_cv_file__usr_local_cuda_=yes
else
ac_cv_file__usr_local_cuda_=no
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__usr_local_cuda_" >&5
$as_echo "$ac_cv_file__usr_local_cuda_" >&6; }
if test "x$ac_cv_file__usr_local_cuda_" = xyes; then :
CUDAPATH="/usr/local/cuda"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for /usr/local/cuda/include" >&5
$as_echo_n "checking for /usr/local/cuda/include... " >&6; }
if ${ac_cv_file__usr_local_cuda_include+:} false; then :
$as_echo_n "(cached) " >&6
else
test "$cross_compiling" = yes &&
as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5
if test -r "/usr/local/cuda/include"; then
ac_cv_file__usr_local_cuda_include=yes
else
ac_cv_file__usr_local_cuda_include=no
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__usr_local_cuda_include" >&5
$as_echo "$ac_cv_file__usr_local_cuda_include" >&6; }
if test "x$ac_cv_file__usr_local_cuda_include" = xyes; then :
CUDA_CFLAGS+=" -I/usr/local/cuda/include"
else
CUDA_CFLAGS=""
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for /usr/local/cuda/lib64" >&5
$as_echo_n "checking for /usr/local/cuda/lib64... " >&6; }
if ${ac_cv_file__usr_local_cuda_lib64+:} false; then :
$as_echo_n "(cached) " >&6
else
test "$cross_compiling" = yes &&
as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5
if test -r "/usr/local/cuda/lib64"; then
ac_cv_file__usr_local_cuda_lib64=yes
else
ac_cv_file__usr_local_cuda_lib64=no
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__usr_local_cuda_lib64" >&5
$as_echo "$ac_cv_file__usr_local_cuda_lib64" >&6; }
if test "x$ac_cv_file__usr_local_cuda_lib64" = xyes; then :
CUDA_LDLIBS+=" -L/usr/local/cuda/lib64"
fi
fi
CUDA_LDLIBS+=" -lcuda -lcudart -lcublas -lcufft"
# -----------------------------------------
# Checking for nvcc
# -----------------------------------------
# Extract the first word of "nvcc", so it can be a program name with args.
set dummy nvcc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_NVCC+:} false; then :
$as_echo_n "(cached) " >&6
else
case $NVCC in
[\\/]* | ?:[\\/]*)
ac_cv_path_NVCC="$NVCC" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
as_dummy="$PATH:$CUDAPATH/bin"
for as_dir in $as_dummy
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_NVCC="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_NVCC" && ac_cv_path_NVCC="no"
;;
esac
fi
NVCC=$ac_cv_path_NVCC
if test -n "$NVCC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $NVCC" >&5
$as_echo "$NVCC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$NVCC" = "xno" && test "x$enable_cuda_env_check" = "xyes"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find nvcc compiler. To enable CUDA, please add path to
nvcc in the PATH environment variable and/or specify the path
where CUDA is installed using: --with-cuda=PATH" >&5
$as_echo "$as_me: WARNING: Cannot find nvcc compiler. To enable CUDA, please add path to
nvcc in the PATH environment variable and/or specify the path
where CUDA is installed using: --with-cuda=PATH" >&2;}
fi
# -----------------------------------------
# Setup nvcc flags
# -----------------------------------------
if test x$DEBUG = xtrue
then
NVCCFLAGS+=" -g -arch=compute_$with_cuda_cc -code=sm_$with_cuda_cc"
else
NVCCFLAGS+=" -O3 -arch=compute_$with_cuda_cc -code=sm_$with_cuda_cc"
fi
# -----------------------------------------
# Check if nvcc works
# -----------------------------------------
ac_compile_nvcc=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether nvcc works" >&5
$as_echo_n "checking whether nvcc works... " >&6; }
cat>conftest.cu<<EOF
__global__ static void test_cuda() {
const int tid = threadIdx.x;
const int bid = blockIdx.x;
__syncthreads();
}
EOF
if test "x$NVCC" != "xno"
then
if $NVCC -c $NVCCFLAGS conftest.cu &> /dev/null
then
ac_compile_nvcc=yes
fi
fi
rm -f conftest.cu conftest.o
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_compile_nvcc" >&5
$as_echo "$ac_compile_nvcc" >&6; }
if test "x$ac_compile_nvcc" = "xno" && test "x$enable_cuda_env_check" = "xyes"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: CUDA compiler has problems." >&5
$as_echo "$as_me: WARNING: CUDA compiler has problems." >&2;}
fi
# -----------------------------------------
# Check for headers and libraries
# -----------------------------------------
ax_save_CXXFLAGS="${CXXFLAGS}"
ax_save_LIBS="${LIBS}"
FCFLAGS="$CUDA_CFLAGS $CXXFLAGS"
LIBS="$CUDA_LDLIBS $LIBS"
# And the header and the lib
if test "x$enable_cuda_env_check" = "xyes"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cuInit in -lcuda" >&5
$as_echo_n "checking for cuInit in -lcuda... " >&6; }
if ${ac_cv_lib_cuda_cuInit+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lcuda $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char cuInit ();
int
main ()
{
return cuInit ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_cuda_cuInit=yes
else
ac_cv_lib_cuda_cuInit=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cuda_cuInit" >&5
$as_echo "$ac_cv_lib_cuda_cuInit" >&6; }
if test "x$ac_cv_lib_cuda_cuInit" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBCUDA 1
_ACEOF
LIBS="-lcuda $LIBS"
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "Couldn't find libcuda
See \`config.log' for more details" "$LINENO" 5; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cudaMalloc in -lcudart" >&5
$as_echo_n "checking for cudaMalloc in -lcudart... " >&6; }
if ${ac_cv_lib_cudart_cudaMalloc+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lcudart $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char cudaMalloc ();
int
main ()
{
return cudaMalloc ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_cudart_cudaMalloc=yes
else
ac_cv_lib_cudart_cudaMalloc=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cudart_cudaMalloc" >&5
$as_echo "$ac_cv_lib_cudart_cudaMalloc" >&6; }
if test "x$ac_cv_lib_cudart_cudaMalloc" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBCUDART 1
_ACEOF
LIBS="-lcudart $LIBS"
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "Couldn't find libcudart
See \`config.log' for more details" "$LINENO" 5; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cublasInit in -lcublas" >&5
$as_echo_n "checking for cublasInit in -lcublas... " >&6; }
if ${ac_cv_lib_cublas_cublasInit+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lcublas $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char cublasInit ();
int
main ()
{
return cublasInit ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_cublas_cublasInit=yes
else
ac_cv_lib_cublas_cublasInit=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cublas_cublasInit" >&5
$as_echo "$ac_cv_lib_cublas_cublasInit" >&6; }
if test "x$ac_cv_lib_cublas_cublasInit" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBCUBLAS 1
_ACEOF
LIBS="-lcublas $LIBS"
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "Couldn't find libcublas
See \`config.log' for more details" "$LINENO" 5; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cufftPlanMany in -lcufft" >&5
$as_echo_n "checking for cufftPlanMany in -lcufft... " >&6; }
if ${ac_cv_lib_cufft_cufftPlanMany+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lcufft $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char cufftPlanMany ();
int
main ()
{
return cufftPlanMany ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_cufft_cufftPlanMany=yes
else
ac_cv_lib_cufft_cufftPlanMany=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cufft_cufftPlanMany" >&5
$as_echo "$ac_cv_lib_cufft_cufftPlanMany" >&6; }
if test "x$ac_cv_lib_cufft_cufftPlanMany" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBCUFFT 1
_ACEOF
LIBS="-lcufft $LIBS"
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "Couldn't find libcufft
See \`config.log' for more details" "$LINENO" 5; }
fi
fi
new_cusolver="yes"
CC_stash=$CC
CC=nvcc
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cusolverDnZhegvdx_bufferSize in -lcusolver" >&5
$as_echo_n "checking for cusolverDnZhegvdx_bufferSize in -lcusolver... " >&6; }
if ${ac_cv_lib_cusolver_cusolverDnZhegvdx_bufferSize+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lcusolver $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char cusolverDnZhegvdx_bufferSize ();
int
main ()
{
return cusolverDnZhegvdx_bufferSize ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_cusolver_cusolverDnZhegvdx_bufferSize=yes
else
ac_cv_lib_cusolver_cusolverDnZhegvdx_bufferSize=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cusolver_cusolverDnZhegvdx_bufferSize" >&5
$as_echo "$ac_cv_lib_cusolver_cusolverDnZhegvdx_bufferSize" >&6; }
if test "x$ac_cv_lib_cusolver_cusolverDnZhegvdx_bufferSize" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBCUSOLVER 1
_ACEOF
LIBS="-lcusolver $LIBS"
else
new_cusolver="no"
fi
CC=$CC_stash
# Returning to the original flags
CXXFLAGS=${ax_save_CXXFLAGS}
LIBS=${ax_save_LIBS}
try_dflags="$try_dflags -D__CUDA"
cuda_extlibs="devxlib"
cuda_libs="$mMcudalib=cufft,cublas,cusolver,curand \$(TOPDIR)/external/devxlib/src/libdevXlib.a"
cuda_fflags="$mMcuda=cc$with_cuda_cc,cuda$with_cuda_runtime"
cuda_fflags="$cuda_fflags \$(MOD_FLAG)\$(TOPDIR)/external/devxlib/src"
cuda_fflags="$cuda_fflags \$(MOD_FLAG)\$(TOPDIR)/external/devxlib/include"
if test ${new_cusolver} != yes; then
# -----------------------------------------
# Fortran flags
# -----------------------------------------
if test "$f90_major_version" -le 19; then
# NVHPC v. 19 and previous: new solver not avaliable
cuda_fflags="$cuda_fflags \$(MOD_FLAG)\$(TOPDIR)/EIGENSOLVER_GPU/lib_eigsolve"
cuda_extlibs="$cuda_extlibs eigensolver"
cuda_libs="$cuda_libs \$(TOPDIR)/EIGENSOLVER_GPU/lib_eigsolve/lib_eigsolve.a"
@ -4789,25 +4334,22 @@ $as_echo "$as_me: WARNING: Using legacy custom solver." >&2;}
else
try_dflags="$try_dflags -D__USE_CUSOLVER"
fi
# -----------------------------------------
# C flags - not sure whether they are suitable for old version as well
# -----------------------------------------
cuda_cflags=" -I$with_cuda/include -gpu=cc$with_cuda_cc,cuda$with_cuda_runtime"
ldflags="$ldflags $mMcuda=cc$with_cuda_cc,cuda$with_cuda_runtime"
gpu_arch="$with_cuda_cc"
gpu_runtime="$with_cuda_runtime"
cuda_path="$CUDAPATH"
cuda_runtime="$with_cuda_runtime"
if test "$enable_openacc" == "yes"; then
ldflags="$ldflags -acc"
cuda_fflags="$cuda_fflags -acc"
CUDA_CFLAGS="$CUDA_CFLAGS -acc -gpu=cc$with_cuda_cc,cuda$with_cuda_runtime"
cuda_cflags="$cuda_cflags -acc"
fi
fi
# Announcing the new variables
# For C (maybe needed in the future)
# And for Fortran
@ -7513,6 +7055,7 @@ $as_echo "${elpa_libs}" >&6; }
# Setting HDF5...
# Check whether --with-hdf5 was given.
if test "${with_hdf5+set}" = set; then :
withval=$with_hdf5; if test "$withval" = "no" ; then

View File

@ -1,4 +1,4 @@
# Copyright (C) 2001-2016 Quantum ESPRESSO Foundation
# Copyright (C) 2001-2022 Quantum ESPRESSO Foundation
#####
#
# SYNOPSIS
@ -7,25 +7,15 @@
#
# DESCRIPTION
#
# Figures out if CUDA Driver API/nvcc is available, i.e. existence of:
# nvcc
# cuda.h
# libcuda.a
#
# If something isn't found, fails straight away.
#
# The following variables (for C) are substituted in the makefile:
# NVCC : the nvcc compiler command.
# NVCCFLAGS : nvcc specific flags
# CUDA_CFLAGS : CUDA includes
# CUDA_LDLIBS : CUDA libraries
# For Fortran:
# Simplified compilation for NVidia GPUs using nvhpc compiler
# Assumes a standard installation of a recente nvhpc sdk
# The following variables are substituted in the makefile:
# gpu_arch
# gpu_runtime
# cuda_runtime
# cuda_cflags
# cuda_fflags
# cuda_libs
# cuda_extlibs
# cuda_path
#
# LICENCE
# Public domain
@ -35,13 +25,13 @@
AC_DEFUN([X_AC_QE_CUDA], [
# Variables
NVCC=no
CUDA_CFLAGS=
CUDA_LDLIBS=
cuda_path=
gpu_arch=
cuda_runtime=
cuda_cflags=
cuda_fflags=
cuda_libs=
cuda_extlibs=
# FIXME: currently devxlib is needed also for non-CUDA compilation
cuda_extlibs=devxlib
# Provide your CUDA path with this
AC_ARG_WITH([cuda],
@ -64,15 +54,12 @@ AC_ARG_ENABLE([openacc],
[],
[enable_openacc=yes])
AC_ARG_ENABLE([cuda-env-check],
[AS_HELP_STRING([--enable-cuda-env-check],[The configure script will check CUDA installation and report problems @<:@default=no@:>@])],
[],
[enable_cuda_env_check=no])
if test "$f90_major_version" -gt 20 || (test "$f90_major_version" -eq 20 && test "$f90_minor_version" -ge 7); then
# NVHPC v. 20.7 and later
mMcuda="-cuda -gpu"
mMcudalib="-cudalib"
else
# NVHPC previous to v. 20.7
mMcuda="-Mcuda"
mMcudalib="-Mcudalib"
fi
@ -80,7 +67,7 @@ fi
if test "x$with_cuda" != "xno"
then
# -----------------------------------------
# Check compiler is PGI
# Check compiler
# -----------------------------------------
AC_LANG_PUSH([Fortran])
AC_FC_SRCEXT([f90])
@ -88,116 +75,23 @@ then
AC_LANG_POP([Fortran])
if test "x$have_cudafor" != "xyes"
then
AC_MSG_ERROR([You do not have the cudafor module. Are you using a PGI compiler?])
AC_MSG_ERROR([You do not have the cudafor module. Are you using NVHPC compiler?])
fi
# -----------------------------------------
# Setup CUDA paths
# Headers and libraries
# -----------------------------------------
if test "x$with_cuda" != "xyes"
then
#AX_NORMALIZE_PATH([with_cuda], ["/"])
CUDAPATH="$with_cuda"
CUDA_CFLAGS+=" -I$with_cuda/include"
CUDA_LDLIBS+=" -L$with_cuda/lib64"
else
AC_CHECK_FILE(/usr/local/cuda/,[CUDAPATH="/usr/local/cuda"],[])
AC_CHECK_FILE(/usr/local/cuda/include,[CUDA_CFLAGS+=" -I/usr/local/cuda/include"],[CUDA_CFLAGS=""])
AC_CHECK_FILE(/usr/local/cuda/lib64,[CUDA_LDLIBS+=" -L/usr/local/cuda/lib64"],[])
fi
CUDA_LDLIBS+=" -lcuda -lcudart -lcublas -lcufft"
# -----------------------------------------
# Checking for nvcc
# -----------------------------------------
AC_PATH_PROG([NVCC],[nvcc],[no],[$PATH:$CUDAPATH/bin])
if test "x$NVCC" = "xno" && test "x$enable_cuda_env_check" = "xyes"
then
AC_MSG_WARN([Cannot find nvcc compiler. To enable CUDA, please add path to
nvcc in the PATH environment variable and/or specify the path
where CUDA is installed using: --with-cuda=PATH])
fi
# -----------------------------------------
# Setup nvcc flags
# -----------------------------------------
AC_ARG_VAR(NVCCFLAGS,[Additional nvcc flags (example: NVCCFLAGS="-arch=compute_30 -code=sm_30")])
if test x$DEBUG = xtrue
then
NVCCFLAGS+=" -g -arch=compute_$with_cuda_cc -code=sm_$with_cuda_cc"
else
NVCCFLAGS+=" -O3 -arch=compute_$with_cuda_cc -code=sm_$with_cuda_cc"
fi
# -----------------------------------------
# Check if nvcc works
# -----------------------------------------
ac_compile_nvcc=no
AC_MSG_CHECKING([whether nvcc works])
cat>conftest.cu<<EOF
__global__ static void test_cuda() {
const int tid = threadIdx.x;
const int bid = blockIdx.x;
__syncthreads();
}
EOF
if test "x$NVCC" != "xno"
then
if $NVCC -c $NVCCFLAGS conftest.cu &> /dev/null
then
ac_compile_nvcc=yes
fi
fi
rm -f conftest.cu conftest.o
AC_MSG_RESULT([$ac_compile_nvcc])
if test "x$ac_compile_nvcc" = "xno" && test "x$enable_cuda_env_check" = "xyes"
then
AC_MSG_WARN([CUDA compiler has problems.])
fi
# -----------------------------------------
# Check for headers and libraries
# -----------------------------------------
ax_save_CXXFLAGS="${CXXFLAGS}"
ax_save_LIBS="${LIBS}"
FCFLAGS="$CUDA_CFLAGS $CXXFLAGS"
LIBS="$CUDA_LDLIBS $LIBS"
# And the header and the lib
if test "x$enable_cuda_env_check" = "xyes"
then
AC_CHECK_LIB([cuda], [cuInit], [], AC_MSG_FAILURE([Couldn't find libcuda]))
AC_CHECK_LIB([cudart], [cudaMalloc], [], AC_MSG_FAILURE([Couldn't find libcudart]))
AC_CHECK_LIB([cublas], [cublasInit], [], AC_MSG_FAILURE([Couldn't find libcublas]))
AC_CHECK_LIB([cufft], [cufftPlanMany], [], AC_MSG_FAILURE([Couldn't find libcufft]))
fi
new_cusolver="yes"
CC_stash=$CC
CC=nvcc
AC_CHECK_LIB([cusolver], [cusolverDnZhegvdx_bufferSize], [], new_cusolver="no")
CC=$CC_stash
# Returning to the original flags
CXXFLAGS=${ax_save_CXXFLAGS}
LIBS=${ax_save_LIBS}
try_dflags="$try_dflags -D__CUDA"
cuda_extlibs="devxlib"
cuda_libs="$mMcudalib=cufft,cublas,cusolver,curand \$(TOPDIR)/external/devxlib/src/libdevXlib.a"
cuda_fflags="$mMcuda=cc$with_cuda_cc,cuda$with_cuda_runtime"
cuda_fflags="$cuda_fflags \$(MOD_FLAG)\$(TOPDIR)/external/devxlib/src"
cuda_fflags="$cuda_fflags \$(MOD_FLAG)\$(TOPDIR)/external/devxlib/include"
if test ${new_cusolver} != yes; then
# -----------------------------------------
# Fortran flags
# -----------------------------------------
if test "$f90_major_version" -le 19; then
# NVHPC v. 19 and previous: new solver not avaliable
cuda_fflags="$cuda_fflags \$(MOD_FLAG)\$(TOPDIR)/EIGENSOLVER_GPU/lib_eigsolve"
cuda_extlibs="$cuda_extlibs eigensolver"
cuda_libs="$cuda_libs \$(TOPDIR)/EIGENSOLVER_GPU/lib_eigsolve/lib_eigsolve.a"
@ -205,29 +99,26 @@ EOF
else
try_dflags="$try_dflags -D__USE_CUSOLVER"
fi
# -----------------------------------------
# C flags - not sure whether they are suitable for old version as well
# -----------------------------------------
cuda_cflags=" -I$with_cuda/include -gpu=cc$with_cuda_cc,cuda$with_cuda_runtime"
ldflags="$ldflags $mMcuda=cc$with_cuda_cc,cuda$with_cuda_runtime"
gpu_arch="$with_cuda_cc"
gpu_runtime="$with_cuda_runtime"
cuda_path="$CUDAPATH"
cuda_runtime="$with_cuda_runtime"
if test "$enable_openacc" == "yes"; then
ldflags="$ldflags -acc"
cuda_fflags="$cuda_fflags -acc"
CUDA_CFLAGS="$CUDA_CFLAGS -acc -gpu=cc$with_cuda_cc,cuda$with_cuda_runtime"
cuda_cflags="$cuda_cflags -acc"
fi
fi
# Announcing the new variables
# For C (maybe needed in the future)
AC_SUBST([NVCC])
AC_SUBST([NVCCFLAGS])
AC_SUBST([CUDA_CFLAGS])
AC_SUBST([CUDA_LDLIBS])
# And for Fortran
AC_SUBST(gpu_arch)
AC_SUBST(gpu_runtime)
AC_SUBST(cuda_runtime)
AC_SUBST(cuda_cflags)
AC_SUBST(cuda_fflags)
AC_SUBST(cuda_libs)
AC_SUBST(cuda_extlibs)
AC_SUBST(cuda_path)
])

View File

@ -89,20 +89,17 @@ MPIF90 = @mpif90@
F90 = @f90@
CC = @cc@
# CUDA Toolkit path
CUDA_PATH=@cuda_path@
# GPU architecture (Kepler: 35, Pascal: 60, Volta: 70 )
GPU_ARCH=@gpu_arch@
# CUDA runtime (Pascal: 8.0, Volta: 9.0)
CUDA_RUNTIME=@gpu_runtime@
CUDA_RUNTIME=@cuda_runtime@
# CUDA F90 Flags
CUDA_F90FLAGS=@cuda_fflags@ $(MOD_FLAG)$(TOPDIR)/external/devxlib/src
# CUDA C Flags
CUDA_CFLAGS=@CUDA_CFLAGS@
CUDA_CFLAGS=@cuda_cflags@
# C preprocessor and preprocessing flags - for explicit preprocessing,
# if needed (see the compilation rules above)
@ -174,7 +171,7 @@ MASS_LIBS = @mass_libs@
# CUDA libraries
CUDA_LIBS=@cuda_libs@ -L$(TOPDIR)/external/devxlib/src -ldevXlib
CUDA_EXTLIBS = devxlib @cuda_extlibs@
CUDA_EXTLIBS = @cuda_extlibs@
# ar command and flags - for most architectures: AR = ar, ARFLAGS = ruv