Browse Source

Fix build on systems which have libnvml but not nvmlDeviceGetTotalEnergyConsumption

Samuel Thibault 5 years ago
parent
commit
53001908c6
2 changed files with 3 additions and 2 deletions
  1. 1 0
      configure.ac
  2. 2 2
      src/drivers/cuda/driver_cuda.c

+ 1 - 0
configure.ac

@@ -1359,6 +1359,7 @@ if test x$enable_cuda = xyes; then
 	    ]
 	)
 	if test x$have_valid_nvml = xyes ; then
+		AC_CHECK_FUNCS([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"
 	fi

+ 2 - 2
src/drivers/cuda/driver_cuda.c

@@ -537,7 +537,7 @@ static int start_job_on_cuda(struct _starpu_job *j, struct _starpu_worker *worke
 				async ? &task_finished[workerid][pipeline_idx] : NULL);
 		}
 #else
-#ifdef HAVE_LIBNVIDIA_ML
+#ifdef HAVE_NVMLDEVICEGETTOTALENERGYCONSUMPTION
 		unsigned long long energy_start = 0;
 		nvmlReturn_t nvmlRet = -1;
 		if (profiling && task->profiling_info)
@@ -561,7 +561,7 @@ static void finish_job_on_cuda(struct _starpu_job *j, struct _starpu_worker *wor
 	int profiling = starpu_profiling_status_get();
 
 
-#ifdef HAVE_LIBNVIDIA_ML
+#ifdef HAVE_NVMLDEVICEGETTOTALENERGYCONSUMPTION
 	if (profiling && j->task->profiling_info && j->task->profiling_info->energy_consumed)
 	{
 		unsigned long long energy_end;