Bläddra i källkod

Mixed up of svn files

Andra Hugo 14 år sedan
förälder
incheckning
1eefdd8500

+ 96 - 97
examples/lu/lu_example.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2009, 2010-2011  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
  * it under the terms of the GNU Lesser General Public License as published by
@@ -26,9 +26,9 @@
 #include "xlu.h"
 #include "xlu_kernels.h"
 
-static unsigned long lu_size = 10240;//4096;
-static unsigned lu_nblocks = 10;
-static unsigned lu_check = 0;
+static unsigned long size = 4096;
+static unsigned nblocks = 16;
+static unsigned check = 0;
 static unsigned pivot = 0;
 static unsigned no_stride = 0;
 static unsigned profile = 0;
@@ -36,28 +36,29 @@ static unsigned bound = 0;
 static unsigned bounddeps = 0;
 static unsigned boundprio = 0;
 
-TYPE *A;
-TYPE *A_saved;
+#define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
+
+TYPE *A, *A_saved;
 
 /* in case we use non-strided blocks */
 TYPE **A_blocks;
 
-static void lu_parse_args(int argc, char **argv)
+static void parse_args(int argc, char **argv)
 {
 	int i;
 	for (i = 1; i < argc; i++) {
 		if (strcmp(argv[i], "-size") == 0) {
 			char *argptr;
-			lu_size = strtol(argv[++i], &argptr, 10);
+			size = strtol(argv[++i], &argptr, 10);
 		}
 
 		if (strcmp(argv[i], "-nblocks") == 0) {
 			char *argptr;
-			lu_nblocks = strtol(argv[++i], &argptr, 10);
+			nblocks = strtol(argv[++i], &argptr, 10);
 		}
 
 		if (strcmp(argv[i], "-check") == 0) {
-			lu_check = 1;
+			check = 1;
 		}
 
 		if (strcmp(argv[i], "-piv") == 0) {
@@ -90,90 +91,90 @@ static void lu_parse_args(int argc, char **argv)
 static void display_matrix(TYPE *m, unsigned n, unsigned ld, char *str)
 {
 #if 0
-	fprintf(stderr, "***********\n");
-	fprintf(stderr, "Display matrix %s\n", str);
+	FPRINTF(stderr, "***********\n");
+	FPRINTF(stderr, "Display matrix %s\n", str);
 	unsigned i,j;
 	for (j = 0; j < n; j++)
 	{
 		for (i = 0; i < n; i++)
 		{
-			fprintf(stderr, "%2.2f\t", m[i+j*ld]);
+			FPRINTF(stderr, "%2.2f\t", m[i+j*ld]);
 		}
-		fprintf(stderr, "\n");
+		FPRINTF(stderr, "\n");
 	}
-	fprintf(stderr, "***********\n");
+	FPRINTF(stderr, "***********\n");
 #endif
 }
 
-void copy_blocks_into_matrix()
+void copy_blocks_into_matrix(void)
 {
-	unsigned blocklu_size = (lu_size/lu_nblocks);
+	unsigned blocksize = (size/nblocks);
 
 	unsigned i, j;
 	unsigned bi, bj;
-	for (bj = 0; bj < lu_nblocks; bj++)
-	for (bi = 0; bi < lu_nblocks; bi++)
+	for (bj = 0; bj < nblocks; bj++)
+	for (bi = 0; bi < nblocks; bi++)
 	{
-		for (j = 0; j < blocklu_size; j++)
-		for (i = 0; i < blocklu_size; i++)
+		for (j = 0; j < blocksize; j++)
+		for (i = 0; i < blocksize; i++)
 		{
-			A[(i+bi*blocklu_size) + (j + bj*blocklu_size)*lu_size] =
-				A_blocks[bi+lu_nblocks*bj][i + j * blocklu_size];
+			A[(i+bi*blocksize) + (j + bj*blocksize)*size] =
+				A_blocks[bi+nblocks*bj][i + j * blocksize];
 		}
 
-		//free(A_blocks[bi+lu_nblocks*bj]);
+		/* free(A_blocks[bi+nblocks*bj]); */
 	}
 }
 
 
 
-void copy_matrix_into_blocks()
+void copy_matrix_into_blocks(void)
 {
-	unsigned blocklu_size = (lu_size/lu_nblocks);
+	unsigned blocksize = (size/nblocks);
 
 	unsigned i, j;
 	unsigned bi, bj;
-	for (bj = 0; bj < lu_nblocks; bj++)
-	for (bi = 0; bi < lu_nblocks; bi++)
+	for (bj = 0; bj < nblocks; bj++)
+	for (bi = 0; bi < nblocks; bi++)
 	{
-		starpu_data_malloc_pinned_if_possible((void **)&A_blocks[bi+lu_nblocks*bj], (size_t)blocklu_size*blocklu_size*sizeof(TYPE));
+		starpu_malloc((void **)&A_blocks[bi+nblocks*bj], (size_t)blocksize*blocksize*sizeof(TYPE));
 
-		for (j = 0; j < blocklu_size; j++)
-		for (i = 0; i < blocklu_size; i++)
+		for (j = 0; j < blocksize; j++)
+		for (i = 0; i < blocksize; i++)
 		{
-			A_blocks[bi+lu_nblocks*bj][i + j * blocklu_size] =
-			A[(i+bi*blocklu_size) + (j + bj*blocklu_size)*lu_size];
+			A_blocks[bi+nblocks*bj][i + j * blocksize] =
+			A[(i+bi*blocksize) + (j + bj*blocksize)*size];
 		}
 	}
 }
 
-static void init_matrix()
+static void init_matrix(void)
 {
 	/* allocate matrix */
-	starpu_data_malloc_pinned_if_possible((void **)&A, (size_t)lu_size*lu_size*sizeof(TYPE));
+	starpu_malloc((void **)&A, (size_t)size*size*sizeof(TYPE));
 	STARPU_ASSERT(A);
 
 	starpu_srand48((long int)time(NULL));
-	//	starpu_srand48(0);
+	/* starpu_srand48(0); */
 
 	/* initialize matrix content */
 	unsigned long i,j;
-	for (j = 0; j < lu_size; j++)
+	for (j = 0; j < size; j++)
 	{
-		for (i = 0; i < lu_size; i++)
+		for (i = 0; i < size; i++)
 		{
-		  A[i + j*lu_size] = (TYPE)starpu_drand48();
+			A[i + j*size] = (TYPE)starpu_drand48();
 		}
 	}
 
 }
 
-static void save_matrix()
+static void save_matrix(void)
 {
-	A_saved = malloc((size_t)lu_size*lu_size*sizeof(TYPE));
+	A_saved = malloc((size_t)size*size*sizeof(TYPE));
 	STARPU_ASSERT(A_saved);
 
-	memcpy(A_saved, A, (size_t)lu_size*lu_size*sizeof(TYPE));
+	memcpy(A_saved, A, (size_t)size*size*sizeof(TYPE));
 }
 
 static double frobenius_norm(TYPE *v, unsigned n)
@@ -196,89 +197,88 @@ static double frobenius_norm(TYPE *v, unsigned n)
 static void pivot_saved_matrix(unsigned *ipiv)
 {
 	unsigned k;
-	for (k = 0; k < lu_size; k++)
+	for (k = 0; k < size; k++)
 	{
 		if (k != ipiv[k])
 		{
-	//		fprintf(stderr, "SWAP %d and %d\n", k, ipiv[k]);
-			CPU_SWAP(lu_size, &A_saved[k*lu_size], 1, &A_saved[ipiv[k]*lu_size], 1);
+	/*		FPRINTF(stderr, "SWAP %d and %d\n", k, ipiv[k]); */
+			CPU_SWAP(size, &A_saved[k*size], 1, &A_saved[ipiv[k]*size], 1);
 		}
 	}
 }
 
-static void lu_check_result()
+static void check_result(void)
 {
 	unsigned i,j;
 	TYPE *L, *U;
 
-	L = malloc((size_t)lu_size*lu_size*sizeof(TYPE));
-	U = malloc((size_t)lu_size*lu_size*sizeof(TYPE));
+	L = malloc((size_t)size*size*sizeof(TYPE));
+	U = malloc((size_t)size*size*sizeof(TYPE));
 
-	memset(L, 0, lu_size*lu_size*sizeof(TYPE));
-	memset(U, 0, lu_size*lu_size*sizeof(TYPE));
+	memset(L, 0, size*size*sizeof(TYPE));
+	memset(U, 0, size*size*sizeof(TYPE));
 
 	/* only keep the lower part */
-	for (j = 0; j < lu_size; j++)
+	for (j = 0; j < size; j++)
 	{
 		for (i = 0; i < j; i++)
 		{
-			L[j+i*lu_size] = A[j+i*lu_size];
+			L[j+i*size] = A[j+i*size];
 		}
 
 		/* diag i = j */
-		L[j+j*lu_size] = A[j+j*lu_size];
-		U[j+j*lu_size] = 1.0;
+		L[j+j*size] = A[j+j*size];
+		U[j+j*size] = 1.0;
 
-		for (i = j+1; i < lu_size; i++)
+		for (i = j+1; i < size; i++)
 		{
-			U[j+i*lu_size] = A[j+i*lu_size];
+			U[j+i*size] = A[j+i*size];
 		}
 	}
 
-	display_matrix(L, lu_size, lu_size, "L");
-	display_matrix(U, lu_size, lu_size, "U");
+	display_matrix(L, size, size, "L");
+	display_matrix(U, size, size, "U");
 
 	/* now A_err = L, compute L*U */
-	CPU_TRMM("R", "U", "N", "U", lu_size, lu_size, 1.0f, U, lu_size, L, lu_size);
+	CPU_TRMM("R", "U", "N", "U", size, size, 1.0f, U, size, L, size);
 
-	display_matrix(A_saved, lu_size, lu_size, "P A_saved");
-	display_matrix(L, lu_size, lu_size, "LU");
+	display_matrix(A_saved, size, size, "P A_saved");
+	display_matrix(L, size, size, "LU");
 
 	/* compute "LU - A" in L*/
-	CPU_AXPY(lu_size*lu_size, -1.0, A_saved, 1, L, 1);
-	display_matrix(L, lu_size, lu_size, "Residuals");
+	CPU_AXPY(size*size, -1.0, A_saved, 1, L, 1);
+	display_matrix(L, size, size, "Residuals");
 	
-	TYPE err = CPU_ASUM(lu_size*lu_size, L, 1);
-	int max = CPU_IAMAX(lu_size*lu_size, L, 1);
+	TYPE err = CPU_ASUM(size*size, L, 1);
+	int max = CPU_IAMAX(size*size, L, 1);
 
-	fprintf(stderr, "Avg error : %e\n", err/(lu_size*lu_size));
-	fprintf(stderr, "Max error : %e\n", L[max]);
+	FPRINTF(stderr, "Avg error : %e\n", err/(size*size));
+	FPRINTF(stderr, "Max error : %e\n", L[max]);
 
-	double residual = frobenius_norm(L, lu_size);
-	double matnorm = frobenius_norm(A_saved, lu_size);
+	double residual = frobenius_norm(L, size);
+	double matnorm = frobenius_norm(A_saved, size);
 
-	fprintf(stderr, "||%sA-LU|| / (||A||*N) : %e\n", pivot?"P":"", residual/(matnorm*lu_size));
+	FPRINTF(stderr, "||%sA-LU|| / (||A||*N) : %e\n", pivot?"P":"", residual/(matnorm*size));
 
-	if (residual/(matnorm*lu_size) > 1e-5)
+	if (residual/(matnorm*size) > 1e-5)
 		exit(-1);
 }
 
-double run_lu(struct starpu_sched_ctx *sched_ctx, int argc, char **argv)
+int main(int argc, char **argv)
 {
-  printf("enter lu\n");
-	lu_parse_args(argc, argv);
+	parse_args(argc, argv);
 
-	//	starpu_init(NULL);
+	starpu_init(NULL);
 
-	//	starpu_helper_cublas_init();
+	starpu_helper_cublas_init();
 
 	init_matrix();
 
 	unsigned *ipiv;
-	if (lu_check)
-	  save_matrix();
+	if (check)
+		save_matrix();
 
-	display_matrix(A, lu_size, lu_size, "A");
+	display_matrix(A, size, size, "A");
 
 	if (bound)
 		starpu_bound_start(bounddeps, boundprio);
@@ -286,18 +286,17 @@ double run_lu(struct starpu_sched_ctx *sched_ctx, int argc, char **argv)
 	if (profile)
 		starpu_profiling_status_set(STARPU_PROFILING_ENABLE);
 
-	double gflops = -1;
 	/* Factorize the matrix (in place) */
 	if (pivot)
 	{
- 		ipiv = malloc(lu_size*sizeof(unsigned));
+ 		ipiv = malloc(size*sizeof(unsigned));
 		if (no_stride)
 		{
 			/* in case the LU decomposition uses non-strided blocks, we _copy_ the matrix into smaller blocks */
-			A_blocks = malloc(lu_nblocks*lu_nblocks*sizeof(TYPE **));
+			A_blocks = malloc(nblocks*nblocks*sizeof(TYPE **));
 			copy_matrix_into_blocks();
 
-			gflops = STARPU_LU(lu_decomposition_pivot_no_stride)(A_blocks, ipiv, lu_size, lu_size, lu_nblocks, sched_ctx);
+			STARPU_LU(lu_decomposition_pivot_no_stride)(A_blocks, ipiv, size, size, nblocks);
 
 			copy_blocks_into_matrix();
 			free(A_blocks);
@@ -309,21 +308,21 @@ double run_lu(struct starpu_sched_ctx *sched_ctx, int argc, char **argv)
 
 			gettimeofday(&start, NULL);
 
-			gflops = STARPU_LU(lu_decomposition_pivot)(A, ipiv, lu_size, lu_size, lu_nblocks, sched_ctx);
+			STARPU_LU(lu_decomposition_pivot)(A, ipiv, size, size, nblocks);
 	
 			gettimeofday(&end, NULL);
 
 			double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 			
-			unsigned n = lu_size;
+			unsigned n = size;
 			double flop = (2.0f*n*n*n)/3.0f;
-			gflops = flop/timing/1000.0f;
+			FPRINTF(stderr, "Synthetic GFlops (TOTAL) : \n");
+			FPRINTF(stdout, "%d	%6.2f\n", n, (flop/timing/1000.0f));
 		}
 	}
 	else
 	{
-	  gflops = STARPU_LU(lu_decomposition)(A, lu_size, lu_size, lu_nblocks, sched_ctx);
-			printf("no pivot \n");
+		STARPU_LU(lu_decomposition)(A, size, size, nblocks);
 	}
 
 	if (profile)
@@ -338,25 +337,25 @@ double run_lu(struct starpu_sched_ctx *sched_ctx, int argc, char **argv)
 		if (bounddeps) {
 			FILE *f = fopen("lu.pl", "w");
 			starpu_bound_print_lp(f);
-			fprintf(stderr,"system printed to lu.pl\n");
+			FPRINTF(stderr,"system printed to lu.pl\n");
 		} else {
 			starpu_bound_compute(&min, NULL, 0);
 			if (min != 0.)
-				fprintf(stderr, "theoretical min: %lf ms\n", min);
+				FPRINTF(stderr, "theoretical min: %lf ms\n", min);
 		}
 	}
 
-	if (lu_check)
+	if (check)
 	{
 		if (pivot)
-		  pivot_saved_matrix(ipiv);
+			pivot_saved_matrix(ipiv);
 
-		lu_check_result();
+		check_result();
 	}
 
-	//	starpu_helper_cublas_shutdown();
+	starpu_helper_cublas_shutdown();
 
-	//	starpu_shutdown();
+	starpu_shutdown();
 
-	return gflops;
+	return 0;
 }

+ 30 - 30
examples/lu/xlu.c

@@ -1,8 +1,8 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
+ * Copyright (C) 2009, 2010-2011  Université de Bordeaux 1
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  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
@@ -50,7 +50,7 @@ static struct starpu_task *create_task(starpu_tag_t id)
 
 static struct starpu_task *create_task_11(starpu_data_handle dataA, unsigned k)
 {
-//	printf("task 11 k = %d TAG = %llx\n", k, (TAG11(k)));
+/*	printf("task 11 k = %d TAG = %llx\n", k, (TAG11(k))); */
 
 	struct starpu_task *task = create_task(TAG11(k));
 
@@ -72,9 +72,9 @@ static struct starpu_task *create_task_11(starpu_data_handle dataA, unsigned k)
 	return task;
 }
 
-static void create_task_12(starpu_data_handle dataA, unsigned k, unsigned j, struct starpu_sched_ctx *sched_ctx)
+static void create_task_12(starpu_data_handle dataA, unsigned k, unsigned j)
 {
-//	printf("task 12 k,i = %d,%d TAG = %llx\n", k,i, TAG12(k,i));
+/*	printf("task 12 k,i = %d,%d TAG = %llx\n", k,i, TAG12(k,i)); */
 
 	struct starpu_task *task = create_task(TAG12(k, j));
 	
@@ -98,10 +98,10 @@ static void create_task_12(starpu_data_handle dataA, unsigned k, unsigned j, str
 		starpu_tag_declare_deps(TAG12(k, j), 1, TAG11(k));
 	}
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
-static void create_task_21(starpu_data_handle dataA, unsigned k, unsigned i, struct starpu_sched_ctx *sched_ctx)
+static void create_task_21(starpu_data_handle dataA, unsigned k, unsigned i)
 {
 	struct starpu_task *task = create_task(TAG21(k, i));
 
@@ -125,12 +125,12 @@ static void create_task_21(starpu_data_handle dataA, unsigned k, unsigned i, str
 		starpu_tag_declare_deps(TAG21(k, i), 1, TAG11(k));
 	}
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
-static void create_task_22(starpu_data_handle dataA, unsigned k, unsigned i, unsigned j, struct starpu_sched_ctx *sched_ctx)
+static void create_task_22(starpu_data_handle dataA, unsigned k, unsigned i, unsigned j)
 {
-//	printf("task 22 k,i,j = %d,%d,%d TAG = %llx\n", k,i,j, TAG22(k,i,j));
+/*	printf("task 22 k,i,j = %d,%d,%d TAG = %llx\n", k,i,j, TAG22(k,i,j)); */
 
 	struct starpu_task *task = create_task(TAG22(k, i, j));
 
@@ -156,14 +156,14 @@ static void create_task_22(starpu_data_handle dataA, unsigned k, unsigned i, uns
 		starpu_tag_declare_deps(TAG22(k, i, j), 2, TAG12(k, j), TAG21(k, i));
 	}
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
 /*
  *	code to bootstrap the factorization 
  */
 
-static double dw_codelet_facto_v3(starpu_data_handle dataA, unsigned lu_nblocks, struct starpu_sched_ctx *sched_ctx)
+static void dw_codelet_facto_v3(starpu_data_handle dataA, unsigned nblocks)
 {
 	struct timeval start;
 	struct timeval end;
@@ -173,7 +173,7 @@ static double dw_codelet_facto_v3(starpu_data_handle dataA, unsigned lu_nblocks,
 	/* create all the DAG nodes */
 	unsigned i,j,k;
 
-	for (k = 0; k < lu_nblocks; k++)
+	for (k = 0; k < nblocks; k++)
 	{
 		struct starpu_task *task = create_task_11(dataA, k);
 
@@ -182,49 +182,50 @@ static double dw_codelet_facto_v3(starpu_data_handle dataA, unsigned lu_nblocks,
 			entry_task = task;
 		}
 		else {
-		  starpu_task_submit_to_ctx(task, sched_ctx);
+			starpu_task_submit(task);
 		}
 		
-		for (i = k+1; i<lu_nblocks; i++)
+		for (i = k+1; i<nblocks; i++)
 		{
-		  create_task_12(dataA, k, i, sched_ctx);
-		  create_task_21(dataA, k, i, sched_ctx);
+			create_task_12(dataA, k, i);
+			create_task_21(dataA, k, i);
 		}
 
-		for (i = k+1; i<lu_nblocks; i++)
+		for (i = k+1; i<nblocks; i++)
 		{
-			for (j = k+1; j<lu_nblocks; j++)
+			for (j = k+1; j<nblocks; j++)
 			{
-			  create_task_22(dataA, k, i, j, sched_ctx);
+				create_task_22(dataA, k, i, j);
 			}
 		}
 	}
 
 	/* schedule the codelet */
 	gettimeofday(&start, NULL);
-	int ret = starpu_task_submit_to_ctx(entry_task, sched_ctx);
+	int ret = starpu_task_submit(entry_task);
 	if (STARPU_UNLIKELY(ret == -ENODEV))
 	{
-		fprintf(stderr, "No worker may execute this task\n");
+		FPRINTF(stderr, "No worker may execute this task\n");
 		exit(-1);
 	}
 
 
 
 	/* stall the application until the end of computations */
-	starpu_tag_wait(TAG11(lu_nblocks-1));
-	printf("lu finish waiting for %d nblocks\n", lu_nblocks-1);
+	starpu_tag_wait(TAG11(nblocks-1));
 
 	gettimeofday(&end, NULL);
 
 	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	FPRINTF(stderr, "Computation took (in ms)\n");
+	FPRINTF(stdout, "%2.2f\n", timing/1000);
 
 	unsigned n = starpu_matrix_get_nx(dataA);
 	double flop = (2.0f*n*n*n)/3.0f;
-	return (flop/timing/1000.0f);
+	FPRINTF(stderr, "Synthetic GFlops : %2.2f\n", (flop/timing/1000.0f));
 }
 
-double STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned lu_nblocks, struct starpu_sched_ctx *sched_ctx)
+void STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned nblocks)
 {
 	starpu_data_handle dataA;
 
@@ -237,21 +238,20 @@ double STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsig
 
 	struct starpu_data_filter f;
 		f.filter_func = starpu_vertical_block_filter_func;
-		f.nchildren = lu_nblocks;
+		f.nchildren = nblocks;
 		f.get_nchildren = NULL;
 		f.get_child_ops = NULL;
 
 	struct starpu_data_filter f2;
 		f2.filter_func = starpu_block_filter_func;
-		f2.nchildren = lu_nblocks;
+		f2.nchildren = nblocks;
 		f2.get_nchildren = NULL;
 		f2.get_child_ops = NULL;
 
 	starpu_data_map_filters(dataA, 2, &f, &f2);
 
-	double gflops = dw_codelet_facto_v3(dataA, lu_nblocks, sched_ctx);
+	dw_codelet_facto_v3(dataA, nblocks);
 
 	/* gather all the data */
 	starpu_data_unpartition(dataA, 0);
-	return gflops;
 }

+ 10 - 8
examples/lu/xlu.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2009, 2010-2011  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
  * it under the terms of the GNU Lesser General Public License as published by
@@ -27,6 +27,8 @@
 
 #include <common/blas.h>
 
+#define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
+
 #define BLAS3_FLOP(n1,n2,n3)    \
         (2*((uint64_t)n1)*((uint64_t)n2)*((uint64_t)n3))
 
@@ -74,9 +76,9 @@ static void __attribute__ ((unused)) compare_A_LU(float *A, float *LU,
 		}
 	}
 
-	printf("max error between A and L*U = %f \n", max_err);
+	FPRINTF(stdout, "max error between A and L*U = %f \n", max_err);
 }
-#endif // CHECK_RESULTS
+#endif /* CHECK_RESULTS */
 
 void dw_cpu_codelet_update_u11(void **, void *);
 void dw_cpu_codelet_update_u12(void **, void *);
@@ -110,8 +112,8 @@ struct piv_s {
 	unsigned last; /* last element */
 };
 
-double STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned nblocks, struct starpu_sched_ctx *sched_ctx);
-double STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks, struct starpu_sched_ctx *sched_ctx);
-double STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks, struct starpu_sched_ctx *sched_ctx);
+void STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned nblocks);
+void STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks);
+void STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks);
 
-#endif // __XLU_H__
+#endif /* __XLU_H__ */

+ 26 - 28
examples/lu/xlu_implicit.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2010  Université de Bordeaux 1
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  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
@@ -21,7 +21,7 @@
 
 static unsigned no_prio = 0;
 
-static void create_task_11(starpu_data_handle dataA, unsigned k, struct starpu_sched_ctx *sched_ctx)
+static void create_task_11(starpu_data_handle dataA, unsigned k)
 {
 	struct starpu_task *task = starpu_task_create();
 	task->cl = &cl11;
@@ -34,10 +34,10 @@ static void create_task_11(starpu_data_handle dataA, unsigned k, struct starpu_s
 	if (!no_prio)
 		task->priority = STARPU_MAX_PRIO;
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
-static void create_task_12(starpu_data_handle dataA, unsigned k, unsigned j, struct starpu_sched_ctx *sched_ctx)
+static void create_task_12(starpu_data_handle dataA, unsigned k, unsigned j)
 {
 	struct starpu_task *task = starpu_task_create();
 	task->cl = &cl12;
@@ -51,10 +51,10 @@ static void create_task_12(starpu_data_handle dataA, unsigned k, unsigned j, str
 	if (!no_prio && (j == k+1))
 		task->priority = STARPU_MAX_PRIO;
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
-static void create_task_21(starpu_data_handle dataA, unsigned k, unsigned i, struct starpu_sched_ctx *sched_ctx)
+static void create_task_21(starpu_data_handle dataA, unsigned k, unsigned i)
 {
 	struct starpu_task *task = starpu_task_create();
 
@@ -69,10 +69,10 @@ static void create_task_21(starpu_data_handle dataA, unsigned k, unsigned i, str
 	if (!no_prio && (i == k+1))
 		task->priority = STARPU_MAX_PRIO;
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
-static void create_task_22(starpu_data_handle dataA, unsigned k, unsigned i, unsigned j, struct starpu_sched_ctx *sched_ctx)
+static void create_task_22(starpu_data_handle dataA, unsigned k, unsigned i, unsigned j)
 {
 	struct starpu_task *task = starpu_task_create();
 
@@ -89,14 +89,14 @@ static void create_task_22(starpu_data_handle dataA, unsigned k, unsigned i, uns
 	if (!no_prio &&  (i == k + 1) && (j == k +1) )
 		task->priority = STARPU_MAX_PRIO;
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
 /*
  *	code to bootstrap the factorization 
  */
 
-static double dw_codelet_facto_v3(starpu_data_handle dataA, unsigned lu_nblocks, struct starpu_sched_ctx *sched_ctx)
+static void dw_codelet_facto_v3(starpu_data_handle dataA, unsigned nblocks)
 {
 	struct timeval start;
 	struct timeval end;
@@ -106,36 +106,36 @@ static double dw_codelet_facto_v3(starpu_data_handle dataA, unsigned lu_nblocks,
 
 	gettimeofday(&start, NULL);
 
-	for (k = 0; k < lu_nblocks; k++)
+	for (k = 0; k < nblocks; k++)
 	{
-	  create_task_11(dataA, k, sched_ctx);
+		create_task_11(dataA, k);
 		
-		for (i = k+1; i<lu_nblocks; i++)
+		for (i = k+1; i<nblocks; i++)
 		{
-		  create_task_12(dataA, k, i, sched_ctx);
-		  create_task_21(dataA, k, i, sched_ctx);
+			create_task_12(dataA, k, i);
+			create_task_21(dataA, k, i);
 		}
 
-		for (i = k+1; i<lu_nblocks; i++)
-		for (j = k+1; j<lu_nblocks; j++)
-		  create_task_22(dataA, k, i, j, sched_ctx);
-		  
+		for (i = k+1; i<nblocks; i++)
+		for (j = k+1; j<nblocks; j++)
+				create_task_22(dataA, k, i, j);
 	}
 
 	/* stall the application until the end of computations */
-	//starpu_task_wait_for_all();
-	starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx);
+	starpu_task_wait_for_all();
 
 	gettimeofday(&end, NULL);
 
 	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	FPRINTF(stderr, "Computation took (in ms)\n");
+	FPRINTF(stdout, "%2.2f\n", timing/1000);
 
 	unsigned n = starpu_matrix_get_nx(dataA);
 	double flop = (2.0f*n*n*n)/3.0f;
-	return (flop/timing/1000.0f);
+	FPRINTF(stderr, "Synthetic GFlops : %2.2f\n", (flop/timing/1000.0f));
 }
 
-double STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned lu_nblocks, struct starpu_sched_ctx *sched_ctx)
+void STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned nblocks)
 {
 	starpu_data_handle dataA;
 
@@ -145,22 +145,20 @@ double STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsig
 	
 	struct starpu_data_filter f;
 		f.filter_func = starpu_vertical_block_filter_func;
-		f.nchildren = lu_nblocks;
+		f.nchildren = nblocks;
 		f.get_nchildren = NULL;
 		f.get_child_ops = NULL;
 
 	struct starpu_data_filter f2;
 		f2.filter_func = starpu_block_filter_func;
-		f2.nchildren = lu_nblocks;
+		f2.nchildren = nblocks;
 		f2.get_nchildren = NULL;
 		f2.get_child_ops = NULL;
 
 	starpu_data_map_filters(dataA, 2, &f, &f2);
 
-	double gflops = dw_codelet_facto_v3(dataA, lu_nblocks, sched_ctx);
+	dw_codelet_facto_v3(dataA, nblocks);
 
 	/* gather all the data */
 	starpu_data_unpartition(dataA, 0);
-	starpu_data_unregister(dataA);
-	return gflops;
 }

+ 30 - 28
examples/lu/xlu_implicit_pivot.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2010  Université de Bordeaux 1
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  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
@@ -28,7 +28,7 @@ static unsigned no_prio = 0;
 static void create_task_pivot(starpu_data_handle *dataAp, unsigned nblocks,
 					struct piv_s *piv_description,
 					unsigned k, unsigned i,
-			      starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct starpu_sched_ctx *sched_ctx)
+					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
 	struct starpu_task *task = starpu_task_create();
 
@@ -44,12 +44,12 @@ static void create_task_pivot(starpu_data_handle *dataAp, unsigned nblocks,
 	if (!no_prio && (i == k+1))
 		task->priority = STARPU_MAX_PRIO;
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
 static void create_task_11_pivot(starpu_data_handle *dataAp, unsigned nblocks,
 					unsigned k, struct piv_s *piv_description,
-					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct starpu_sched_ctx *sched_ctx)
+					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
 	struct starpu_task *task = starpu_task_create();
 
@@ -65,11 +65,11 @@ static void create_task_11_pivot(starpu_data_handle *dataAp, unsigned nblocks,
 	if (!no_prio)
 		task->priority = STARPU_MAX_PRIO;
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
 static void create_task_12(starpu_data_handle *dataAp, unsigned nblocks, unsigned k, unsigned j,
-		starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct starpu_sched_ctx *sched_ctx)
+		starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
 	struct starpu_task *task = starpu_task_create();
 	
@@ -84,11 +84,11 @@ static void create_task_12(starpu_data_handle *dataAp, unsigned nblocks, unsigne
 	if (!no_prio && (j == k+1))
 		task->priority = STARPU_MAX_PRIO;
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
 static void create_task_21(starpu_data_handle *dataAp, unsigned nblocks, unsigned k, unsigned i,
-				starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct starpu_sched_ctx *sched_ctx)
+				starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
 	struct starpu_task *task = starpu_task_create();
 
@@ -103,11 +103,11 @@ static void create_task_21(starpu_data_handle *dataAp, unsigned nblocks, unsigne
 	if (!no_prio && (i == k+1))
 		task->priority = STARPU_MAX_PRIO;
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
 static void create_task_22(starpu_data_handle *dataAp, unsigned nblocks, unsigned k, unsigned i, unsigned j,
-				starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct starpu_sched_ctx *sched_ctx)
+				starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
 	struct starpu_task *task = starpu_task_create();
 
@@ -124,7 +124,7 @@ static void create_task_22(starpu_data_handle *dataAp, unsigned nblocks, unsigne
 	if (!no_prio &&  (i == k + 1) && (j == k +1) )
 		task->priority = STARPU_MAX_PRIO;
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
 /*
@@ -134,7 +134,7 @@ static void create_task_22(starpu_data_handle *dataAp, unsigned nblocks, unsigne
 static double dw_codelet_facto_pivot(starpu_data_handle *dataAp,
 					struct piv_s *piv_description,
 					unsigned nblocks,
-					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct starpu_sched_ctx *sched_ctx)
+					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
 	struct timeval start;
 	struct timeval end;
@@ -145,28 +145,27 @@ static double dw_codelet_facto_pivot(starpu_data_handle *dataAp,
 	unsigned i,j,k;
 	for (k = 0; k < nblocks; k++)
 	{
-	  create_task_11_pivot(dataAp, nblocks, k, piv_description, get_block, sched_ctx);
+		create_task_11_pivot(dataAp, nblocks, k, piv_description, get_block);
 
 		for (i = 0; i < nblocks; i++)
 		{
 			if (i != k)
-			  create_task_pivot(dataAp, nblocks, piv_description, k, i, get_block, sched_ctx);
+				create_task_pivot(dataAp, nblocks, piv_description, k, i, get_block);
 		}
 	
 		for (i = k+1; i<nblocks; i++)
 		{
-		  create_task_12(dataAp, nblocks, k, i, get_block, sched_ctx);
-		  create_task_21(dataAp, nblocks, k, i, get_block, sched_ctx);
+			create_task_12(dataAp, nblocks, k, i, get_block);
+			create_task_21(dataAp, nblocks, k, i, get_block);
 		}
 
 		for (i = k+1; i<nblocks; i++)
 		for (j = k+1; j<nblocks; j++)
-		  create_task_22(dataAp, nblocks, k, i, j, get_block, sched_ctx);
+			create_task_22(dataAp, nblocks, k, i, j, get_block);
 	}
 
 	/* stall the application until the end of computations */
-	//     starpu_task_wait_for_all();
-	starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx);
+	starpu_task_wait_for_all();
 
 	gettimeofday(&end, NULL);
 
@@ -182,7 +181,7 @@ starpu_data_handle get_block_with_striding(starpu_data_handle *dataAp,
 }
 
 
-double STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks, struct starpu_sched_ctx *sched_ctx)
+void STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks)
 {
 	starpu_data_handle dataA;
 
@@ -218,16 +217,17 @@ double STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned si
 	}
 
 	double timing;
-	timing = dw_codelet_facto_pivot(&dataA, piv_description, nblocks, get_block_with_striding, sched_ctx);
+	timing = dw_codelet_facto_pivot(&dataA, piv_description, nblocks, get_block_with_striding);
+
+	FPRINTF(stderr, "Computation took (in ms)\n");
+	FPRINTF(stderr, "%2.2f\n", timing/1000);
 
 	unsigned n = starpu_matrix_get_nx(dataA);
 	double flop = (2.0f*n*n*n)/3.0f;
-	double gflops = flop/timing/1000.0f;
+	FPRINTF(stderr, "Synthetic GFlops : %2.2f\n", (flop/timing/1000.0f));
 
 	/* gather all the data */
 	starpu_data_unpartition(dataA, 0);
-	starpu_data_unregister(dataA);
-	return gflops;
 }
 
 
@@ -237,7 +237,7 @@ starpu_data_handle get_block_with_no_striding(starpu_data_handle *dataAp, unsign
 	return dataAp[i+j*nblocks];
 }
 
-double STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks, struct starpu_sched_ctx *sched_ctx)
+void STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks)
 {
 	starpu_data_handle *dataAp = malloc(nblocks*nblocks*sizeof(starpu_data_handle));
 
@@ -266,16 +266,18 @@ double STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv,
 	}
 
 	double timing;
-	timing = dw_codelet_facto_pivot(dataAp, piv_description, nblocks, get_block_with_no_striding, sched_ctx);
+	timing = dw_codelet_facto_pivot(dataAp, piv_description, nblocks, get_block_with_no_striding);
+
+	FPRINTF(stderr, "Computation took (in ms)\n");
+	FPRINTF(stderr, "%2.2f\n", timing/1000);
 
 	unsigned n = starpu_matrix_get_nx(dataAp[0])*nblocks;
 	double flop = (2.0f*n*n*n)/3.0f;
-	double gflops = flop/timing/1000.0f;
+	FPRINTF(stderr, "Synthetic GFlops : %2.2f\n", (flop/timing/1000.0f));
 
 	for (bj = 0; bj < nblocks; bj++)
 	for (bi = 0; bi < nblocks; bi++)
 	{
 		starpu_data_unregister(dataAp[bi+nblocks*bj]);
 	}
-	return gflops;
 }

+ 6 - 27
examples/lu/xlu_kernels.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
+ * Copyright (C) 2009, 2010-2011  Université de Bordeaux 1
  * Copyright (C) 2010  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -55,14 +55,6 @@ static inline void STARPU_LU(common_u22)(void *descr[],
 
 #ifdef STARPU_USE_CUDA
 		case 1:
-			status = cublasGetError();
-			if (STARPU_UNLIKELY(status != CUBLAS_STATUS_SUCCESS))
-				STARPU_ABORT();
-
-			if (STARPU_UNLIKELY((cures = cudaThreadSynchronize()) != cudaSuccess))
-				STARPU_CUDA_REPORT_ERROR(cures);
-
-
 			CUBLAS_GEMM('n', 'n', dx, dy, dz,
 				(TYPE)-1.0, right, ld21, left, ld12,
 				(TYPE)1.0f, center, ld22);
@@ -92,7 +84,7 @@ void STARPU_LU(cublas_u22)(void *descr[], void *_args)
 {
 	STARPU_LU(common_u22)(descr, 1, _args);
 }
-#endif// STARPU_USE_CUDA
+#endif /* STARPU_USE_CUDA */
 
 static struct starpu_perfmodel_t STARPU_LU(model_22) = {
 	.type = STARPU_HISTORY_BASED,
@@ -175,7 +167,7 @@ void STARPU_LU(cublas_u12)(void *descr[], void *_args)
 {
 	STARPU_LU(common_u12)(descr, 1, _args);
 }
-#endif // STARPU_USE_CUDA
+#endif /* STARPU_USE_CUDA */
 
 static struct starpu_perfmodel_t STARPU_LU(model_12) = {
 	.type = STARPU_HISTORY_BASED,
@@ -295,11 +287,6 @@ static inline void STARPU_LU(common_u11)(void *descr[],
 
 	unsigned long z;
 
-#ifdef STARPU_USE_CUDA
-	cublasStatus status;
-	cudaError_t cures;
-#endif
-
 	switch (s) {
 		case 0:
 			for (z = 0; z < nx; z++)
@@ -333,14 +320,6 @@ static inline void STARPU_LU(common_u11)(void *descr[],
 						&sub11[z+(z+1)*ld], ld,
 						&sub11[(z+1) + (z+1)*ld],ld);
 			}
-
-			status = cublasGetError();
-			if (STARPU_UNLIKELY(status != CUBLAS_STATUS_SUCCESS))
-				STARPU_ABORT();
-
-			if (STARPU_UNLIKELY((cures = cudaThreadSynchronize()) != cudaSuccess))
-				STARPU_CUDA_REPORT_ERROR(cures);
-
 			
 			cudaThreadSynchronize();
 
@@ -362,7 +341,7 @@ void STARPU_LU(cublas_u11)(void *descr[], void *_args)
 {
 	STARPU_LU(common_u11)(descr, 1, _args);
 }
-#endif// STARPU_USE_CUDA
+#endif /* STARPU_USE_CUDA */
 
 static struct starpu_perfmodel_t STARPU_LU(model_11) = {
 	.type = STARPU_HISTORY_BASED,
@@ -496,7 +475,7 @@ void STARPU_LU(cublas_u11_pivot)(void *descr[], void *_args)
 {
 	STARPU_LU(common_u11_pivot)(descr, 1, _args);
 }
-#endif// STARPU_USE_CUDA
+#endif /* STARPU_USE_CUDA */
 
 static struct starpu_perfmodel_t STARPU_LU(model_11_pivot) = {
 	.type = STARPU_HISTORY_BASED,
@@ -581,7 +560,7 @@ void STARPU_LU(cublas_pivot)(void *descr[], void *_args)
 	STARPU_LU(common_pivot)(descr, 1, _args);
 }
 
-#endif// STARPU_USE_CUDA
+#endif /* STARPU_USE_CUDA */
 
 static struct starpu_perfmodel_t STARPU_LU(model_pivot) = {
 	.type = STARPU_HISTORY_BASED,

+ 2 - 2
examples/lu/xlu_kernels.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
+ * Copyright (C) 2009, 2010-2011  Université de Bordeaux 1
  * Copyright (C) 2010  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -43,4 +43,4 @@ extern starpu_codelet cl21;
 extern starpu_codelet cl22;
 extern starpu_codelet cl_pivot;
 
-#endif // __XLU_KERNELS_H__
+#endif /* __XLU_KERNELS_H__ */

+ 87 - 92
examples/lu/xlu_pivot.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2009, 2010-2011  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
  * it under the terms of the GNU Lesser General Public License as published by
@@ -46,18 +46,17 @@ static struct starpu_task *create_task(starpu_tag_t id)
 	return task;
 }
 
-static void create_task_pivot(starpu_data_handle *dataAp, unsigned lu_nblocks,
+static void create_task_pivot(starpu_data_handle *dataAp, unsigned nblocks,
 					struct piv_s *piv_description,
 					unsigned k, unsigned i,
-			      starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned),
-			      struct starpu_sched_ctx *sched_ctx)
+					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
 	struct starpu_task *task = create_task(PIVOT(k, i));
 
 	task->cl = &cl_pivot;
 
 	/* which sub-data is manipulated ? */
-	task->buffers[0].handle = get_block(dataAp, lu_nblocks, k, i);
+	task->buffers[0].handle = get_block(dataAp, nblocks, k, i);
 	task->buffers[0].mode = STARPU_RW;
 
 	task->cl_arg = &piv_description[k];
@@ -76,24 +75,24 @@ static void create_task_pivot(starpu_data_handle *dataAp, unsigned lu_nblocks,
 			starpu_tag_declare_deps(PIVOT(k, i), 2, TAG11(k), TAG22(k-1, i, k));
 		}
 		else {
-			starpu_tag_t *tags = malloc((lu_nblocks - k)*sizeof(starpu_tag_t));
+			starpu_tag_t *tags = malloc((nblocks - k)*sizeof(starpu_tag_t));
 			
 			tags[0] = TAG11(k);
 			unsigned ind, ind2;
-			for (ind = k + 1, ind2 = 0; ind < lu_nblocks; ind++, ind2++)
+			for (ind = k + 1, ind2 = 0; ind < nblocks; ind++, ind2++)
 			{
 				tags[1 + ind2] = TAG22(k-1, ind, k);
 			}
 
 			/* perhaps we could do better ... :/  */
-			starpu_tag_declare_deps_array(PIVOT(k, i), (lu_nblocks-k), tags);
+			starpu_tag_declare_deps_array(PIVOT(k, i), (nblocks-k), tags);
 		}
 	}
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
-static struct starpu_task *create_task_11_pivot(starpu_data_handle *dataAp, unsigned lu_nblocks,
+static struct starpu_task *create_task_11_pivot(starpu_data_handle *dataAp, unsigned nblocks,
 					unsigned k, struct piv_s *piv_description,
 					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
@@ -104,7 +103,7 @@ static struct starpu_task *create_task_11_pivot(starpu_data_handle *dataAp, unsi
 	task->cl_arg = &piv_description[k];
 
 	/* which sub-data is manipulated ? */
-	task->buffers[0].handle = get_block(dataAp, lu_nblocks, k, k);
+	task->buffers[0].handle = get_block(dataAp, nblocks, k, k);
 	task->buffers[0].mode = STARPU_RW;
 
 	/* this is an important task */
@@ -119,11 +118,10 @@ static struct starpu_task *create_task_11_pivot(starpu_data_handle *dataAp, unsi
 	return task;
 }
 
-static void create_task_12(starpu_data_handle *dataAp, unsigned lu_nblocks, unsigned k, unsigned j,
-			   starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned),
-			   struct starpu_sched_ctx *sched_ctx)
+static void create_task_12(starpu_data_handle *dataAp, unsigned nblocks, unsigned k, unsigned j,
+		starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
-//	printf("task 12 k,i = %d,%d TAG = %llx\n", k,i, TAG12(k,i));
+/*	printf("task 12 k,i = %d,%d TAG = %llx\n", k,i, TAG12(k,i)); */
 
 	struct starpu_task *task = create_task(TAG12(k, j));
 	
@@ -132,9 +130,9 @@ static void create_task_12(starpu_data_handle *dataAp, unsigned lu_nblocks, unsi
 	task->cl_arg = (void *)(task->tag_id);
 
 	/* which sub-data is manipulated ? */
-	task->buffers[0].handle = get_block(dataAp, lu_nblocks, k, k);
+	task->buffers[0].handle = get_block(dataAp, nblocks, k, k);
 	task->buffers[0].mode = STARPU_R;
-	task->buffers[1].handle = get_block(dataAp, lu_nblocks, j, k);
+	task->buffers[1].handle = get_block(dataAp, nblocks, j, k);
 	task->buffers[1].mode = STARPU_RW;
 
 	if (!no_prio && (j == k+1)) {
@@ -152,21 +150,20 @@ static void create_task_12(starpu_data_handle *dataAp, unsigned lu_nblocks, unsi
 		starpu_tag_declare_deps(TAG12(k, j), 1, TAG11(k));
 	}
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
-static void create_task_21(starpu_data_handle *dataAp, unsigned lu_nblocks, unsigned k, unsigned i,
-			   starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), 
-			   struct starpu_sched_ctx *sched_ctx)
+static void create_task_21(starpu_data_handle *dataAp, unsigned nblocks, unsigned k, unsigned i,
+				starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
 	struct starpu_task *task = create_task(TAG21(k, i));
 
 	task->cl = &cl21;
 	
 	/* which sub-data is manipulated ? */
-	task->buffers[0].handle = get_block(dataAp, lu_nblocks, k, k); 
+	task->buffers[0].handle = get_block(dataAp, nblocks, k, k); 
 	task->buffers[0].mode = STARPU_R;
-	task->buffers[1].handle = get_block(dataAp, lu_nblocks, k, i); 
+	task->buffers[1].handle = get_block(dataAp, nblocks, k, i); 
 	task->buffers[1].mode = STARPU_RW;
 
 	if (!no_prio && (i == k+1)) {
@@ -178,14 +175,13 @@ static void create_task_21(starpu_data_handle *dataAp, unsigned lu_nblocks, unsi
 	/* enforce dependencies ... */
 	starpu_tag_declare_deps(TAG21(k, i), 1, PIVOT(k, i));
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
-static void create_task_22(starpu_data_handle *dataAp, unsigned lu_nblocks, unsigned k, unsigned i, unsigned j,
-			   starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned),
-			   struct starpu_sched_ctx *sched_ctx)
+static void create_task_22(starpu_data_handle *dataAp, unsigned nblocks, unsigned k, unsigned i, unsigned j,
+				starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
-//	printf("task 22 k,i,j = %d,%d,%d TAG = %llx\n", k,i,j, TAG22(k,i,j));
+/*	printf("task 22 k,i,j = %d,%d,%d TAG = %llx\n", k,i,j, TAG22(k,i,j)); */
 
 	struct starpu_task *task = create_task(TAG22(k, i, j));
 
@@ -194,11 +190,11 @@ static void create_task_22(starpu_data_handle *dataAp, unsigned lu_nblocks, unsi
 	task->cl_arg = (void *)(task->tag_id);
 
 	/* which sub-data is manipulated ? */
-	task->buffers[0].handle = get_block(dataAp, lu_nblocks, k, i); /* produced by TAG21(k, i) */
+	task->buffers[0].handle = get_block(dataAp, nblocks, k, i); /* produced by TAG21(k, i) */
 	task->buffers[0].mode = STARPU_R;
-	task->buffers[1].handle = get_block(dataAp, lu_nblocks, j, k); /* produced by TAG12(k, j) */ 
+	task->buffers[1].handle = get_block(dataAp, nblocks, j, k); /* produced by TAG12(k, j) */ 
 	task->buffers[1].mode = STARPU_R;
-	task->buffers[2].handle = get_block(dataAp, lu_nblocks, j, i);  /* produced by TAG22(k-1, i, j) */
+	task->buffers[2].handle = get_block(dataAp, nblocks, j, i);  /* produced by TAG22(k-1, i, j) */
 	task->buffers[2].mode = STARPU_RW;
 
 	if (!no_prio &&  (i == k + 1) && (j == k +1) ) {
@@ -213,7 +209,7 @@ static void create_task_22(starpu_data_handle *dataAp, unsigned lu_nblocks, unsi
 		starpu_tag_declare_deps(TAG22(k, i, j), 2, TAG12(k, j), TAG21(k, i));
 	}
 
-	starpu_task_submit_to_ctx(task, sched_ctx);
+	starpu_task_submit(task);
 }
 
 /*
@@ -222,9 +218,8 @@ static void create_task_22(starpu_data_handle *dataAp, unsigned lu_nblocks, unsi
 
 static double dw_codelet_facto_pivot(starpu_data_handle *dataAp,
 					struct piv_s *piv_description,
-					unsigned lu_nblocks,
-				     starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), 
-				     struct starpu_sched_ctx *sched_ctx)
+					unsigned nblocks,
+					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
 	struct timeval start;
 	struct timeval end;
@@ -234,46 +229,46 @@ static double dw_codelet_facto_pivot(starpu_data_handle *dataAp,
 	/* create all the DAG nodes */
 	unsigned i,j,k;
 
-	for (k = 0; k < lu_nblocks; k++)
+	for (k = 0; k < nblocks; k++)
 	{
-		struct starpu_task *task = create_task_11_pivot(dataAp, lu_nblocks, k, piv_description, get_block);
+		struct starpu_task *task = create_task_11_pivot(dataAp, nblocks, k, piv_description, get_block);
 
 		/* we defer the launch of the first task */
 		if (k == 0) {
 			entry_task = task;
 		}
 		else {
-		  starpu_task_submit_to_ctx(task, sched_ctx);
+			starpu_task_submit(task);
 		}
 
-		for (i = 0; i < lu_nblocks; i++)
+		for (i = 0; i < nblocks; i++)
 		{
 			if (i != k)
-			  create_task_pivot(dataAp, lu_nblocks, piv_description, k, i, get_block, sched_ctx);
+				create_task_pivot(dataAp, nblocks, piv_description, k, i, get_block);
 		}
 	
-		for (i = k+1; i<lu_nblocks; i++)
+		for (i = k+1; i<nblocks; i++)
 		{
-		  create_task_12(dataAp, lu_nblocks, k, i, get_block, sched_ctx);
-		  create_task_21(dataAp, lu_nblocks, k, i, get_block, sched_ctx);
+			create_task_12(dataAp, nblocks, k, i, get_block);
+			create_task_21(dataAp, nblocks, k, i, get_block);
 		}
 
-		for (i = k+1; i<lu_nblocks; i++)
+		for (i = k+1; i<nblocks; i++)
 		{
-			for (j = k+1; j<lu_nblocks; j++)
+			for (j = k+1; j<nblocks; j++)
 			{
-			  create_task_22(dataAp, lu_nblocks, k, i, j, get_block, sched_ctx);
+				create_task_22(dataAp, nblocks, k, i, j, get_block);
 			}
 		}
 	}
 
-	/* we wait the last task (TAG11(lu_nblocks - 1)) and all the pivot tasks */
-	starpu_tag_t *tags = malloc(lu_nblocks*lu_nblocks*sizeof(starpu_tag_t));
+	/* we wait the last task (TAG11(nblocks - 1)) and all the pivot tasks */
+	starpu_tag_t *tags = malloc(nblocks*nblocks*sizeof(starpu_tag_t));
 	unsigned ndeps = 0;
 
-	tags[ndeps++] = TAG11(lu_nblocks - 1);
+	tags[ndeps++] = TAG11(nblocks - 1);
 
-	for (j = 0; j < lu_nblocks; j++)
+	for (j = 0; j < nblocks; j++)
 	{
 		for (i = 0; i < j; i++)
 		{
@@ -283,17 +278,16 @@ static double dw_codelet_facto_pivot(starpu_data_handle *dataAp,
 
 	/* schedule the codelet */
 	gettimeofday(&start, NULL);
-	int ret = starpu_task_submit_to_ctx(entry_task, sched_ctx);
+	int ret = starpu_task_submit(entry_task);
 	if (STARPU_UNLIKELY(ret == -ENODEV))
 	{
-		fprintf(stderr, "No worker may execute this task\n");
+		FPRINTF(stderr, "No worker may execute this task\n");
 		exit(-1);
 	}
 
 	/* stall the application until the end of computations */
 	starpu_tag_wait_array(ndeps, tags);
-	printf("lu pivot  finish waiting for %d blocks \n", lu_nblocks);
-//	starpu_task_wait_for_all();
+/*	starpu_task_wait_for_all(); */
 
 	gettimeofday(&end, NULL);
 
@@ -302,14 +296,14 @@ static double dw_codelet_facto_pivot(starpu_data_handle *dataAp,
 }
 
 starpu_data_handle get_block_with_striding(starpu_data_handle *dataAp,
-			unsigned lu_nblocks __attribute__((unused)), unsigned j, unsigned i)
+			unsigned nblocks __attribute__((unused)), unsigned j, unsigned i)
 {
 	/* we use filters */
 	return starpu_data_get_sub_data(*dataAp, 2, j, i);
 }
 
 
-double STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned lu_nblocks, struct starpu_sched_ctx *sched_ctx)
+void STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks)
 {
 	starpu_data_handle dataA;
 
@@ -322,11 +316,11 @@ double STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned si
 
 	struct starpu_data_filter f;
 		f.filter_func = starpu_vertical_block_filter_func;
-		f.nchildren = lu_nblocks;
+		f.nchildren = nblocks;
 
 	struct starpu_data_filter f2;
 		f2.filter_func = starpu_block_filter_func;
-		f2.nchildren = lu_nblocks;
+		f2.nchildren = nblocks;
 
 	starpu_data_map_filters(dataA, 2, &f, &f2);
 
@@ -334,88 +328,89 @@ double STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned si
 	for (i = 0; i < size; i++)
 		ipiv[i] = i;
 
-	struct piv_s *piv_description = malloc(lu_nblocks*sizeof(struct piv_s));
+	struct piv_s *piv_description = malloc(nblocks*sizeof(struct piv_s));
 	unsigned block;
-	for (block = 0; block < lu_nblocks; block++)
+	for (block = 0; block < nblocks; block++)
 	{
 		piv_description[block].piv = ipiv;
-		piv_description[block].first = block * (size / lu_nblocks);
-		piv_description[block].last = (block + 1) * (size / lu_nblocks);
+		piv_description[block].first = block * (size / nblocks);
+		piv_description[block].last = (block + 1) * (size / nblocks);
 	}
 
 #if 0
 	unsigned j;
-	for (j = 0; j < lu_nblocks; j++)
-	for (i = 0; i < lu_nblocks; i++)
+	for (j = 0; j < nblocks; j++)
+	for (i = 0; i < nblocks; i++)
 	{
-		printf("BLOCK %d %d	%p\n", i, j, &matA[i*(size/lu_nblocks) + j * (size/lu_nblocks)*ld]);
+		printf("BLOCK %d %d	%p\n", i, j, &matA[i*(size/nblocks) + j * (size/nblocks)*ld]);
 	}
 #endif
 
 	double timing;
-	timing = dw_codelet_facto_pivot(&dataA, piv_description, lu_nblocks, get_block_with_striding, sched_ctx);
+	timing = dw_codelet_facto_pivot(&dataA, piv_description, nblocks, get_block_with_striding);
 
-	fprintf(stderr, "Computation took (in ms)\n");
-	fprintf(stderr, "%2.2f\n", timing/1000);
+	FPRINTF(stderr, "Computation took (in ms)\n");
+	FPRINTF(stderr, "%2.2f\n", timing/1000);
 
 	unsigned n = starpu_matrix_get_nx(dataA);
 	double flop = (2.0f*n*n*n)/3.0f;
-	double gflops = flop/timing/1000.0f;
+	FPRINTF(stderr, "Synthetic GFlops : %2.2f\n", (flop/timing/1000.0f));
 
 	/* gather all the data */
 	starpu_data_unpartition(dataA, 0);
-	return gflops;
 }
 
 
-starpu_data_handle get_block_with_no_striding(starpu_data_handle *dataAp, unsigned lu_nblocks, unsigned j, unsigned i)
+starpu_data_handle get_block_with_no_striding(starpu_data_handle *dataAp, unsigned nblocks, unsigned j, unsigned i)
 {
 	/* dataAp is an array of data handle */
-	return dataAp[i+j*lu_nblocks];
+	return dataAp[i+j*nblocks];
 }
 
-double STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned lu_nblocks, struct starpu_sched_ctx *sched_ctx)
+void STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks)
 {
-	starpu_data_handle *dataAp = malloc(lu_nblocks*lu_nblocks*sizeof(starpu_data_handle));
+	starpu_data_handle *dataAp = malloc(nblocks*nblocks*sizeof(starpu_data_handle));
 
 	/* monitor and partition the A matrix into blocks :
 	 * one block is now determined by 2 unsigned (i,j) */
 	unsigned bi, bj;
-	for (bj = 0; bj < lu_nblocks; bj++)
-	for (bi = 0; bi < lu_nblocks; bi++)
+	for (bj = 0; bj < nblocks; bj++)
+	for (bi = 0; bi < nblocks; bi++)
 	{
-		starpu_matrix_data_register(&dataAp[bi+lu_nblocks*bj], 0,
-			(uintptr_t)matA[bi+lu_nblocks*bj], size/lu_nblocks,
-			size/lu_nblocks, size/lu_nblocks, sizeof(TYPE));
+		starpu_matrix_data_register(&dataAp[bi+nblocks*bj], 0,
+			(uintptr_t)matA[bi+nblocks*bj], size/nblocks,
+			size/nblocks, size/nblocks, sizeof(TYPE));
 
 		/* We already enforce deps by hand */
-		starpu_data_set_sequential_consistency_flag(dataAp[bi+lu_nblocks*bj], 0);
+		starpu_data_set_sequential_consistency_flag(dataAp[bi+nblocks*bj], 0);
 	}
 
 	unsigned i;
 	for (i = 0; i < size; i++)
 		ipiv[i] = i;
 
-	struct piv_s *piv_description = malloc(lu_nblocks*sizeof(struct piv_s));
+	struct piv_s *piv_description = malloc(nblocks*sizeof(struct piv_s));
 	unsigned block;
-	for (block = 0; block < lu_nblocks; block++)
+	for (block = 0; block < nblocks; block++)
 	{
 		piv_description[block].piv = ipiv;
-		piv_description[block].first = block * (size / lu_nblocks);
-		piv_description[block].last = (block + 1) * (size / lu_nblocks);
+		piv_description[block].first = block * (size / nblocks);
+		piv_description[block].last = (block + 1) * (size / nblocks);
 	}
 
 	double timing;
-	timing = dw_codelet_facto_pivot(dataAp, piv_description, lu_nblocks, get_block_with_no_striding, sched_ctx);
+	timing = dw_codelet_facto_pivot(dataAp, piv_description, nblocks, get_block_with_no_striding);
+
+	FPRINTF(stderr, "Computation took (in ms)\n");
+	FPRINTF(stderr, "%2.2f\n", timing/1000);
 
-	unsigned n = starpu_matrix_get_nx(dataAp[0])*lu_nblocks;
+	unsigned n = starpu_matrix_get_nx(dataAp[0])*nblocks;
 	double flop = (2.0f*n*n*n)/3.0f;
-	double gflops = flop/timing/1000.0f;
+	FPRINTF(stderr, "Synthetic GFlops : %2.2f\n", (flop/timing/1000.0f));
 
-	for (bj = 0; bj < lu_nblocks; bj++)
-	for (bi = 0; bi < lu_nblocks; bi++)
+	for (bj = 0; bj < nblocks; bj++)
+	for (bi = 0; bi < nblocks; bi++)
 	{
-		starpu_data_unregister(dataAp[bi+lu_nblocks*bj]);
+		starpu_data_unregister(dataAp[bi+nblocks*bj]);
 	}
-	return gflops;
 }