瀏覽代碼

fix windows build

Samuel Thibault 14 年之前
父節點
當前提交
cd742e33b6

+ 34 - 0
README

@@ -84,6 +84,40 @@ The password is 'anonsvn'
   $ make
   $ make install
 
++---------------------
+| IV.c. Windows build:
+
+- c:\cuda\include\host_defines.h has a bogus CUDARTAPI definition which makes
+  linking fail completely. Replace the first occurence of
+
+    #define CUDARTAPI
+    
+  with
+    
+    #ifdef _WIN32
+    #define CUDARTAPI __stdcall
+    #else
+    #define CUDARTAPI
+    #endif
+
+  While at it, you can also comment the __cdecl definition to avoid spurious
+  warnings.
+
+- If you have a non-english version of windows, use
+
+    export LANG=C
+
+  else libtool has troubles parsing the translated output of the toolchain.
+
+- libtool is not able to find the libraries automatically, you need to make some
+  copies:
+
+    copy c:\cuda\lib\cuda.lib c:\cuda\lib\libcuda.lib
+    copy c:\cuda\lib\cudart.lib c:\cuda\lib\libcudart.lib
+    copy c:\cuda\lib\cublas.lib c:\cuda\lib\libcublas.lib
+    copy c:\cuda\lib\cufft.lib c:\cuda\lib\libcufft.lib
+    copy c:\cuda\lib\OpenCL.lib c:\cuda\lib\libOpenCL.lib
+
 ++============++
 || V. Contact ||
 ++============++

+ 3 - 2
configure.ac

@@ -184,8 +184,9 @@ if test x$enable_cuda = xyes -o x$enable_cuda = xmaybe; then
 			# in case this was not explicit yet
 			enable_cuda=yes
 		], cuda_dir=/usr/local/cuda/)
-# TODO: try other paths as well (including /c/cuda for windows)
-	
+
+	[ ! -d "$cuda_dir" -a -d "/c/cuda" ] && cuda_dir=/c/cuda
+
 	if test -d "$cuda_dir/include/"; then
 		CPPFLAGS="${CPPFLAGS} -I$cuda_dir/include/ "
                 STARPU_CUDA_CPPFLAGS="-I$cuda_dir/include/"

+ 2 - 1
examples/incrementer/incrementer_kernels.cu

@@ -24,8 +24,9 @@ static __global__ void cuda_incrementer(float * tab)
 	return;
 }
 
-extern "C" void cuda_codelet(void *descr[], __attribute__ ((unused)) void *_args)
+extern "C" void cuda_codelet(void *descr[], void *_args)
 {
+	(void)_args;
 	float *val = (float *)STARPU_VECTOR_GET_PTR(descr[0]);
 
 	cuda_incrementer<<<1,1>>>(val);

+ 0 - 1
examples/spmv/spmv_cuda.cu

@@ -14,7 +14,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <stdint.h>
 #include <starpu.h>
 
 #define MIN(a,b)	((a)<(b)?(a):(b))

+ 4 - 0
include/pthread_win32/pthread.h

@@ -248,6 +248,7 @@ typedef pthread_mutex_t pthread_rwlock_t;
 #define pthread_rwlock_wrlock(lock) pthread_mutex_lock(lock)
 #define pthread_rwlock_rdlock(lock) pthread_mutex_lock(lock)
 #define pthread_rwlock_unlock(lock) pthread_mutex_unlock(lock)
+#define pthread_rwlock_destroy(lock) pthread_mutex_destroy(lock)
 
 /**************
  * conditions *
@@ -259,10 +260,13 @@ typedef struct {
 } pthread_cond_t;
 #define PTHREAD_COND_INITIALIZER { NULL, 0}
 
+#ifndef STARPU_TIMESPEC_DEFINED
+#define STARPU_TIMESPEC_DEFINED 1
 struct timespec {
   time_t  tv_sec;  /* Seconds */
   long    tv_nsec; /* Nanoseconds */
 };
+#endif /* STARPU_TIMESPEC_DEFINED */
 
 typedef unsigned pthread_condattr_t;
 

+ 8 - 0
include/starpu.h

@@ -18,7 +18,15 @@
 #define __STARPU_H__
 
 #include <stdlib.h>
+
+#ifndef _MSC_VER
 #include <stdint.h>
+#else
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned long uint32_t;
+typedef unsigned long long uint64_t;
+#endif
 
 #include <starpu_config.h>
 #include <starpu_util.h>

+ 11 - 0
include/starpu_profiling.h

@@ -19,6 +19,17 @@
 
 #include <errno.h>
 #include <sys/time.h>
+
+#ifdef __MINGW32__
+#ifndef STARPU_TIMESPEC_DEFINED
+#define STARPU_TIMESPEC_DEFINED 1
+struct timespec {
+  time_t  tv_sec;  /* Seconds */
+  long    tv_nsec; /* Nanoseconds */
+};
+#endif /* STARPU_TIMESPEC_DEFINED */
+#endif
+
 #include <starpu.h>
 
 #ifdef __cplusplus

+ 2 - 1
mpi/tests/ring_kernel.cu

@@ -21,8 +21,9 @@ static __global__ void cuda_incrementer(unsigned *token)
 	(*token)++;
 }
 
-extern "C" void increment_cuda(void *descr[], __attribute__ ((unused)) void *_args)
+extern "C" void increment_cuda(void *descr[], void *_args)
 {
+	(void) _args;
 	unsigned *tokenptr = (unsigned *)STARPU_VECTOR_GET_PTR(descr[0]);
 
 	cuda_incrementer<<<1,1>>>(tokenptr);

+ 9 - 3
src/core/perfmodel/perfmodel_bus.c

@@ -549,7 +549,9 @@ static void write_bus_affinity_file_content(void)
 	f = fopen(path, "w+");
 	if (!f)
 	{
-		perror("fopen");
+		perror("fopen write_buf_affinity_file_content");
+		fprintf(stderr,"path '%s'\n", path);
+		fflush(stderr);
 		STARPU_ABORT();
 	}
 
@@ -686,7 +688,9 @@ static void write_bus_latency_file_content(void)
 	f = fopen(path, "w+");
 	if (!f)
 	{
-		perror("fopen");
+		perror("fopen write_bus_latency_file_content");
+		fprintf(stderr,"path '%s'\n", path);
+		fflush(stderr);
 		STARPU_ABORT();
 	}
 
@@ -773,7 +777,9 @@ static void load_bus_bandwidth_file_content(void)
 	f = fopen(path, "r");
 	if (!f)
 	{
-		perror("fopen");
+		perror("fopen load_bus_bandwidth_file_content");
+		fprintf(stderr,"path '%s'\n", path);
+		fflush(stderr);
 		STARPU_ABORT();
 	}
 

+ 7 - 6
src/core/perfmodel/perfmodel_history.c

@@ -411,7 +411,6 @@ static void load_history_based_model(struct starpu_perfmodel_t *model, unsigned
  * the performance model files */
 int starpu_list_models(void)
 {
-#ifdef DT_REG
         char path[256];
         DIR *dp;
         struct dirent *ep;
@@ -423,7 +422,13 @@ int starpu_list_models(void)
         dp = opendir(path);
         if (dp != NULL) {
                 while ((ep = readdir(dp))) {
-                        if (ep->d_type == DT_REG) {
+#ifdef DT_REG
+                        if (ep->d_type == DT_REG)
+#else
+			if (strcmp(ep->d_name, ".")
+			 && strcmp(ep->d_name, ".."))
+#endif
+			{
                                 fprintf(stdout, "file: <%s>\n", ep->d_name);
                         }
                 }
@@ -434,10 +439,6 @@ int starpu_list_models(void)
                 perror ("Couldn't open the directory");
                 return 1;
         }
-#else
-	perror ("not supported\n");
-	return 1;
-#endif
 }
 
 /* This function is intended to be used by external tools that should read the

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

@@ -72,7 +72,7 @@ unsigned _starpu_get_cuda_device_count(void)
 	cudaError_t cures;
 	cures = cudaGetDeviceCount(&cnt);
 	if (STARPU_UNLIKELY(cures))
-		 STARPU_CUDA_REPORT_ERROR(cures);
+		 return 0;
 	
 	return (unsigned)cnt;
 }

+ 5 - 0
tools/calibrate_bus.c

@@ -18,6 +18,11 @@
 
 int main(int argc, char **argv)
 {
+#ifdef __MINGW32__
+	WSADATA wsadata;
+	WSAStartup(MAKEWORD(1,0), &wsadata);
+#endif
+
 	starpu_force_bus_sampling();
 
 	return 0;

+ 5 - 0
tools/perfmodel_display.c

@@ -271,6 +271,11 @@ int main(int argc, char **argv)
 {
 //	assert(argc == 2);
 
+#ifdef __MINGW32__
+	WSADATA wsadata;
+	WSAStartup(MAKEWORD(1,0), &wsadata);
+#endif
+
 	parse_args(argc, argv);
 
         if (list) {