improved CUDA/DKS checks

This commit is contained in:
suter_a 2016-03-07 16:41:07 +01:00
parent b157d01506
commit d9a35a25bb

View File

@ -852,28 +852,91 @@ dnl -----------------------------------------------
dnl Ask user if DKS support should be enabled (DKS = Dynamic Kernel Scheduler. Used to interface GPU's, MIC, etc) dnl Ask user if DKS support should be enabled (DKS = Dynamic Kernel Scheduler. Used to interface GPU's, MIC, etc)
dnl ----------------------------------------------- dnl -----------------------------------------------
AC_ARG_ENABLE([dks], [AS_HELP_STRING([--enable-dks],[build musrfit with DKS (GPU/MIC) support [default=no]])], [DKS_ENABLED=1], [DKS_ENABLED=0]) AC_ARG_ENABLE([dks], [AS_HELP_STRING([--enable-dks],[build musrfit with DKS (GPU/MIC) support [default=no]])], [
DKS_LIBDIR=""
DKS_INCDIR=""
DKS_LIBS=""
DKS_CFLAGS=""
DKS_LIBDIR="" dnl ---------------------------------------------
DKS_INCDIR="" dnl Check (i) that Cuda is found. (ii) that DKS is found
DKS_LIBS="" dnl Eventually also openCL only should be tested, i.e. DKS without Cuda
DKS_CFLAGS="" dnl This could also mean openCL without GPU, e.g. on Mac OS X
if test "${DKS_ENABLED}" == "1"; then dnl ---------------------------------------------
dnl ---------------------------------------------
dnl Eventually some strict testing about the availibilty of DKS should go in here dnl ---------------------------------------------
dnl Most probably it will be most sensible to ship DKS with the musrfit source code dnl check for Cuda
dnl All hard wired stuff needs to disappear dnl ---------------------------------------------
dnl --------------------------------------------- AC_ARG_WITH([cuda],
AC_DEFINE([HAVE_DKS], [1], [Define to 1 if DKS is available]) [AS_HELP_STRING([--with-cuda],[prefix of the CUDA installation, e.g. /usr/local/cuda])],
AC_DEFINE([DKS_CUDA], [1], [Define to 1 if DKS Cuda is available]) [cuda_prefix=$withval],
DKS_CUDADIR="/usr/local/cuda-6.5/targets/x86_64-linux" [cuda_prefix="/usr/local/cuda"])
DKS_INCDIR="/home/l_suter_a/DKS/src"
DKS_CFLAGS="-DDKS_OPENCL -DDKS_CUDA -I${DKS_INCDIR} -I${DKS_CUDADIR}/include" dnl Setting the prefix to the default if only --with-cuda was given
DKS_LIBDIR="/home/l_suter_a/DKS/build/src" AC_MSG_CHECKING([whether CUDA is installed in a standard location])
DKS_LIBS="-L${DKS_CUDADIR}/lib -lOpenCL -L${DKS_LIBDIR} -ldksshared" if test "$cuda_prefix" == "yes"; then
AC_SUBST(DKS_CFLAGS) if test "$withval" == "yes"; then
AC_SUBST(DKS_LIBS) cuda_prefix="/usr/local/cuda"
fi fi
fi
AC_MSG_RESULT([${cuda_prefix}])
dnl Checking for nvcc
AC_MSG_CHECKING([nvcc in $cuda_prefix/bin])
if test -x "$cuda_prefix/bin/nvcc"; then
AC_MSG_RESULT([found])
AC_DEFINE_UNQUOTED([NVCC_PATH], ["$cuda_prefix/bin/nvcc"], [path to nvcc binary])
else
AC_MSG_RESULT([not found!])
AC_MSG_FAILURE([nvcc was not found in $cuda_prefix/bin])
fi
CUDA_CFLAGS="-I$cuda_prefix/include"
CXXFLAGS="$CUDA_CFLAGS $CXXFLAGS"
CUDA_LDFLAGS="-L$cuda_prefix/lib64"
LDFLAGS="$CUDA_LDFLAGS $LDFLAGS"
dnl And the header and the lib
AC_CHECK_HEADER([cuda.h], [], AC_MSG_FAILURE([Couldn't find cuda.h]), [#include <cuda.h>])
AC_CHECK_LIB([cuda], [cuInit], [], AC_MSG_FAILURE([Couldn't find libcuda]))
dnl -------------------------------------------
dnl check for DKS
dnl -------------------------------------------
AC_ARG_WITH([dks],
[AS_HELP_STRING([--with-dks],[prefix of the DKS installation, e.g. /usr/local/DKS/build])],
[dks_prefix=$withval],
[dks_prefix="/usr/local/DKS/build"])
dnl Setting the prefix to the default if only --with-dks was given
AC_MSG_CHECKING([whether DKS is installed in a standard location])
if test "$dks_prefix" == "yes"; then
if test "$withval" == "yes"; then
dks_prefix="/usr/local/DKS/build"
fi
fi
if test -x "$dks_prefix"; then
AC_MSG_RESULT([found])
else
AC_MSG_RESULT([not found!])
AC_MSG_FAILURE([$dks_prefix not present])
fi
AC_DEFINE([HAVE_DKS], [1], [Define to 1 if DKS is available])
dnl AC_DEFINE([DKS_CUDA], [1], [Define to 1 if DKS Cuda is available])
DKS_CUDADIR="$cuda_prefix"
DKS_INCDIR="$dks_prefix/include"
DKS_CFLAGS="-DDKS_OPENCL -DDKS_CUDA -I${DKS_INCDIR} ${CUDA_CFLAGS}"
DKS_LIBDIR="$dks_prefix/lib"
DKS_LIBS="${CUDA_LDFLAGS} -lOpenCL -L${DKS_LIBDIR} -ldksshared"
AC_SUBST(DKS_CFLAGS)
AC_SUBST(DKS_LIBS)
DKS_ENABLED=1
],
[DKS_ENABLED=0]
)
dnl ----------------------------------------------- dnl -----------------------------------------------
dnl Ask user if the building of musredit/musrgui should be disabled dnl Ask user if the building of musredit/musrgui should be disabled
@ -1234,7 +1297,7 @@ AC_CONFIG_FILES([Makefile \
src/classes/PMusr.pc \ src/classes/PMusr.pc \
src/classes/PUserFcnBase.pc \ src/classes/PUserFcnBase.pc \
src/external/Makefile \ src/external/Makefile \
src/external/MusrRoot/Makefile \ src/external/MusrRoot/Makefile \
src/external/MusrRoot/TMusrRunHeader.pc \ src/external/MusrRoot/TMusrRunHeader.pc \
src/external/TLemRunHeader/Makefile \ src/external/TLemRunHeader/Makefile \
src/external/TLemRunHeader/TLemRunHeader.pc \ src/external/TLemRunHeader/TLemRunHeader.pc \
@ -1370,7 +1433,7 @@ else
echo " Qt not needed (Qt editors disabled)" echo " Qt not needed (Qt editors disabled)"
fi fi
echo "" echo ""
if test "${DKS_ENABLED}" -eq 1; then if test "${DKS_ENABLED}" = "1"; then
echo " DKS enabled" echo " DKS enabled"
else else
echo " DKS disabled" echo " DKS disabled"