Przeglądaj źródła

Improve detection of NVML availability. Do not only check the library is available, also check the compiled code can be run.

Nathalie Furmento 6 lat temu
rodzic
commit
3920b52d57
2 zmienionych plików z 33 dodań i 5 usunięć
  1. 4 0
      ChangeLog
  2. 29 5
      configure.ac

+ 4 - 0
ChangeLog

@@ -27,6 +27,10 @@ Small features:
   * Add starpu_filter_nparts_compute_chunk_size_and_offset helper.
   * Add starpu_bcsr_filter_canonical_block_child_ops.
 
+Small changes:
+  * Improve detection of NVML availability. Do not only check the
+    library is available, also check the compiled code can be run.
+
 StarPU 1.3.0 (git revision 24ca83c6dbb102e1cfc41db3bb21c49662067062)
 ==============================================
 

+ 29 - 5
configure.ac

@@ -1337,11 +1337,35 @@ if test x$enable_cuda = xyes; then
 		      STARPU_CUDA_LDFLAGS="$STARPU_CUDA_LDFLAGS -lcusparse"])
 	AC_CHECK_DECLS([cusparseSetStream], [], [], [[#include <cusparse.h>]])
 
-	AC_CHECK_HEADER([nvml.h],
-	  [AC_CHECK_LIB([nvidia-ml], [nvmlDeviceGetTotalEnergyConsumption],
-		        [AC_DEFINE([HAVE_LIBNVIDIA_ML], [1], [Define to 1 if you have the nvidia-ml library])
-		         STARPU_CUDA_LDFLAGS="$STARPU_CUDA_LDFLAGS -lnvidia-ml"])])
-        CPPFLAGS="${SAVED_CPPFLAGS}"
+	LDFLAGS="${LDFLAGS} -lnvidia-ml"
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+		[[#include <nvml.h>]],
+		[[nvmlInit();]]
+		)],
+	    [
+	      AC_RUN_IFELSE([AC_LANG_PROGRAM(
+	        [[#include <nvml.h>]],
+		[[nvmlInit();]]
+		)],
+		[have_valid_nvml="yes"],
+		[
+	          AC_MSG_RESULT([NVML found and can be compiled, but compiled application can not be run, you are probably on a machine without the CUDA driver])
+	          have_valid_nvml="no"
+		])
+	    ],
+	    [
+	    AC_MSG_ERROR([NVML found, but nvml.h could not be compiled])
+	    have_valid_nvml="no"
+	    ]
+	)
+	if test x$have_valid_nvml = xyes ; then
+		AC_DEFINE([HAVE_LIBNVIDIA_ML], [1], [Define to 1 if you have the nvidia-ml library])
+		STARPU_CUDA_LDFLAGS="$STARPU_CUDA_LDFLAGS -lnvidia-ml"
+	fi
+	AC_MSG_CHECKING(whether nvidia-ml should be used)
+	AC_MSG_RESULT($have_valid_nvml)
+
+	CPPFLAGS="${SAVED_CPPFLAGS}"
 	LDFLAGS="${SAVED_LDFLAGS}"
 	LIBS="${SAVED_LIBS}"
 fi