Browse Source

Fix build without OpenGL headers

Samuel Thibault 12 years ago
parent
commit
972caa3d96
2 changed files with 13 additions and 0 deletions
  1. 2 0
      configure.ac
  2. 11 0
      src/drivers/cuda/driver_cuda.c

+ 2 - 0
configure.ac

@@ -479,6 +479,8 @@ if test x$enable_cuda = xyes; then
 		NVCCFLAGS="${NVCCFLAGS} -m64"
 		NVCCFLAGS="${NVCCFLAGS} -m64"
 		AC_SUBST(NVCCFLAGS)
 		AC_SUBST(NVCCFLAGS)
 	fi
 	fi
+
+	AC_CHECK_HEADERS([cuda_gl_interop.h])
 fi
 fi
 
 
 have_magma=no
 have_magma=no

+ 11 - 0
src/drivers/cuda/driver_cuda.c

@@ -26,7 +26,9 @@
 #include <drivers/driver_common/driver_common.h>
 #include <drivers/driver_common/driver_common.h>
 #include "driver_cuda.h"
 #include "driver_cuda.h"
 #include <core/sched_policy.h>
 #include <core/sched_policy.h>
+#ifdef HAVE_CUDA_GL_INTEROP_H
 #include <cuda_gl_interop.h>
 #include <cuda_gl_interop.h>
+#endif
 
 
 /* the number of CUDA devices */
 /* the number of CUDA devices */
 static int ncudagpus;
 static int ncudagpus;
@@ -113,13 +115,20 @@ void starpu_cuda_set_device(int devid)
 {
 {
 	cudaError_t cures;
 	cudaError_t cures;
 	struct starpu_conf *conf = _starpu_get_machine_config()->conf;
 	struct starpu_conf *conf = _starpu_get_machine_config()->conf;
+#if !defined(HAVE_CUDA_MEMCPY_PEER) && defined(HAVE_CUDA_GL_INTEROP_H)
 	unsigned i;
 	unsigned i;
+#endif
 
 
 #ifdef HAVE_CUDA_MEMCPY_PEER
 #ifdef HAVE_CUDA_MEMCPY_PEER
 	if (conf->n_cuda_opengl_interoperability) {
 	if (conf->n_cuda_opengl_interoperability) {
 		fprintf(stderr, "OpenGL interoperability was requested, but StarPU was built with multithread GPU control support, please reconfigure with --disable-cuda-memcpy-peer but that will disable the memcpy-peer optimizations\n");
 		fprintf(stderr, "OpenGL interoperability was requested, but StarPU was built with multithread GPU control support, please reconfigure with --disable-cuda-memcpy-peer but that will disable the memcpy-peer optimizations\n");
 		STARPU_ABORT();
 		STARPU_ABORT();
 	}
 	}
+#elif !defined(HAVE_CUDA_GL_INTEROP_H)
+	if (conf->n_cuda_opengl_interoperability) {
+		fprintf(stderr,"OpenGL interoperability was requested, but cuda_gl_interop.h could not be compiled, please make sure that OpenGL headers were available before ./configure run.");
+		STARPU_ABORT();
+	}
 #else
 #else
 	for (i = 0; i < conf->n_cuda_opengl_interoperability; i++)
 	for (i = 0; i < conf->n_cuda_opengl_interoperability; i++)
 		if (conf->cuda_opengl_interoperability[i] == devid) {
 		if (conf->cuda_opengl_interoperability[i] == devid) {
@@ -130,7 +139,9 @@ void starpu_cuda_set_device(int devid)
 
 
 	cures = cudaSetDevice(devid);
 	cures = cudaSetDevice(devid);
 
 
+#if !defined(HAVE_CUDA_MEMCPY_PEER) && defined(HAVE_CUDA_GL_INTEROP_H)
 done:
 done:
+#endif
 	if (STARPU_UNLIKELY(cures))
 	if (STARPU_UNLIKELY(cures))
 		STARPU_CUDA_REPORT_ERROR(cures);
 		STARPU_CUDA_REPORT_ERROR(cures);
 }
 }