|
| 1 | +dnl -*- autoconf -*- |
| 2 | +dnl |
| 3 | +dnl Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana |
| 4 | +dnl University Research and Technology |
| 5 | +dnl Corporation. All rights reserved. |
| 6 | +dnl Copyright (c) 2004-2005 The University of Tennessee and The University |
| 7 | +dnl of Tennessee Research Foundation. All rights |
| 8 | +dnl reserved. |
| 9 | +dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, |
| 10 | +dnl University of Stuttgart. All rights reserved. |
| 11 | +dnl Copyright (c) 2004-2005 The Regents of the University of California. |
| 12 | +dnl All rights reserved. |
| 13 | +dnl Copyright (c) 2006-2016 Cisco Systems, Inc. All rights reserved. |
| 14 | +dnl Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. |
| 15 | +dnl Copyright (c) 2009 IBM Corporation. All rights reserved. |
| 16 | +dnl Copyright (c) 2009 Los Alamos National Security, LLC. All rights |
| 17 | +dnl reserved. |
| 18 | +dnl Copyright (c) 2009-2011 Oak Ridge National Labs. All rights reserved. |
| 19 | +dnl Copyright (c) 2011-2015 NVIDIA Corporation. All rights reserved. |
| 20 | +dnl Copyright (c) 2015 Research Organization for Information Science |
| 21 | +dnl and Technology (RIST). All rights reserved. |
| 22 | +dnl Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved. |
| 23 | +dnl $COPYRIGHT$ |
| 24 | +dnl |
| 25 | +dnl Additional copyrights may follow |
| 26 | +dnl |
| 27 | +dnl $HEADER$ |
| 28 | +dnl |
| 29 | + |
| 30 | + |
| 31 | +# OPAL_CHECK_CUDART(prefix, [action-if-found], [action-if-not-found]) |
| 32 | +# -------------------------------------------------------- |
| 33 | +# check if CUDA runtime library support can be found. sets prefix_{CPPFLAGS, |
| 34 | +# LDFLAGS, LIBS} as needed and runs action-if-found if there is |
| 35 | +# support, otherwise executes action-if-not-found |
| 36 | + |
| 37 | +# |
| 38 | +# Check for CUDA support |
| 39 | +# |
| 40 | +AC_DEFUN([OPAL_CHECK_CUDART],[ |
| 41 | +OPAL_VAR_SCOPE_PUSH([cudart_save_CPPFLAGS cudart_save_LDFLAGS cudart_save_LIBS]) |
| 42 | +
|
| 43 | +cudart_save_CPPFLAGS="$CPPFLAGS" |
| 44 | +cudart_save_LDFLAGS="$LDFLAGS" |
| 45 | +cudart_save_LIBS="$LIBS" |
| 46 | +
|
| 47 | +# |
| 48 | +# Check to see if the user provided paths for CUDART |
| 49 | +# |
| 50 | +AC_ARG_WITH([cudart], |
| 51 | + [AS_HELP_STRING([--with-cudart=DIR], |
| 52 | + [Path to the CUDA runtime library and header files])]) |
| 53 | +AC_MSG_CHECKING([if --with-cudart is set]) |
| 54 | +AC_ARG_WITH([cudart-libdir], |
| 55 | + [AS_HELP_STRING([--with-cudart-libdir=DIR], |
| 56 | + [Search for CUDA runtime libraries in DIR])]) |
| 57 | +
|
| 58 | +#################################### |
| 59 | +#### Check for CUDA runtime library |
| 60 | +#################################### |
| 61 | +AS_IF([test "x$with_cudart" != "xno" || test "x$with_cudart" = "x"], |
| 62 | + [opal_check_cudart_happy=no |
| 63 | + AC_MSG_RESULT([not set (--with-cudart=$with_cudart)])], |
| 64 | + [AS_IF([test ! -d "$with_cudart"], |
| 65 | + [AC_MSG_RESULT([not found]) |
| 66 | + AC_MSG_WARN([Directory $with_cudart not found])] |
| 67 | + [AS_IF([test "x`ls $with_cudart/include/cuda_runtime.h 2> /dev/null`" = "x"] |
| 68 | + [AC_MSG_RESULT([not found]) |
| 69 | + AC_MSG_WARN([Could not find cuda_runtime.h in $with_cudart/include])] |
| 70 | + [opal_check_cudart_happy=yes |
| 71 | + opal_cudart_incdir="$with_cudart/include"])])]) |
| 72 | +
|
| 73 | +AS_IF([test "$opal_check_cudart_happy" = "no" && test "$with_cudart" != "no"], |
| 74 | + [AC_PATH_PROG([nvcc_bin], [nvcc], ["not-found"]) |
| 75 | + AS_IF([test "$nvcc_bin" = "not-found"], |
| 76 | + [AC_MSG_WARN([Could not find nvcc binary])], |
| 77 | + [nvcc_dirname=`AS_DIRNAME([$nvcc_bin])` |
| 78 | + with_cudart=$nvcc_dirname/../ |
| 79 | + opal_cudart_incdir=$nvcc_dirname/../include |
| 80 | + opal_check_cudart_happy=yes]) |
| 81 | + ] |
| 82 | + []) |
| 83 | +
|
| 84 | +AS_IF([test x"$with_cudart_libdir" = "x"], |
| 85 | + [with_cudart_libdir=$with_cudart/lib64/] |
| 86 | + []) |
| 87 | +
|
| 88 | +AS_IF([test "$opal_check_cudart_happy" = "yes"], |
| 89 | + [OAC_CHECK_PACKAGE([cudart], |
| 90 | + [$1], |
| 91 | + [cuda_runtime.h], |
| 92 | + [cudart], |
| 93 | + [cudaMalloc], |
| 94 | + [opal_check_cudart_happy="yes"], |
| 95 | + [opal_check_cudart_happy="no"])], |
| 96 | + []) |
| 97 | +
|
| 98 | +
|
| 99 | +AC_MSG_CHECKING([if have cuda runtime library support]) |
| 100 | +if test "$opal_check_cudart_happy" = "yes"; then |
| 101 | + AC_MSG_RESULT([yes (-I$opal_cudart_incdir)]) |
| 102 | + CUDART_SUPPORT=1 |
| 103 | + common_cudart_CPPFLAGS="-I$opal_cudart_incdir" |
| 104 | + AC_SUBST([common_cudart_CPPFLAGS]) |
| 105 | +else |
| 106 | + AC_MSG_RESULT([no]) |
| 107 | + CUDART_SUPPORT=0 |
| 108 | +fi |
| 109 | +
|
| 110 | +
|
| 111 | +OPAL_SUMMARY_ADD([Accelerators], [CUDART support], [], [$opal_check_cudart_happy]) |
| 112 | +AM_CONDITIONAL([OPAL_cudart_support], [test "x$CUDART_SUPPORT" = "x1"]) |
| 113 | +AC_DEFINE_UNQUOTED([OPAL_CUDART_SUPPORT],$CUDART_SUPPORT, |
| 114 | + [Whether we have cuda runtime library support]) |
| 115 | +
|
| 116 | +CPPFLAGS=${cudart_save_CPPFLAGS} |
| 117 | +LDFLAGS=${cudart_save_LDFLAGS} |
| 118 | +LIBS=${cudart_save_LIBS} |
| 119 | +OPAL_VAR_SCOPE_POP |
| 120 | +])dnl |
0 commit comments