[cig-commits] [commit] devel: updates configuration files to compile CUDA executables without MPI (5168199)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Thu Sep 11 10:23:30 PDT 2014
Repository : https://github.com/geodynamics/specfem3d
On branch : devel
Link : https://github.com/geodynamics/specfem3d/compare/3704c888212d30d103ff64ed797e3904be39dd35...e84e7ba6f8959cb80449833335af69c684b5a5ee
>---------------------------------------------------------------
commit 5168199ae5810f2497832b68094581fefb1efc57
Author: daniel peter <peterda at ethz.ch>
Date: Thu Feb 20 17:11:24 2014 +0100
updates configuration files to compile CUDA executables without MPI
>---------------------------------------------------------------
5168199ae5810f2497832b68094581fefb1efc57
configure | 150 +++++++++++++++++++++++++++++++++++++++++++----------------
configure.ac | 37 ++++++++++++++-
2 files changed, 144 insertions(+), 43 deletions(-)
diff --git a/configure b/configure
index b9e7be4..3ee17a7 100755
--- a/configure
+++ b/configure
@@ -2897,8 +2897,8 @@ if test "$want_pyre" = yes; then
if test -n "$PYTHON"; then
# If the user set $PYTHON, use it and don't search something else.
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version is >= 2.3" >&5
-$as_echo_n "checking whether $PYTHON version is >= 2.3... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version >= 2.3" >&5
+$as_echo_n "checking whether $PYTHON version >= 2.3... " >&6; }
prog="import sys
# split strings by '.' and convert to numeric. Append some zeros
# because we need at least 4 digits for the hex conversion.
@@ -2916,9 +2916,7 @@ sys.exit(sys.hexversion < minverhex)"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- as_fn_error $? "Python interpreter is too old" "$LINENO" 5
+ as_fn_error $? "too old" "$LINENO" 5
fi
am_display_PYTHON=$PYTHON
else
@@ -2930,7 +2928,7 @@ if ${am_cv_pathless_PYTHON+:} false; then :
$as_echo_n "(cached) " >&6
else
- for am_cv_pathless_PYTHON in python python2 python3 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
+ for am_cv_pathless_PYTHON in python python2 python3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
test "$am_cv_pathless_PYTHON" = none && break
prog="import sys
# split strings by '.' and convert to numeric. Append some zeros
@@ -3037,25 +3035,6 @@ $as_echo "$am_cv_python_platform" >&6; }
PYTHON_PLATFORM=$am_cv_python_platform
- # Just factor out some code duplication.
- am_python_setup_sysconfig="\
-import sys
-# Prefer sysconfig over distutils.sysconfig, for better compatibility
-# with python 3.x. See automake bug#10227.
-try:
- import sysconfig
-except ImportError:
- can_use_sysconfig = 0
-else:
- can_use_sysconfig = 1
-# Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs:
-# <https://github.com/pypa/virtualenv/issues/118>
-try:
- from platform import python_implementation
- if python_implementation() == 'CPython' and sys.version[:3] == '2.7':
- can_use_sysconfig = 0
-except ImportError:
- pass"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON script directory" >&5
@@ -3069,14 +3048,7 @@ else
else
am_py_prefix=$prefix
fi
- am_cv_python_pythondir=`$PYTHON -c "
-$am_python_setup_sysconfig
-if can_use_sysconfig:
- sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
-else:
- from distutils import sysconfig
- sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
-sys.stdout.write(sitedir)"`
+ am_cv_python_pythondir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(0,0,prefix='$am_py_prefix'))" 2>/dev/null`
case $am_cv_python_pythondir in
$am_py_prefix*)
am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
@@ -3113,14 +3085,7 @@ else
else
am_py_exec_prefix=$exec_prefix
fi
- am_cv_python_pyexecdir=`$PYTHON -c "
-$am_python_setup_sysconfig
-if can_use_sysconfig:
- sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'})
-else:
- from distutils import sysconfig
- sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix')
-sys.stdout.write(sitedir)"`
+ am_cv_python_pyexecdir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(1,0,prefix='$am_py_exec_prefix'))" 2>/dev/null`
case $am_cv_python_pyexecdir in
$am_py_exec_prefix*)
am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
@@ -7968,6 +7933,7 @@ if test "$want_cuda" != no; then
## CUDA ##
## ---- ##"
+ if test "$want_mpi" = yes; then
@@ -8138,6 +8104,108 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ else
+ # note: CUDA could be run without mpi, however CIT_CUDA_CONFIG is not working without it...
+ # checks for compiler
+ # 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
+for as_dir in $PATH
+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
+
+ ;;
+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 -z "$NVCC" ; then
+ as_fn_error $? "cannot find 'nvcc' program." "$LINENO" 5
+ fi
+ # checks for CUDA headers
+ if test "x$CUDA_INC" != "x"; then
+ CUDA_CPPFLAGS="-I$CUDA_INC"
+ CPPFLAGS="$CUDA_CPPFLAGS $CPPFLAGS"
+ fi
+ ac_fn_c_check_header_mongrel "$LINENO" "cuda_runtime.h" "ac_cv_header_cuda_runtime_h" "$ac_includes_default"
+if test "x$ac_cv_header_cuda_runtime_h" = xyes; then :
+
+else
+
+ as_fn_error $? "CUDA runtime header not found; try setting CUDA_INC." "$LINENO" 5
+
+fi
+
+
+ # checks for CUDA libraries
+ if test "x$CUDA_LIB" != "x"; then
+ CUDA_LDFLAGS="-L$CUDA_LIB"
+ LDFLAGS="$CUDA_LDFLAGS $LDFLAGS"
+ fi
+ CUDA_LIBS="-lcudart"
+ LIBS="$CUDA_LIBS $LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cudaMalloc in -lcudart" >&5
+$as_echo_n "checking for cudaMalloc in -lcudart... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <cuda_runtime.h>
+#ifdef FC_DUMMY_MAIN
+#ifndef FC_DUMMY_MAIN_EQ_F77
+# ifdef __cplusplus
+ extern "C"
+# endif
+ int FC_DUMMY_MAIN() { return 1; }
+#endif
+#endif
+int
+main ()
+{
+void* ptr = 0;
+ cudaMalloc(&ptr, 1);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ as_fn_error $? "CUDA library not found; try setting CUDA_LIB." "$LINENO" 5
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ fi
fi
diff --git a/configure.ac b/configure.ac
index 56ceea5..cddc1aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -378,8 +378,41 @@ fi
if test "$want_cuda" != no; then
AS_BOX([CUDA])
AC_ARG_VAR(CUDA_FLAGS, [Cuda compiler flags])
- CIT_CUDA_CONFIG
- CIT_MPI_INCDIR([$MPIFC])
+ if test "$want_mpi" = yes; then
+ CIT_CUDA_CONFIG
+ CIT_MPI_INCDIR([$MPIFC])
+ else
+ # note: CUDA could be run without mpi, however CIT_CUDA_CONFIG is not working without it...
+ # checks for compiler
+ AC_PATH_PROG(NVCC, nvcc)
+ if test -z "$NVCC" ; then
+ AC_MSG_ERROR([cannot find 'nvcc' program.])
+ fi
+ # checks for CUDA headers
+ if test "x$CUDA_INC" != "x"; then
+ CUDA_CPPFLAGS="-I$CUDA_INC"
+ CPPFLAGS="$CUDA_CPPFLAGS $CPPFLAGS"
+ fi
+ AC_CHECK_HEADER([cuda_runtime.h], [], [
+ AC_MSG_ERROR([CUDA runtime header not found; try setting CUDA_INC.])
+ ])
+ # checks for CUDA libraries
+ if test "x$CUDA_LIB" != "x"; then
+ CUDA_LDFLAGS="-L$CUDA_LIB"
+ LDFLAGS="$CUDA_LDFLAGS $LDFLAGS"
+ fi
+ CUDA_LIBS="-lcudart"
+ LIBS="$CUDA_LIBS $LIBS"
+ AC_MSG_CHECKING([for cudaMalloc in -lcudart])
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([[#include <cuda_runtime.h>]],
+ [[void* ptr = 0;]]
+ [[cudaMalloc(&ptr, 1);]])],
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)
+ AC_MSG_ERROR([CUDA library not found; try setting CUDA_LIB.])
+ ])
+ fi
fi
More information about the CIG-COMMITS
mailing list