瀏覽代碼

merge trunk

Nathalie Furmento 10 年之前
父節點
當前提交
eb85895d18
共有 61 個文件被更改,包括 243 次插入306 次删除
  1. 1 1
      Makefile.am
  2. 0 1
      examples/audio/starpu_audio_processing.c
  3. 0 1
      examples/axpy/axpy.c
  4. 0 1
      examples/basic_examples/mult.c
  5. 0 1
      examples/binary/binary.c
  6. 0 1
      examples/callback/callback.c
  7. 0 1
      examples/callback/prologue.c
  8. 0 1
      examples/cg/cg.c
  9. 0 1
      examples/cholesky/cholesky.h
  10. 0 1
      examples/heat/dw_factolu.c
  11. 0 1
      examples/heat/dw_factolu.h
  12. 0 1
      examples/incrementer/incrementer.c
  13. 0 1
      examples/lu/xlu.h
  14. 0 1
      examples/mandelbrot/mandelbrot.c
  15. 0 1
      examples/mult/xgemm.c
  16. 0 1
      examples/pi/pi.c
  17. 0 1
      examples/pi/pi_redux.c
  18. 0 1
      examples/ppm_downscaler/yuv_downscaler.c
  19. 16 16
      examples/sched_ctx_utils/sched_ctx_utils.c
  20. 0 1
      examples/sched_ctx_utils/sched_ctx_utils.h
  21. 0 1
      examples/spmv/dw_block_spmv.c
  22. 0 1
      examples/spmv/spmv.h
  23. 8 36
      examples/stencil/stencil-kernels.c
  24. 4 5
      examples/stencil/stencil.c
  25. 3 3
      examples/stencil/stencil.h
  26. 6 9
      examples/worker_collections/worker_list_example.c
  27. 6 9
      examples/worker_collections/worker_tree_example.c
  28. 0 1
      include/pthread_win32/pthread.h
  29. 4 2
      include/starpu_thread_util.h
  30. 1 1
      src/common/timing.c
  31. 1 0
      src/core/disk_ops/disk_leveldb.cpp
  32. 4 1
      src/dolib.c
  33. 5 7
      tests/experiments/bandwidth_cuda/cuda_bandwidth.c
  34. 5 7
      tests/experiments/latency/cuda_latency.c
  35. 9 10
      tests/helper/cublas_init.c
  36. 30 1
      tests/loader.c
  37. 6 7
      tests/main/empty_task.c
  38. 0 1
      tests/main/empty_task_sync_point.c
  39. 0 1
      tests/main/get_current_task.c
  40. 6 7
      tests/main/multithreaded.c
  41. 6 7
      tests/main/multithreaded_init.c
  42. 9 10
      tests/main/pause_resume.c
  43. 6 8
      tests/main/regenerate.c
  44. 8 9
      tests/main/restart.c
  45. 6 7
      tests/main/starpu_task_wait.c
  46. 6 7
      tests/main/starpu_task_wait_for_all.c
  47. 7 9
      tests/main/static_restartable.c
  48. 7 9
      tests/main/static_restartable_tag.c
  49. 7 9
      tests/main/static_restartable_using_initializer.c
  50. 3 4
      tests/main/subgraph_repeat.c
  51. 3 4
      tests/main/subgraph_repeat_regenerate.c
  52. 3 4
      tests/main/subgraph_repeat_regenerate_tag.c
  53. 3 4
      tests/main/subgraph_repeat_tag.c
  54. 0 1
      tests/main/submit.c
  55. 6 8
      tests/main/wait_all_regenerable_tasks.c
  56. 6 7
      tests/microbenchs/async_tasks_overhead.c
  57. 6 8
      tests/microbenchs/local_pingpong.c
  58. 8 9
      tests/microbenchs/matrix_as_vector.c
  59. 6 7
      tests/microbenchs/sync_tasks_overhead.c
  60. 12 13
      tests/microbenchs/tasks_overhead.c
  61. 10 17
      tests/microbenchs/tasks_size_overhead.c

+ 1 - 1
Makefile.am

@@ -98,7 +98,7 @@ starpu-top/starpu_top$(EXEEXT): all-local
 all-local:
 	cd starpu-top ; $(QMAKE) ; $(MAKE)
 if STARPU_DEVEL
-	@if grep -r sys/time.h $$( find $(srcdir)/src $(srcdir)/mpi/src $(srcdir)/include -name \*.[ch] -a \! -name starpu_util.h ) ; \
+	@if grep -r sys/time.h $$( find $(srcdir)/examples $(srcdir)/tests $(srcdir)/src $(srcdir)/mpi/src $(srcdir)/include -name \*.[ch] -a \! -name starpu_util.h -a \! -name timer.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 ; \

+ 0 - 1
examples/audio/starpu_audio_processing.c

@@ -21,7 +21,6 @@
 #include <math.h>
 #include <string.h>
 #include <sys/types.h>
-#include <sys/time.h>
 
 #include <starpu.h>
 #include <fftw3.h>

+ 0 - 1
examples/axpy/axpy.c

@@ -20,7 +20,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
-#include <sys/time.h>
 #include <math.h>
 
 #include <common/blas.h>

+ 0 - 1
examples/basic_examples/mult.c

@@ -34,7 +34,6 @@
 #include <string.h>
 #include <math.h>
 #include <sys/types.h>
-#include <sys/time.h>
 #include <signal.h>
 
 #include <starpu.h>

+ 0 - 1
examples/binary/binary.c

@@ -16,7 +16,6 @@
  */
 
 #include <starpu.h>
-#include <sys/time.h>
 
 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
 

+ 0 - 1
examples/callback/callback.c

@@ -16,7 +16,6 @@
  */
 
 #include <starpu.h>
-#include <sys/time.h>
 
 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
 

+ 0 - 1
examples/callback/prologue.c

@@ -16,7 +16,6 @@
  */
 
 #include <starpu.h>
-#include <sys/time.h>
 
 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
 

+ 0 - 1
examples/cg/cg.c

@@ -16,7 +16,6 @@
 
 #include <math.h>
 #include <assert.h>
-#include <sys/time.h>
 #include <starpu.h>
 #include <common/blas.h>
 

+ 0 - 1
examples/cholesky/cholesky.h

@@ -21,7 +21,6 @@
 #include <limits.h>
 #include <string.h>
 #include <math.h>
-#include <sys/time.h>
 #ifdef STARPU_USE_CUDA
 #include <cuda.h>
 #include <cuda_runtime.h>

+ 0 - 1
examples/heat/dw_factolu.c

@@ -17,7 +17,6 @@
  */
 
 #include "dw_factolu.h"
-#include <sys/time.h>
 
 #if 0
 #define debug(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)

+ 0 - 1
examples/heat/dw_factolu.h

@@ -21,7 +21,6 @@
 #include <semaphore.h>
 #include <string.h>
 #include <math.h>
-#include <sys/time.h>
 #include <starpu.h>
 #ifdef STARPU_USE_CUDA
 #include <cuda.h>

+ 0 - 1
examples/incrementer/incrementer.c

@@ -16,7 +16,6 @@
  */
 
 #include <starpu.h>
-#include <sys/time.h>
 
 static unsigned niter = 50000;
 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)

+ 0 - 1
examples/lu/xlu.h

@@ -18,7 +18,6 @@
 #ifndef __XLU_H__
 #define __XLU_H__
 
-#include <sys/time.h>
 #include <starpu.h>
 #include <common/blas.h>
 

+ 0 - 1
examples/mandelbrot/mandelbrot.c

@@ -16,7 +16,6 @@
  */
 
 #include <starpu.h>
-#include <sys/time.h>
 #include <math.h>
 #include <limits.h>
 #ifdef STARPU_HAVE_X11

+ 0 - 1
examples/mult/xgemm.c

@@ -20,7 +20,6 @@
 #include <string.h>
 #include <math.h>
 #include <sys/types.h>
-#include <sys/time.h>
 #include <starpu.h>
 
 #include <common/blas.h>

+ 0 - 1
examples/pi/pi.c

@@ -19,7 +19,6 @@
 #include "SobolQRNG/sobol.h"
 #include "SobolQRNG/sobol_gold.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_redux.c

@@ -16,7 +16,6 @@
 
 #include <starpu.h>
 #include <stdlib.h>
-#include <sys/time.h>
 
 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
 #define PI	3.14159265358979323846

+ 0 - 1
examples/ppm_downscaler/yuv_downscaler.c

@@ -20,7 +20,6 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #include <unistd.h>
 #include <assert.h>
 #include <stdio.h>

+ 16 - 16
examples/sched_ctx_utils/sched_ctx_utils.c

@@ -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
  *
  * 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
@@ -131,10 +131,10 @@ void start_2benchs(void (*bench)(unsigned, unsigned))
 	starpu_pthread_t tid[2];
 	starpu_pthread_mutex_init(&mut, NULL);
 
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	starpu_pthread_create(&tid[0], NULL, (void*)start_bench, (void*)&p1);
 	starpu_pthread_create(&tid[1], NULL, (void*)start_bench, (void*)&p2);
@@ -142,11 +142,11 @@ void start_2benchs(void (*bench)(unsigned, unsigned))
 	starpu_pthread_join(tid[0], NULL);
 	starpu_pthread_join(tid[1], NULL);
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
 	starpu_pthread_mutex_destroy(&mut);
 
-	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	double timing = end - start;
 	timing /= 1000000;
 
 	printf("%2.2f %2.2f ", rv[0].flops, rv[1].flops);
@@ -160,18 +160,18 @@ void start_1stbench(void (*bench)(unsigned, unsigned))
 	p1.size = size1;
 	p1.nblocks = nblocks1;
 
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	start_bench((void*)&p1);
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
 	starpu_pthread_mutex_destroy(&mut);
 
-	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	double timing = end - start;
 	timing /= 1000000;
 
 	printf("%2.2f ", rv[0].flops);
@@ -184,18 +184,18 @@ void start_2ndbench(void (*bench)(unsigned, unsigned))
 	p2.size = size2;
 	p2.nblocks = nblocks2;
 
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	start_bench((void*)&p2);
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
 	starpu_pthread_mutex_destroy(&mut);
 
-	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	double timing = end - start;
 	timing /= 1000000;
 
 	printf("%2.2f ", rv[1].flops);

+ 0 - 1
examples/sched_ctx_utils/sched_ctx_utils.h

@@ -17,7 +17,6 @@
 #include <limits.h>
 #include <string.h>
 #include <math.h>
-#include <sys/time.h>
 #include <stdlib.h>
 
 void parse_args_ctx(int argc, char **argv);

+ 0 - 1
examples/spmv/dw_block_spmv.c

@@ -16,7 +16,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include "dw_block_spmv.h"
 #include "matrix_market/mm_to_bcsr.h"
 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)

+ 0 - 1
examples/spmv/spmv.h

@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 #include <math.h>
-#include <sys/time.h>
 #include <signal.h>
 
 #include <starpu.h>

+ 8 - 36
examples/stencil/stencil-kernels.c

@@ -16,34 +16,6 @@
  */
 
 #include "stencil.h"
-#include <sys/time.h>
-
-#ifndef timersub
-#define	timersub(x, y, res) \
-	do \
-	{						   \
-		(res)->tv_sec = (x)->tv_sec - (y)->tv_sec; \
-		(res)->tv_usec = (x)->tv_usec - (y)->tv_usec; \
-		if ((res)->tv_usec < 0) \
-		{			 \
-			(res)->tv_sec--; \
-			(res)->tv_usec += 1000000; \
-		} \
-	} while (0)
-#endif
-#ifndef timeradd
-#define	timeradd(x, y, res) \
-	do \
-	{						   \
-		(res)->tv_sec = (x)->tv_sec + (y)->tv_sec; \
-		(res)->tv_usec = (x)->tv_usec + (y)->tv_usec; \
-		if ((res)->tv_usec >= 1000000) \
-		{			       \
-			(res)->tv_sec++; \
-			(res)->tv_usec -= 1000000; \
-		} \
-	} while (0)
-#endif
 
 /* Computation Kernels */
 
@@ -123,7 +95,7 @@
 int who_runs_what_len;
 int *who_runs_what;
 int *who_runs_what_index;
-struct timeval *last_tick;
+double *last_tick;
 
 /* Achieved iterations */
 static int achieved_iter;
@@ -133,16 +105,16 @@ unsigned update_per_worker[STARPU_NMAXWORKERS];
 
 static void record_who_runs_what(struct block_description *block)
 {
-	struct timeval tv, tv2, diff, delta = {.tv_sec = 0, .tv_usec = get_ticks() * 1000};
+	double now, now2, diff, delta = get_ticks() * 1000;
 	int workerid = starpu_worker_get_id();
 
-	gettimeofday(&tv, NULL);
-	timersub(&tv, &start, &tv2);
-	timersub(&tv2, &last_tick[block->bz], &diff);
-	while (timercmp(&diff, &delta, >=))
+	now = starpu_timing_now();
+	now2 = now - start;
+	diff = now2 - last_tick[block->bz];
+	while (diff >= delta)
 	{
-		timeradd(&last_tick[block->bz], &delta, &last_tick[block->bz]);
-		timersub(&tv2, &last_tick[block->bz], &diff);
+		last_tick[block->bz] += delta;
+		diff = now2 - last_tick[block->bz];
 		if (who_runs_what_index[block->bz] < who_runs_what_len)
 			who_runs_what[block->bz + (who_runs_what_index[block->bz]++) * get_nbz()] = -1;
 	}

+ 4 - 5
examples/stencil/stencil.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
- * Copyright (C) 2010-2012  Université de Bordeaux 1
+ * Copyright (C) 2010-2012, 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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include "stencil.h"
 
 /* Main application */
@@ -149,7 +148,7 @@ static void init_problem(int argc, char **argv, int rank, int world_size)
 	who_runs_what_len = 2*niter;
 	who_runs_what = (int *) calloc(nbz * who_runs_what_len, sizeof(*who_runs_what));
 	who_runs_what_index = (int *) calloc(nbz, sizeof(*who_runs_what_index));
-	last_tick = (struct timeval *) calloc(nbz, sizeof(*last_tick));
+	last_tick = (double *) calloc(nbz, sizeof(*last_tick));
 }
 
 static void free_problem(int rank)
@@ -165,7 +164,7 @@ static void free_problem(int rank)
  *	Main body
  */
 
-struct timeval start;
+double start;
 double begin, end;
 double timing; 
 
@@ -254,7 +253,7 @@ int main(int argc, char **argv)
 	if (rank == 0)
 		FPRINTF(stderr, "GO !\n");
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	begin = starpu_timing_now();
 

+ 3 - 3
examples/stencil/stencil.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
- * Copyright (C) 2010-2011  Université de Bordeaux 1
+ * Copyright (C) 2010-2011, 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
@@ -130,11 +130,11 @@ extern unsigned update_per_worker[STARPU_NMAXWORKERS];
 extern unsigned top_per_worker[STARPU_NMAXWORKERS];
 extern unsigned bottom_per_worker[STARPU_NMAXWORKERS];
 
-extern struct timeval start;
+extern double start;
 extern int who_runs_what_len;
 extern int *who_runs_what;
 extern int *who_runs_what_index;
-extern struct timeval *last_tick;
+extern double *last_tick;
 
 #ifndef _externC
 #define _externC

+ 6 - 9
examples/worker_collections/worker_list_example.c

@@ -16,7 +16,6 @@
  */
 
 #include <starpu.h>
-#include <sys/time.h>
 
 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
 
@@ -40,18 +39,16 @@ int main()
 
 	FPRINTF(stderr, "ncpus %d \n", ncpus);
 
-	struct timeval start_time;
-        struct timeval end_time;
-        gettimeofday(&start_time, NULL);
+	double start_time;
+	double end_time;
 
-	co->init(co);
+	start_time = starpu_timing_now();
 
-	gettimeofday(&end_time, NULL);
+	co->init(co);
 
-        long diff_s = end_time.tv_sec  - start_time.tv_sec;
-        long diff_us = end_time.tv_usec  - start_time.tv_usec;
+	end_time = starpu_timing_now();
 
-	float timing = (float)(diff_s*1000000 + diff_us)/1000;
+	double timing = (end_time - start_time) / 1000;
 
 	int i;
 	for(i = 0; i < ncpus; i++)

+ 6 - 9
examples/worker_collections/worker_tree_example.c

@@ -16,7 +16,6 @@
  */
 
 #include <starpu.h>
-#include <sys/time.h>
 
 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
 
@@ -53,18 +52,16 @@ int main()
 
 	FPRINTF(stderr, "ncpus %d \n", ncpus);
 
-	struct timeval start_time;
-        struct timeval end_time;
-        gettimeofday(&start_time, NULL);
+	double start_time;
+	double end_time;
 
-	co->init(co);
+	start_time = starpu_timing_now();
 
-	gettimeofday(&end_time, NULL);
+	co->init(co);
 
-        long diff_s = end_time.tv_sec  - start_time.tv_sec;
-        long diff_us = end_time.tv_usec  - start_time.tv_usec;
+	end_time = starpu_timing_now();
 
-	float timing = (float)(diff_s*1000000 + diff_us)/1000;
+	double timing = (end_time - start_time) / 1000;
 
 	int i;
 	for(i = 0; i < ncpus; i++)

+ 0 - 1
include/pthread_win32/pthread.h

@@ -33,7 +33,6 @@ extern "C" {
 
 #include <windows.h>
 #include <sys/types.h>
-#undef interface
 #include <stdio.h>
 #include <errno.h>
 

+ 4 - 2
include/starpu_thread_util.h

@@ -21,6 +21,7 @@
 #include <starpu_util.h>
 #include <errno.h>
 
+#if !(defined(_MSC_VER) && !defined(BUILDING_STARPU))
 /*
  * Encapsulation of the starpu_pthread_create_* functions.
  */
@@ -80,9 +81,9 @@
 } while (0)
 
 #define STARPU_PTHREAD_MUTEX_TRYLOCK(mutex) \
-	_STARPU_PTHREAD_MUTEX_TRYLOCK(mutex, __FILE__, __LINE__)
+	_starpu_pthread_mutex_trylock(mutex, __FILE__, __LINE__)
 static STARPU_INLINE
-int _STARPU_PTHREAD_MUTEX_TRYLOCK(starpu_pthread_mutex_t *mutex, char *file, int line)
+int _starpu_pthread_mutex_trylock(starpu_pthread_mutex_t *mutex, char *file, int line)
 {
 	int p_ret = starpu_pthread_mutex_trylock(mutex);
 	if (STARPU_UNLIKELY(p_ret != 0 && p_ret != EBUSY)) {
@@ -305,5 +306,6 @@ int _starpu_pthread_rwlock_trywrlock(starpu_pthread_rwlock_t *rwlock, char *file
 			STARPU_ABORT();                                        \
 	}                                                                      \
 } while (0)
+#endif /* _MSC_VER */
 
 #endif /* __STARPU_THREAD_UTIL_H__ */

+ 1 - 1
src/common/timing.c

@@ -130,7 +130,7 @@ 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)
+static int mygettimeofday(struct timeval *tv, void *tz)
 {
 	if (tv)
 	{

+ 1 - 0
src/core/disk_ops/disk_leveldb.cpp

@@ -17,6 +17,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <common/config.h>
 #include <leveldb/db.h>
 #include <leveldb/options.h>
 

+ 4 - 1
src/dolib.c

@@ -16,9 +16,12 @@
 
 /* Wrapper to avoid msys' tendency to turn / into \ and : into ;  */
 
-#include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 int main(int argc, char *argv[])
 {

+ 5 - 7
tests/experiments/bandwidth_cuda/cuda_bandwidth.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010  Université de Bordeaux 1
+ * Copyright (C) 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
@@ -31,8 +31,6 @@
 #include <pthread.h>
 #include <assert.h>
 
-#include <sys/time.h>
-
 int GPU_LD	=	2048;
 int CPU_LD	=	2048;
 int MATRIXSIZE	=	1024;
@@ -116,7 +114,7 @@ void benchmark_memcpy(void)
 {
 	unsigned count;
 
-	struct timeval tv_start, tv_end;
+	double tv_start, tv_end;
 	unsigned long long usecs;
 
 	double bytes = 4.0*MATRIXSIZE*MATRIXSIZE*ITER;
@@ -138,7 +136,7 @@ void benchmark_memcpy(void)
 	cublasAlloc(GPU_LD*GPU_LD, sizeof(float), &d_A);
 	STARPU_ASSERT(d_A);
 
-	gettimeofday(&tv_start, NULL);	
+	tv_start = starpu_timing_now();	
 
 	if (!pinned)
 	{
@@ -186,8 +184,8 @@ void benchmark_memcpy(void)
 	
 	}
 
-	gettimeofday(&tv_end, NULL);
-	usecs = (tv_end.tv_usec - tv_start.tv_usec) + 1000000*(tv_end.tv_sec - tv_start.tv_sec);
+	tv_end = starpu_timing_now();
+	usecs = tv_end - tv_start;
 	printf("%2.2f\n", bytes/usecs);
 
 	if (pinned)

+ 5 - 7
tests/experiments/latency/cuda_latency.c

@@ -19,7 +19,6 @@
 #include <cuda_runtime.h>
 #include <assert.h>
 #include <sys/types.h>
-#include <sys/time.h>
 
 static starpu_pthread_t thread[2];
 static unsigned thread_is_initialized[2];
@@ -181,11 +180,11 @@ int main(int argc, char **argv)
 		STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 	}
 
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	/* Start the ping pong */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	ready = 1;
@@ -200,10 +199,9 @@ int main(int argc, char **argv)
 	}
 	STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 	
-	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 +
-		(end.tv_usec - start.tv_usec));
+	double timing = end - start;
 
 	fprintf(stderr, "Took %.0f ms for %d iterations\n", timing/1000, niter);
 	fprintf(stderr, "Latency: %.2f us\n", timing/(2*niter));

+ 9 - 10
tests/helper/cublas_init.c

@@ -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, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
@@ -23,8 +22,8 @@
 #include <stdlib.h>
 #include "../helper.h"
 
-struct timeval start;
-struct timeval end;
+static double start;
+static double end;
 
 //static float *data = NULL;
 
@@ -41,15 +40,15 @@ int main(int argc, char **argv)
 	double init_timing;
 	double shutdown_timing;
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	starpu_cublas_init();
-	gettimeofday(&end, NULL);
-	init_timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	init_timing = end - start;
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	starpu_cublas_shutdown();
-	gettimeofday(&end, NULL);
-	shutdown_timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	end = starpu_timing_now();
+	shutdown_timing = end - start;
 
 	FPRINTF(stderr, "Total:\n");
 	FPRINTF(stderr, "\tinit: %2.2f us\n", init_timing/(1000));

+ 30 - 1
tests/loader.c

@@ -16,7 +16,6 @@
 
 #include <common/config.h>
 
-#include <sys/time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
@@ -27,12 +26,42 @@
 #include <signal.h>
 #include <string.h>
 
+#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
+#include <windows.h>
+#else
+#include <sys/time.h>
+#endif
+
 #define  DEFAULT_TIMEOUT       600
 #define  AUTOTEST_SKIPPED_TEST 77
 
 static pid_t child_pid = 0;
 static int   timeout;
 
+#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
+
 static void launch_gdb(const char *exe)
 {
 #ifdef STARPU_GDB_PATH

+ 6 - 7
tests/main/empty_task.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010-2011  Université de Bordeaux 1
+ * Copyright (C) 2009, 2010-2011, 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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 
@@ -53,8 +52,8 @@ int main(int argc, char **argv)
 {
 	int ret;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	parse_args(argc, argv);
 
@@ -64,7 +63,7 @@ int main(int argc, char **argv)
 
 	FPRINTF(stderr, "#tasks : %u\n", ntasks);
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	unsigned i;
 	for (i = 0; i < ntasks; i++)
@@ -84,9 +83,9 @@ int main(int argc, char **argv)
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
 	}
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	timing = end - start;
 
 	FPRINTF(stderr, "Total: %f secs\n", timing/1000000);
 	FPRINTF(stderr, "Per task: %f usecs\n", timing/ntasks);

+ 0 - 1
tests/main/empty_task_sync_point.c

@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 

+ 0 - 1
tests/main/get_current_task.c

@@ -16,7 +16,6 @@
  */
 
 #include <config.h>
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <starpu.h>

+ 6 - 7
tests/main/multithreaded.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010-2011  Université de Bordeaux 1
+ * Copyright (C) 2009, 2010-2011, 2013-2014  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
  * Copyright (C) 2011  Centre National de la Recherche Scientifique
  *
@@ -16,7 +16,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 
@@ -99,8 +98,8 @@ int main(int argc, char **argv)
 {
 	//	unsigned i;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 	int ret;
 
 	parse_args(argc, argv);
@@ -111,7 +110,7 @@ int main(int argc, char **argv)
 
 	FPRINTF(stderr, "#tasks : %u\n", ntasks);
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	unsigned t;
 	for (t = 0; t < nthreads; t++)
@@ -126,9 +125,9 @@ int main(int argc, char **argv)
 		STARPU_ASSERT(ret == 0);
 	}
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	timing = end - start;
 
 	FPRINTF(stderr, "Total: %f secs\n", timing/1000000);
 	FPRINTF(stderr, "Per task: %f usecs\n", timing/(nthreads*ntasks));

+ 6 - 7
tests/main/multithreaded_init.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010  Institut National de Recherche en Informatique et Automatique
- * Copyright (C) 2010-2011  Université de Bordeaux 1
+ * Copyright (C) 2010-2011, 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
@@ -14,7 +14,6 @@
  *
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
-#include <sys/time.h>
 #include <stdio.h>
 #include <starpu.h>
 #include "../helper.h"
@@ -48,15 +47,15 @@ int main(int argc, char **argv)
 {
 	unsigned i;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	glob_argc = &argc;
 	glob_argv = &argv;
 
 	starpu_pthread_t threads[NUM_THREADS];
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	for (i = 0; i < NUM_THREADS; ++i)
 	{
@@ -70,9 +69,9 @@ int main(int argc, char **argv)
 		STARPU_ASSERT(ret == 0);
 	}
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	timing = end - start;
 
 	FPRINTF(stderr, "Success : %d threads launching simultaneously starpu_init\n", NUM_THREADS);
 	FPRINTF(stderr, "Total: %f secs\n", timing/1000000);

+ 9 - 10
tests/main/pause_resume.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2011, 2013  Université de Bordeaux 1
+ * Copyright (C) 2010-2011, 2013-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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 
@@ -45,8 +44,8 @@ static struct starpu_codelet dummy_codelet =
 int main(int argc, char **argv)
 {
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 	int ret;
 
 #ifdef STARPU_HAVE_VALGRIND_H
@@ -68,11 +67,11 @@ int main(int argc, char **argv)
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert");
 	}
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	starpu_resume();
 	starpu_task_wait_for_all();
-	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;
 
 	FPRINTF(stderr, "Without interruptions:\n\tTotal: %f secs\n", timing/1000000);
 	FPRINTF(stderr, "\tPer task: %f usecs\n", timing/ntasks);
@@ -87,14 +86,14 @@ int main(int argc, char **argv)
 	}
 	starpu_resume();
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (i = 0; i < 100; i++) {
 		starpu_pause();
 		starpu_resume();
 	}
 	starpu_task_wait_for_all();
-	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;
 
 	FPRINTF(stderr, "With 100 interruptions:\n\tTotal: %f secs\n", timing/1000000);
 	FPRINTF(stderr, "\tPer task: %f usecs\n", timing/ntasks);

+ 6 - 8
tests/main/regenerate.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2012  Université de Bordeaux 1
+ * Copyright (C) 2010-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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <starpu.h>
@@ -82,8 +81,8 @@ int main(int argc, char **argv)
 {
 	//	unsigned i;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 	int ret;
 
 	parse_args(argc, argv);
@@ -104,7 +103,7 @@ int main(int argc, char **argv)
 
 	FPRINTF(stderr, "#tasks : %u\n", ntasks);
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	ret = starpu_task_submit(&task);
 	if (ret == -ENODEV) goto enodev;
@@ -115,10 +114,9 @@ int main(int argc, char **argv)
 		STARPU_PTHREAD_COND_WAIT(&cond, &mutex);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000
-				+ (end.tv_usec - start.tv_usec));
+	timing = end - start;
 
 	FPRINTF(stderr, "Total: %f secs\n", timing/1000000);
 	FPRINTF(stderr, "Per task: %f usecs\n", timing/ntasks);

+ 8 - 9
tests/main/restart.c

@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
@@ -30,8 +29,8 @@
   #define N	10
 #endif
 
-static struct timeval start;
-static struct timeval end;
+static double start;
+static double end;
 
 int main(int argc, char **argv)
 {
@@ -43,20 +42,20 @@ int main(int argc, char **argv)
 
 	for (iter = 0; iter < N; iter++)
 	{
-		gettimeofday(&start, NULL);
+		start = starpu_timing_now();
 		/* Initialize StarPU */
 		ret = starpu_initialize(NULL, &argc, &argv);
-		gettimeofday(&end, NULL);
+		end = starpu_timing_now();
 		if (ret == -ENODEV)
 			goto enodev;
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
-		init_timing += (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+		init_timing += end - start;
 
-		gettimeofday(&start, NULL);
+		start = starpu_timing_now();
 		/* Shutdown StarPU */
 		starpu_shutdown();
-		gettimeofday(&end, NULL);
-		shutdown_timing += (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+		end = starpu_timing_now();
+		shutdown_timing += end - start;
 	}
 
 	FPRINTF(stderr, "starpu_init: %2.2f seconds\n", init_timing/(N*1000000));

+ 6 - 7
tests/main/starpu_task_wait.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2011  Université de Bordeaux 1
+ * Copyright (C) 2010-2011, 2013-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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 
@@ -66,8 +65,8 @@ static void parse_args(int argc, char **argv)
 int main(int argc, char **argv)
 {
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 	int ret;
 
 	parse_args(argc, argv);
@@ -82,7 +81,7 @@ int main(int argc, char **argv)
 
 	FPRINTF(stderr, "#tasks : %u\n", ntasks);
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	unsigned i;
 	for (i = 0; i < ntasks; i++)
@@ -107,9 +106,9 @@ int main(int argc, char **argv)
 		starpu_task_destroy(task);
 	}
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	timing = end - start;
 
 	FPRINTF(stderr, "Total: %f secs\n", timing/1000000);
 	FPRINTF(stderr, "Per task: %f usecs\n", timing/ntasks);

+ 6 - 7
tests/main/starpu_task_wait_for_all.c

@@ -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, 2012, 2013  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -16,7 +16,6 @@
  */
 
 #include <starpu.h>
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 #include "../helper.h"
@@ -82,8 +81,8 @@ int main(int argc, char **argv)
 {
 	unsigned i;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 	int ret;
 	struct starpu_conf conf;
 
@@ -97,7 +96,7 @@ int main(int argc, char **argv)
 
 	FPRINTF(stderr, "#tasks : %u\n", ntasks);
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (i = 0; i < ntasks; i++)
 	{
 		ret = inject_one_task();
@@ -108,9 +107,9 @@ int main(int argc, char **argv)
 	ret = starpu_task_wait_for_all();
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	timing = end - start;
 
 	FPRINTF(stderr, "Total: %f secs\n", timing/1000000);
 	FPRINTF(stderr, "Per task: %f usecs\n", timing/ntasks);

+ 7 - 9
tests/main/static_restartable.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010-2011  Université de Bordeaux 1
- * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
+ * Copyright (C) 2009, 2010-2011, 2013-2014  Université de Bordeaux 1
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * 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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 
@@ -59,8 +58,8 @@ int main(int argc, char **argv)
 
 	unsigned i;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 	int ret;
 
 	parse_args(argc, argv);
@@ -82,7 +81,7 @@ int main(int argc, char **argv)
 
 	FPRINTF(stderr, "#tasks : %u\n", ntasks);
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	for (i = 0; i < ntasks; i++)
 	{
@@ -94,10 +93,9 @@ int main(int argc, char **argv)
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
 	}
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000
-				+ (end.tv_usec - start.tv_usec));
+	timing = end - start;
 
 	FPRINTF(stderr, "Total: %f secs\n", timing/1000000);
 	FPRINTF(stderr, "Per task: %f usecs\n", timing/ntasks);

+ 7 - 9
tests/main/static_restartable_tag.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010-2012  Université de Bordeaux 1
- * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
+ * Copyright (C) 2009, 2010-2014  Université de Bordeaux 1
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  * Copyright (C) 2012 inria
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -16,7 +16,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 
@@ -61,8 +60,8 @@ int main(int argc, char **argv)
 {
 	unsigned i;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 	int ret;
 
 	parse_args(argc, argv);
@@ -86,7 +85,7 @@ int main(int argc, char **argv)
 
 	FPRINTF(stderr, "#tasks : %u\n", ntasks);
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	for (i = 0; i < ntasks; i++)
 	{
@@ -98,10 +97,9 @@ int main(int argc, char **argv)
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_tag_wait");
 	}
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000
-				+ (end.tv_usec - start.tv_usec));
+	timing = end - start;
 
 	FPRINTF(stderr, "Total: %f secs\n", timing/1000000);
 	FPRINTF(stderr, "Per task: %f usecs\n", timing/ntasks);

+ 7 - 9
tests/main/static_restartable_using_initializer.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010-2011  Université de Bordeaux 1
- * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
+ * Copyright (C) 2009, 2010-2011, 2013-2014  Université de Bordeaux 1
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * 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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 
@@ -62,8 +61,8 @@ int main(int argc, char **argv)
 {
 	unsigned i;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 	int ret;
 
 	parse_args(argc, argv);
@@ -81,7 +80,7 @@ int main(int argc, char **argv)
 
 	FPRINTF(stderr, "#tasks : %u\n", ntasks);
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	for (i = 0; i < ntasks; i++)
 	{
@@ -94,10 +93,9 @@ int main(int argc, char **argv)
 	}
 
 	starpu_task_clean(&task);
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000
-				+ (end.tv_usec - start.tv_usec));
+	timing = end - start;
 
 	FPRINTF(stderr, "Total: %f secs\n", timing/1000000);
 	FPRINTF(stderr, "Per task: %f usecs\n", timing/ntasks);

+ 3 - 4
tests/main/subgraph_repeat.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2012-2014  Université de Bordeaux 1
- * Copyright (C) 2010, 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
  *
  * 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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <starpu.h>
 #include <common/thread.h>
 
@@ -99,8 +98,8 @@ int main(int argc, char **argv)
 {
 //	unsigned i;
 //	double timing;
-//	struct timeval start;
-//	struct timeval end;
+//	double start;
+//	double end;
 	int ret;
 
 	ret = starpu_initialize(NULL, &argc, &argv);

+ 3 - 4
tests/main/subgraph_repeat_regenerate.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2014  Université de Bordeaux 1
- * Copyright (C) 2010, 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
  *
  * 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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <starpu.h>
 #include <common/thread.h>
 
@@ -98,8 +97,8 @@ int main(int argc, char **argv)
 {
 //	unsigned i;
 //	double timing;
-//	struct timeval start;
-//	struct timeval end;
+//	double start;
+//	double end;
 	int ret;
 
 	ret = starpu_initialize(NULL, &argc, &argv);

+ 3 - 4
tests/main/subgraph_repeat_regenerate_tag.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2014  Université de Bordeaux 1
- * Copyright (C) 2010, 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
  *
  * 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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <starpu.h>
 #include <common/thread.h>
 
@@ -139,8 +138,8 @@ int main(int argc, char **argv)
 {
 //	unsigned i;
 //	double timing;
-//	struct timeval start;
-//	struct timeval end;
+//	double start;
+//	double end;
 	int ret;
 
 	ret = starpu_initialize(NULL, &argc, &argv);

+ 3 - 4
tests/main/subgraph_repeat_tag.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2014  Université de Bordeaux 1
- * Copyright (C) 2010, 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
  *
  * 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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <starpu.h>
 
 #include "../helper.h"
@@ -121,8 +120,8 @@ int main(int argc, char **argv)
 {
 //	unsigned i;
 //	double timing;
-//	struct timeval start;
-//	struct timeval end;
+//	double start;
+//	double end;
 	int ret;
 
 	ret = starpu_initialize(NULL, &argc, &argv);

+ 0 - 1
tests/main/submit.c

@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <starpu.h>

+ 6 - 8
tests/main/wait_all_regenerable_tasks.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2011  Université de Bordeaux 1
+ * Copyright (C) 2010-2011, 2013-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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <starpu.h>
@@ -71,8 +70,8 @@ int main(int argc, char **argv)
 {
 	int ret;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	parse_args(argc, argv);
 
@@ -99,7 +98,7 @@ int main(int argc, char **argv)
 
 	FPRINTF(stderr, "#tasks : %d x %u tasks\n", K, ntasks);
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	
 	for (i = 0; i < K; i++)
 	{
@@ -114,7 +113,7 @@ int main(int argc, char **argv)
 
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
 	/* Check that all the tasks have been properly executed */
 	unsigned total_cnt = 0;
@@ -123,8 +122,7 @@ int main(int argc, char **argv)
 
 	STARPU_ASSERT(total_cnt == K*ntasks);
 
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000
-				+ (end.tv_usec - start.tv_usec));
+	timing = end - start;
 
 	FPRINTF(stderr, "Total: %f secs\n", timing/1000000);
 	FPRINTF(stderr, "Per task: %f usecs\n", timing/(K*ntasks));

+ 6 - 7
tests/microbenchs/async_tasks_overhead.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2012  Université de Bordeaux 1
+ * Copyright (C) 2010-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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <starpu.h>
@@ -84,8 +83,8 @@ int main(int argc, char **argv)
 	int ret;
 	unsigned i;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
@@ -112,7 +111,7 @@ int main(int argc, char **argv)
 		tasks[i] = task;
 	}
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (i = 0; i < ntasks; i++)
 	{
 		ret = starpu_task_submit(tasks[i]);
@@ -123,7 +122,7 @@ int main(int argc, char **argv)
 	ret = starpu_task_wait_for_all();
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
 	/* Read profiling feedback */
 	for (i = 0; i < ntasks; i++)
@@ -141,7 +140,7 @@ int main(int argc, char **argv)
 		cumulated_pop += pop_duration;
 	}
 
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	timing = end - start;
 
 	fprintf(stderr, "Total: %f secs\n", timing/1000000);
 	fprintf(stderr, "Per task: %f usecs\n", timing/ntasks);

+ 6 - 8
tests/microbenchs/local_pingpong.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010  Université de Bordeaux 1
+ * Copyright (C) 2010, 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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
@@ -39,8 +38,8 @@ static char worker_1_name[128];
 static unsigned memory_node_0;
 static unsigned memory_node_1;
 
-struct timeval start;
-struct timeval end;
+double start;
+double end;
 
 int main(int argc, char **argv)
 {
@@ -93,14 +92,13 @@ int main(int argc, char **argv)
 	//	unsigned nwarmupiter = 128;
 	_starpu_benchmark_ping_pong(v_handle, memory_node_0, memory_node_1, 128);
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	_starpu_benchmark_ping_pong(v_handle, memory_node_0, memory_node_1, niter);
 
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 +
-					(end.tv_usec - start.tv_usec));
+	double timing = end - start;
 
 	fprintf(stderr, "Took %f ms\n", timing/1000);
 	fprintf(stderr, "Avg. transfer time : %f us\n", timing/(2*niter));

+ 8 - 9
tests/microbenchs/matrix_as_vector.c

@@ -16,7 +16,6 @@
 
 #include <starpu.h>
 #include "../helper.h"
-#include <sys/time.h>
 
 #ifdef STARPU_USE_CUDA
 #  include <cublas.h>
@@ -91,8 +90,8 @@ int check_size(int nx, struct starpu_codelet *vector_codelet, struct starpu_code
 	starpu_data_handle_t vector_handle, matrix_handle;
 	int ret, i, loop, maxloops;
 	double vector_timing, matrix_timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	starpu_malloc((void **) &matrix, nx*sizeof(matrix[0]));
 	maxloops = LOOPS;
@@ -102,7 +101,7 @@ int check_size(int nx, struct starpu_codelet *vector_codelet, struct starpu_code
 		maxloops=1;
 #endif /* STARPU_HAVE_VALGRIND_H */
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for(loop=1 ; loop<=maxloops ; loop++)
 	{
 		for(i=0 ; i<nx ; i++) matrix[i] = i;
@@ -111,13 +110,13 @@ int check_size(int nx, struct starpu_codelet *vector_codelet, struct starpu_code
 		starpu_data_unregister(vector_handle);
 		if (ret == -ENODEV) goto end;
 	}
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	vector_timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	vector_timing = end - start;
 	vector_timing /= maxloops;
 	mean = matrix[0];
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for(loop=1 ; loop<=maxloops ; loop++)
 	{
 		for(i=0 ; i<nx ; i++) matrix[i] = i;
@@ -126,9 +125,9 @@ int check_size(int nx, struct starpu_codelet *vector_codelet, struct starpu_code
 		starpu_data_unregister(matrix_handle);
 		if (ret == -ENODEV) goto end;
 	}
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	matrix_timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	matrix_timing = end - start;
 	matrix_timing /= maxloops;
 
 	if (mean == matrix[0])

+ 6 - 7
tests/microbenchs/sync_tasks_overhead.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2012  Université de Bordeaux 1
+ * Copyright (C) 2010-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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 
@@ -71,8 +70,8 @@ int main(int argc, char **argv)
 	int ret;
 	unsigned i;
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 #ifdef STARPU_QUICK_CHECK
 	ntasks = 128;
@@ -86,16 +85,16 @@ int main(int argc, char **argv)
 
 	fprintf(stderr, "#tasks : %u\n", ntasks);
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	for (i = 0; i < ntasks; i++)
 	{
 		ret = inject_one_task();
 		if (ret == -ENODEV) goto enodev;
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
-	gettimeofday(&end, NULL);
+	end = starpu_timing_now();
 
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	timing = end - start;
 
 	fprintf(stderr, "Total: %f secs\n", timing/1000000);
 	fprintf(stderr, "Per task: %f usecs\n", timing/ntasks);

+ 12 - 13
tests/microbenchs/tasks_overhead.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2011, 2013  Université de Bordeaux 1
+ * Copyright (C) 2010-2011, 2013-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
@@ -15,7 +15,6 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 
@@ -89,12 +88,12 @@ int main(int argc, char **argv)
 	unsigned i;
 
 	double timing_submit;
-	struct timeval start_submit;
-	struct timeval end_submit;
+	double start_submit;
+	double end_submit;
 
 	double timing_exec;
-	struct timeval start_exec;
-	struct timeval end_exec;
+	double start_exec;
+	double end_exec;
 
 	parse_args(argc, argv);
 
@@ -114,7 +113,7 @@ int main(int argc, char **argv)
 	/* submit tasks (but don't execute them yet !) */
 	tasks = (struct starpu_task *) calloc(1, ntasks*sizeof(struct starpu_task));
 
-	gettimeofday(&start_submit, NULL);
+	start_submit = starpu_timing_now();
 	for (i = 0; i < ntasks; i++)
 	{
 		starpu_task_init(&tasks[i]);
@@ -133,7 +132,7 @@ int main(int argc, char **argv)
 	}
 	tasks[ntasks-1].detach = 0;
 
-	gettimeofday(&start_submit, NULL);
+	start_submit = starpu_timing_now();
 	for (i = 1; i < ntasks; i++)
 	{
 		starpu_tag_declare_deps((starpu_tag_t)i, 1, (starpu_tag_t)(i-1));
@@ -148,13 +147,13 @@ int main(int argc, char **argv)
 	if (ret == -ENODEV) goto enodev;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
-	gettimeofday(&end_submit, NULL);
+	end_submit = starpu_timing_now();
 
 	/* wait for the execution of the tasks */
-	gettimeofday(&start_exec, NULL);
+	start_exec = starpu_timing_now();
 	ret = starpu_task_wait(&tasks[ntasks-1]);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_tag_wait");
-	gettimeofday(&end_exec, NULL);
+	end_exec = starpu_timing_now();
 
 	starpu_task_wait_for_all();
 
@@ -164,8 +163,8 @@ int main(int argc, char **argv)
 	for (buffer = 0; buffer < nbuffers; buffer++)
 		starpu_data_unregister(data_handles[buffer]);
 
-	timing_submit = (double)((end_submit.tv_sec - start_submit.tv_sec)*1000000 + (end_submit.tv_usec - start_submit.tv_usec));
-	timing_exec = (double)((end_exec.tv_sec - start_exec.tv_sec)*1000000 + (end_exec.tv_usec - start_exec.tv_usec));
+	timing_submit = end_submit - start_submit;
+	timing_exec = end_exec - start_exec;
 
 	fprintf(stderr, "Total submit: %f secs\n", timing_submit/1000000);
 	fprintf(stderr, "Per task submit: %f usecs\n", timing_submit/ntasks);

+ 10 - 17
tests/microbenchs/tasks_size_overhead.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2013  Université de Bordeaux 1
+ * Copyright (C) 2010-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
@@ -23,7 +23,6 @@
  * Thanks Martin Tillenius for the idea.
  */
 
-#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 
@@ -52,20 +51,14 @@ struct starpu_task *tasks;
 
 void func(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg)
 {
-	struct timeval tv1, tv2;
+	double tv1, tv2;
 	unsigned n = (uintptr_t)arg;
 	long usec = 0;
-	gettimeofday(&tv1, NULL);
+	tv1 = starpu_timing_now();
 	do
 	{
-		gettimeofday(&tv2, NULL);
-		if (tv2.tv_usec < tv1.tv_usec)
-		{
-			tv2.tv_usec += 1000000;
-			tv2.tv_sec--;
-		}
-		usec = (tv2.tv_sec-tv1.tv_sec)*1000000
-			+ (tv2.tv_usec - tv1.tv_usec);
+		tv2 = starpu_timing_now();
+		usec = tv2 - tv1;
 	}
 	while (usec < n);
 }
@@ -104,8 +97,8 @@ int main(int argc, char **argv)
 	unsigned totcpus, ncpus;
 
 	double timing;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	struct starpu_conf conf;
 
@@ -167,7 +160,7 @@ int main(int argc, char **argv)
 		for (size = START; size <= STOP; size *= FACTOR)
 		{
 			/* submit tasks */
-			gettimeofday(&start, NULL);
+			start = starpu_timing_now();
 			for (i = 0; i < ntasks; i++)
 			{
 				starpu_task_init(&tasks[i]);
@@ -188,12 +181,12 @@ int main(int argc, char **argv)
 			}
 			ret = starpu_task_wait_for_all();
 			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
-			gettimeofday(&end, NULL);
+			end = starpu_timing_now();
 
 			for (i = 0; i < ntasks; i++)
 				starpu_task_clean(&tasks[i]);
 
-			timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+			timing = end - start;
 
 			FPRINTF(stdout, "%u\t%f\t", size, timing/1000000);
 			fflush(stdout);