From fe8152ef762a221833dbbddf144ae31fa96ff6fa Mon Sep 17 00:00:00 2001 From: Giovanni La Mura Date: Wed, 4 Sep 2024 18:12:06 +0200 Subject: [PATCH] Enable manual definition of MAGMA folder --- build/configure | 210 +++++++++++++++++++++++++++++++++------------ build/configure.ac | 111 +++++++++++++++++------- 2 files changed, 233 insertions(+), 88 deletions(-) diff --git a/build/configure b/build/configure index 4643b039..f4110fda 100755 --- a/build/configure +++ b/build/configure @@ -24832,12 +24832,12 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # Environment setup - if test "x$HDF5_INCLUDE$HDF5_LIB" = "x"; then + if test "x${HDF5_INCLUDE}${HDF5_LIB}" = "x"; then pkg-config --version > /dev/null use_pkg_config=$? if test "x$use_pkg_config" = "x0"; then declare -a pkg_array=$(pkg-config --list-all | grep hdf5-serial) - for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5-serial + for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5-serial > /dev/null result=$? if test "x$result" = "x0"; then cflags=$(pkg-config --cflags-only-I hdf5-serial) @@ -24846,7 +24846,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu export HDF5_LIB=$(echo "${ldflags:2}") else declare -a pkg_array=$(pkg-config --list-all | grep hdf5) - for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5 + for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5 > /dev/null result=$? if test "x$result" = "x0"; then cflags=$(pkg-config --cflags-only-I hdf5) @@ -25186,7 +25186,7 @@ then : if test "x$use_pkg_config" = "x0"; then # pkg-config is available declare -a pkg_array=$(pkg-config --list-all | grep ${MKL_BUILD}) - for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep ${MKL_BUILD} + for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep ${MKL_BUILD} > /dev/null result=$? if test "x$result" = "x0"; then # MKL was found @@ -25196,7 +25196,7 @@ then : else # MKL was not found, so configuration searches for LAPACKe declare -a pkg_array=$(pkg-config --list-all | grep lapacke${LAPACK_LDSPEC}) - for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapacke${LAPACK_LDSPEC} + for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapacke${LAPACK_LDSPEC} > /dev/null result=$? if test "x$result" = "x0"; then # LAPACKe was found @@ -25207,7 +25207,7 @@ then : if test "x${LAPACKFLAGS}${LAPACKLDFLAGS}" = "x"; then # LAPACKe was not found, so configuration searches for LAPACK declare -a pkg_array=$(pkg-config --list-all | grep lapack${LAPACK_LDSPEC}) - for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapack${LAPACK_LDSPEC} + for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapack${LAPACK_LDSPEC} > /dev/null result=$? if test "x$result" = "x0"; then # LAPACK was found @@ -25270,7 +25270,7 @@ else case e in #( if test "x$use_pkg_config" = "x0"; then # pkg-config is available declare -a pkg_array=$(pkg-config --list-all | grep ${MKL_BUILD}) - for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep ${MKL_BUILD} + for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep ${MKL_BUILD} > /dev/null result=$? if test "x$result" = "x0"; then # MKL was found @@ -25280,7 +25280,7 @@ else case e in #( else # MKL was not found, so configuration searches for LAPACKe declare -a pkg_array=$(pkg-config --list-all | grep lapacke${LAPACK_LDSPEC}) - for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapacke${LAPACK_LDSPEC} + for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapacke${LAPACK_LDSPEC} > /dev/null result=$? if test "x$result" = "x0"; then # LAPACKe was found @@ -25291,7 +25291,7 @@ else case e in #( if test "x${LAPACKFLAGS}${LAPACKLDFLAGS}" = "x"; then # LAPACKe was not found, so configuration searches for LAPACK declare -a pkg_array=$(pkg-config --list-all | grep lapack${LAPACK_LDSPEC}) - for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapack${LAPACK_LDSPEC} + for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapack${LAPACK_LDSPEC} > /dev/null result=$? if test "x$result" = "x0"; then # LAPACK was found @@ -25348,34 +25348,83 @@ then : MAGMALDFLAGS="" else - if test "x$withval" != "xyes" and "x$withval" != "xauto"; then - export MAGMA_HOME=$withval + if test "x$withval" != "xyes"; then + if test "x$withval" != "xauto"; then + export MAGMA_HOME=$withval + fi fi - if test -f /usr/local/cuda/include/cuda.h; then - CUDAFLAGS="-I/usr/local/cuda/include" - CUDALDFLAGS="-L/usr/local/cuda/lib64 -lcudart" - elif test -f /usr/include/cuda.h; then - CUDAFLAGS="-I/usr/include" - CUDALDFLAGS="-lcudart" - elif test "x$CUDA_HOME" != "x"; then - CUDAFLAGS="-I${CUDA_HOME}/include" - CUDALDFLAGS="-L${CUDA_HOME}/lib64 -lcudart" - fi - if test "x$CUDAFLAGS" != "x"; then - if test -f /usr/include/magma_v2.h; then - export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I/usr/include" - export MAGMALDFLAGS="$CUDALDFLAGS -lmagma" - elif test -f /usr/local/include/magma_v2.h; then - export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I/usr/local/include" - export MAGMALDFLAGS="$CUDALDFLAGS -lmagma" - elif test "x$MAGMA_HOME" != "x"; then - export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_HOME}/include" - export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_HOME}/lib -lmagma" - elif test "x$MAGMA_ROOT" != "x"; then - export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_ROOT}/include" - export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_ROOT}/lib -lmagma" + if test "x$ENABLE_ILP64" = "xyes"; then + # 64-bit indices are enabled + MAGMA_ILP64_FLAG="-DMAGMA_ILP64" + MAGMA_LD_SPEC="64" + else + # 64-bit indices are disabled + MAGMA_ILP64_FLAG="" + MAGMA_LD_SPEC="" + fi # end of 64-bit decision tree + pkg-config --version > /dev/null + use_pkg_config=$? + if test "x$use_pkg_config" = "x0"; then + # pkg-config is available + declare -a pkg_array=$(pkg-config --list-all | grep cudart) + for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart > /dev/null + result=$? + if test "x$result" = "x0"; then + # CUDA runtime detected + cuda_pkg=$(for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart) + CUDAFLAGS=$(pkg-config --cflags ${cuda_pkg}) + CUDALDFLAGS=$(pkg-config --libs ${cuda_pkg}) + fi # end of CUDA runtime decision tree + else + # pkg-config is not available + if test -f /usr/local/cuda/include/cuda.h; then + CUDAFLAGS="-I/usr/local/cuda/include" + CUDALDFLAGS="-L/usr/local/cuda/lib64 -lcudart" + elif test -f /usr/include/cuda.h; then + CUDAFLAGS="-I/usr/include" + CUDALDFLAGS="-lcudart" + elif test "x$CUDA_HOME" != "x"; then + CUDAFLAGS="-I${CUDA_HOME}/include" + CUDALDFLAGS="-L${CUDA_HOME}/lib64 -lcudart" + fi + fi # end of pkg-config decision tree + if test "x${MAGMA_ROOT}${MAGMA_HOME}${MAGMA_DIR}" = "x"; then + # MAGMA environment is not defined + if "x$use_pkg_config" = "x0"; then + # use pkg-config to search for MAGMA + declare -a pkg_array=$(pkg-config --list-all | grep magma) + for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep magma > /dev/null + result=$? + if test "x$result" = "x0"; then + # MAGMA was found + magma_pkg=$(for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep magma) + MAGMA_INCLUDE=$(pkg-config --cflags-only-I ${magma_pkg}) + MAGMA_LIBS_DIR=$(pkg-config --cflags-only-L ${magma_pkg}) + export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS ${MAGMA_INCLUDE}" + export MAGMALDFLAGS="$CUDALDFLAGS ${MAGMA_LIBS_DIR} -lmagma" + fi # end of MAGMA decision tree + else + # search for MAGMA in some standard folders + if test "x$CUDAFLAGS" != "x"; then + if test -f /usr/include/magma_v2.h; then + export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS -I/usr/include" + export MAGMALDFLAGS="$CUDALDFLAGS -lmagma" + elif test -f /usr/local/include/magma_v2.h; then + export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS -I/usr/local/include" + export MAGMALDFLAGS="$CUDALDFLAGS -lmagma" + fi + fi + fi # end of pkg-config decision tree + else + # MAGMA environment is defined, so configuration makes sure that MAGMA_ROOT is defined too + if test "x${MAGMA_HOME}" != "x"; then + MAGMA_ROOT="${MAGMA_HOME}" + elif test "x${MAGMA_DIR}" != "x"; then + MAGMA_ROOT="${MAGMA_DIR}" fi + export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_ROOT}/include" + export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_ROOT}/lib -lmagma" fi @@ -25398,30 +25447,77 @@ fi else case e in #( e) - if test -f /usr/local/cuda/include/cuda.h; then - CUDAFLAGS="-I/usr/local/cuda/include" - CUDALDFLAGS="-L/usr/local/cuda/lib64 -lcudart" - elif test -f /usr/include/cuda.h; then - CUDAFLAGS="-I/usr/include" - CUDALDFLAGS="-lcudart" - elif test "x$CUDA_HOME" != "x"; then - CUDAFLAGS="-I${CUDA_HOME}/include" - CUDALDFLAGS="-L${CUDA_HOME}/lib64 -lcudart" - fi - if test "x$CUDAFLAGS" != "x"; then - if test -f /usr/include/magma_v2.h; then - export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I/usr/include" - export MAGMALDFLAGS="$CUDALDFLAGS -lmagma" - elif test -f /usr/local/include/magma_v2.h; then - export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I/usr/local/include" - export MAGMALDFLAGS="$CUDALDFLAGS -lmagma" - elif test "x$MAGMA_HOME" != "x"; then - export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_HOME}/include" - export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_HOME}/lib -lmagma" - elif test "x$MAGMA_ROOT" != "x"; then - export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_ROOT}/include" - export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_ROOT}/lib -lmagma" + if test "x$ENABLE_ILP64" = "xyes"; then + # 64-bit indices are enabled + MAGMA_ILP64_FLAG="-DMAGMA_ILP64" + MAGMA_LD_SPEC="64" + else + # 64-bit indices are disabled + MAGMA_ILP64_FLAG="" + MAGMA_LD_SPEC="" + fi # end of 64-bit decision tree + pkg-config --version > /dev/null + use_pkg_config=$? + if test "x$use_pkg_config" = "x0"; then + # pkg-config is available + declare -a pkg_array=$(pkg-config --list-all | grep cudart) + for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart > /dev/null + result=$? + if test "x$result" = "x0"; then + # CUDA runtime detected + cuda_pkg=$(for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart) + CUDAFLAGS=$(pkg-config --cflags ${cuda_pkg}) + CUDALDFLAGS=$(pkg-config --libs ${cuda_pkg}) + fi # end of CUDA runtime decision tree + else + # pkg-config is not available + if test -f /usr/local/cuda/include/cuda.h; then + CUDAFLAGS="-I/usr/local/cuda/include" + CUDALDFLAGS="-L/usr/local/cuda/lib64 -lcudart" + elif test -f /usr/include/cuda.h; then + CUDAFLAGS="-I/usr/include" + CUDALDFLAGS="-lcudart" + elif test "x$CUDA_HOME" != "x"; then + CUDAFLAGS="-I${CUDA_HOME}/include" + CUDALDFLAGS="-L${CUDA_HOME}/lib64 -lcudart" + fi + fi # end of pkg-config decision tree + if test "x${MAGMA_ROOT}${MAGMA_HOME}${MAGMA_DIR}" = "x"; then + # MAGMA environment is not defined + if "x$use_pkg_config" = "x0"; then + # use pkg-config to search for MAGMA + declare -a pkg_array=$(pkg-config --list-all | grep magma) + for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep magma > /dev/null + result=$? + if test "x$result" = "x0"; then + # MAGMA was found + magma_pkg=$(for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep magma) + MAGMA_INCLUDE=$(pkg-config --cflags-only-I ${magma_pkg}) + MAGMA_LIBS_DIR=$(pkg-config --cflags-only-L ${magma_pkg}) + export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS ${MAGMA_INCLUDE}" + export MAGMALDFLAGS="$CUDALDFLAGS ${MAGMA_LIBS_DIR} -lmagma" + fi # end of MAGMA decision tree + else + # search for MAGMA in some standard folders + if test "x$CUDAFLAGS" != "x"; then + if test -f /usr/include/magma_v2.h; then + export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS -I/usr/include" + export MAGMALDFLAGS="$CUDALDFLAGS -lmagma" + elif test -f /usr/local/include/magma_v2.h; then + export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS -I/usr/local/include" + export MAGMALDFLAGS="$CUDALDFLAGS -lmagma" + fi + fi + fi # end of pkg-config decision tree + else + # MAGMA environment is defined, so configuration makes sure that MAGMA_ROOT is defined too + if test "x${MAGMA_HOME}" != "x"; then + MAGMA_ROOT="${MAGMA_HOME}" + elif test "x${MAGMA_DIR}" != "x"; then + MAGMA_ROOT="${MAGMA_DIR}" fi + export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_ROOT}/include" + export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_ROOT}/lib -lmagma" fi diff --git a/build/configure.ac b/build/configure.ac index 5d6150e2..b49aa826 100644 --- a/build/configure.ac +++ b/build/configure.ac @@ -2,12 +2,12 @@ m4_define( [M4_DETECT_HDF5], [ - if test "x$HDF5_INCLUDE$HDF5_LIB" = "x"; then + if test "x${HDF5_INCLUDE}${HDF5_LIB}" = "x"; then pkg-config --version > /dev/null use_pkg_config=$? if test "x$use_pkg_config" = "x0"; then declare -a pkg_array=$(pkg-config --list-all | grep hdf5-serial) - for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5-serial + for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5-serial > /dev/null result=$? if test "x$result" = "x0"; then cflags=$(pkg-config --cflags-only-I hdf5-serial) @@ -16,7 +16,7 @@ m4_define( export HDF5_LIB=$(echo "${ldflags:2}") else declare -a pkg_array=$(pkg-config --list-all | grep hdf5) - for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5 + for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep hdf5 > /dev/null result=$? if test "x$result" = "x0"; then cflags=$(pkg-config --cflags-only-I hdf5) @@ -98,7 +98,7 @@ m4_define( if test "x$use_pkg_config" = "x0"; then # pkg-config is available declare -a pkg_array=$(pkg-config --list-all | grep ${MKL_BUILD}) - for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep ${MKL_BUILD} + for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep ${MKL_BUILD} > /dev/null result=$? if test "x$result" = "x0"; then # MKL was found @@ -108,7 +108,7 @@ m4_define( else # MKL was not found, so configuration searches for LAPACKe declare -a pkg_array=$(pkg-config --list-all | grep lapacke${LAPACK_LDSPEC}) - for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapacke${LAPACK_LDSPEC} + for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapacke${LAPACK_LDSPEC} > /dev/null result=$? if test "x$result" = "x0"; then # LAPACKe was found @@ -119,7 +119,7 @@ m4_define( if test "x${LAPACKFLAGS}${LAPACKLDFLAGS}" = "x"; then # LAPACKe was not found, so configuration searches for LAPACK declare -a pkg_array=$(pkg-config --list-all | grep lapack${LAPACK_LDSPEC}) - for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapack${LAPACK_LDSPEC} + for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep lapack${LAPACK_LDSPEC} > /dev/null result=$? if test "x$result" = "x0"; then # LAPACK was found @@ -149,30 +149,77 @@ m4_define( m4_define( [M4_DETECT_MAGMA], [ - if test -f /usr/local/cuda/include/cuda.h; then - CUDAFLAGS="-I/usr/local/cuda/include" - CUDALDFLAGS="-L/usr/local/cuda/lib64 -lcudart" - elif test -f /usr/include/cuda.h; then - CUDAFLAGS="-I/usr/include" - CUDALDFLAGS="-lcudart" - elif test "x$CUDA_HOME" != "x"; then - CUDAFLAGS="-I${CUDA_HOME}/include" - CUDALDFLAGS="-L${CUDA_HOME}/lib64 -lcudart" - fi - if test "x$CUDAFLAGS" != "x"; then - if test -f /usr/include/magma_v2.h; then - export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I/usr/include" - export MAGMALDFLAGS="$CUDALDFLAGS -lmagma" - elif test -f /usr/local/include/magma_v2.h; then - export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I/usr/local/include" - export MAGMALDFLAGS="$CUDALDFLAGS -lmagma" - elif test "x$MAGMA_HOME" != "x"; then - export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_HOME}/include" - export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_HOME}/lib -lmagma" - elif test "x$MAGMA_ROOT" != "x"; then - export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_ROOT}/include" - export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_ROOT}/lib -lmagma" + if test "x$ENABLE_ILP64" = "xyes"; then + # 64-bit indices are enabled + MAGMA_ILP64_FLAG="-DMAGMA_ILP64" + MAGMA_LD_SPEC="64" + else + # 64-bit indices are disabled + MAGMA_ILP64_FLAG="" + MAGMA_LD_SPEC="" + fi # end of 64-bit decision tree + pkg-config --version > /dev/null + use_pkg_config=$? + if test "x$use_pkg_config" = "x0"; then + # pkg-config is available + declare -a pkg_array=$(pkg-config --list-all | grep cudart) + for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart > /dev/null + result=$? + if test "x$result" = "x0"; then + # CUDA runtime detected + cuda_pkg=$(for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart) + CUDAFLAGS=$(pkg-config --cflags ${cuda_pkg}) + CUDALDFLAGS=$(pkg-config --libs ${cuda_pkg}) + fi # end of CUDA runtime decision tree + else + # pkg-config is not available + if test -f /usr/local/cuda/include/cuda.h; then + CUDAFLAGS="-I/usr/local/cuda/include" + CUDALDFLAGS="-L/usr/local/cuda/lib64 -lcudart" + elif test -f /usr/include/cuda.h; then + CUDAFLAGS="-I/usr/include" + CUDALDFLAGS="-lcudart" + elif test "x$CUDA_HOME" != "x"; then + CUDAFLAGS="-I${CUDA_HOME}/include" + CUDALDFLAGS="-L${CUDA_HOME}/lib64 -lcudart" + fi + fi # end of pkg-config decision tree + if test "x${MAGMA_ROOT}${MAGMA_HOME}${MAGMA_DIR}" = "x"; then + # MAGMA environment is not defined + if "x$use_pkg_config" = "x0"; then + # use pkg-config to search for MAGMA + declare -a pkg_array=$(pkg-config --list-all | grep magma) + for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep magma > /dev/null + result=$? + if test "x$result" = "x0"; then + # MAGMA was found + magma_pkg=$(for i in "${pkg_array[[@]]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep magma) + MAGMA_INCLUDE=$(pkg-config --cflags-only-I ${magma_pkg}) + MAGMA_LIBS_DIR=$(pkg-config --cflags-only-L ${magma_pkg}) + export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS ${MAGMA_INCLUDE}" + export MAGMALDFLAGS="$CUDALDFLAGS ${MAGMA_LIBS_DIR} -lmagma" + fi # end of MAGMA decision tree + else + # search for MAGMA in some standard folders + if test "x$CUDAFLAGS" != "x"; then + if test -f /usr/include/magma_v2.h; then + export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS -I/usr/include" + export MAGMALDFLAGS="$CUDALDFLAGS -lmagma" + elif test -f /usr/local/include/magma_v2.h; then + export MAGMAFLAGS="-DUSE_MAGMA ${MAGMA_ILP64_FLAG} $CUDAFLAGS -I/usr/local/include" + export MAGMALDFLAGS="$CUDALDFLAGS -lmagma" + fi + fi + fi # end of pkg-config decision tree + else + # MAGMA environment is defined, so configuration makes sure that MAGMA_ROOT is defined too + if test "x${MAGMA_HOME}" != "x"; then + MAGMA_ROOT="${MAGMA_HOME}" + elif test "x${MAGMA_DIR}" != "x"; then + MAGMA_ROOT="${MAGMA_DIR}" fi + export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 $CUDAFLAGS -I${MAGMA_ROOT}/include" + export MAGMALDFLAGS="$CUDALDFLAGS -L${MAGMA_ROOT}/lib -lmagma" fi ] ) @@ -501,8 +548,10 @@ AC_ARG_WITH( AC_SUBST([MAGMAFLAGS], [""]) AC_SUBST([MAGMALDFLAGS], [""]) else - if test "x$withval" != "xyes" and "x$withval" != "xauto"; then - export MAGMA_HOME=$withval + if test "x$withval" != "xyes"; then + if test "x$withval" != "xauto"; then + export MAGMA_HOME=$withval + fi fi M4_DETECT_MAGMA AS_IF( -- GitLab