浏览代码

Changed computing method

Andra Hugo 14 年之前
父节点
当前提交
7a0a4c2641

+ 7 - 5
examples/Makefile.am

@@ -437,18 +437,18 @@ examplebin_PROGRAMS += 				\
 
 
 cholesky_and_lu_cholesky_and_lu_SOURCES =			\
 cholesky_and_lu_cholesky_and_lu_SOURCES =			\
 	cholesky_and_lu/cholesky_and_lu.c			\
 	cholesky_and_lu/cholesky_and_lu.c			\
-	cholesky_and_lu/cholesky/cholesky_tile_tag.c		\
+	cholesky_and_lu/cholesky/cholesky_implicit.c		\
 	cholesky_and_lu/cholesky/cholesky_models.c		\
 	cholesky_and_lu/cholesky/cholesky_models.c		\
 	cholesky_and_lu/cholesky/cholesky_kernels.c		\
 	cholesky_and_lu/cholesky/cholesky_kernels.c		\
-	cholesky_and_lu/lu/slu.c				\
-	cholesky_and_lu/lu/slu_pivot.c				\
+	cholesky_and_lu/lu/slu_implicit.c				\
+	cholesky_and_lu/lu/slu_implicit_pivot.c				\
 	cholesky_and_lu/lu/slu_kernels.c			\
 	cholesky_and_lu/lu/slu_kernels.c			\
 	common/blas.c
 	common/blas.c
 endif
 endif
 
 
-###########################
+#############################################
 # Cholesky and Lu without sched ctx example #
 # Cholesky and Lu without sched ctx example #
-###########################
+#############################################
 if !NO_BLAS_LIB
 if !NO_BLAS_LIB
 
 
 examplebin_PROGRAMS += 				\
 examplebin_PROGRAMS += 				\
@@ -465,6 +465,8 @@ cholesky_and_lu_without_sched_ctx_cholesky_and_lu_without_sched_ctx_SOURCES =
 	common/blas.c
 	common/blas.c
 endif
 endif
 
 
+
+
 ################
 ################
 # Heat example #
 # Heat example #
 ################
 ################

+ 2 - 4
examples/cholesky_and_lu/cholesky/cholesky.h

@@ -72,11 +72,9 @@ void chol_cublas_codelet_update_u22(void *descr[], void *_args);
 #endif
 #endif
 
 
 int run_cholesky_grain_tag(struct starpu_sched_ctx *sched_ctx, int argc, char **argv);
 int run_cholesky_grain_tag(struct starpu_sched_ctx *sched_ctx, int argc, char **argv);
-int run_cholesky_implicit(struct starpu_sched_ctx *sched_ctx, int argc, char **argv);
+double run_cholesky_implicit(struct starpu_sched_ctx *sched_ctx, int argc, char **argv);
 int run_cholesky_tag(struct starpu_sched_ctx *sched_ctx, int argc, char **argv);
 int run_cholesky_tag(struct starpu_sched_ctx *sched_ctx, int argc, char **argv);
-int run_cholesky_tile_tag(struct starpu_sched_ctx *sched_ctx, int argc, char **argv, 
-			  struct timeval *start);
-int finish_cholesky_tile_tag(struct timeval *end);
+double run_cholesky_tile_tag(struct starpu_sched_ctx *sched_ctx, int argc, char **argv);
 
 
 extern struct starpu_perfmodel_t chol_model_11;
 extern struct starpu_perfmodel_t chol_model_11;
 extern struct starpu_perfmodel_t chol_model_21;
 extern struct starpu_perfmodel_t chol_model_21;

+ 12 - 13
examples/cholesky_and_lu/cholesky/cholesky_implicit.c

@@ -69,7 +69,7 @@ static void callback_turn_spmd_on(void *arg __attribute__ ((unused)))
 	cl22.type = STARPU_SPMD;
 	cl22.type = STARPU_SPMD;
 }
 }
 
 
-static void _cholesky(starpu_data_handle dataA, unsigned nblocks, struct starpu_sched_ctx *sched_ctx)
+static double _cholesky(starpu_data_handle dataA, unsigned nblocks, struct starpu_sched_ctx *sched_ctx)
 {
 {
 	struct timeval start;
 	struct timeval start;
 	struct timeval end;
 	struct timeval end;
@@ -119,23 +119,22 @@ static void _cholesky(starpu_data_handle dataA, unsigned nblocks, struct starpu_
 		}
 		}
 	}
 	}
 
 
-	starpu_task_wait_for_all();
+	//		starpu_task_wait_for_all();
+	starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx);
 
 
 	starpu_data_unpartition(dataA, 0);
 	starpu_data_unpartition(dataA, 0);
 
 
 	gettimeofday(&end, NULL);
 	gettimeofday(&end, NULL);
 
 
 	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
-	fprintf(stderr, "Computation took (in ms)\n");
-	printf("%2.2f\n", timing/1000);
-
 	unsigned long n = starpu_matrix_get_nx(dataA);
 	unsigned long n = starpu_matrix_get_nx(dataA);
 
 
 	double flop = (1.0f*n*n*n)/3.0f;
 	double flop = (1.0f*n*n*n)/3.0f;
-	fprintf(stderr, "Synthetic GFlops : %2.2f\n", (flop/timing/1000.0f));
+	
+	return (flop/timing/1000.0f);
 }
 }
 
 
-static void cholesky(float *matA, unsigned size, unsigned ld, unsigned nblocks, struct starpu_sched_ctx *sched_ctx)
+static double cholesky(float *matA, unsigned size, unsigned ld, unsigned nblocks, struct starpu_sched_ctx *sched_ctx)
 {
 {
 	starpu_data_handle dataA;
 	starpu_data_handle dataA;
 
 
@@ -157,10 +156,10 @@ static void cholesky(float *matA, unsigned size, unsigned ld, unsigned nblocks,
 
 
 	starpu_data_map_filters(dataA, 2, &f, &f2);
 	starpu_data_map_filters(dataA, 2, &f, &f2);
 
 
-	_cholesky(dataA, nblocks, sched_ctx);
+	return _cholesky(dataA, nblocks, sched_ctx);
 }
 }
 
 
-int run_cholesky_implicit(struct starpu_sched_ctx *sched_ctx, int argc, char **argv)
+double run_cholesky_implicit(struct starpu_sched_ctx *sched_ctx, int argc, char **argv)
 {
 {
 	/* create a simple definite positive symetric matrix example
 	/* create a simple definite positive symetric matrix example
 	 *
 	 *
@@ -171,7 +170,7 @@ int run_cholesky_implicit(struct starpu_sched_ctx *sched_ctx, int argc, char **a
 
 
 	//	starpu_init(NULL);
 	//	starpu_init(NULL);
 
 
-	starpu_helper_cublas_init();
+	//	starpu_helper_cublas_init();
 
 
 	float *mat;
 	float *mat;
 	starpu_data_malloc_pinned_if_possible((void **)&mat, (size_t)size*size*sizeof(float));
 	starpu_data_malloc_pinned_if_possible((void **)&mat, (size_t)size*size*sizeof(float));
@@ -205,7 +204,7 @@ int run_cholesky_implicit(struct starpu_sched_ctx *sched_ctx, int argc, char **a
 	}
 	}
 #endif
 #endif
 
 
-	cholesky(mat, size, size, nblocks);
+	double gflops = cholesky(mat, size, size, nblocks, sched_ctx);
 
 
 #ifdef PRINT_OUTPUT
 #ifdef PRINT_OUTPUT
 	printf("Results :\n");
 	printf("Results :\n");
@@ -276,8 +275,8 @@ int run_cholesky_implicit(struct starpu_sched_ctx *sched_ctx, int argc, char **a
 	        }
 	        }
 	}
 	}
 
 
-	starpu_helper_cublas_shutdown();
+	//	starpu_helper_cublas_shutdown();
 	//	starpu_shutdown();
 	//	starpu_shutdown();
 
 
-	return 0;
+	return gflops;
 }
 }

+ 38 - 43
examples/cholesky_and_lu/cholesky/cholesky_tile_tag.c

@@ -17,16 +17,14 @@
 
 
 #include "cholesky.h"
 #include "cholesky.h"
 
 
-/* A [ y ] [ x ] */
-float *A[NMAXBLOCKS][NMAXBLOCKS];
-starpu_data_handle A_state[NMAXBLOCKS][NMAXBLOCKS];
-//struct timeval start;
-//struct timeval end;
-
 /*
 /*
  *	Some useful functions
  *	Some useful functions
  */
  */
 
 
+/* A [ y ] [ x ] */
+float *ch_A[NMAXBLOCKS][NMAXBLOCKS];
+starpu_data_handle ch_A_state[NMAXBLOCKS][NMAXBLOCKS];
+
 static struct starpu_task *create_task(starpu_tag_t id)
 static struct starpu_task *create_task(starpu_tag_t id)
 {
 {
 	struct starpu_task *task = starpu_task_create();
 	struct starpu_task *task = starpu_task_create();
@@ -68,7 +66,7 @@ static struct starpu_task * create_task_11(unsigned k, unsigned nblocks)
 	task->cl = &cl11;
 	task->cl = &cl11;
 
 
 	/* which sub-data is manipulated ? */
 	/* which sub-data is manipulated ? */
-	task->buffers[0].handle = A_state[k][k];
+	task->buffers[0].handle = ch_A_state[k][k];
 	task->buffers[0].mode = STARPU_RW;
 	task->buffers[0].mode = STARPU_RW;
 
 
 	/* this is an important task */
 	/* this is an important task */
@@ -107,9 +105,9 @@ static void create_task_21(unsigned k, unsigned j, struct starpu_sched_ctx *sche
 	task->cl = &cl21;	
 	task->cl = &cl21;	
 
 
 	/* which sub-data is manipulated ? */
 	/* which sub-data is manipulated ? */
-	task->buffers[0].handle = A_state[k][k]; 
+	task->buffers[0].handle = ch_A_state[k][k]; 
 	task->buffers[0].mode = STARPU_R;
 	task->buffers[0].mode = STARPU_R;
-	task->buffers[1].handle = A_state[j][k]; 
+	task->buffers[1].handle = ch_A_state[j][k]; 
 	task->buffers[1].mode = STARPU_RW;
 	task->buffers[1].mode = STARPU_RW;
 
 
 	if (j == k+1) {
 	if (j == k+1) {
@@ -154,11 +152,11 @@ static void create_task_22(unsigned k, unsigned i, unsigned j, struct starpu_sch
 	task->cl = &cl22;
 	task->cl = &cl22;
 
 
 	/* which sub-data is manipulated ? */
 	/* which sub-data is manipulated ? */
-	task->buffers[0].handle = A_state[i][k]; 
+	task->buffers[0].handle = ch_A_state[i][k]; 
 	task->buffers[0].mode = STARPU_R;
 	task->buffers[0].mode = STARPU_R;
-	task->buffers[1].handle = A_state[j][k]; 
+	task->buffers[1].handle = ch_A_state[j][k]; 
 	task->buffers[1].mode = STARPU_R;
 	task->buffers[1].mode = STARPU_R;
-	task->buffers[2].handle = A_state[j][i]; 
+	task->buffers[2].handle = ch_A_state[j][i]; 
 	task->buffers[2].mode = STARPU_RW;
 	task->buffers[2].mode = STARPU_RW;
 
 
 	if ( (i == k + 1) && (j == k +1) ) {
 	if ( (i == k + 1) && (j == k +1) ) {
@@ -183,8 +181,11 @@ static void create_task_22(unsigned k, unsigned i, unsigned j, struct starpu_sch
  *	and construct the DAG
  *	and construct the DAG
  */
  */
 
 
-static void cholesky_no_stride(struct starpu_sched_ctx *sched_ctx, struct timeval *start)
+static double cholesky_no_stride(struct starpu_sched_ctx *sched_ctx)
 {
 {
+	struct timeval start;
+	struct timeval end;
+
 	struct starpu_task *entry_task = NULL;
 	struct starpu_task *entry_task = NULL;
 
 
 	/* create all the DAG nodes */
 	/* create all the DAG nodes */
@@ -192,7 +193,7 @@ static void cholesky_no_stride(struct starpu_sched_ctx *sched_ctx, struct timeva
 
 
 	for (k = 0; k < nblocks; k++)
 	for (k = 0; k < nblocks; k++)
 	{
 	{
-		struct starpu_task *task = create_task_11(k, nblocks);
+	  struct starpu_task *task = create_task_11(k, nblocks);
 		/* we defer the launch of the first task */
 		/* we defer the launch of the first task */
 		if (k == 0) {
 		if (k == 0) {
 			entry_task = task;
 			entry_task = task;
@@ -214,14 +215,22 @@ static void cholesky_no_stride(struct starpu_sched_ctx *sched_ctx, struct timeva
 	}
 	}
 
 
 	/* schedule the codelet */
 	/* schedule the codelet */
-	if(start != NULL){
-		gettimeofday(start, NULL);
-	}
+	gettimeofday(&start, NULL);
+		
 	starpu_task_submit_to_ctx(entry_task, sched_ctx);
 	starpu_task_submit_to_ctx(entry_task, sched_ctx);
 
 
+	/* stall the application until the end of computations */
+	starpu_tag_wait(TAG11(nblocks-1));
+	printf("cholesky finish wait for %d blocks \n", nblocks - 1);
+
+        gettimeofday(&end, NULL);
+
+        double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+        double flop = (1.0f*size*size*size)/3.0f;
+	return flop/timing/1000.0f;
 }
 }
 
 
-int run_cholesky_tile_tag(struct starpu_sched_ctx *sched_ctx, int argc, char **argv, struct timeval *start)
+double run_cholesky_tile_tag(struct starpu_sched_ctx *sched_ctx, int argc, char **argv)
 {
 {
 	unsigned x, y;
 	unsigned x, y;
 	unsigned i, j;
 	unsigned i, j;
@@ -236,14 +245,14 @@ int run_cholesky_tile_tag(struct starpu_sched_ctx *sched_ctx, int argc, char **a
 	/* Disable sequential consistency */
 	/* Disable sequential consistency */
 	starpu_data_set_default_sequential_consistency_flag(0);
 	starpu_data_set_default_sequential_consistency_flag(0);
 
 
-	starpu_helper_cublas_init();
+	//	starpu_helper_cublas_init();
 
 
 	for (y = 0; y < nblocks; y++)
 	for (y = 0; y < nblocks; y++)
 	for (x = 0; x < nblocks; x++)
 	for (x = 0; x < nblocks; x++)
 	{
 	{
 		if (x <= y) {
 		if (x <= y) {
-			A[y][x] = malloc(BLOCKSIZE*BLOCKSIZE*sizeof(float));
-			assert(A[y][x]);
+			ch_A[y][x] = malloc(BLOCKSIZE*BLOCKSIZE*sizeof(float));
+			assert(ch_A[y][x]);
 		}
 		}
 	}
 	}
 
 
@@ -253,11 +262,11 @@ int run_cholesky_tile_tag(struct starpu_sched_ctx *sched_ctx, int argc, char **a
 	{
 	{
 		if (x <= y) {
 		if (x <= y) {
 #ifdef STARPU_HAVE_POSIX_MEMALIGN
 #ifdef STARPU_HAVE_POSIX_MEMALIGN
-			posix_memalign((void **)&A[y][x], 128, BLOCKSIZE*BLOCKSIZE*sizeof(float));
+			posix_memalign((void **)&ch_A[y][x], 128, BLOCKSIZE*BLOCKSIZE*sizeof(float));
 #else
 #else
-			A[y][x] = malloc(BLOCKSIZE*BLOCKSIZE*sizeof(float));
+			ch_A[y][x] = malloc(BLOCKSIZE*BLOCKSIZE*sizeof(float));
 #endif
 #endif
-			assert(A[y][x]);
+			assert(ch_A[y][x]);
 		}
 		}
 	}
 	}
 
 
@@ -271,12 +280,12 @@ int run_cholesky_tile_tag(struct starpu_sched_ctx *sched_ctx, int argc, char **a
 		for (i = 0; i < BLOCKSIZE; i++)
 		for (i = 0; i < BLOCKSIZE; i++)
 		for (j = 0; j < BLOCKSIZE; j++)
 		for (j = 0; j < BLOCKSIZE; j++)
 		{
 		{
-			A[y][x][i*BLOCKSIZE + j] =
+			ch_A[y][x][i*BLOCKSIZE + j] =
 				(float)(1.0f/((float) (1.0+(x*BLOCKSIZE+i)+(y*BLOCKSIZE+j))));
 				(float)(1.0f/((float) (1.0+(x*BLOCKSIZE+i)+(y*BLOCKSIZE+j))));
 
 
 			/* make it a little more numerically stable ... ;) */
 			/* make it a little more numerically stable ... ;) */
 			if ((x == y) && (i == j))
 			if ((x == y) && (i == j))
-				A[y][x][i*BLOCKSIZE + j] += (float)(2*size);
+				ch_A[y][x][i*BLOCKSIZE + j] += (float)(2*size);
 		}
 		}
 	}
 	}
 
 
@@ -286,27 +295,13 @@ int run_cholesky_tile_tag(struct starpu_sched_ctx *sched_ctx, int argc, char **a
 	for (x = 0; x < nblocks; x++)
 	for (x = 0; x < nblocks; x++)
 	{
 	{
 		if (x <= y) {
 		if (x <= y) {
-			starpu_matrix_data_register(&A_state[y][x], 0, (uintptr_t)A[y][x], 
+			starpu_matrix_data_register(&ch_A_state[y][x], 0, (uintptr_t)ch_A[y][x], 
 				BLOCKSIZE, BLOCKSIZE, BLOCKSIZE, sizeof(float));
 				BLOCKSIZE, BLOCKSIZE, BLOCKSIZE, sizeof(float));
 		}
 		}
 	}
 	}
 
 
-	cholesky_no_stride(sched_ctx, start);
+	return cholesky_no_stride(sched_ctx);
 
 
 	//	starpu_shutdown();
 	//	starpu_shutdown();
-	return 0;
-}
-
-
-int finish_cholesky_tile_tag(struct timeval *end){	
-  //	starpu_helper_cublas_shutdown();
-
-	/* stall the application until the end of computations */
-	starpu_tag_wait(TAG11(nblocks-1));
-
-	if(end != NULL){
-	  gettimeofday(end, NULL);
-	}
-
-	return 0;
+	//	return 0;
 }
 }

+ 64 - 17
examples/cholesky_and_lu/cholesky_and_lu.c

@@ -1,33 +1,80 @@
 #include "cholesky/cholesky.h"
 #include "cholesky/cholesky.h"
 #include "lu/lu_example_float.c"
 #include "lu/lu_example_float.c"
+#include <pthread.h>
 
 
-int main(int argc, char **argv)
-{
-  struct timeval start;
-  struct timeval end;
+typedef struct {
+  int argc;
+  char **argv;
+} params;
 
 
-  starpu_init(NULL);
+#define NSAMPLES 10
+struct starpu_sched_ctx sched_ctx;
+struct starpu_sched_ctx sched_ctx2;
+
+void* func_cholesky(void *val){
+  params *p = (params*)val;
 
 
-  struct starpu_sched_ctx sched_ctx;
   int procs[] = {1, 2, 3};
   int procs[] = {1, 2, 3};
-  starpu_create_sched_ctx(&sched_ctx, "heft", procs, 3);
+  starpu_create_sched_ctx(&sched_ctx, "heft", procs, 3, "cholesky");
+
+  int i;
+  double *flops = (double*)malloc(sizeof(double));
+  (*flops) = 0;
+  for(i = 0; i < NSAMPLES; i++)
+    {
+      (*flops) += run_cholesky_implicit(&sched_ctx, p->argc, p->argv);
+    }
 
 
-  run_cholesky_tile_tag(&sched_ctx, argc, argv, &start);
+  (*flops) /= NSAMPLES;
+  return (void*)flops;
+}
+
+void* func_lu(void *val){
+  params *p = (params*)val;
 
 
-  struct starpu_sched_ctx sched_ctx2;
   int procs2[] = {0, 4, 5, 6, 7, 8, 9, 10, 11};
   int procs2[] = {0, 4, 5, 6, 7, 8, 9, 10, 11};
-  starpu_create_sched_ctx(&sched_ctx2, "heft", procs2, 5);
+  starpu_create_sched_ctx(&sched_ctx2, "heft", procs2, 9, "lu");
 
 
-  run_lu(&sched_ctx2, argc, argv, NULL);
+  int i;
+  double *flops = (double*)malloc(sizeof(double));
+  (*flops) = 0;
+  for(i = 0; i < NSAMPLES; i++)
+    {
+      printf("%d ", i);
+      (*flops) += run_lu(&sched_ctx2, p->argc, p->argv);
+    }
 
 
-  finish_cholesky_tile_tag(NULL);
-  finish_lu(&end);
-  //starpu_task_wait_for_all();
+  (*flops) /= NSAMPLES;
+  return (void*)flops;
+}
 
 
-  starpu_shutdown();
+int main(int argc, char **argv)
+{
+  starpu_init(NULL);
+  starpu_helper_cublas_init();
+
+  pthread_t tid[2];
+
+  params p;
+  p.argc = argc;
+  p.argv = argv;
+
+  pthread_create(&tid[0], NULL, (void*)func_cholesky, (void*)&p);
+  pthread_create(&tid[1], NULL, (void*)func_cholesky, (void*)&p);
 
 
-  double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
-  printf("%2.2f\n", timing/1000);
+  void *gflops_cholesky1;
+  void *gflops_cholesky2;
+  //  void *gflops_lu = func_lu(&p);
+ 
+  pthread_join(tid[0], &gflops_cholesky1);
+  pthread_join(tid[1], &gflops_cholesky2);
+
+  void *gflops_cholesky3 = func_cholesky(&p);
+
+  printf("%2.2f %2.2f %2.2f\n", *((double*)gflops_cholesky1), *((double*)gflops_cholesky2), *((double*)gflops_cholesky3));
+
+  starpu_helper_cublas_shutdown();
+  starpu_shutdown();
 
 
   return 0;
   return 0;
 }
 }

+ 1 - 2
examples/cholesky_and_lu_without_sched_ctx/cholesky/cholesky.h

@@ -74,8 +74,7 @@ void chol_cublas_codelet_update_u22(void *descr[], void *_args);
 int run_cholesky_grain_tag(int argc, char **argv);
 int run_cholesky_grain_tag(int argc, char **argv);
 int run_cholesky_implicit(int argc, char **argv);
 int run_cholesky_implicit(int argc, char **argv);
 int run_cholesky_tag(int argc, char **argv);
 int run_cholesky_tag(int argc, char **argv);
-int run_cholesky_tile_tag(int argc, char **argv, struct timeval *start);
-int finish_cholesky_tile_tag(struct timeval *end);
+double run_cholesky_tile_tag(int argc, char **argv);
 
 
 extern struct starpu_perfmodel_t chol_model_11;
 extern struct starpu_perfmodel_t chol_model_11;
 extern struct starpu_perfmodel_t chol_model_21;
 extern struct starpu_perfmodel_t chol_model_21;

+ 16 - 20
examples/cholesky_and_lu_without_sched_ctx/cholesky/cholesky_tile_tag.c

@@ -184,8 +184,11 @@ static void create_task_22(unsigned k, unsigned i, unsigned j)
  *	and construct the DAG
  *	and construct the DAG
  */
  */
 
 
-static void cholesky_no_stride(struct timeval *start)
+static double cholesky_no_stride()
 {
 {
+	struct timeval start;
+	struct timeval end;
+
 	struct starpu_task *entry_task = NULL;
 	struct starpu_task *entry_task = NULL;
 
 
 	/* create all the DAG nodes */
 	/* create all the DAG nodes */
@@ -215,13 +218,20 @@ static void cholesky_no_stride(struct timeval *start)
 	}
 	}
 
 
 	/* schedule the codelet */
 	/* schedule the codelet */
-	if(start != NULL)
-	  gettimeofday(start, NULL);
+	gettimeofday(&start, NULL);
 	starpu_task_submit(entry_task);
 	starpu_task_submit(entry_task);
 
 
+	/* stall the application until the end of computations */
+	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));
+        double flop = (1.0f*size*size*size)/3.0f;
+        return flop/timing/1000.0f;
 }
 }
 
 
-int run_cholesky_tile_tag(int argc, char **argv, struct timeval *start)
+double run_cholesky_tile_tag(int argc, char **argv)
 {
 {
 	unsigned x, y;
 	unsigned x, y;
 	unsigned i, j;
 	unsigned i, j;
@@ -291,22 +301,8 @@ int run_cholesky_tile_tag(int argc, char **argv, struct timeval *start)
 		}
 		}
 	}
 	}
 
 
-	cholesky_no_stride(start);
-
-	//	starpu_shutdown();
-	return 0;
-}
+	double gflops = cholesky_no_stride();
 
 
-
-int finish_cholesky_tile_tag(struct timeval *end){	
-  //	starpu_helper_cublas_shutdown();
-
-	/* stall the application until the end of computations */
-	starpu_tag_wait(TAG11(nblocks-1));
 	starpu_shutdown();
 	starpu_shutdown();
-
-	if(end != NULL)
-	  gettimeofday(end, NULL);
-
-	return 0;
+	return gflops;
 }
 }

+ 45 - 8
examples/cholesky_and_lu_without_sched_ctx/cholesky_and_lu_without_sched_ctx.c

@@ -1,20 +1,57 @@
 #include "cholesky/cholesky.h"
 #include "cholesky/cholesky.h"
 #include "lu/lu_example_float.c"
 #include "lu/lu_example_float.c"
 
 
+typedef struct {
+  int argc;
+  char **argv;
+} params;
+
+#define NSAMPLES 10
+
+/* void* func_cholesky(void *val){ */
+/*   params *p = (params*)val; */
+/*   int i; */
+/*   double *flops = (double*)malloc(sizeof(double)); */
+/*   for(i = 0; i < NSAMPLES; i++) */
+/*     (*flops) += run_cholesky_tile_tag(p->argc, p->argv); */
+
+/*   (*flops) /= NSAMPLES; */
+
+/*   return (void*)flops; */
+/* } */
+
+/* void* func_lu(void *val){ */
+/*   params *p = (params*)val; */
+
+/*   int i; */
+/*   double *flops = (double*)malloc(sizeof(double)); */
+/*   for(i = 0; i < NSAMPLES; i++) */
+/*     (*flops) += run_lu(p->argc, p->argv); */
+
+/*   (*flops) /= NSAMPLES; */
+
+/*   return (void*)flops; */
+/* } */
+
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
-  struct timeval start;
-  struct timeval end;
+  pthread_t tid[2];
+
+  params p;
+  p.argc = argc;
+  p.argv = argv;
+
+  /* pthread_create(&tid[0], NULL, (void*)func_cholesky, (void*)&p); */
+  /* pthread_create(&tid[1], NULL, (void*)func_lu, (void*)&p); */
 
 
-  run_cholesky_tile_tag(argc, argv, &start);
+  /* void *gflops_cholesky; */
+  /* void *gflops_lu; */
 
 
-  run_lu(argc, argv, NULL);
+  /* pthread_join(tid[0], &gflops_cholesky); */
+  /* pthread_join(tid[1], &gflops_lu); */
 
 
-  finish_cholesky_tile_tag(NULL);
-  finish_lu(&end);
+  /* printf("%2.2f %2.2f\n", *((double*)gflops_cholesky), *((double*)gflops_lu)); */
 
 
-  double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
-  printf("%2.2f\n", timing/1000);
 
 
   return 0;
   return 0;
 }
 }

+ 8 - 35
examples/cholesky_and_lu_without_sched_ctx/lu/lu_example.c

@@ -35,8 +35,6 @@ static unsigned profile = 0;
 static unsigned bound = 0;
 static unsigned bound = 0;
 static unsigned bounddeps = 0;
 static unsigned bounddeps = 0;
 static unsigned boundprio = 0;
 static unsigned boundprio = 0;
-/* struct timeval lu_start; */
-/* struct timeval lu_end; */
 unsigned *ipiv;
 unsigned *ipiv;
 
 
 TYPE *A, *A_saved;
 TYPE *A, *A_saved;
@@ -265,13 +263,13 @@ static void check_result(void)
 		exit(-1);
 		exit(-1);
 }
 }
 
 
-int run_lu(int argc, char **argv, struct timeval *start)
+double run_lu(int argc, char **argv)
 {
 {
 	lu_parse_args(argc, argv);
 	lu_parse_args(argc, argv);
 
 
 	starpu_init(NULL);
 	starpu_init(NULL);
 
 
-	//	starpu_helper_cublas_init();
+	starpu_helper_cublas_init();
 
 
 	init_matrix();
 	init_matrix();
 
 
@@ -286,6 +284,7 @@ int run_lu(int argc, char **argv, struct timeval *start)
 	if (profile)
 	if (profile)
 		starpu_profiling_status_set(STARPU_PROFILING_ENABLE);
 		starpu_profiling_status_set(STARPU_PROFILING_ENABLE);
 
 
+	double gflops = -1;
 	/* Factorize the matrix (in place) */
 	/* Factorize the matrix (in place) */
 	if (pivot)
 	if (pivot)
 	{
 	{
@@ -296,7 +295,7 @@ int run_lu(int argc, char **argv, struct timeval *start)
 			A_blocks = malloc(lu_nblocks*lu_nblocks*sizeof(TYPE **));
 			A_blocks = malloc(lu_nblocks*lu_nblocks*sizeof(TYPE **));
 			copy_matrix_into_blocks();
 			copy_matrix_into_blocks();
 
 
-			STARPU_LU(lu_decomposition_pivot_no_stride)(A_blocks, ipiv, lu_size, lu_size, lu_nblocks, start);
+			gflops = STARPU_LU(lu_decomposition_pivot_no_stride)(A_blocks, ipiv, lu_size, lu_size, lu_nblocks);
 
 
 			copy_blocks_into_matrix();
 			copy_blocks_into_matrix();
 			free(A_blocks);
 			free(A_blocks);
@@ -304,41 +303,14 @@ int run_lu(int argc, char **argv, struct timeval *start)
 		else 
 		else 
 		{
 		{
 
 
-		  STARPU_LU(lu_decomposition_pivot)(A, ipiv, lu_size, lu_size, lu_nblocks, start);
+		  gflops = STARPU_LU(lu_decomposition_pivot)(A, ipiv, lu_size, lu_size, lu_nblocks);
 		}
 		}
 	}
 	}
 	else
 	else
 	{
 	{
-	  STARPU_LU(lu_decomposition)(A, lu_size, lu_size, lu_nblocks, start);
+	  gflops = STARPU_LU(lu_decomposition)(A, lu_size, lu_size, lu_nblocks);
 	}
 	}
 
 
-
-	//	starpu_shutdown();
-
-	return 0;
-}
-
-int finish_lu(struct timeval *end)
-{
-
-	if (pivot)
-	{
-		if (no_stride)
-		{
-		  finish_lu_decomposition_pivot_no_stride(lu_nblocks, end);
-		}
-		else 
-		{
-		  finish_lu_decomposition_pivot(lu_nblocks, end);
-		}
-	}
-	else
-	{
-	  finish_lu_decomposition(lu_nblocks, end);
-	}
-
-  
-  
 	if (profile)
 	if (profile)
 	{
 	{
 		starpu_profiling_status_set(STARPU_PROFILING_DISABLE);
 		starpu_profiling_status_set(STARPU_PROFILING_DISABLE);
@@ -369,5 +341,6 @@ int finish_lu(struct timeval *end)
 
 
 	starpu_helper_cublas_shutdown();
 	starpu_helper_cublas_shutdown();
 	starpu_shutdown();
 	starpu_shutdown();
-	return 0;
+
+	return gflops;
 }
 }

+ 25 - 24
examples/cholesky_and_lu_without_sched_ctx/lu/xlu.c

@@ -29,11 +29,6 @@
 					| (unsigned long long)(j))))
 					| (unsigned long long)(j))))
 
 
 static unsigned no_prio = 0;
 static unsigned no_prio = 0;
-//struct timeval xlu_start;
-//struct timeval xlu_end;
-starpu_data_handle xlu_dataA;
-
-
 
 
 /*
 /*
  *	Construct the DAG
  *	Construct the DAG
@@ -165,8 +160,11 @@ static void create_task_22(starpu_data_handle dataA, unsigned k, unsigned i, uns
  *	code to bootstrap the factorization 
  *	code to bootstrap the factorization 
  */
  */
 
 
-static void dw_codelet_facto_v3(starpu_data_handle dataA, unsigned nblocks, struct timeval *start)
+static double dw_codelet_facto_v3(starpu_data_handle dataA, unsigned nblocks)
 {
 {
+	struct timeval start;
+	struct timeval end;
+
 	struct starpu_task *entry_task = NULL;
 	struct starpu_task *entry_task = NULL;
 
 
 	/* create all the DAG nodes */
 	/* create all the DAG nodes */
@@ -200,8 +198,7 @@ static void dw_codelet_facto_v3(starpu_data_handle dataA, unsigned nblocks, stru
 	}
 	}
 
 
 	/* schedule the codelet */
 	/* schedule the codelet */
-	if(start != NULL)
-	  gettimeofday(start, NULL);
+	gettimeofday(&start, NULL);
 	int ret = starpu_task_submit(entry_task);
 	int ret = starpu_task_submit(entry_task);
 	if (STARPU_UNLIKELY(ret == -ENODEV))
 	if (STARPU_UNLIKELY(ret == -ENODEV))
 	{
 	{
@@ -209,16 +206,28 @@ static void dw_codelet_facto_v3(starpu_data_handle dataA, unsigned nblocks, stru
 		exit(-1);
 		exit(-1);
 	}
 	}
 
 
+	/* stall the application until the end of computations */
+        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));
+
+        unsigned n = starpu_matrix_get_nx(dataA);
+        double flop = (2.0f*n*n*n)/3.0f;
+        return (flop/timing/1000.0f);
 }
 }
 
 
-void STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned nblocks, struct timeval *start)
+double STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned nblocks)
 {
 {
+	starpu_data_handle dataA;
+
 	/* monitor and partition the A matrix into blocks :
 	/* monitor and partition the A matrix into blocks :
 	 * one block is now determined by 2 unsigned (i,j) */
 	 * one block is now determined by 2 unsigned (i,j) */
-	starpu_matrix_data_register(&xlu_dataA, 0, (uintptr_t)matA, ld, size, size, sizeof(TYPE));
+	starpu_matrix_data_register(&dataA, 0, (uintptr_t)matA, ld, size, size, sizeof(TYPE));
 
 
 	/* We already enforce deps by hand */
 	/* We already enforce deps by hand */
-	starpu_data_set_sequential_consistency_flag(xlu_dataA, 0);
+	starpu_data_set_sequential_consistency_flag(dataA, 0);
 
 
 	struct starpu_data_filter f;
 	struct starpu_data_filter f;
 		f.filter_func = starpu_vertical_block_filter_func;
 		f.filter_func = starpu_vertical_block_filter_func;
@@ -232,19 +241,11 @@ void STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigne
 		f2.get_nchildren = NULL;
 		f2.get_nchildren = NULL;
 		f2.get_child_ops = NULL;
 		f2.get_child_ops = NULL;
 
 
-	starpu_data_map_filters(xlu_dataA, 2, &f, &f2);
-
-	dw_codelet_facto_v3(xlu_dataA, nblocks, start);
-}
-
-void finish_lu_decomposition(unsigned nblocks, struct timeval *end)
-{
-	/* stall the application until the end of computations */
-	starpu_tag_wait(TAG11(nblocks-1));
+	starpu_data_map_filters(dataA, 2, &f, &f2);
 
 
-	if(end != NULL)
-	  gettimeofday(end, NULL);
+	double gflops = dw_codelet_facto_v3(dataA, nblocks);
 
 
-	/* gather all the data */
-	starpu_data_unpartition(xlu_dataA, 0);
+        /* gather all the data */
+        starpu_data_unpartition(dataA, 0);
+        return gflops;
 }
 }

+ 3 - 7
examples/cholesky_and_lu_without_sched_ctx/lu/xlu.h

@@ -110,12 +110,8 @@ struct piv_s {
 	unsigned last; /* last element */
 	unsigned last; /* last element */
 };
 };
 
 
-void STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned nblocks, struct timeval *start);
-void STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks, struct timeval *start);
-void STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks, struct timeval *start);
-
-void finish_lu_decomposition(unsigned nblocks, struct timeval *end);
-void finish_lu_decomposition_pivot_no_stride(unsigned nblocks, struct timeval *end);
-void finish_lu_decomposition_pivot(unsigned nblocks, struct timeval *end);
+double STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned nblocks);
+double STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks);
+double STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks);
 
 
 #endif // __XLU_H__
 #endif // __XLU_H__

+ 60 - 71
examples/cholesky_and_lu_without_sched_ctx/lu/xlu_pivot.c

@@ -226,8 +226,11 @@ static void create_task_22(starpu_data_handle *dataAp, unsigned nblocks, unsigne
 static double dw_codelet_facto_pivot(starpu_data_handle *dataAp,
 static double dw_codelet_facto_pivot(starpu_data_handle *dataAp,
 				     struct piv_s *piv_description,
 				     struct piv_s *piv_description,
 				     unsigned nblocks,
 				     unsigned nblocks,
-				     starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct timeval *start)
+				     starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
 {
 {
+	struct timeval start;
+	struct timeval end;
+
 	struct starpu_task *entry_task = NULL;
 	struct starpu_task *entry_task = NULL;
 
 
 	/* create all the DAG nodes */
 	/* create all the DAG nodes */
@@ -266,9 +269,25 @@ static double dw_codelet_facto_pivot(starpu_data_handle *dataAp,
 		}
 		}
 	}
 	}
 
 
+
+	/* 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(nblocks - 1);
+
+        for (j = 0; j < nblocks; j++)
+          {
+            for (i = 0; i < j; i++)
+              {
+                tags[ndeps++] = PIVOT(j, i);
+              }
+          }
+
 	/* schedule the codelet */
 	/* schedule the codelet */
-	if(start != NULL)
-	  gettimeofday(start, NULL);
+	gettimeofday(&start, NULL);
 	int ret = starpu_task_submit(entry_task);
 	int ret = starpu_task_submit(entry_task);
 	if (STARPU_UNLIKELY(ret == -ENODEV))
 	if (STARPU_UNLIKELY(ret == -ENODEV))
 	{
 	{
@@ -276,7 +295,15 @@ static double dw_codelet_facto_pivot(starpu_data_handle *dataAp,
 		exit(-1);
 		exit(-1);
 	}
 	}
 
 
-	return 0;
+	/* stall the application until the end of computations */
+        starpu_tag_wait_array(ndeps, tags);
+	//      starpu_task_wait_for_all();   
+
+        gettimeofday(&end, NULL);
+
+        double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+
+        return timing;
 }
 }
 
 
 starpu_data_handle get_block_with_striding(starpu_data_handle *dataAp,
 starpu_data_handle get_block_with_striding(starpu_data_handle *dataAp,
@@ -287,15 +314,15 @@ starpu_data_handle get_block_with_striding(starpu_data_handle *dataAp,
 }
 }
 
 
 
 
-void STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks, struct timeval *start)
+double STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks)
 {
 {
-
+	starpu_data_handle dataA;
 	/* monitor and partition the A matrix into blocks :
 	/* monitor and partition the A matrix into blocks :
 	 * one block is now determined by 2 unsigned (i,j) */
 	 * one block is now determined by 2 unsigned (i,j) */
-	starpu_matrix_data_register(&xlu_pivot_dataA, 0, (uintptr_t)matA, ld, size, size, sizeof(TYPE));
+	starpu_matrix_data_register(&dataA, 0, (uintptr_t)matA, ld, size, size, sizeof(TYPE));
 
 
 	/* We already enforce deps by hand */
 	/* We already enforce deps by hand */
-	starpu_data_set_sequential_consistency_flag(xlu_pivot_dataA, 0);
+	starpu_data_set_sequential_consistency_flag(dataA, 0);
 
 
 	struct starpu_data_filter f;
 	struct starpu_data_filter f;
 		f.filter_func = starpu_vertical_block_filter_func;
 		f.filter_func = starpu_vertical_block_filter_func;
@@ -305,7 +332,7 @@ void STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size
 		f2.filter_func = starpu_block_filter_func;
 		f2.filter_func = starpu_block_filter_func;
 		f2.nchildren = nblocks;
 		f2.nchildren = nblocks;
 
 
-	starpu_data_map_filters(xlu_pivot_dataA, 2, &f, &f2);
+	starpu_data_map_filters(dataA, 2, &f, &f2);
 
 
 	unsigned i;
 	unsigned i;
 	for (i = 0; i < size; i++)
 	for (i = 0; i < size; i++)
@@ -329,7 +356,15 @@ void STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size
 	}
 	}
 #endif
 #endif
 
 
-	dw_codelet_facto_pivot(&xlu_pivot_dataA, piv_description, nblocks, get_block_with_striding, start);
+	double timing;
+        timing = dw_codelet_facto_pivot(&dataA, piv_description, nblocks, get_block_with_striding);
+	unsigned n = starpu_matrix_get_nx(dataA);
+        double flop = (2.0f*n*n*n)/3.0f;
+        double gflops = flop/timing/1000.0f;
+
+        /* gather all the data */
+        starpu_data_unpartition(dataA, 0);
+        return gflops;
 }
 }
 
 
 
 
@@ -339,9 +374,9 @@ starpu_data_handle get_block_with_no_striding(starpu_data_handle *dataAp, unsign
 	return dataAp[i+j*nblocks];
 	return dataAp[i+j*nblocks];
 }
 }
 
 
-void STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks, struct timeval *start)
+double STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks)
 {
 {
-	xlu_pivot_dataAp = malloc(nblocks*nblocks*sizeof(starpu_data_handle));
+	starpu_data_handle *dataAp = malloc(nblocks*nblocks*sizeof(starpu_data_handle));
 
 
 	/* monitor and partition the A matrix into blocks :
 	/* monitor and partition the A matrix into blocks :
 	 * one block is now determined by 2 unsigned (i,j) */
 	 * one block is now determined by 2 unsigned (i,j) */
@@ -349,12 +384,12 @@ void STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, un
 	for (bj = 0; bj < nblocks; bj++)
 	for (bj = 0; bj < nblocks; bj++)
 	for (bi = 0; bi < nblocks; bi++)
 	for (bi = 0; bi < nblocks; bi++)
 	{
 	{
-		starpu_matrix_data_register(&xlu_pivot_dataAp[bi+nblocks*bj], 0,
+		starpu_matrix_data_register(&dataAp[bi+nblocks*bj], 0,
 			(uintptr_t)matA[bi+nblocks*bj], size/nblocks,
 			(uintptr_t)matA[bi+nblocks*bj], size/nblocks,
 			size/nblocks, size/nblocks, sizeof(TYPE));
 			size/nblocks, size/nblocks, sizeof(TYPE));
 
 
 		/* We already enforce deps by hand */
 		/* We already enforce deps by hand */
-		starpu_data_set_sequential_consistency_flag(xlu_pivot_dataAp[bi+nblocks*bj], 0);
+		starpu_data_set_sequential_consistency_flag(dataAp[bi+nblocks*bj], 0);
 	}
 	}
 
 
 	unsigned i;
 	unsigned i;
@@ -370,65 +405,19 @@ void STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, un
 		piv_description[block].last = (block + 1) * (size / nblocks);
 		piv_description[block].last = (block + 1) * (size / nblocks);
 	}
 	}
 
 
-	dw_codelet_facto_pivot(xlu_pivot_dataAp, piv_description, nblocks, get_block_with_no_striding, start);
-}
-
-void finish_lu_decomposition_pivot(unsigned nblocks, struct timeval *end)
-{
-	/* 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(nblocks - 1);
-
-	unsigned i, j;
-	for (j = 0; j < nblocks; j++)
-	{
-		for (i = 0; i < j; i++)
-		{
-			tags[ndeps++] = PIVOT(j, i);
-		}
-	}
+	double timing;
+        timing = dw_codelet_facto_pivot(dataAp, piv_description, nblocks, get_block_with_no_striding);
 
 
-	/* stall the application until the end of computations */
-	starpu_tag_wait_array(ndeps, tags);
-//	starpu_task_wait_for_all();
+	unsigned n = starpu_matrix_get_nx(dataAp[0])*nblocks;
+        double flop = (2.0f*n*n*n)/3.0f;
+        double gflops = flop/timing/1000.0f;
 
 
-	if(end != NULL)
-	  gettimeofday(end, NULL);
+        for (bj = 0; bj < nblocks; bj++)
+	  for (bi = 0; bi < nblocks; bi++)
+            {
+              starpu_data_unregister(dataAp[bi+nblocks*bj]);
+            }
+        return gflops;
 
 
-	/* gather all the data */
-	starpu_data_unpartition(xlu_pivot_dataA, 0);
 }
 }
 
 
-void finish_lu_decomposition_pivot_no_stride(unsigned nblocks, struct timeval *end)
-{
-	/* 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(nblocks - 1);
-
-	unsigned i, j;
-	for (j = 0; j < nblocks; j++)
-	{
-		for (i = 0; i < j; i++)
-		{
-			tags[ndeps++] = PIVOT(j, i);
-		}
-	}
-
-	/* stall the application until the end of computations */
-	starpu_tag_wait_array(ndeps, tags);
-//	starpu_task_wait_for_all();
-
-	if(end != NULL)
-	  gettimeofday(end, NULL);
-
-	unsigned bi, bj;
-	for (bj = 0; bj < nblocks; bj++)
-	for (bi = 0; bi < nblocks; bi++)
-	{
-		starpu_data_unregister(xlu_pivot_dataAp[bi+nblocks*bj]);
-	}
-}

+ 86 - 83
examples/lu/lu_example.c

@@ -26,9 +26,9 @@
 #include "xlu.h"
 #include "xlu.h"
 #include "xlu_kernels.h"
 #include "xlu_kernels.h"
 
 
-static unsigned long size = 4096;
-static unsigned nblocks = 16;
-static unsigned check = 0;
+static unsigned long lu_size = 10240;//4096;
+static unsigned lu_nblocks = 10;
+static unsigned lu_check = 0;
 static unsigned pivot = 0;
 static unsigned pivot = 0;
 static unsigned no_stride = 0;
 static unsigned no_stride = 0;
 static unsigned profile = 0;
 static unsigned profile = 0;
@@ -36,27 +36,28 @@ static unsigned bound = 0;
 static unsigned bounddeps = 0;
 static unsigned bounddeps = 0;
 static unsigned boundprio = 0;
 static unsigned boundprio = 0;
 
 
-TYPE *A, *A_saved;
+TYPE *A;
+TYPE *A_saved;
 
 
 /* in case we use non-strided blocks */
 /* in case we use non-strided blocks */
 TYPE **A_blocks;
 TYPE **A_blocks;
 
 
-static void parse_args(int argc, char **argv)
+static void lu_parse_args(int argc, char **argv)
 {
 {
 	int i;
 	int i;
 	for (i = 1; i < argc; i++) {
 	for (i = 1; i < argc; i++) {
 		if (strcmp(argv[i], "-size") == 0) {
 		if (strcmp(argv[i], "-size") == 0) {
 			char *argptr;
 			char *argptr;
-			size = strtol(argv[++i], &argptr, 10);
+			lu_size = strtol(argv[++i], &argptr, 10);
 		}
 		}
 
 
 		if (strcmp(argv[i], "-nblocks") == 0) {
 		if (strcmp(argv[i], "-nblocks") == 0) {
 			char *argptr;
 			char *argptr;
-			nblocks = strtol(argv[++i], &argptr, 10);
+			lu_nblocks = strtol(argv[++i], &argptr, 10);
 		}
 		}
 
 
 		if (strcmp(argv[i], "-check") == 0) {
 		if (strcmp(argv[i], "-check") == 0) {
-			check = 1;
+			lu_check = 1;
 		}
 		}
 
 
 		if (strcmp(argv[i], "-piv") == 0) {
 		if (strcmp(argv[i], "-piv") == 0) {
@@ -104,75 +105,75 @@ static void display_matrix(TYPE *m, unsigned n, unsigned ld, char *str)
 #endif
 #endif
 }
 }
 
 
-void copy_blocks_into_matrix(void)
+void copy_blocks_into_matrix()
 {
 {
-	unsigned blocksize = (size/nblocks);
+	unsigned blocklu_size = (lu_size/lu_nblocks);
 
 
 	unsigned i, j;
 	unsigned i, j;
 	unsigned bi, bj;
 	unsigned bi, bj;
-	for (bj = 0; bj < nblocks; bj++)
-	for (bi = 0; bi < nblocks; bi++)
+	for (bj = 0; bj < lu_nblocks; bj++)
+	for (bi = 0; bi < lu_nblocks; bi++)
 	{
 	{
-		for (j = 0; j < blocksize; j++)
-		for (i = 0; i < blocksize; i++)
+		for (j = 0; j < blocklu_size; j++)
+		for (i = 0; i < blocklu_size; i++)
 		{
 		{
-			A[(i+bi*blocksize) + (j + bj*blocksize)*size] =
-				A_blocks[bi+nblocks*bj][i + j * blocksize];
+			A[(i+bi*blocklu_size) + (j + bj*blocklu_size)*lu_size] =
+				A_blocks[bi+lu_nblocks*bj][i + j * blocklu_size];
 		}
 		}
 
 
-		//free(A_blocks[bi+nblocks*bj]);
+		//free(A_blocks[bi+lu_nblocks*bj]);
 	}
 	}
 }
 }
 
 
 
 
 
 
-void copy_matrix_into_blocks(void)
+void copy_matrix_into_blocks()
 {
 {
-	unsigned blocksize = (size/nblocks);
+	unsigned blocklu_size = (lu_size/lu_nblocks);
 
 
 	unsigned i, j;
 	unsigned i, j;
 	unsigned bi, bj;
 	unsigned bi, bj;
-	for (bj = 0; bj < nblocks; bj++)
-	for (bi = 0; bi < nblocks; bi++)
+	for (bj = 0; bj < lu_nblocks; bj++)
+	for (bi = 0; bi < lu_nblocks; bi++)
 	{
 	{
-		starpu_data_malloc_pinned_if_possible((void **)&A_blocks[bi+nblocks*bj], (size_t)blocksize*blocksize*sizeof(TYPE));
+		starpu_data_malloc_pinned_if_possible((void **)&A_blocks[bi+lu_nblocks*bj], (size_t)blocklu_size*blocklu_size*sizeof(TYPE));
 
 
-		for (j = 0; j < blocksize; j++)
-		for (i = 0; i < blocksize; i++)
+		for (j = 0; j < blocklu_size; j++)
+		for (i = 0; i < blocklu_size; i++)
 		{
 		{
-			A_blocks[bi+nblocks*bj][i + j * blocksize] =
-			A[(i+bi*blocksize) + (j + bj*blocksize)*size];
+			A_blocks[bi+lu_nblocks*bj][i + j * blocklu_size] =
+			A[(i+bi*blocklu_size) + (j + bj*blocklu_size)*lu_size];
 		}
 		}
 	}
 	}
 }
 }
 
 
-static void init_matrix(void)
+static void init_matrix()
 {
 {
 	/* allocate matrix */
 	/* allocate matrix */
-	starpu_data_malloc_pinned_if_possible((void **)&A, (size_t)size*size*sizeof(TYPE));
+	starpu_data_malloc_pinned_if_possible((void **)&A, (size_t)lu_size*lu_size*sizeof(TYPE));
 	STARPU_ASSERT(A);
 	STARPU_ASSERT(A);
 
 
 	starpu_srand48((long int)time(NULL));
 	starpu_srand48((long int)time(NULL));
-	//starpu_srand48(0);
+	//	starpu_srand48(0);
 
 
 	/* initialize matrix content */
 	/* initialize matrix content */
 	unsigned long i,j;
 	unsigned long i,j;
-	for (j = 0; j < size; j++)
+	for (j = 0; j < lu_size; j++)
 	{
 	{
-		for (i = 0; i < size; i++)
+		for (i = 0; i < lu_size; i++)
 		{
 		{
-			A[i + j*size] = (TYPE)starpu_drand48();
+		  A[i + j*lu_size] = (TYPE)starpu_drand48();
 		}
 		}
 	}
 	}
 
 
 }
 }
 
 
-static void save_matrix(void)
+static void save_matrix()
 {
 {
-	A_saved = malloc((size_t)size*size*sizeof(TYPE));
+	A_saved = malloc((size_t)lu_size*lu_size*sizeof(TYPE));
 	STARPU_ASSERT(A_saved);
 	STARPU_ASSERT(A_saved);
 
 
-	memcpy(A_saved, A, (size_t)size*size*sizeof(TYPE));
+	memcpy(A_saved, A, (size_t)lu_size*lu_size*sizeof(TYPE));
 }
 }
 
 
 static double frobenius_norm(TYPE *v, unsigned n)
 static double frobenius_norm(TYPE *v, unsigned n)
@@ -195,88 +196,89 @@ static double frobenius_norm(TYPE *v, unsigned n)
 static void pivot_saved_matrix(unsigned *ipiv)
 static void pivot_saved_matrix(unsigned *ipiv)
 {
 {
 	unsigned k;
 	unsigned k;
-	for (k = 0; k < size; k++)
+	for (k = 0; k < lu_size; k++)
 	{
 	{
 		if (k != ipiv[k])
 		if (k != ipiv[k])
 		{
 		{
 	//		fprintf(stderr, "SWAP %d and %d\n", k, ipiv[k]);
 	//		fprintf(stderr, "SWAP %d and %d\n", k, ipiv[k]);
-			CPU_SWAP(size, &A_saved[k*size], 1, &A_saved[ipiv[k]*size], 1);
+			CPU_SWAP(lu_size, &A_saved[k*lu_size], 1, &A_saved[ipiv[k]*lu_size], 1);
 		}
 		}
 	}
 	}
 }
 }
 
 
-static void check_result(void)
+static void lu_check_result()
 {
 {
 	unsigned i,j;
 	unsigned i,j;
 	TYPE *L, *U;
 	TYPE *L, *U;
 
 
-	L = malloc((size_t)size*size*sizeof(TYPE));
-	U = malloc((size_t)size*size*sizeof(TYPE));
+	L = malloc((size_t)lu_size*lu_size*sizeof(TYPE));
+	U = malloc((size_t)lu_size*lu_size*sizeof(TYPE));
 
 
-	memset(L, 0, size*size*sizeof(TYPE));
-	memset(U, 0, size*size*sizeof(TYPE));
+	memset(L, 0, lu_size*lu_size*sizeof(TYPE));
+	memset(U, 0, lu_size*lu_size*sizeof(TYPE));
 
 
 	/* only keep the lower part */
 	/* only keep the lower part */
-	for (j = 0; j < size; j++)
+	for (j = 0; j < lu_size; j++)
 	{
 	{
 		for (i = 0; i < j; i++)
 		for (i = 0; i < j; i++)
 		{
 		{
-			L[j+i*size] = A[j+i*size];
+			L[j+i*lu_size] = A[j+i*lu_size];
 		}
 		}
 
 
 		/* diag i = j */
 		/* diag i = j */
-		L[j+j*size] = A[j+j*size];
-		U[j+j*size] = 1.0;
+		L[j+j*lu_size] = A[j+j*lu_size];
+		U[j+j*lu_size] = 1.0;
 
 
-		for (i = j+1; i < size; i++)
+		for (i = j+1; i < lu_size; i++)
 		{
 		{
-			U[j+i*size] = A[j+i*size];
+			U[j+i*lu_size] = A[j+i*lu_size];
 		}
 		}
 	}
 	}
 
 
-	display_matrix(L, size, size, "L");
-	display_matrix(U, size, size, "U");
+	display_matrix(L, lu_size, lu_size, "L");
+	display_matrix(U, lu_size, lu_size, "U");
 
 
 	/* now A_err = L, compute L*U */
 	/* now A_err = L, compute L*U */
-	CPU_TRMM("R", "U", "N", "U", size, size, 1.0f, U, size, L, size);
+	CPU_TRMM("R", "U", "N", "U", lu_size, lu_size, 1.0f, U, lu_size, L, lu_size);
 
 
-	display_matrix(A_saved, size, size, "P A_saved");
-	display_matrix(L, size, size, "LU");
+	display_matrix(A_saved, lu_size, lu_size, "P A_saved");
+	display_matrix(L, lu_size, lu_size, "LU");
 
 
 	/* compute "LU - A" in L*/
 	/* compute "LU - A" in L*/
-	CPU_AXPY(size*size, -1.0, A_saved, 1, L, 1);
-	display_matrix(L, size, size, "Residuals");
+	CPU_AXPY(lu_size*lu_size, -1.0, A_saved, 1, L, 1);
+	display_matrix(L, lu_size, lu_size, "Residuals");
 	
 	
-	TYPE err = CPU_ASUM(size*size, L, 1);
-	int max = CPU_IAMAX(size*size, L, 1);
+	TYPE err = CPU_ASUM(lu_size*lu_size, L, 1);
+	int max = CPU_IAMAX(lu_size*lu_size, L, 1);
 
 
-	fprintf(stderr, "Avg error : %e\n", err/(size*size));
+	fprintf(stderr, "Avg error : %e\n", err/(lu_size*lu_size));
 	fprintf(stderr, "Max error : %e\n", L[max]);
 	fprintf(stderr, "Max error : %e\n", L[max]);
 
 
-	double residual = frobenius_norm(L, size);
-	double matnorm = frobenius_norm(A_saved, size);
+	double residual = frobenius_norm(L, lu_size);
+	double matnorm = frobenius_norm(A_saved, lu_size);
 
 
-	fprintf(stderr, "||%sA-LU|| / (||A||*N) : %e\n", pivot?"P":"", residual/(matnorm*size));
+	fprintf(stderr, "||%sA-LU|| / (||A||*N) : %e\n", pivot?"P":"", residual/(matnorm*lu_size));
 
 
-	if (residual/(matnorm*size) > 1e-5)
+	if (residual/(matnorm*lu_size) > 1e-5)
 		exit(-1);
 		exit(-1);
 }
 }
 
 
-int main(int argc, char **argv)
+double run_lu(struct starpu_sched_ctx *sched_ctx, int argc, char **argv)
 {
 {
-	parse_args(argc, argv);
+  printf("enter lu\n");
+	lu_parse_args(argc, argv);
 
 
-	starpu_init(NULL);
+	//	starpu_init(NULL);
 
 
-	starpu_helper_cublas_init();
+	//	starpu_helper_cublas_init();
 
 
 	init_matrix();
 	init_matrix();
 
 
 	unsigned *ipiv;
 	unsigned *ipiv;
-	if (check)
-		save_matrix();
+	if (lu_check)
+	  save_matrix();
 
 
-	display_matrix(A, size, size, "A");
+	display_matrix(A, lu_size, lu_size, "A");
 
 
 	if (bound)
 	if (bound)
 		starpu_bound_start(bounddeps, boundprio);
 		starpu_bound_start(bounddeps, boundprio);
@@ -284,17 +286,18 @@ int main(int argc, char **argv)
 	if (profile)
 	if (profile)
 		starpu_profiling_status_set(STARPU_PROFILING_ENABLE);
 		starpu_profiling_status_set(STARPU_PROFILING_ENABLE);
 
 
+	double gflops = -1;
 	/* Factorize the matrix (in place) */
 	/* Factorize the matrix (in place) */
 	if (pivot)
 	if (pivot)
 	{
 	{
- 		ipiv = malloc(size*sizeof(unsigned));
+ 		ipiv = malloc(lu_size*sizeof(unsigned));
 		if (no_stride)
 		if (no_stride)
 		{
 		{
 			/* in case the LU decomposition uses non-strided blocks, we _copy_ the matrix into smaller blocks */
 			/* in case the LU decomposition uses non-strided blocks, we _copy_ the matrix into smaller blocks */
-			A_blocks = malloc(nblocks*nblocks*sizeof(TYPE **));
+			A_blocks = malloc(lu_nblocks*lu_nblocks*sizeof(TYPE **));
 			copy_matrix_into_blocks();
 			copy_matrix_into_blocks();
 
 
-			STARPU_LU(lu_decomposition_pivot_no_stride)(A_blocks, ipiv, size, size, nblocks);
+			gflops = STARPU_LU(lu_decomposition_pivot_no_stride)(A_blocks, ipiv, lu_size, lu_size, lu_nblocks, sched_ctx);
 
 
 			copy_blocks_into_matrix();
 			copy_blocks_into_matrix();
 			free(A_blocks);
 			free(A_blocks);
@@ -306,21 +309,21 @@ int main(int argc, char **argv)
 
 
 			gettimeofday(&start, NULL);
 			gettimeofday(&start, NULL);
 
 
-			STARPU_LU(lu_decomposition_pivot)(A, ipiv, size, size, nblocks);
+			gflops = STARPU_LU(lu_decomposition_pivot)(A, ipiv, lu_size, lu_size, lu_nblocks, sched_ctx);
 	
 	
 			gettimeofday(&end, NULL);
 			gettimeofday(&end, NULL);
 
 
 			double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 			double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 			
 			
-			unsigned n = size;
+			unsigned n = lu_size;
 			double flop = (2.0f*n*n*n)/3.0f;
 			double flop = (2.0f*n*n*n)/3.0f;
-			fprintf(stderr, "Synthetic GFlops (TOTAL) : \n");
-			fprintf(stdout, "%d	%6.2f\n", n, (flop/timing/1000.0f));
+			gflops = flop/timing/1000.0f;
 		}
 		}
 	}
 	}
 	else
 	else
 	{
 	{
-		STARPU_LU(lu_decomposition)(A, size, size, nblocks);
+	  gflops = STARPU_LU(lu_decomposition)(A, lu_size, lu_size, lu_nblocks, sched_ctx);
+			printf("no pivot \n");
 	}
 	}
 
 
 	if (profile)
 	if (profile)
@@ -343,17 +346,17 @@ int main(int argc, char **argv)
 		}
 		}
 	}
 	}
 
 
-	if (check)
+	if (lu_check)
 	{
 	{
 		if (pivot)
 		if (pivot)
-			pivot_saved_matrix(ipiv);
+		  pivot_saved_matrix(ipiv);
 
 
-		check_result();
+		lu_check_result();
 	}
 	}
 
 
-	starpu_helper_cublas_shutdown();
+	//	starpu_helper_cublas_shutdown();
 
 
-	starpu_shutdown();
+	//	starpu_shutdown();
 
 
-	return 0;
+	return gflops;
 }
 }

+ 24 - 24
examples/lu/xlu.c

@@ -72,7 +72,7 @@ static struct starpu_task *create_task_11(starpu_data_handle dataA, unsigned k)
 	return task;
 	return task;
 }
 }
 
 
-static void create_task_12(starpu_data_handle dataA, unsigned k, unsigned j)
+static void create_task_12(starpu_data_handle dataA, unsigned k, unsigned j, struct starpu_sched_ctx *sched_ctx)
 {
 {
 //	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));
 
 
@@ -98,10 +98,10 @@ static void create_task_12(starpu_data_handle dataA, unsigned k, unsigned j)
 		starpu_tag_declare_deps(TAG12(k, j), 1, TAG11(k));
 		starpu_tag_declare_deps(TAG12(k, j), 1, TAG11(k));
 	}
 	}
 
 
-	starpu_task_submit(task);
+	starpu_task_submit_to_ctx(task, sched_ctx);
 }
 }
 
 
-static void create_task_21(starpu_data_handle dataA, unsigned k, unsigned i)
+static void create_task_21(starpu_data_handle dataA, unsigned k, unsigned i, struct starpu_sched_ctx *sched_ctx)
 {
 {
 	struct starpu_task *task = create_task(TAG21(k, i));
 	struct starpu_task *task = create_task(TAG21(k, i));
 
 
@@ -125,10 +125,10 @@ static void create_task_21(starpu_data_handle dataA, unsigned k, unsigned i)
 		starpu_tag_declare_deps(TAG21(k, i), 1, TAG11(k));
 		starpu_tag_declare_deps(TAG21(k, i), 1, TAG11(k));
 	}
 	}
 
 
-	starpu_task_submit(task);
+	starpu_task_submit_to_ctx(task, sched_ctx);
 }
 }
 
 
-static void create_task_22(starpu_data_handle dataA, unsigned k, unsigned i, unsigned j)
+static void create_task_22(starpu_data_handle dataA, unsigned k, unsigned i, unsigned j, struct starpu_sched_ctx *sched_ctx)
 {
 {
 //	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));
 
 
@@ -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_tag_declare_deps(TAG22(k, i, j), 2, TAG12(k, j), TAG21(k, i));
 	}
 	}
 
 
-	starpu_task_submit(task);
+	starpu_task_submit_to_ctx(task, sched_ctx);
 }
 }
 
 
 /*
 /*
  *	code to bootstrap the factorization 
  *	code to bootstrap the factorization 
  */
  */
 
 
-static void dw_codelet_facto_v3(starpu_data_handle dataA, unsigned nblocks)
+static double dw_codelet_facto_v3(starpu_data_handle dataA, unsigned lu_nblocks, struct starpu_sched_ctx *sched_ctx)
 {
 {
 	struct timeval start;
 	struct timeval start;
 	struct timeval end;
 	struct timeval end;
@@ -173,7 +173,7 @@ static void dw_codelet_facto_v3(starpu_data_handle dataA, unsigned nblocks)
 	/* create all the DAG nodes */
 	/* create all the DAG nodes */
 	unsigned i,j,k;
 	unsigned i,j,k;
 
 
-	for (k = 0; k < nblocks; k++)
+	for (k = 0; k < lu_nblocks; k++)
 	{
 	{
 		struct starpu_task *task = create_task_11(dataA, k);
 		struct starpu_task *task = create_task_11(dataA, k);
 
 
@@ -182,27 +182,27 @@ static void dw_codelet_facto_v3(starpu_data_handle dataA, unsigned nblocks)
 			entry_task = task;
 			entry_task = task;
 		}
 		}
 		else {
 		else {
-			starpu_task_submit(task);
+		  starpu_task_submit_to_ctx(task, sched_ctx);
 		}
 		}
 		
 		
-		for (i = k+1; i<nblocks; i++)
+		for (i = k+1; i<lu_nblocks; i++)
 		{
 		{
-			create_task_12(dataA, k, i);
-			create_task_21(dataA, k, i);
+		  create_task_12(dataA, k, i, sched_ctx);
+		  create_task_21(dataA, k, i, sched_ctx);
 		}
 		}
 
 
-		for (i = k+1; i<nblocks; i++)
+		for (i = k+1; i<lu_nblocks; i++)
 		{
 		{
-			for (j = k+1; j<nblocks; j++)
+			for (j = k+1; j<lu_nblocks; j++)
 			{
 			{
-				create_task_22(dataA, k, i, j);
+			  create_task_22(dataA, k, i, j, sched_ctx);
 			}
 			}
 		}
 		}
 	}
 	}
 
 
 	/* schedule the codelet */
 	/* schedule the codelet */
 	gettimeofday(&start, NULL);
 	gettimeofday(&start, NULL);
-	int ret = starpu_task_submit(entry_task);
+	int ret = starpu_task_submit_to_ctx(entry_task, sched_ctx);
 	if (STARPU_UNLIKELY(ret == -ENODEV))
 	if (STARPU_UNLIKELY(ret == -ENODEV))
 	{
 	{
 		fprintf(stderr, "No worker may execute this task\n");
 		fprintf(stderr, "No worker may execute this task\n");
@@ -212,20 +212,19 @@ static void dw_codelet_facto_v3(starpu_data_handle dataA, unsigned nblocks)
 
 
 
 
 	/* stall the application until the end of computations */
 	/* stall the application until the end of computations */
-	starpu_tag_wait(TAG11(nblocks-1));
+	starpu_tag_wait(TAG11(lu_nblocks-1));
+	printf("lu finish waiting for %d nblocks\n", lu_nblocks-1);
 
 
 	gettimeofday(&end, NULL);
 	gettimeofday(&end, NULL);
 
 
 	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
-	fprintf(stderr, "Computation took (in ms)\n");
-	printf("%2.2f\n", timing/1000);
 
 
 	unsigned n = starpu_matrix_get_nx(dataA);
 	unsigned n = starpu_matrix_get_nx(dataA);
 	double flop = (2.0f*n*n*n)/3.0f;
 	double flop = (2.0f*n*n*n)/3.0f;
-	fprintf(stderr, "Synthetic GFlops : %2.2f\n", (flop/timing/1000.0f));
+	return (flop/timing/1000.0f);
 }
 }
 
 
-void STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned nblocks)
+double STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned lu_nblocks, struct starpu_sched_ctx *sched_ctx)
 {
 {
 	starpu_data_handle dataA;
 	starpu_data_handle dataA;
 
 
@@ -238,20 +237,21 @@ void STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigne
 
 
 	struct starpu_data_filter f;
 	struct starpu_data_filter f;
 		f.filter_func = starpu_vertical_block_filter_func;
 		f.filter_func = starpu_vertical_block_filter_func;
-		f.nchildren = nblocks;
+		f.nchildren = lu_nblocks;
 		f.get_nchildren = NULL;
 		f.get_nchildren = NULL;
 		f.get_child_ops = NULL;
 		f.get_child_ops = NULL;
 
 
 	struct starpu_data_filter f2;
 	struct starpu_data_filter f2;
 		f2.filter_func = starpu_block_filter_func;
 		f2.filter_func = starpu_block_filter_func;
-		f2.nchildren = nblocks;
+		f2.nchildren = lu_nblocks;
 		f2.get_nchildren = NULL;
 		f2.get_nchildren = NULL;
 		f2.get_child_ops = NULL;
 		f2.get_child_ops = NULL;
 
 
 	starpu_data_map_filters(dataA, 2, &f, &f2);
 	starpu_data_map_filters(dataA, 2, &f, &f2);
 
 
-	dw_codelet_facto_v3(dataA, nblocks);
+	double gflops = dw_codelet_facto_v3(dataA, lu_nblocks, sched_ctx);
 
 
 	/* gather all the data */
 	/* gather all the data */
 	starpu_data_unpartition(dataA, 0);
 	starpu_data_unpartition(dataA, 0);
+	return gflops;
 }
 }

+ 3 - 3
examples/lu/xlu.h

@@ -110,8 +110,8 @@ struct piv_s {
 	unsigned last; /* last element */
 	unsigned last; /* last element */
 };
 };
 
 
-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);
+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);
 
 
 #endif // __XLU_H__
 #endif // __XLU_H__

+ 27 - 25
examples/lu/xlu_implicit.c

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

+ 27 - 29
examples/lu/xlu_implicit_pivot.c

@@ -28,7 +28,7 @@ static unsigned no_prio = 0;
 static void create_task_pivot(starpu_data_handle *dataAp, unsigned nblocks,
 static void create_task_pivot(starpu_data_handle *dataAp, unsigned nblocks,
 					struct piv_s *piv_description,
 					struct piv_s *piv_description,
 					unsigned k, unsigned i,
 					unsigned k, unsigned i,
-					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
+			      starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct starpu_sched_ctx *sched_ctx)
 {
 {
 	struct starpu_task *task = starpu_task_create();
 	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))
 	if (!no_prio && (i == k+1))
 		task->priority = STARPU_MAX_PRIO;
 		task->priority = STARPU_MAX_PRIO;
 
 
-	starpu_task_submit(task);
+	starpu_task_submit_to_ctx(task, sched_ctx);
 }
 }
 
 
 static void create_task_11_pivot(starpu_data_handle *dataAp, unsigned nblocks,
 static void create_task_11_pivot(starpu_data_handle *dataAp, unsigned nblocks,
 					unsigned k, struct piv_s *piv_description,
 					unsigned k, struct piv_s *piv_description,
-					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
+					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct starpu_sched_ctx *sched_ctx)
 {
 {
 	struct starpu_task *task = starpu_task_create();
 	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)
 	if (!no_prio)
 		task->priority = STARPU_MAX_PRIO;
 		task->priority = STARPU_MAX_PRIO;
 
 
-	starpu_task_submit(task);
+	starpu_task_submit_to_ctx(task, sched_ctx);
 }
 }
 
 
 static void create_task_12(starpu_data_handle *dataAp, unsigned nblocks, unsigned k, unsigned j,
 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))
+		starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct starpu_sched_ctx *sched_ctx)
 {
 {
 	struct starpu_task *task = starpu_task_create();
 	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))
 	if (!no_prio && (j == k+1))
 		task->priority = STARPU_MAX_PRIO;
 		task->priority = STARPU_MAX_PRIO;
 
 
-	starpu_task_submit(task);
+	starpu_task_submit_to_ctx(task, sched_ctx);
 }
 }
 
 
 static void create_task_21(starpu_data_handle *dataAp, unsigned nblocks, unsigned k, unsigned i,
 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))
+				starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct starpu_sched_ctx *sched_ctx)
 {
 {
 	struct starpu_task *task = starpu_task_create();
 	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))
 	if (!no_prio && (i == k+1))
 		task->priority = STARPU_MAX_PRIO;
 		task->priority = STARPU_MAX_PRIO;
 
 
-	starpu_task_submit(task);
+	starpu_task_submit_to_ctx(task, sched_ctx);
 }
 }
 
 
 static void create_task_22(starpu_data_handle *dataAp, unsigned nblocks, unsigned k, unsigned i, unsigned j,
 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))
+				starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct starpu_sched_ctx *sched_ctx)
 {
 {
 	struct starpu_task *task = starpu_task_create();
 	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) )
 	if (!no_prio &&  (i == k + 1) && (j == k +1) )
 		task->priority = STARPU_MAX_PRIO;
 		task->priority = STARPU_MAX_PRIO;
 
 
-	starpu_task_submit(task);
+	starpu_task_submit_to_ctx(task, sched_ctx);
 }
 }
 
 
 /*
 /*
@@ -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,
 static double dw_codelet_facto_pivot(starpu_data_handle *dataAp,
 					struct piv_s *piv_description,
 					struct piv_s *piv_description,
 					unsigned nblocks,
 					unsigned nblocks,
-					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned))
+					starpu_data_handle (* get_block)(starpu_data_handle *, unsigned, unsigned, unsigned), struct starpu_sched_ctx *sched_ctx)
 {
 {
 	struct timeval start;
 	struct timeval start;
 	struct timeval end;
 	struct timeval end;
@@ -145,27 +145,28 @@ static double dw_codelet_facto_pivot(starpu_data_handle *dataAp,
 	unsigned i,j,k;
 	unsigned i,j,k;
 	for (k = 0; k < nblocks; k++)
 	for (k = 0; k < nblocks; k++)
 	{
 	{
-		create_task_11_pivot(dataAp, nblocks, k, piv_description, get_block);
+	  create_task_11_pivot(dataAp, nblocks, k, piv_description, get_block, sched_ctx);
 
 
 		for (i = 0; i < nblocks; i++)
 		for (i = 0; i < nblocks; i++)
 		{
 		{
 			if (i != k)
 			if (i != k)
-				create_task_pivot(dataAp, nblocks, piv_description, k, i, get_block);
+			  create_task_pivot(dataAp, nblocks, piv_description, k, i, get_block, sched_ctx);
 		}
 		}
 	
 	
 		for (i = k+1; i<nblocks; i++)
 		for (i = k+1; i<nblocks; i++)
 		{
 		{
-			create_task_12(dataAp, nblocks, k, i, get_block);
-			create_task_21(dataAp, nblocks, k, i, get_block);
+		  create_task_12(dataAp, nblocks, k, i, get_block, sched_ctx);
+		  create_task_21(dataAp, nblocks, k, i, get_block, sched_ctx);
 		}
 		}
 
 
 		for (i = k+1; i<nblocks; i++)
 		for (i = k+1; i<nblocks; i++)
 		for (j = k+1; j<nblocks; j++)
 		for (j = k+1; j<nblocks; j++)
-			create_task_22(dataAp, nblocks, k, i, j, get_block);
+		  create_task_22(dataAp, nblocks, k, i, j, get_block, sched_ctx);
 	}
 	}
 
 
 	/* stall the application until the end of computations */
 	/* stall the application until the end of computations */
-	starpu_task_wait_for_all();
+	//     starpu_task_wait_for_all();
+	starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx);
 
 
 	gettimeofday(&end, NULL);
 	gettimeofday(&end, NULL);
 
 
@@ -181,7 +182,7 @@ starpu_data_handle get_block_with_striding(starpu_data_handle *dataAp,
 }
 }
 
 
 
 
-void STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks)
+double STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks, struct starpu_sched_ctx *sched_ctx)
 {
 {
 	starpu_data_handle dataA;
 	starpu_data_handle dataA;
 
 
@@ -217,17 +218,16 @@ void STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size
 	}
 	}
 
 
 	double timing;
 	double timing;
-	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);
+	timing = dw_codelet_facto_pivot(&dataA, piv_description, nblocks, get_block_with_striding, sched_ctx);
 
 
 	unsigned n = starpu_matrix_get_nx(dataA);
 	unsigned n = starpu_matrix_get_nx(dataA);
 	double flop = (2.0f*n*n*n)/3.0f;
 	double flop = (2.0f*n*n*n)/3.0f;
-	fprintf(stderr, "Synthetic GFlops : %2.2f\n", (flop/timing/1000.0f));
+	double gflops = flop/timing/1000.0f;
 
 
 	/* gather all the data */
 	/* gather all the data */
 	starpu_data_unpartition(dataA, 0);
 	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];
 	return dataAp[i+j*nblocks];
 }
 }
 
 
-void STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned 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)
 {
 {
 	starpu_data_handle *dataAp = malloc(nblocks*nblocks*sizeof(starpu_data_handle));
 	starpu_data_handle *dataAp = malloc(nblocks*nblocks*sizeof(starpu_data_handle));
 
 
@@ -266,18 +266,16 @@ void STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, un
 	}
 	}
 
 
 	double timing;
 	double timing;
-	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);
+	timing = dw_codelet_facto_pivot(dataAp, piv_description, nblocks, get_block_with_no_striding, sched_ctx);
 
 
 	unsigned n = starpu_matrix_get_nx(dataAp[0])*nblocks;
 	unsigned n = starpu_matrix_get_nx(dataAp[0])*nblocks;
 	double flop = (2.0f*n*n*n)/3.0f;
 	double flop = (2.0f*n*n*n)/3.0f;
-	fprintf(stderr, "Synthetic GFlops : %2.2f\n", (flop/timing/1000.0f));
+	double gflops = flop/timing/1000.0f;
 
 
 	for (bj = 0; bj < nblocks; bj++)
 	for (bj = 0; bj < nblocks; bj++)
 	for (bi = 0; bi < nblocks; bi++)
 	for (bi = 0; bi < nblocks; bi++)
 	{
 	{
 		starpu_data_unregister(dataAp[bi+nblocks*bj]);
 		starpu_data_unregister(dataAp[bi+nblocks*bj]);
 	}
 	}
+	return gflops;
 }
 }

+ 21 - 0
examples/lu/xlu_kernels.c

@@ -55,6 +55,14 @@ static inline void STARPU_LU(common_u22)(void *descr[],
 
 
 #ifdef STARPU_USE_CUDA
 #ifdef STARPU_USE_CUDA
 		case 1:
 		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,
 			CUBLAS_GEMM('n', 'n', dx, dy, dz,
 				(TYPE)-1.0, right, ld21, left, ld12,
 				(TYPE)-1.0, right, ld21, left, ld12,
 				(TYPE)1.0f, center, ld22);
 				(TYPE)1.0f, center, ld22);
@@ -287,6 +295,11 @@ static inline void STARPU_LU(common_u11)(void *descr[],
 
 
 	unsigned long z;
 	unsigned long z;
 
 
+#ifdef STARPU_USE_CUDA
+	cublasStatus status;
+	cudaError_t cures;
+#endif
+
 	switch (s) {
 	switch (s) {
 		case 0:
 		case 0:
 			for (z = 0; z < nx; z++)
 			for (z = 0; z < nx; z++)
@@ -320,6 +333,14 @@ static inline void STARPU_LU(common_u11)(void *descr[],
 						&sub11[z+(z+1)*ld], ld,
 						&sub11[z+(z+1)*ld], ld,
 						&sub11[(z+1) + (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();
 			cudaThreadSynchronize();
 
 

+ 84 - 79
examples/lu/xlu_pivot.c

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