Преглед на файлове

Make LU example compatible with simgrid

Samuel Thibault преди 10 години
родител
ревизия
70af20310c
променени са 5 файла, в които са добавени 28 реда и са изтрити 27 реда
  1. 6 6
      examples/lu/lu_example.c
  2. 5 5
      examples/lu/xlu.c
  3. 5 5
      examples/lu/xlu_implicit.c
  4. 7 6
      examples/lu/xlu_implicit_pivot.c
  5. 5 5
      examples/lu/xlu_pivot.c

+ 6 - 6
examples/lu/lu_example.c

@@ -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
@@ -346,16 +346,16 @@ int main(int argc, char **argv)
 		}
 		else
 		{
-			struct timeval start;
-			struct timeval end;
+			double start;
+			double end;
 
-			gettimeofday(&start, NULL);
+			start = starpu_timing_now();
 
 			ret = STARPU_LU(lu_decomposition_pivot)(A, ipiv, size, size, nblocks);
 
-			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;
 
 			unsigned n = size;
 			double flop = (2.0f*n*n*n)/3.0f;

+ 5 - 5
examples/lu/xlu.c

@@ -170,8 +170,8 @@ static int create_task_22(starpu_data_handle_t dataA, unsigned k, unsigned i, un
 static int dw_codelet_facto_v3(starpu_data_handle_t dataA, unsigned nblocks)
 {
 	int ret;
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	struct starpu_task *entry_task = NULL;
 
@@ -213,7 +213,7 @@ static int dw_codelet_facto_v3(starpu_data_handle_t dataA, unsigned nblocks)
 	}
 
 	/* schedule the codelet */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	ret = starpu_task_submit(entry_task);
 	if (ret == -ENODEV) return ret;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
@@ -221,9 +221,9 @@ static int dw_codelet_facto_v3(starpu_data_handle_t dataA, unsigned nblocks)
 	/* stall the application until the end of computations */
 	starpu_tag_wait(TAG11(nblocks-1));
 
-	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, "Computation took (in ms)\n");
 	FPRINTF(stdout, "%2.2f\n", timing/1000);
 

+ 5 - 5
examples/lu/xlu_implicit.c

@@ -110,14 +110,14 @@ static int create_task_22(starpu_data_handle_t dataA, unsigned k, unsigned i, un
 
 static int dw_codelet_facto_v3(starpu_data_handle_t dataA, unsigned nblocks)
 {
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 	int ret;
 
 	/* create all the DAG nodes */
 	unsigned i,j,k;
 
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 
 	for (k = 0; k < nblocks; k++)
 	{
@@ -142,9 +142,9 @@ static int dw_codelet_facto_v3(starpu_data_handle_t dataA, unsigned nblocks)
 	/* stall the application until the end of computations */
 	starpu_task_wait_for_all();
 
-	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, "Computation took (in ms)\n");
 	FPRINTF(stdout, "%2.2f\n", timing/1000);
 

+ 7 - 6
examples/lu/xlu_implicit_pivot.c

@@ -155,14 +155,15 @@ static int dw_codelet_facto_pivot(starpu_data_handle_t *dataAp,
 				  starpu_data_handle_t (* get_block)(starpu_data_handle_t *, unsigned, unsigned, unsigned),
 				  double *timing)
 {
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 	int ret;
 
-	gettimeofday(&start, NULL);
-
 	/* create all the DAG nodes */
 	unsigned i,j,k;
+
+	start = starpu_timing_now();
+
 	for (k = 0; k < nblocks; k++)
 	{
 	     ret = create_task_11_pivot(dataAp, nblocks, k, piv_description, get_block);
@@ -196,9 +197,9 @@ static int dw_codelet_facto_pivot(starpu_data_handle_t *dataAp,
 	/* stall the application until the end of computations */
 	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;
 	return 0;
 }
 

+ 5 - 5
examples/lu/xlu_pivot.c

@@ -232,8 +232,8 @@ static int dw_codelet_facto_pivot(starpu_data_handle_t *dataAp,
 {
 	int ret;
 
-	struct timeval start;
-	struct timeval end;
+	double start;
+	double end;
 
 	struct starpu_task *entry_task = NULL;
 
@@ -298,7 +298,7 @@ static int dw_codelet_facto_pivot(starpu_data_handle_t *dataAp,
 	}
 
 	/* schedule the codelet */
-	gettimeofday(&start, NULL);
+	start = starpu_timing_now();
 	ret = starpu_task_submit(entry_task);
 	if (ret != -ENODEV) STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
@@ -307,9 +307,9 @@ static int dw_codelet_facto_pivot(starpu_data_handle_t *dataAp,
 /*	starpu_task_wait_for_all(); */
 	free(tags);
 
-	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;
 	return 0;
 }