소스 검색

fix windows cuda build, disable opencl on windows for now (no fork there...)

Samuel Thibault 15 년 전
부모
커밋
c2a62115aa

+ 7 - 1
configure.ac

@@ -45,7 +45,10 @@ AC_PATH_PROGS([STARPU_MS_LIB], [lib])
 AC_ARG_VAR([STARPU_MS_LIB], [Path to Microsoft's Visual Studio `lib' tool])
 AM_CONDITIONAL([STARPU_HAVE_MS_LIB], [test "x$STARPU_MS_LIB" != "x"])
 case "$target" in
-*-*-mingw*|*-*-cygwin*) starpu_windows=yes ;;
+*-*-mingw*|*-*-cygwin*)
+  starpu_windows=yes
+  AC_DEFINE(STARPU_HAVE_WINDOWS, [], [Define this on windows.])
+  ;;
 esac
 AM_CONDITIONAL([STARPU_HAVE_WINDOWS], [test "x$starpu_windows" = "xyes"])
 
@@ -334,6 +337,9 @@ AC_DEFINE_UNQUOTED(STARPU_MAXOPENCLDEVS, [$nmaxopencldev],
 AC_ARG_ENABLE(opencl, [AS_HELP_STRING([--disable-opencl],
 		[do not use OpenCL device(s)])],, [enable_opencl=maybe])
 
+case "$target" in
+*-*-mingw*|*-*-cygwin*) enable_opencl=no ;;
+esac
 if test x$enable_opencl = xyes -o x$enable_opencl = xmaybe; then
 	#AC_MSG_CHECKING(whether OpenCL is available)
 	AC_ARG_WITH(opencl-dir, 

+ 1 - 0
examples/pi/pi.c

@@ -16,6 +16,7 @@
 
 #include "SobolQRNG/sobol.h"
 #include "pi.h"
+#include <sys/time.h>
 
 #ifdef STARPU_USE_CUDA
 void cuda_kernel(void **descr, void *cl_arg);

+ 0 - 1
examples/pi/pi.h

@@ -19,7 +19,6 @@
 
 #include <starpu.h>
 #include <stdio.h>
-#include <sys/time.h>
 
 #define NSHOT_PER_TASK	(16*1024*1024ULL)
 

+ 1 - 1
examples/pi/pi_kernel.cu

@@ -124,7 +124,7 @@ extern "C" void cuda_kernel(void *descr[], void *cl_arg)
 	unsigned *per_block_cnt;
 	cudaMalloc((void **)&per_block_cnt, nblocks*sizeof(unsigned));
 
-	assert((nx % nblocks) == 0);
+	STARPU_ASSERT((nx % nblocks) == 0);
 
 	/* How many threads per block ? At most 256, but no more threads than
 	 * there are entries to process per block. */

+ 1 - 1
examples/variable/variable_kernels.cu

@@ -22,7 +22,7 @@ static __global__ void cuda_variable(float * tab)
 	return;
 }
 
-extern "C" void cuda_codelet(void *descr[], __attribute__ ((unused)) void *_args)
+extern "C" void cuda_codelet(void *descr[], STARPU_ATTRIBUTE_UNUSED void *_args)
 {
 	float *val = (float *)STARPU_GET_VECTOR_PTR(descr[0]);
 

+ 2 - 0
include/starpu_config.h.in

@@ -42,6 +42,8 @@
 
 #undef STARPU_HAVE_LIBNUMA
 
+#undef STARPU_HAVE_WINDOWS
+
 #undef starpu_drand48
 #undef starpu_srand48
 

+ 3 - 3
include/starpu_perfmodel.h

@@ -17,15 +17,15 @@
 #ifndef __STARPU_PERFMODEL_H__
 #define __STARPU_PERFMODEL_H__
 
+#include <starpu_config.h>
 #include <stdio.h>
-#ifndef __MINGW32__
+#ifndef STARPU_HAVE_WINDOWS
 #include <pthread.h>
 #else
 #include <windows.h>
 #undef interface
 #endif
 #include <starpu.h>
-#include <starpu_config.h>
 #include <starpu_task.h>
 
 #ifdef __cplusplus
@@ -105,7 +105,7 @@ struct starpu_perfmodel_t {
 	} is_loaded;
 	unsigned benchmarking;
 
-#ifndef __MINGW32__
+#ifndef STARPU_HAVE_WINDOWS
 	pthread_rwlock_t model_rwlock;
 #else
 	HANDLE model_rwlock;

+ 25 - 5
include/starpu_util.h

@@ -42,7 +42,11 @@ extern "C" {
 #ifdef STARPU_NO_ASSERT
 #define STARPU_ASSERT(x)	do {} while(0);
 #else
-#define STARPU_ASSERT(x)	assert(x)
+#  if defined(__CUDACC__) && defined(STARPU_HAVE_WINDOWS)
+#    define STARPU_ASSERT(x)	do { if (!(x)) *(int*)NULL = 0; } while(0)
+#  else
+#    define STARPU_ASSERT(x)	assert(x)
+#  endif
 #endif
 
 #define STARPU_ABORT()		abort()
@@ -50,6 +54,12 @@ extern "C" {
 #define STARPU_UNLIKELY(expr)          (__builtin_expect(!!(expr),0))
 #define STARPU_LIKELY(expr)            (__builtin_expect(!!(expr),1))
 
+#ifdef __GNUC__
+#  define STARPU_ATTRIBUTE_UNUSED                  __attribute__((unused))
+#else
+#  define STARPU_ATTRIBUTE_UNUSED                  
+#endif
+
 #if defined(__i386__) || defined(__x86_64__)
 static inline unsigned starpu_cmpxchg(unsigned *ptr, unsigned old, unsigned next) {
 	__asm__ __volatile__("lock cmpxchgl %2,%1": "+a" (old), "+m" (*ptr) : "q" (next) : "memory");
@@ -115,6 +125,18 @@ STARPU_ATOMIC_SOMETHING(or, old | value)
 
 #ifdef STARPU_USE_CUDA
 
+#if defined(__CUDACC__) && defined(STARPU_HAVE_WINDOWS)
+#define STARPU_CUBLAS_OOPS() do { \
+		printf("oops  %s \n", errormsg); \
+		*(int*)NULL = 0; \
+	} while (0);
+#else
+#define STARPU_CUBLAS_OOPS() do { \
+		printf("oops  in %s ... %s \n", __func__, errormsg); \
+		assert(0);						\
+	} while (0);
+#endif
+
 #define STARPU_CUBLAS_REPORT_ERROR(status) 					\
 	do {								\
 		char *errormsg;						\
@@ -144,8 +166,7 @@ STARPU_ATOMIC_SOMETHING(or, old | value)
 				errormsg = "unknown error";		\
 				break;					\
 		}							\
-		printf("oops  in %s ... %s \n", __func__, errormsg);	\
-		assert(0);						\
+		STARPU_CUBLAS_OOPS();					\
 	} while (0)  
 
 
@@ -153,8 +174,7 @@ STARPU_ATOMIC_SOMETHING(or, old | value)
 #define STARPU_CUDA_REPORT_ERROR(status) 				\
 	do {								\
 		const char *errormsg = cudaGetErrorString(status);	\
-		printf("oops  in %s ... %s \n", __func__, errormsg);	\
-		assert(0);						\
+		STARPU_CUBLAS_OOPS();					\
 	} while (0)  
 
 #endif // STARPU_USE_CUDA

+ 1 - 1
tests/datawizard/cuda_codelet_unsigned_inc.cu

@@ -21,7 +21,7 @@ static __global__ void _cuda_unsigned_inc(unsigned *val)
 	val[0]++;
 }
 
-extern "C" void cuda_codelet_unsigned_inc(void *descr[], __attribute__ ((unused)) void *cl_arg)
+extern "C" void cuda_codelet_unsigned_inc(void *descr[], STARPU_ATTRIBUTE_UNUSED void *cl_arg)
 {
 	unsigned *val = (unsigned *)STARPU_GET_VARIABLE_PTR(descr[0]);
 

+ 1 - 1
tests/datawizard/scratch_cuda.cu

@@ -32,7 +32,7 @@ static __global__ void increment_vector(unsigned *v, unsigned *tmp, int nx)
 	}
 }
 
-extern "C" void cuda_f(void *descr[], __attribute__ ((unused)) void *_args)
+extern "C" void cuda_f(void *descr[], STARPU_ATTRIBUTE_UNUSED void *_args)
 {
 	unsigned *v = (unsigned *)STARPU_GET_VECTOR_PTR(descr[0]);
 	unsigned *tmp = (unsigned *)STARPU_GET_VECTOR_PTR(descr[1]);

+ 2 - 2
tests/datawizard/sync_and_notify_data_kernels.cu

@@ -25,7 +25,7 @@ extern "C" __global__ void _cuda_incA(unsigned *v)
 	v[0]++;
 }
 
-extern "C" void cuda_codelet_incA(void *descr[], __attribute__ ((unused)) void *_args)
+extern "C" void cuda_codelet_incA(void *descr[], STARPU_ATTRIBUTE_UNUSED void *_args)
 {
 	unsigned *v = (unsigned *)STARPU_GET_VECTOR_PTR(descr[0]);
 
@@ -43,7 +43,7 @@ extern "C" __global__ void _cuda_incC(unsigned *v)
 	v[2]++;
 }
 
-extern "C" void cuda_codelet_incC(void *descr[], __attribute__ ((unused)) void *_args)
+extern "C" void cuda_codelet_incC(void *descr[], STARPU_ATTRIBUTE_UNUSED void *_args)
 {
 	unsigned *v = (unsigned *)STARPU_GET_VECTOR_PTR(descr[0]);