Browse Source

merge trunk

Samuel Thibault 10 years ago
parent
commit
651e5f8222

+ 1 - 0
ChangeLog

@@ -113,6 +113,7 @@ New features:
 Small changes:
   * Lock performance model files while writing and reading them to avoid
     issues on parallel launches, MPI runs notably.
+  * Lots of build fixes for icc on Windows.
 
 StarPU 1.1.2 (svn revision 13011)
 ==============================================

+ 10 - 1
Makefile.am

@@ -1,6 +1,6 @@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
-# Copyright (C) 2009-2013  Université de Bordeaux 1
+# Copyright (C) 2009-2014  Université de Bordeaux 1
 # Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
 #
 # StarPU is free software; you can redistribute it and/or modify
@@ -128,6 +128,15 @@ EXTRA_DIST = AUTHORS COPYING.LGPL README STARPU-VERSION STARPU-REVISION build-au
 
 DISTCLEANFILES = STARPU-REVISION
 
+if STARPU_DEVEL
+all-local:
+	@if grep -r sys/time.h $$( find $(srcdir)/src $(srcdir)/mpi/src $(srcdir)/include -name \*.[ch] -a \! -name starpu_util.h ) ; \
+	then \
+		echo "Please do not include sys/time, it is not available on Windows, include starpu_util.h and use starpu_timing_now() instead" ; \
+		false ; \
+	fi
+endif
+
 include starpu-top/extradist
 
 showcheck:

+ 14 - 0
configure.ac

@@ -1939,6 +1939,7 @@ IS_SUPPORTED_CFLAG(-Wall)
 IS_SUPPORTED_CFLAG(-Wextra)
 IS_SUPPORTED_CFLAG(-Werror=implicit)
 IS_SUPPORTED_CFLAG(-Werror=implicit-function-declaration)
+IS_SUPPORTED_CFLAG(-Werror=pointer-arith)
 
 if test "x$STARPU_DEVEL" != x; then
 	AC_DEFINE(STARPU_DEVEL, [1], [enable developer warnings])
@@ -1946,6 +1947,7 @@ if test "x$STARPU_DEVEL" != x; then
 	IS_SUPPORTED_CFLAG(-Wundef)
 	IS_SUPPORTED_CFLAG(-Wshadow)
 fi
+AM_CONDITIONAL([STARPU_DEVEL],[test "x$STARPU_DEVEL" != x])
 
 AC_SUBST(GLOBAL_AM_CFLAGS)
 
@@ -2489,6 +2491,18 @@ AC_SUBST(SOCL_VENDORS)
 AC_CONFIG_FILES(tests/regression/regression.sh tests/regression/profiles tests/regression/profiles.build.only)
 AC_CONFIG_HEADER(src/common/config.h include/starpu_config.h gcc-plugin/include/starpu-gcc/config.h starpu-top/config.h)
 
+AH_BOTTOM([
+#if defined(STARPU_DEVEL) && defined(BUILDING_STARPU)
+#  ifndef STARPU_CHECKED_UNISTD_H
+#    define STARPU_CHECKED_UNISTD_H
+#    ifdef _UNISTD_H
+#      define _UNISTD_H PLEASE_DONT_INCLUDE_IT
+#      error Please do not unconditionally include unistd.h, it is not available on Windows, include config.h and test for HAVE_UNISTD_H
+#    endif
+#  endif
+#endif
+])
+
 AC_OUTPUT([
 	Makefile
 	src/Makefile

+ 7 - 5
examples/interface/complex_interface.c

@@ -128,9 +128,10 @@ static int complex_pack_data(starpu_data_handle_t handle, unsigned node, void **
 	*count = complex_get_size(handle);
 	if (ptr != NULL)
 	{
-		*ptr = malloc(*count);
-		memcpy(*ptr, complex_interface->real, complex_interface->nx*sizeof(double));
-		memcpy(*ptr+complex_interface->nx*sizeof(double), complex_interface->imaginary, complex_interface->nx*sizeof(double));
+		char *data;
+		data = *ptr = malloc(*count);
+		memcpy(data, complex_interface->real, complex_interface->nx*sizeof(double));
+		memcpy(data+complex_interface->nx*sizeof(double), complex_interface->imaginary, complex_interface->nx*sizeof(double));
 	}
 
 	return 0;
@@ -138,13 +139,14 @@ static int complex_pack_data(starpu_data_handle_t handle, unsigned node, void **
 
 static int complex_unpack_data(starpu_data_handle_t handle, unsigned node, void *ptr, size_t count)
 {
+	char *data = ptr;
 	STARPU_ASSERT(starpu_data_test_if_allocated_on_node(handle, node));
 
 	struct starpu_complex_interface *complex_interface = (struct starpu_complex_interface *)
 		starpu_data_get_interface_on_node(handle, node);
 
-	memcpy(complex_interface->real, ptr, complex_interface->nx*sizeof(double));
-	memcpy(complex_interface->imaginary, ptr+complex_interface->nx*sizeof(double), complex_interface->nx*sizeof(double));
+	memcpy(complex_interface->real, data, complex_interface->nx*sizeof(double));
+	memcpy(complex_interface->imaginary, data+complex_interface->nx*sizeof(double), complex_interface->nx*sizeof(double));
 
 	return 0;
 }

+ 1 - 1
include/starpu_profiling.h

@@ -21,7 +21,7 @@
 #include <starpu.h>
 #include <errno.h>
 #include <time.h>
-#include <sys/time.h>
+#include <starpu_util.h>
 
 #ifdef __cplusplus
 extern "C"

+ 14 - 0
include/starpu_util.h

@@ -273,6 +273,20 @@ int starpu_data_cpy(starpu_data_handle_t dst_handle, starpu_data_handle_t src_ha
 
 double starpu_timing_now(void);
 
+#ifdef _WIN32
+#ifndef _TIMESPEC_DEFINED
+#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
+#else
+#include <sys/time.h>
+#endif /* _WIN32 */
+
 #ifdef __cplusplus
 }
 #endif

+ 1 - 1
mpi/src/starpu_mpi.c

@@ -1348,7 +1348,7 @@ int _starpu_mpi_initialize(int *argc, char ***argv, int initialize_mpi)
 	argc_argv->argv = argv;
 
 #ifdef STARPU_MPI_ACTIVITY
-	hookid = starpu_progression_hook_register(progression_hook_func, NULL);
+	hookid = starpu_progression_hook_register(_starpu_mpi_progression_hook_func, NULL);
 	STARPU_ASSERT_MSG(hookid >= 0, "starpu_progression_hook_register failed");
 #endif /* STARPU_MPI_ACTIVITY */
 

+ 3 - 3
socl/src/cl_enqueuecopybuffer.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010,2011, 2014 University of Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -46,8 +46,8 @@ static void soclEnqueueCopyBuffer_cpu_task(void *descr[], void *args) {
   ev->prof_start = _socl_nanotime();
   gc_entity_release(ev);
 
-   void * src = (void*)STARPU_VARIABLE_GET_PTR(descr[0]);
-   void * dst = (void*)STARPU_VARIABLE_GET_PTR(descr[1]);
+   char * src = (void*)STARPU_VARIABLE_GET_PTR(descr[0]);
+   char * dst = (void*)STARPU_VARIABLE_GET_PTR(descr[1]);
 
    memcpy(dst+cmd->dst_offset, src+cmd->src_offset, cmd->cb);
 

+ 2 - 2
socl/src/cl_enqueuereadbuffer.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010,2011, 2014 University of Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -23,7 +23,7 @@ static void soclEnqueueReadBuffer_cpu_task(void *descr[], void *args) {
   ev->prof_start = _socl_nanotime();
   gc_entity_release(ev);
 
-   void * ptr = (void*)STARPU_VARIABLE_GET_PTR(descr[0]);
+   char * ptr = (void*)STARPU_VARIABLE_GET_PTR(descr[0]);
    DEBUG_MSG("[Buffer %d] Reading %ld bytes from %p to %p\n", cmd->buffer->id, cmd->cb, ptr+cmd->offset, cmd->ptr);
 
    //This fix is for people who use USE_HOST_PTR and still use ReadBuffer to sync the buffer in host mem at host_ptr.

+ 2 - 2
socl/src/cl_enqueuewritebuffer.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010,2011, 2014 University of Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -24,7 +24,7 @@ static void soclEnqueueWriteBuffer_cpu_task(void *descr[], void *args) {
   ev->prof_start = _socl_nanotime();
   gc_entity_release(ev);
 
-   void * ptr = (void*)STARPU_VARIABLE_GET_PTR(descr[0]);
+   char * ptr = (void*)STARPU_VARIABLE_GET_PTR(descr[0]);
    DEBUG_MSG("[Buffer %d] Writing %ld bytes from %p to %p\n", cmd->buffer->id, cmd->cb, cmd->ptr, ptr+cmd->offset);
 
    //FIXME: Fix for people who use USE_HOST_PTR, modify data at host_ptr and use WriteBuffer to commit the change.

+ 3 - 2
src/common/fxt.h

@@ -23,12 +23,13 @@
 #define _GNU_SOURCE  /* ou _BSD_SOURCE ou _SVID_SOURCE */
 #endif
 
-#include <unistd.h>
-
 #include <string.h>
 #include <sys/types.h>
 #include <stdlib.h>
 #include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <common/utils.h>
 #include <starpu.h>
 

+ 31 - 3
src/common/timing.c

@@ -15,9 +15,9 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <starpu.h>
 #include <common/config.h>
+#include <starpu_util.h>
 #include <profiling/profiling.h>
 #include <common/timing.h>
 #include <math.h>
@@ -26,6 +26,10 @@
 #include <msg/msg.h>
 #endif
 
+#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
+#include <windows.h>
+#endif
+
 #ifdef STARPU_SIMGRID
 void _starpu_timing_init(void)
 {
@@ -125,6 +129,30 @@ static unsigned long long _starpu_residual = 0;
 
 static int _starpu_inited = 0;
 
+#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
+static int mygettimeofday(struct timeval tv, void *tz)
+{
+	if (tv)
+	{
+		FILETIME ft;
+		unsigned long long res;
+		GetSystemTimeAsFileTime(&ft);
+		/* 100-nanosecond intervals since January 1, 1601 */
+		res = ft.dwHighDateTime;
+		res <<= 32;
+		res |= ft.dwLowDateTime;
+		res /= 10;
+		/* Now we have microseconds */
+		res -= (((1970-1601)*365) + 89) * 24ULL * 3600ULL * 1000000ULL;
+		/* Now we are based on epoch */
+		tv->tv_sec = res / 1000000ULL;
+		tv->tv_usec = res % 1000000ULL;
+	}
+}
+#else
+#define mygettimeofday(tv,tz) gettimeofday(tv,tz)
+#endif
+
 void _starpu_timing_init(void)
 {
 	static union starpu_u_tick t1, t2;
@@ -146,10 +174,10 @@ void _starpu_timing_init(void)
 		struct timespec ts = { .tv_sec = 0, .tv_nsec = 500000000UL };
 
 		STARPU_GET_TICK(t1);
-		gettimeofday(&tv1,0);
+		mygettimeofday(&tv1,0);
 		_starpu_sleep(ts);
 		STARPU_GET_TICK(t2);
-		gettimeofday(&tv2,0);
+		mygettimeofday(&tv2,0);
 		_starpu_scale = ((tv2.tv_sec*1e6 + tv2.tv_usec) -
 				 (tv1.tv_sec*1e6 + tv1.tv_usec)) /
 			(double)(STARPU_TICK_DIFF(t1, t2));

+ 5 - 3
src/common/timing.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
+ * Copyright (C) 2009, 2010, 2014  Université de Bordeaux 1
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -23,11 +23,13 @@
  * functions.
  */
 
-#include <sys/time.h>
-#include <unistd.h>
 #include <stdint.h>
 #include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <starpu.h>
+#include <starpu_util.h>
 
 void _starpu_timing_init(void);
 void _starpu_clock_gettime(struct timespec *ts);

+ 6 - 2
src/common/utils.c

@@ -19,13 +19,18 @@
 #include <common/config.h>
 #include <common/utils.h>
 #include <errno.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <fcntl.h>
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #include <io.h>
 #include <sys/locking.h>
 #define mkdir(path, mode) mkdir(path)
+#if !defined(__MINGW32__)
+#define ftruncate(fd, length) _chsize(fd, length)
+#endif
 #endif
 
 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
@@ -35,8 +40,7 @@ static char * dirname(char * path)
    char drive[_MAX_DRIVE];
    char dir[_MAX_DIR];
    /* Remove trailing slash */
-   while (strlen(path) > 0 && (*(path+strlen(path)-1) == '/' || *(path+strlen(p
-th)-1) == '\\'))
+   while (strlen(path) > 0 && (*(path+strlen(path)-1) == '/' || *(path+strlen(path)-1) == '\\'))
       *(path+strlen(path)-1) = '\0';
    _splitpath(path, drive, dir, NULL, NULL);
    _makepath(path, drive, dir, NULL, NULL);

+ 8 - 8
src/core/disk_ops/disk_leveldb.cpp

@@ -266,8 +266,8 @@ get_leveldb_bandwidth_between_disk_and_main_ram(unsigned node)
 
 	unsigned iter;
 	double timing_slowness, timing_latency;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 	
 	srand (time (NULL)); 
 	char * buf = (char *) malloc(SIZE_DISK_MIN*sizeof(char));
@@ -281,13 +281,13 @@ get_leveldb_bandwidth_between_disk_and_main_ram(unsigned node)
 	struct starpu_leveldb_obj * tmp = (struct starpu_leveldb_obj *) mem;
 
 	/* Measure upload slowness */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; ++iter)
 	{
 		_starpu_disk_write(STARPU_MAIN_RAM, node, mem, buf, 0, SIZE_DISK_MIN, NULL);
 	}
-	gettimeofday(&end, NULL);
-	timing_slowness = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing_slowness = end - start;
 
 
 	/* free memory */
@@ -297,13 +297,13 @@ get_leveldb_bandwidth_between_disk_and_main_ram(unsigned node)
 	STARPU_ASSERT(buf != NULL);
 
 	/* Measure latency */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; ++iter)
 	{
 		_starpu_disk_write(STARPU_MAIN_RAM, node, mem, buf, rand() % (SIZE_DISK_MIN -1) , 1, NULL);
 	}
-	gettimeofday(&end, NULL);
-	timing_latency = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing_latency = end - start;
 
 	_starpu_disk_free(node, mem, SIZE_DISK_MIN);
 	free(buf);

+ 8 - 9
src/core/disk_ops/disk_stdio.c

@@ -18,7 +18,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #include <errno.h>
 #include <time.h>
 
@@ -269,8 +268,8 @@ static int get_stdio_bandwidth_between_disk_and_main_ram(unsigned node)
 {
 	unsigned iter;
 	double timing_slowness, timing_latency;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	srand (time (NULL));
 	char * buf = malloc(SIZE_DISK_MIN);
@@ -286,7 +285,7 @@ static int get_stdio_bandwidth_between_disk_and_main_ram(unsigned node)
 	memset(buf, 0, SIZE_DISK_MIN);
 
 	/* Measure upload slowness */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; ++iter)
 	{
 		_starpu_disk_write(STARPU_MAIN_RAM, node, mem, buf, 0, SIZE_DISK_MIN, NULL);
@@ -301,8 +300,8 @@ static int get_stdio_bandwidth_between_disk_and_main_ram(unsigned node)
 #endif
 		STARPU_ASSERT_MSG(res == 0, "Slowness computation failed \n");
 	}
-	gettimeofday(&end, NULL);
-	timing_slowness = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing_slowness = end - start;
 
 
 	/* free memory */
@@ -314,7 +313,7 @@ static int get_stdio_bandwidth_between_disk_and_main_ram(unsigned node)
 	*buf = 0;
 
 	/* Measure latency */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; ++iter)
 	{
 		_starpu_disk_write(STARPU_MAIN_RAM, node, mem, buf, rand() % (SIZE_DISK_MIN -1) , 1, NULL);
@@ -329,8 +328,8 @@ static int get_stdio_bandwidth_between_disk_and_main_ram(unsigned node)
 #endif
 		STARPU_ASSERT_MSG(res == 0, "Latency computation failed");
 	}
-	gettimeofday(&end, NULL);
-	timing_latency = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing_latency = end - start;
 
 	_starpu_disk_free(node, mem, SIZE_DISK_MIN);
 	free(buf);

+ 4 - 2
src/core/disk_ops/disk_unistd.c

@@ -15,12 +15,14 @@
  */
 
 #include <fcntl.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #include <stdint.h>
 
+#include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <starpu.h>
 #include <core/disk.h>
 #include <core/perfmodel/perfmodel.h>

+ 4 - 2
src/core/disk_ops/disk_unistd_o_direct.c

@@ -15,12 +15,14 @@
  */
 
 #include <fcntl.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #include <stdint.h>
 
+#include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <starpu.h>
 #include <core/disk.h>
 #include <core/perfmodel/perfmodel.h>

+ 12 - 10
src/core/disk_ops/unistd/disk_unistd_global.c

@@ -15,16 +15,18 @@
  */
 
 #include <fcntl.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #include <stdint.h>
 #ifdef HAVE_AIO_H
 #include <aio.h>
 #endif
 #include <errno.h>
 
+#include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <starpu.h>
 #include <core/disk.h>
 #include <core/perfmodel/perfmodel.h>
@@ -315,8 +317,8 @@ get_unistd_global_bandwidth_between_disk_and_main_ram(unsigned node)
 	int res;
 	unsigned iter;
 	double timing_slowness, timing_latency;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	srand (time (NULL)); 
 	char * buf;
@@ -332,7 +334,7 @@ get_unistd_global_bandwidth_between_disk_and_main_ram(unsigned node)
 	struct starpu_unistd_global_obj * tmp = (struct starpu_unistd_global_obj *) mem;
 
 	/* Measure upload slowness */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; ++iter)
 	{
 		_starpu_disk_write(STARPU_MAIN_RAM, node, mem, buf, 0, SIZE_DISK_MIN, NULL);
@@ -345,8 +347,8 @@ get_unistd_global_bandwidth_between_disk_and_main_ram(unsigned node)
 
 		STARPU_ASSERT_MSG(res == 0, "bandwidth computation failed");
 	}
-	gettimeofday(&end, NULL);
-	timing_slowness = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing_slowness = end - start;
 
 
 	/* free memory */
@@ -356,7 +358,7 @@ get_unistd_global_bandwidth_between_disk_and_main_ram(unsigned node)
 	STARPU_ASSERT(buf != NULL);
 
 	/* Measure latency */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; ++iter)
 	{
 		_starpu_disk_write(STARPU_MAIN_RAM, node, mem, buf, rand() % (SIZE_DISK_MIN -1) , MEM_SIZE, NULL);
@@ -369,8 +371,8 @@ get_unistd_global_bandwidth_between_disk_and_main_ram(unsigned node)
 
 		STARPU_ASSERT_MSG(res == 0, "Latency computation failed");
 	}
-	gettimeofday(&end, NULL);
-	timing_latency = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing_latency = end - start;
 
 	_starpu_disk_free(node, mem, SIZE_DISK_MIN);
 	starpu_free(buf);

+ 3 - 1
src/core/jobs.h

@@ -24,10 +24,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
-#include <unistd.h>
 #include <string.h>
 #include <stdarg.h>
 #include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <common/timing.h>
 #include <common/list.h>
 #include <common/fxt.h>

+ 2 - 0
src/core/perfmodel/perfmodel.c

@@ -20,7 +20,9 @@
 #include <starpu_profiling.h>
 #include <common/config.h>
 #include <common/utils.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <sys/stat.h>
 #include <core/perfmodel/perfmodel.h>
 #include <core/jobs.h>

+ 39 - 38
src/core/perfmodel/perfmodel_bus.c

@@ -22,8 +22,6 @@
 #endif
 #include <sched.h>
 #endif
-#include <unistd.h>
-#include <sys/time.h>
 #include <stdlib.h>
 #include <math.h>
 
@@ -31,6 +29,9 @@
 #include <starpu_cuda.h>
 #include <starpu_opencl.h>
 #include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <core/workers.h>
 #include <core/perfmodel/perfmodel.h>
 #include <core/simgrid.h>
@@ -165,54 +166,54 @@ static void measure_bandwidth_between_host_and_dev_on_cpu_with_cuda(int dev, int
 
 	unsigned iter;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	/* Measure upload bandwidth */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; iter++)
 	{
 		cudaMemcpy(d_buffer, h_buffer, size, cudaMemcpyHostToDevice);
 		cudaThreadSynchronize();
 	}
-	gettimeofday(&end, NULL);
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing = end - start;
 
 	dev_timing_per_cpu[(dev+1)*STARPU_MAXCPUS+cpu].timing_htod = timing/NITER/size;
 
 	/* Measure download bandwidth */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; iter++)
 	{
 		cudaMemcpy(h_buffer, d_buffer, size, cudaMemcpyDeviceToHost);
 		cudaThreadSynchronize();
 	}
-	gettimeofday(&end, NULL);
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing = end - start;
 
 	dev_timing_per_cpu[(dev+1)*STARPU_MAXCPUS+cpu].timing_dtoh = timing/NITER/size;
 
 	/* Measure upload latency */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; iter++)
 	{
 		cudaMemcpy(d_buffer, h_buffer, 1, cudaMemcpyHostToDevice);
 		cudaThreadSynchronize();
 	}
-	gettimeofday(&end, NULL);
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing = end - start;
 
 	dev_timing_per_cpu[(dev+1)*STARPU_MAXCPUS+cpu].latency_htod = timing/NITER;
 
 	/* Measure download latency */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; iter++)
 	{
 		cudaMemcpy(h_buffer, d_buffer, 1, cudaMemcpyDeviceToHost);
 		cudaThreadSynchronize();
 	}
-	gettimeofday(&end, NULL);
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing = end - start;
 
 	dev_timing_per_cpu[(dev+1)*STARPU_MAXCPUS+cpu].latency_dtoh = timing/NITER;
 
@@ -286,30 +287,30 @@ static void measure_bandwidth_between_dev_and_dev_cuda(int src, int dst)
 
 	unsigned iter;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	/* Measure upload bandwidth */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; iter++)
 	{
 		cudaMemcpyPeer(d_buffer, dst, s_buffer, src, size);
 		cudaThreadSynchronize();
 	}
-	gettimeofday(&end, NULL);
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing = end - start;
 
 	cudadev_timing_dtod[src+1][dst+1] = timing/NITER/size;
 
 	/* Measure upload latency */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; iter++)
 	{
 		cudaMemcpyPeer(d_buffer, dst, s_buffer, src, 1);
 		cudaThreadSynchronize();
 	}
-	gettimeofday(&end, NULL);
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing = end - start;
 
 	cudadev_latency_dtod[src+1][dst+1] = timing/NITER;
 
@@ -391,58 +392,58 @@ static void measure_bandwidth_between_host_and_dev_on_cpu_with_opencl(int dev, i
 
         unsigned iter;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	/* Measure upload bandwidth */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; iter++)
 	{
                 err = clEnqueueWriteBuffer(queue, d_buffer, CL_TRUE, 0, size, h_buffer, 0, NULL, NULL);
                 if (STARPU_UNLIKELY(err != CL_SUCCESS)) STARPU_OPENCL_REPORT_ERROR(err);
                 clFinish(queue);
 	}
-	gettimeofday(&end, NULL);
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing = end - start;
 
 	dev_timing_per_cpu[(dev+1)*STARPU_MAXCPUS+cpu].timing_htod = timing/NITER/size;
 
 	/* Measure download bandwidth */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; iter++)
 	{
                 err = clEnqueueReadBuffer(queue, d_buffer, CL_TRUE, 0, size, h_buffer, 0, NULL, NULL);
                 if (STARPU_UNLIKELY(err != CL_SUCCESS)) STARPU_OPENCL_REPORT_ERROR(err);
                 clFinish(queue);
 	}
-	gettimeofday(&end, NULL);
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing = end - start;
 
 	dev_timing_per_cpu[(dev+1)*STARPU_MAXCPUS+cpu].timing_dtoh = timing/NITER/size;
 
 	/* Measure upload latency */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; iter++)
 	{
 		err = clEnqueueWriteBuffer(queue, d_buffer, CL_TRUE, 0, 1, h_buffer, 0, NULL, NULL);
                 if (STARPU_UNLIKELY(err != CL_SUCCESS)) STARPU_OPENCL_REPORT_ERROR(err);
                 clFinish(queue);
 	}
-	gettimeofday(&end, NULL);
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing = end - start;
 
 	dev_timing_per_cpu[(dev+1)*STARPU_MAXCPUS+cpu].latency_htod = timing/NITER;
 
 	/* Measure download latency */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (iter = 0; iter < NITER; iter++)
 	{
 		err = clEnqueueReadBuffer(queue, d_buffer, CL_TRUE, 0, 1, h_buffer, 0, NULL, NULL);
                 if (STARPU_UNLIKELY(err != CL_SUCCESS)) STARPU_OPENCL_REPORT_ERROR(err);
                 clFinish(queue);
 	}
-	gettimeofday(&end, NULL);
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	timing = end - start;
 
 	dev_timing_per_cpu[(dev+1)*STARPU_MAXCPUS+cpu].latency_dtoh = timing/NITER;
 

+ 3 - 1
src/core/perfmodel/perfmodel_history.c

@@ -16,13 +16,15 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <unistd.h>
 #if !defined(_WIN32) || defined(__MINGW__) || defined(__CYGWIN__)
 #include <dirent.h>
 #include <sys/stat.h>
 #endif
 #include <errno.h>
 #include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <common/utils.h>
 #include <core/perfmodel/perfmodel.h>
 #include <core/jobs.h>

+ 3 - 0
src/core/simgrid.c

@@ -16,7 +16,10 @@
 
 #include <starpu.h>
 #include <datawizard/memory_nodes.h>
+#include <common/config.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <core/perfmodel/perfmodel.h>
 #include <core/workers.h>
 #include <core/simgrid.h>

+ 1 - 1
src/core/workers.c

@@ -1023,7 +1023,7 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
 	initialized = CHANGING;
 	STARPU_PTHREAD_MUTEX_UNLOCK(&init_mutex);
 
-#ifdef __MINGW32__
+#if defined(_WIN32) && !defined(__CYGWIN__)
 	WSADATA wsadata;
 	WSAStartup(MAKEWORD(1,0), &wsadata);
 #endif

+ 23 - 23
src/datawizard/copy_driver.c

@@ -524,30 +524,30 @@ int starpu_interface_copy(uintptr_t src, size_t src_offset, unsigned src_node, u
 	switch (_STARPU_MEMORY_NODE_TUPLE(src_kind,dst_kind))
 	{
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_CPU_RAM,STARPU_CPU_RAM):
-		memcpy((void *) dst + dst_offset, (void *) src + src_offset, size);
+		memcpy((void *) (dst + dst_offset), (void *) (src + src_offset), size);
 		return 0;
 
 #ifdef STARPU_USE_CUDA
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_CUDA_RAM,STARPU_CPU_RAM):
 		return starpu_cuda_copy_async_sync(
-				(void*) src + src_offset, src_node,
-				(void*) dst + dst_offset, dst_node,
+				(void*) (src + src_offset), src_node,
+				(void*) (dst + dst_offset), dst_node,
 				size,
 				async_channel?starpu_cuda_get_local_out_transfer_stream():NULL,
 				cudaMemcpyDeviceToHost);
 
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_CPU_RAM,STARPU_CUDA_RAM):
 		return starpu_cuda_copy_async_sync(
-				(void*) src + src_offset, src_node,
-				(void*) dst + dst_offset, dst_node,
+				(void*) (src + src_offset), src_node,
+				(void*) (dst + dst_offset), dst_node,
 				size,
 				async_channel?starpu_cuda_get_local_in_transfer_stream():NULL,
 				cudaMemcpyHostToDevice);
 
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_CUDA_RAM,STARPU_CUDA_RAM):
 		return starpu_cuda_copy_async_sync(
-				(void*) src + src_offset, src_node,
-				(void*) dst + dst_offset, dst_node,
+				(void*) (src + src_offset), src_node,
+				(void*) (dst + dst_offset), dst_node,
 				size,
 				async_channel?starpu_cuda_get_peer_transfer_stream(src_node, dst_node):NULL,
 				cudaMemcpyDeviceToDevice);
@@ -567,54 +567,54 @@ int starpu_interface_copy(uintptr_t src, size_t src_offset, unsigned src_node, u
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_MIC_RAM,STARPU_CPU_RAM):
 		if (async_data)
 			return _starpu_mic_copy_mic_to_ram_async(
-					(void*) src + src_offset, src_node,
-					(void*) dst + dst_offset, dst_node,
+					(void*) (src + src_offset), src_node,
+					(void*) (dst + dst_offset), dst_node,
 					size);
 		else
 			return _starpu_mic_copy_mic_to_ram(
-					(void*) src + src_offset, src_node,
-					(void*) dst + dst_offset, dst_node,
+					(void*) (src + src_offset), src_node,
+					(void*) (dst + dst_offset), dst_node,
 					size);
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_CPU_RAM,STARPU_MIC_RAM):
 		if (async_data)
 			return _starpu_mic_copy_ram_to_mic_async(
-					(void*) src + src_offset, src_node,
-					(void*) dst + dst_offset, dst_node,
+					(void*) (src + src_offset), src_node,
+					(void*) (dst + dst_offset), dst_node,
 					size);
 		else
 			return _starpu_mic_copy_ram_to_mic(
-					(void*) src + src_offset, src_node,
-					(void*) dst + dst_offset, dst_node,
+					(void*) (src + src_offset), src_node,
+					(void*) (dst + dst_offset), dst_node,
 					size);
 #endif
 #ifdef STARPU_USE_SCC
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_SCC_RAM,STARPU_CPU_RAM):
 		return _starpu_scc_copy_sink_to_src(
-				(void*) src + src_offset, src_node,
-				(void*) dst + dst_offset, dst_node,
+				(void*) (src + src_offset), src_node,
+				(void*) (dst + dst_offset), dst_node,
 				size);
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_CPU_RAM,STARPU_SCC_RAM):
 		return _starpu_scc_copy_src_to_sink(
-				(void*) src + src_offset, src_node,
-				(void*) dst + dst_offset, dst_node,
+				(void*) (src + src_offset), src_node,
+				(void*) (dst + dst_offset), dst_node,
 				size);
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_SCC_RAM,STARPU_SCC_RAM):
 		return _starpu_scc_copy_sink_to_sink(
-				(void*) src + src_offset, src_node,
-				(void*) dst + dst_offset, dst_node,
+				(void*) (src + src_offset), src_node,
+				(void*) (dst + dst_offset), dst_node,
 				size);
 #endif
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_CPU_RAM, STARPU_DISK_RAM):
 	{
 		return _starpu_disk_copy_src_to_disk(
-			(void*) src + src_offset, src_node,
+			(void*) (src + src_offset), src_node,
 			(void*) dst, dst_offset, dst_node,
 			size, async_channel);
 	}
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_DISK_RAM, STARPU_CPU_RAM):
 		return _starpu_disk_copy_disk_to_src(
 			(void*) src, src_offset, src_node,
-			(void*) dst + dst_offset, dst_node,
+			(void*) (dst + dst_offset), dst_node,
 			size, async_channel);
 
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_DISK_RAM, STARPU_DISK_RAM):

+ 6 - 6
src/datawizard/interfaces/block_interface.c

@@ -225,14 +225,14 @@ static int pack_block_handle(starpu_data_handle_t handle, unsigned node, void **
 	if (ptr != NULL)
 	{
 		uint32_t z, y;
-		void *block = (void *)block_interface->ptr;
+		char *block = (void *)block_interface->ptr;
 
 		*ptr = malloc(*count);
 
-		void *cur = *ptr;
+		char *cur = *ptr;
 		for(z=0 ; z<block_interface->nz ; z++)
 		{
-			void *block_z = block;
+			char *block_z = block;
 			for(y=0 ; y<block_interface->ny ; y++)
 			{
 				memcpy(cur, block, block_interface->nx*block_interface->elemsize);
@@ -256,11 +256,11 @@ static int unpack_block_handle(starpu_data_handle_t handle, unsigned node, void
 	STARPU_ASSERT(count == block_interface->elemsize * block_interface->nx * block_interface->ny * block_interface->nz);
 
 	uint32_t z, y;
-	void *cur = ptr;
-	void *block = (void *)block_interface->ptr;
+	char *cur = ptr;
+	char *block = (void *)block_interface->ptr;
 	for(z=0 ; z<block_interface->nz ; z++)
 	{
-		void *block_z = block;
+		char *block_z = block;
 		for(y=0 ; y<block_interface->ny ; y++)
 		{
 			memcpy(block, cur, block_interface->nx*block_interface->elemsize);

+ 4 - 4
src/datawizard/interfaces/matrix_interface.c

@@ -216,11 +216,11 @@ static int pack_matrix_handle(starpu_data_handle_t handle, unsigned node, void *
 	if (ptr != NULL)
 	{
 		uint32_t y;
-		void *matrix = (void *)matrix_interface->ptr;
+		char *matrix = (void *)matrix_interface->ptr;
 
 		*ptr = malloc(*count);
 
-		void *cur = *ptr;
+		char *cur = *ptr;
 		for(y=0 ; y<matrix_interface->ny ; y++)
 		{
 			memcpy(cur, matrix, matrix_interface->nx*matrix_interface->elemsize);
@@ -242,8 +242,8 @@ static int unpack_matrix_handle(starpu_data_handle_t handle, unsigned node, void
 	STARPU_ASSERT(count == matrix_interface->elemsize * matrix_interface->nx * matrix_interface->ny);
 
 	uint32_t y;
-	void *cur = ptr;
-	void *matrix = (void *)matrix_interface->ptr;
+	char *cur = ptr;
+	char *matrix = (void *)matrix_interface->ptr;
 	for(y=0 ; y<matrix_interface->ny ; y++)
 	{
 		memcpy(matrix, cur, matrix_interface->nx*matrix_interface->elemsize);

+ 1 - 1
src/drivers/driver_common/driver_common.h

@@ -18,8 +18,8 @@
 #ifndef __DRIVER_COMMON_H__
 #define __DRIVER_COMMON_H__
 
-#include <sys/time.h>
 #include <starpu.h>
+#include <starpu_util.h>
 #include <core/jobs.h>
 #include <common/utils.h>
 

+ 2 - 2
src/drivers/opencl/driver_opencl.c

@@ -376,7 +376,7 @@ cl_int starpu_opencl_copy_async_sync(uintptr_t src, size_t src_offset, unsigned
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_OPENCL_RAM,STARPU_CPU_RAM):
 		err = starpu_opencl_copy_opencl_to_ram(
 				(cl_mem) src, src_node,
-				(void*) dst + dst_offset, dst_node,
+				(void*) (dst + dst_offset), dst_node,
 				size, src_offset, event, &ret);
 		if (STARPU_UNLIKELY(err))
 			STARPU_OPENCL_REPORT_ERROR(err);
@@ -384,7 +384,7 @@ cl_int starpu_opencl_copy_async_sync(uintptr_t src, size_t src_offset, unsigned
 
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_CPU_RAM,STARPU_OPENCL_RAM):
 		err = starpu_opencl_copy_ram_to_opencl(
-				(void*) src + src_offset, src_node,
+				(void*) (src + src_offset), src_node,
 				(cl_mem) dst, dst_node,
 				size, dst_offset, event, &ret);
 		if (STARPU_UNLIKELY(err))

+ 5 - 2
src/drivers/opencl/driver_opencl_utils.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
- * Copyright (C) 2010-2013  Université de Bordeaux 1
+ * Copyright (C) 2010-2014  Université de Bordeaux 1
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -20,9 +20,12 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/types.h>
 
+#include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <starpu_opencl.h>
 #include <starpu_profiling.h>
 #include <core/workers.h>

+ 2 - 2
src/profiling/profiling.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2012  Université de Bordeaux 1
+ * Copyright (C) 2010-2012, 2014  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2013  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -18,9 +18,9 @@
 #ifndef __PROFILING_H__
 #define __PROFILING_H__
 
-#include <sys/time.h>
 #include <starpu.h>
 #include <starpu_profiling.h>
+#include <starpu_util.h>
 #include <common/config.h>
 
 /* Create a task profiling info structure (with the proper time stamps) in case

+ 2 - 2
src/top/starpu_top_connection.c

@@ -15,8 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#define WINVER WindowsXP
-
 #include <starpu_config.h>
 
 #ifdef __MINGW__
@@ -42,7 +40,9 @@
 #include <string.h>
 #include <sys/types.h>
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 
 const char *STARPU_TOP_PORT = "2011";
 const int STARPU_TOP_BUFFER_SIZE=1024;

+ 0 - 1
src/top/starpu_top_task.c

@@ -22,7 +22,6 @@
 #include <core/task.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/time.h>
 #include <common/timing.h>
 
 /********************************************