瀏覽代碼

port r13398 from 1.1: eradicate use of timeval

Samuel Thibault 10 年之前
父節點
當前提交
169bf34d54

+ 5 - 5
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
@@ -116,7 +116,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 +138,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 +186,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 - 6
tests/experiments/latency/cuda_latency.c

@@ -181,11 +181,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 +200,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 - 9
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
@@ -23,8 +23,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 +41,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));

+ 5 - 5
tests/loader.c

@@ -170,8 +170,8 @@ int main(int argc, char *argv[])
 	char *launcher_args;
 	struct sigaction sa;
 	int   ret;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 	double timing;
 
 	test_args = NULL;
@@ -281,7 +281,7 @@ int main(int argc, char *argv[])
 	}
 
 	ret = EXIT_SUCCESS;
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	alarm(timeout);
 	if (child_pid == waitpid(child_pid, &child_exit_status, 0))
 	{
@@ -315,8 +315,8 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	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, "#Execution_time_in_seconds %f %s\n", timing/1000000, test_name);
 
 	return ret;

+ 6 - 6
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
@@ -53,8 +53,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 +64,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 +84,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);

+ 6 - 6
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
  *
@@ -99,8 +99,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 +111,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 +126,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 - 6
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
@@ -48,15 +48,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 +70,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 - 9
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
@@ -45,8 +45,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 +68,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 +87,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 - 7
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
@@ -82,8 +82,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 +104,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 +115,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 - 8
tests/main/restart.c

@@ -30,8 +30,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 +43,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 - 6
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
@@ -66,8 +66,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 +82,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 +107,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 - 6
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
@@ -82,8 +82,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 +97,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 +108,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 - 8
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
@@ -59,8 +59,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 +82,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 +94,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 - 8
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
@@ -61,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);
@@ -86,7 +86,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 +98,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 - 8
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
@@ -62,8 +62,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 +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 +94,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 - 3
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
@@ -99,8 +99,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 - 3
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
@@ -98,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 - 3
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
@@ -139,8 +139,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 - 3
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
@@ -121,8 +121,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);

+ 6 - 7
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
@@ -71,8 +71,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 +99,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 +114,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 +123,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 - 6
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
@@ -84,8 +84,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 +112,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 +123,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 +141,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 - 7
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
@@ -39,8 +39,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 +93,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 - 8
tests/microbenchs/matrix_as_vector.c

@@ -91,8 +91,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 +102,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 +111,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 +126,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 - 6
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
@@ -71,8 +71,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 +86,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 - 12
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
@@ -89,12 +89,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 +114,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 +133,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 +148,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 +164,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 - 16
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
@@ -52,20 +52,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 +98,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 +161,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 +182,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);