Browse Source

remerge + fixes

Andra Hugo 13 years ago
parent
commit
645b9d013d
70 changed files with 572 additions and 187 deletions
  1. 2 1
      README
  2. 2 0
      doc/chapters/mpi-support.texi
  3. 1 1
      examples/Makefile.am
  4. 8 6
      examples/cholesky/cholesky_grain_tag.c
  5. 4 5
      examples/cholesky/cholesky_implicit.c
  6. 16 16
      examples/cholesky/cholesky_tag.c
  7. 1 1
      examples/filters/custom_mf/custom_interface.c
  8. 1 1
      examples/filters/custom_mf/custom_mf_filter.c
  9. 4 0
      examples/spmv/dw_block_spmv.c
  10. 4 0
      examples/tag_example/tag_example2.c
  11. 3 0
      gcc-plugin/tests/Makefile.am
  12. 2 2
      include/starpu_scheduler.h
  13. 3 1
      mpi/examples/cholesky/mpi_cholesky.c
  14. 2 1
      mpi/examples/cholesky/mpi_cholesky_distributed.c
  15. 7 3
      mpi/examples/mpi_lu/plu_example.c
  16. 8 4
      mpi/examples/mpi_lu/pxlu.c
  17. 3 2
      mpi/examples/reduction/mpi_reduction.c
  18. 5 5
      mpi/examples/reduction/mpi_reduction_kernels.c
  19. 2 1
      mpi/examples/scatter_gather/mpi_scatter_gather.c
  20. 2 1
      mpi/examples/stencil/stencil5.c
  21. 42 11
      mpi/starpu_mpi.c
  22. 2 1
      mpi/starpu_mpi.h
  23. 26 5
      mpi/starpu_mpi_insert_task.c
  24. 2 1
      mpi/starpu_mpi_insert_task_cache.c
  25. 4 7
      mpi/starpu_mpi_private.h
  26. 18 19
      mpi/tests/insert_task_owner2.c
  27. 19 20
      mpi/tests/insert_task_owner_data.c
  28. 2 1
      mpi/tests/ring.c
  29. 2 1
      mpi/tests/ring_async.c
  30. 2 1
      mpi/tests/ring_async_implicit.c
  31. 2 0
      socl/src/init.c
  32. 1 1
      src/Makefile.am
  33. 2 2
      src/core/dependencies/htable.c
  34. 6 4
      src/core/perfmodel/perfmodel.c
  35. 0 6
      src/core/perfmodel/perfmodel.h
  36. 2 2
      src/core/perfmodel/perfmodel_bus.c
  37. 2 1
      src/core/task.c
  38. 3 3
      src/datawizard/interfaces/bcsr_interface.c
  39. 2 2
      src/datawizard/interfaces/csr_interface.c
  40. 4 1
      src/datawizard/interfaces/data_interface.c
  41. 2 9
      src/datawizard/interfaces/multiformat_interface.c
  42. 1 0
      src/top/starpu_top_connection.c
  43. 1 1
      tests/Makefile.am
  44. 0 2
      tests/datawizard/acquire_cb_insert.c
  45. 3 3
      tests/datawizard/acquire_release2.c
  46. 2 2
      tests/datawizard/critical_section_with_void_interface.c
  47. 0 2
      tests/datawizard/increment_redux.c
  48. 0 2
      tests/datawizard/increment_redux_lazy.c
  49. 0 2
      tests/datawizard/increment_redux_v2.c
  50. 2 0
      tests/datawizard/interfaces/test_interfaces.c
  51. 0 2
      tests/datawizard/mpi_like.c
  52. 3 4
      tests/datawizard/mpi_like_async.c
  53. 0 2
      tests/datawizard/scratch.c
  54. 0 2
      tests/datawizard/sync_with_data_with_mem.c
  55. 0 2
      tests/datawizard/sync_with_data_with_mem_non_blocking.c
  56. 0 2
      tests/datawizard/sync_with_data_with_mem_non_blocking_implicit.c
  57. 1 0
      tests/errorcheck/invalid_tasks.c
  58. 2 2
      tests/errorcheck/starpu_init_noworker.c
  59. 1 1
      tests/helper.h
  60. 21 0
      tests/loader.c
  61. 0 2
      tests/main/empty_task_chain.c
  62. 0 2
      tests/main/empty_task_sync_point_tasks.c
  63. 0 2
      tests/main/multithreaded_init.c
  64. 2 1
      tests/main/subgraph_repeat_regenerate.c
  65. 87 0
      tools/dev/experimental/name_codelets.cocci
  66. 40 0
      tools/dev/experimental/name_codelets_test.c
  67. 126 0
      tools/dev/experimental/unchecked_starpu_function_calls.cocci
  68. 19 0
      tools/dev/experimental/unchecked_starpu_function_calls_test.c
  69. 9 0
      tools/valgrind/fscanf.suppr
  70. 27 0
      tools/valgrind/starpu.suppr

+ 2 - 1
README

@@ -1,6 +1,6 @@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
-# Copyright (C) 2009, 2010, 2011  Université de Bordeaux 1
+# Copyright (C) 2009-2012  Université de Bordeaux 1
 # Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
 #
 # StarPU is free software; you can redistribute it and/or modify
@@ -69,6 +69,7 @@ advantage of their specificities in a portable fashion.
    * autoconf (version >= 2.60)
    * automake
    * makeinfo
+   * libtool (version >= 2)
 
  * Remark: It is strongly recommanded that you also install the hwloc library
    before installing StarPU. This permits StarPU to actually map the processing

+ 2 - 0
doc/chapters/mpi-support.texi

@@ -66,6 +66,8 @@ by calling @code{starpu_mpi_initialize_extended}.
 
 @subsection Communication
 
+TODO
+
 @deftypefun int starpu_mpi_send (starpu_data_handle_t @var{data_handle}, int @var{dest}, int @var{mpi_tag}, MPI_Comm @var{comm})
 @end deftypefun
 

+ 1 - 1
examples/Makefile.am

@@ -154,7 +154,7 @@ LOADER			=	loader
 loader_CPPFLAGS =  $(AM_CFLAGS) $(AM_CPPFLAGS) -I$(top_builddir)/src/
 LOADER_BIN		=	$(abs_top_builddir)/examples/$(LOADER)
 loader_SOURCES		=	../tests/loader.c
-TESTS_ENVIRONMENT	=	top_builddir="$(abs_top_builddir)" $(LOADER_BIN)
+TESTS_ENVIRONMENT	=	top_builddir="$(abs_top_builddir)" top_srcdir="$(abs_top_srcdir)" $(LOADER_BIN)
 endif
 
 examplebin_PROGRAMS +=				\

+ 8 - 6
examples/cholesky/cholesky_grain_tag.c

@@ -238,6 +238,7 @@ static void cholesky_grain_rec(float *matA, unsigned size, unsigned ld, unsigned
 		/* stall the application until the end of computations */
 		starpu_tag_wait(TAG11_AUX(nblocks-1, reclevel));
 		starpu_data_unpartition(dataA, 0);
+		starpu_data_unregister(dataA);
 		return;
 	}
 	else
@@ -308,17 +309,20 @@ void cholesky_grain(float *matA, unsigned size, unsigned ld, unsigned nblocks, u
 	double flop = (1.0f*size*size*size)/3.0f;
 	FPRINTF(stderr, "Synthetic GFlops : %2.2f\n", (flop/timing/1000.0f));
 
+}
+
+static void shutdown_system(float **matA, unsigned pinned)
+{
 	if (pinned)
 	{
-		starpu_free(matA);
+	     starpu_free(*matA);
 	}
 	else
 	{
-		free(matA);
+	     free(*matA);
 	}
 
 	starpu_helper_cublas_shutdown();
-
 	starpu_shutdown();
 }
 
@@ -332,8 +336,6 @@ int main(int argc, char **argv)
 	parse_args(argc, argv);
 
 	float *mat;
-
-	mat = malloc(size*size*sizeof(float));
 	initialize_system(&mat, size, pinned);
 
 	unsigned i,j;
@@ -367,7 +369,6 @@ int main(int argc, char **argv)
 	}
 #endif
 
-
 	cholesky_grain(mat, size, size, nblocks, nbigblocks, pinned);
 
 #ifdef CHECK_OUTPUT
@@ -416,5 +417,6 @@ int main(int argc, char **argv)
 	free(test_mat);
 #endif
 
+	shutdown_system(&mat, pinned);
 	return 0;
 }

+ 4 - 5
examples/cholesky/cholesky_implicit.c

@@ -259,10 +259,10 @@ static void execute_cholesky(unsigned size, unsigned nblocks)
 		}
 		float *test_mat = malloc(size*size*sizeof(float));
 		STARPU_ASSERT(test_mat);
-	
+
 		SSYRK("L", "N", size, size, 1.0f,
 					mat, size, 0.0f, test_mat, size);
-	
+
 		FPRINTF(stderr, "comparing results ...\n");
 #ifdef PRINT_OUTPUT
 		for (j = 0; j < size; j++)
@@ -281,7 +281,7 @@ static void execute_cholesky(unsigned size, unsigned nblocks)
 			FPRINTF(stdout, "\n");
 		}
 #endif
-	
+
 		for (j = 0; j < size; j++)
 		{
 			for (i = 0; i < size; i++)
@@ -300,8 +300,6 @@ static void execute_cholesky(unsigned size, unsigned nblocks)
 	        }
 		free(test_mat);
 	}
-	starpu_free(mat);
-
 }
 
 int main(int argc, char **argv)
@@ -335,6 +333,7 @@ int main(int argc, char **argv)
 		execute_cholesky(size, nblocks);
 
 	starpu_helper_cublas_shutdown();
+	starpu_free(mat);
 	starpu_shutdown();
 
 	return 0;

+ 16 - 16
examples/cholesky/cholesky_tag.c

@@ -53,7 +53,7 @@ static struct starpu_task * create_task_11(starpu_data_handle_t dataA, unsigned
 /*	FPRINTF(stdout, "task 11 k = %d TAG = %llx\n", k, (TAG11(k))); */
 
 	struct starpu_task *task = create_task(TAG11(k));
-	
+
 	task->cl = &cl11;
 
 	/* which sub-data is manipulated ? */
@@ -88,7 +88,7 @@ static void create_task_21(starpu_data_handle_t dataA, unsigned k, unsigned j)
 {
 	struct starpu_task *task = create_task(TAG21(k, j));
 
-	task->cl = &cl21;	
+	task->cl = &cl21;
 
 	/* which sub-data is manipulated ? */
 	task->handles[0] = starpu_data_get_sub_data(dataA, 2, k, k);
@@ -169,7 +169,7 @@ static void create_task_22(starpu_data_handle_t dataA, unsigned k, unsigned i, u
 
 
 /*
- *	code to bootstrap the factorization 
+ *	code to bootstrap the factorization
  *	and construct the DAG
  */
 
@@ -203,7 +203,7 @@ static void _cholesky(starpu_data_handle_t dataA, unsigned nblocks)
                         }
 
 		}
-		
+
 		for (j = k+1; j<nblocks; j++)
 		{
 			create_task_21(dataA, k, j);
@@ -257,7 +257,7 @@ static int initialize_system(float **A, unsigned dim, unsigned pinned)
 	if (pinned)
 	{
 		starpu_malloc((void **)A, (size_t)dim*dim*sizeof(float));
-	} 
+	}
 	else
 	{
 		*A = malloc(dim*dim*sizeof(float));
@@ -265,7 +265,7 @@ static int initialize_system(float **A, unsigned dim, unsigned pinned)
 	return 0;
 }
 
-static void cholesky(float *matA, unsigned size, unsigned ld, unsigned nblocks, unsigned pinned)
+static void cholesky(float *matA, unsigned size, unsigned ld, unsigned nblocks)
 {
 	starpu_data_handle_t dataA;
 
@@ -292,18 +292,20 @@ static void cholesky(float *matA, unsigned size, unsigned ld, unsigned nblocks,
 	_cholesky(dataA, nblocks);
 
 	starpu_data_unregister(dataA);
+}
 
+static void shutdown_system(float **matA, unsigned pinned)
+{
 	if (pinned)
 	{
-		starpu_free(matA);
+		starpu_free(*matA);
 	}
 	else
 	{
-		free(matA);
+		free(*matA);
 	}
 
 	starpu_helper_cublas_shutdown();
-
 	starpu_shutdown();
 }
 
@@ -317,11 +319,8 @@ int main(int argc, char **argv)
 	parse_args(argc, argv);
 
 	float *mat;
-
-	mat = malloc(size*size*sizeof(float));
 	int ret = initialize_system(&mat, size, pinned);
-	if (ret)
-		return ret;
+	if (ret) return ret;
 
 	unsigned i,j;
 	for (i = 0; i < size; i++)
@@ -355,7 +354,7 @@ int main(int argc, char **argv)
 #endif
 
 
-	cholesky(mat, size, size, nblocks, pinned);
+	cholesky(mat, size, size, nblocks);
 
 #ifdef CHECK_OUTPUT
 	FPRINTF(stdout, "Results :\n");
@@ -381,7 +380,7 @@ int main(int argc, char **argv)
 	float *test_mat = malloc(size*size*sizeof(float));
 	STARPU_ASSERT(test_mat);
 
-	SSYRK("L", "N", size, size, 1.0f, 
+	SSYRK("L", "N", size, size, 1.0f,
 				mat, size, 0.0f, test_mat, size);
 
 	FPRINTF(stderr, "comparing results ...\n");
@@ -399,9 +398,10 @@ int main(int argc, char **argv)
 			}
 		}
 		FPRINTF(stdout, "\n");
-		free(test_mat);
 	}
+	free(test_mat);
 #endif
 
+	shutdown_system(&mat, pinned);
 	return 0;
 }

+ 1 - 1
examples/filters/custom_mf/custom_interface.c

@@ -197,7 +197,7 @@ static ssize_t allocate_custom_buffer_on_node(void *data_interface, uint32_t nod
 #endif /* !STARPU_USE_OPENCL */
 			
 		break;
-#if STARPU_USE_CUDA
+#ifdef STARPU_USE_CUDA
 	case STARPU_CUDA_RAM:
 	{
 		cudaError_t err;

+ 1 - 1
examples/filters/custom_mf/custom_mf_filter.c

@@ -311,7 +311,7 @@ main(void)
 	print_it();
 #endif
 
-#if STARPU_USE_OPENCL
+#ifdef STARPU_USE_OPENCL
 	if (nopencl > 0)
 	{
         	err = starpu_opencl_unload_opencl(&opencl_program);

+ 4 - 0
examples/spmv/dw_block_spmv.c

@@ -75,8 +75,12 @@ void create_data(void)
 
 void unregister_data(void)
 {
+	starpu_data_unpartition(sparse_matrix, 0);
 	starpu_data_unregister(sparse_matrix);
+
+	starpu_data_unpartition(vector_in, 0);
 	starpu_data_unregister(vector_in);
+
 	starpu_data_unregister(vector_out);
 }
 

+ 4 - 0
examples/tag_example/tag_example2.c

@@ -152,6 +152,10 @@ int main(int argc __attribute__((unused)) , char **argv __attribute__((unused)))
 			tag_cleanup_grid(ni, i-1);
 	}
 
+	starpu_task_wait_for_all();
+
+	tag_cleanup_grid(ni, nk-1);
+
 	starpu_shutdown();
 
 	FPRINTF(stderr, "TEST DONE ...\n");

+ 3 - 0
gcc-plugin/tests/Makefile.am

@@ -72,3 +72,6 @@ check-hook:
 	-@echo "GNU Guile not available, test suite not run."
 
 endif !HAVE_GUILE
+
+showcheck:
+	-cat $(TEST_LOGS) /dev/null

+ 2 - 2
include/starpu_scheduler.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2011  Université de Bordeaux 1
- * Copyright (C) 2011  Télécom-SudParis
+ * Copyright (C) 2010, 2011  Université de Bordeaux 1
+ * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2011  INRIA
  *
  * StarPU is free software; you can redistribute it and/or modify

+ 3 - 1
mpi/examples/cholesky/mpi_cholesky.c

@@ -195,7 +195,9 @@ int main(int argc, char **argv)
 	conf.sched_policy_name = "heft";
 	conf.calibrate = 1;
 
-	starpu_init(&conf);
+	int ret = starpu_init(&conf);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+
 	starpu_mpi_initialize_extended(&rank, &nodes);
 	starpu_helper_cublas_init();
 

+ 2 - 1
mpi/examples/cholesky/mpi_cholesky_distributed.c

@@ -195,7 +195,8 @@ int main(int argc, char **argv)
 	conf.sched_policy_name = "heft";
 	conf.calibrate = 1;
 
-	starpu_init(&conf);
+	int ret = starpu_init(&conf);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 	starpu_mpi_initialize_extended(&rank, &nodes);
 	starpu_helper_cublas_init();
 

+ 7 - 3
mpi/examples/mpi_lu/plu_example.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2011  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -35,7 +35,10 @@ static unsigned check = 0;
 static unsigned p = 1;
 static unsigned q = 1;
 static unsigned display = 0;
+
+#ifdef STARPU_HAVE_LIBNUMA
 static unsigned numa = 0;
+#endif
 
 static size_t allocated_memory = 0;
 static size_t allocated_memory_extra = 0;
@@ -421,7 +424,8 @@ int main(int argc, char **argv)
 
 	parse_args(rank, argc, argv);
 
-	starpu_init(NULL);
+	int ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* We disable sequential consistency in this example */
 	starpu_data_set_default_sequential_consistency_flag(0);
@@ -448,7 +452,7 @@ int main(int argc, char **argv)
 
 	display_grid(rank, nblocks);
 
-	TYPE *a_r;
+	TYPE *a_r = NULL;
 //	STARPU_PLU(display_data_content)(a_r, size);
 
 	TYPE *x, *y;

+ 8 - 4
mpi/examples/mpi_lu/pxlu.c

@@ -287,7 +287,8 @@ static void create_task_11_real(unsigned k)
 		starpu_tag_declare_deps(TAG11(k), 1, STARPU_TAG_INIT);
 	}
 
-	starpu_task_submit(task);
+	int ret = starpu_task_submit(task);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 }
 
 static void create_task_11(unsigned k)
@@ -459,7 +460,8 @@ static void create_task_12_real(unsigned k, unsigned j)
 		starpu_tag_declare_deps(TAG12(k, j), 1, tag_11_dep);
 	}
 
-	starpu_task_submit(task);
+	int ret = starpu_task_submit(task);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 }
 
 static void create_task_12(unsigned k, unsigned j)
@@ -628,7 +630,8 @@ static void create_task_21_real(unsigned k, unsigned i)
 		starpu_tag_declare_deps(TAG21(k, i), 1, tag_11_dep);
 	}
 
-	starpu_task_submit(task);
+	int ret = starpu_task_submit(task);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 }
 
 static void create_task_21(unsigned k, unsigned i)
@@ -745,7 +748,8 @@ static void create_task_22_real(unsigned k, unsigned i, unsigned j)
 		starpu_tag_declare_deps(TAG22(k, i, j), 2, tag_12_dep, tag_21_dep);
 	}
 
-	starpu_task_submit(task);
+	int ret = starpu_task_submit(task);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 }
 
 static void create_task_22(unsigned k, unsigned i, unsigned j)

+ 3 - 2
mpi/examples/reduction/mpi_reduction.c

@@ -56,13 +56,14 @@ int main(int argc, char **argv)
 {
         int my_rank, size, x, y;
         long int *vector;
-	long int dot, sum;
+	long int dot, sum=0;
         starpu_data_handle_t *handles;
 	starpu_data_handle_t dot_handle;
 
 	int nb_elements, step;
 
-	starpu_init(NULL);
+	int ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 	starpu_mpi_initialize_extended(&my_rank, &size);
 
 	nb_elements = size*8000;

+ 5 - 5
mpi/examples/reduction/mpi_reduction_kernels.c

@@ -27,7 +27,7 @@
  */
 void init_cpu_func(void *descr[], void *cl_arg)
 {
-	long int *dot = (int *)STARPU_VARIABLE_GET_PTR(descr[0]);
+	long int *dot = (long int *)STARPU_VARIABLE_GET_PTR(descr[0]);
 	*dot = 0;
 	_DISPLAY("Init dot\n");
 }
@@ -37,8 +37,8 @@ void init_cpu_func(void *descr[], void *cl_arg)
  */
 void redux_cpu_func(void *descr[], void *cl_arg)
 {
-	long int *dota = (int *)STARPU_VARIABLE_GET_PTR(descr[0]);
-	long int *dotb = (int *)STARPU_VARIABLE_GET_PTR(descr[1]);
+	long int *dota = (long int *)STARPU_VARIABLE_GET_PTR(descr[0]);
+	long int *dotb = (long int *)STARPU_VARIABLE_GET_PTR(descr[1]);
 
 	*dota = *dota + *dotb;
 	_DISPLAY("Calling redux %ld=%ld+%ld\n", *dota, *dota-*dotb, *dotb);
@@ -49,10 +49,10 @@ void redux_cpu_func(void *descr[], void *cl_arg)
  */
 void dot_cpu_func(void *descr[], void *cl_arg)
 {
-	long int *local_x = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
+	long int *local_x = (long int *)STARPU_VECTOR_GET_PTR(descr[0]);
 	unsigned n = STARPU_VECTOR_GET_NX(descr[0]);
 
-	long int *dot = (int *)STARPU_VARIABLE_GET_PTR(descr[1]);
+	long int *dot = (long int *)STARPU_VARIABLE_GET_PTR(descr[1]);
 
 //	_DISPLAY("Before dot=%ld (adding %d elements...)\n", *dot, n);
 	unsigned i;

+ 2 - 1
mpi/examples/scatter_gather/mpi_scatter_gather.c

@@ -67,7 +67,8 @@ int main(int argc, char **argv)
 	unsigned size = nblocks*block_size;
 	unsigned ld = size / nblocks;
 
-	starpu_init(NULL);
+	int ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 	starpu_mpi_initialize_extended(&rank, &nodes);
 
 	if (rank == 0)

+ 2 - 1
mpi/examples/stencil/stencil5.c

@@ -76,7 +76,8 @@ int main(int argc, char **argv)
         unsigned matrix[X][Y];
         starpu_data_handle_t data_handles[X][Y];
 
-	starpu_init(NULL);
+	int ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 	starpu_mpi_initialize_extended(&my_rank, &size);
         parse_args(argc, argv);
 

+ 42 - 11
mpi/starpu_mpi.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010-2011  Université de Bordeaux 1
+ * Copyright (C) 2009, 2010-2012  Université de Bordeaux 1
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -36,14 +36,17 @@ static struct _starpu_mpi_req_list *new_requests;
 static struct _starpu_mpi_req_list *detached_requests;
 static pthread_mutex_t detached_requests_mutex;
 
-static pthread_cond_t cond;
+/* Condition to wake up progression thread */
+static pthread_cond_t cond_progression;
+/* Condition to wake up waiting for all current MPI requests to finish */
+static pthread_cond_t cond_finished;
 static pthread_mutex_t mutex;
 static pthread_t progress_thread;
 static int running = 0;
 
 /* Count requests posted by the application and not yet submitted to MPI, i.e pushed into the new_requests list */
 static pthread_mutex_t mutex_posted_requests;
-static int posted_requests = 0;
+static int posted_requests = 0, newer_requests, barrier_running = 0;
 
 #define INC_POSTED_REQUESTS(value) { _STARPU_PTHREAD_MUTEX_LOCK(&mutex_posted_requests); posted_requests += value; _STARPU_PTHREAD_MUTEX_UNLOCK(&mutex_posted_requests); }
 
@@ -433,6 +436,29 @@ int starpu_mpi_barrier(MPI_Comm comm)
 	struct _starpu_mpi_req *barrier_req = calloc(1, sizeof(struct _starpu_mpi_req));
 	STARPU_ASSERT(barrier_req);
 
+	/* First wait for *both* all tasks and MPI requests to finish, in case
+	 * some tasks generate MPI requests, MPI requests generate tasks, etc.
+	 */
+	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
+	STARPU_ASSERT_MSG(!barrier_running, "Concurrent starpu_mpi_barrier is not implemented, even on different communicators");
+	barrier_running = 1;
+	do {
+		while (posted_requests)
+			/* Wait for all current MPI requests to finish */
+			_STARPU_PTHREAD_COND_WAIT(&cond_finished, &mutex);
+		/* No current request, clear flag */
+		newer_requests = 0;
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
+		/* Now wait for all tasks */
+		starpu_task_wait_for_all();
+		_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
+		/* Check newer_requests again, in case some MPI requests
+		 * triggered by tasks completed and triggered tasks between
+		 * wait_for_all finished and we take the lock */
+	} while (posted_requests || newer_requests);
+	barrier_running = 0;
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
+
 	/* Initialize the request structure */
 	_STARPU_PTHREAD_MUTEX_INIT(&(barrier_req->req_mutex), NULL);
 	_STARPU_PTHREAD_COND_INIT(&(barrier_req->req_cond), NULL);
@@ -513,8 +539,9 @@ static void submit_mpi_req(void *arg)
 
 	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	_starpu_mpi_req_list_push_front(new_requests, req);
+	newer_requests = 1;
         _STARPU_MPI_DEBUG("Pushing new request type %d\n", req->request_type);
-	_STARPU_PTHREAD_COND_BROADCAST(&cond);
+	_STARPU_PTHREAD_COND_BROADCAST(&cond_progression);
 	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
         _STARPU_MPI_LOG_OUT();
 }
@@ -531,7 +558,7 @@ static unsigned progression_hook_func(void *arg __attribute__((unused)))
 	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	if (!_starpu_mpi_req_list_empty(detached_requests))
 	{
-		_STARPU_PTHREAD_COND_SIGNAL(&cond);
+		_STARPU_PTHREAD_COND_SIGNAL(&cond_progression);
 		may_block = 0;
 	}
 	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
@@ -607,7 +634,7 @@ static void handle_new_request(struct _starpu_mpi_req *req)
 		/* put the submitted request into the list of pending requests
 		 * so that it can be handled by the progression mechanisms */
 		_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
-		_STARPU_PTHREAD_COND_SIGNAL(&cond);
+		_STARPU_PTHREAD_COND_SIGNAL(&cond_progression);
 		_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 	}
         _STARPU_MPI_LOG_OUT();
@@ -640,7 +667,7 @@ static void *progress_thread_func(void *arg)
 	/* notify the main thread that the progression thread is ready */
 	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	running = 1;
-	_STARPU_PTHREAD_COND_SIGNAL(&cond);
+	_STARPU_PTHREAD_COND_SIGNAL(&cond_progression);
 	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 
 	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
@@ -655,7 +682,10 @@ static void *progress_thread_func(void *arg)
 		if (block)
 		{
                         _STARPU_MPI_DEBUG("NO MORE REQUESTS TO HANDLE\n");
-			_STARPU_PTHREAD_COND_WAIT(&cond, &mutex);
+			if (barrier_running)
+				/* Tell mpi_barrier */
+				_STARPU_PTHREAD_COND_SIGNAL(&cond_finished);
+			_STARPU_PTHREAD_COND_WAIT(&cond_progression, &mutex);
 		}
 
 		/* test whether there are some terminated "detached request" */
@@ -736,7 +766,8 @@ static
 int _starpu_mpi_initialize(int initialize_mpi, int *rank, int *world_size)
 {
 	_STARPU_PTHREAD_MUTEX_INIT(&mutex, NULL);
-	_STARPU_PTHREAD_COND_INIT(&cond, NULL);
+	_STARPU_PTHREAD_COND_INIT(&cond_progression, NULL);
+	_STARPU_PTHREAD_COND_INIT(&cond_finished, NULL);
 	new_requests = _starpu_mpi_req_list_new();
 
 	_STARPU_PTHREAD_MUTEX_INIT(&detached_requests_mutex, NULL);
@@ -748,7 +779,7 @@ int _starpu_mpi_initialize(int initialize_mpi, int *rank, int *world_size)
 
 	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	while (!running)
-		_STARPU_PTHREAD_COND_WAIT(&cond, &mutex);
+		_STARPU_PTHREAD_COND_WAIT(&cond_progression, &mutex);
 	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 
         if (rank && world_size) {
@@ -790,7 +821,7 @@ int starpu_mpi_shutdown(void)
 	/* kill the progression thread */
 	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	running = 0;
-	_STARPU_PTHREAD_COND_BROADCAST(&cond);
+	_STARPU_PTHREAD_COND_BROADCAST(&cond_progression);
 	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 
 	pthread_join(progress_thread, &value);

+ 2 - 1
mpi/starpu_mpi.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2011  Université de Bordeaux 1
+ * Copyright (C) 2009-2012  Université de Bordeaux 1
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -42,6 +42,7 @@ int starpu_mpi_shutdown(void);
 
 int starpu_mpi_insert_task(MPI_Comm comm, struct starpu_codelet *codelet, ...);
 void starpu_mpi_get_data_on_node(MPI_Comm comm, starpu_data_handle_t data_handle, int node);
+void starpu_mpi_get_data_on_node_detached(MPI_Comm comm, starpu_data_handle_t data_handle, int node, void (*callback)(void*), void *arg);
 void starpu_mpi_redux_data(MPI_Comm comm, starpu_data_handle_t data_handle);
 
 int starpu_mpi_scatter_detached(starpu_data_handle_t *data_handles, int count, int root, MPI_Comm comm);

+ 26 - 5
mpi/starpu_mpi_insert_task.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011, 2012  Centre National de la Recherche Scientifique
- * Copyright (C) 2011  Université de Bordeaux 1
+ * Copyright (C) 2011-2012  Université de Bordeaux 1
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -410,24 +410,45 @@ int starpu_mpi_insert_task(MPI_Comm comm, struct starpu_codelet *codelet, ...)
         return 0;
 }
 
+void starpu_mpi_get_data_on_node_detached(MPI_Comm comm, starpu_data_handle_t data_handle, int node, void (*callback)(void*), void *arg)
+{
+        int me, rank, tag;
+
+        rank = starpu_data_get_rank(data_handle);
+        tag = starpu_data_get_tag(data_handle);
+	MPI_Comm_rank(comm, &me);
+
+        if (node == rank) return;
+
+        if (me == node)
+        {
+		starpu_mpi_irecv_detached(data_handle, rank, tag, comm, callback, arg);
+        }
+        else if (me == rank)
+        {
+		starpu_mpi_isend_detached(data_handle, node, tag, comm, NULL, NULL);
+        }
+}
+
 void starpu_mpi_get_data_on_node(MPI_Comm comm, starpu_data_handle_t data_handle, int node)
 {
-        int me, rank;
+        int me, rank, tag;
 
         rank = starpu_data_get_rank(data_handle);
+        tag = starpu_data_get_tag(data_handle);
 	MPI_Comm_rank(comm, &me);
 
         if (node == rank) return;
 
         if (me == node)
         {
-                starpu_mpi_irecv_detached(data_handle, rank, 42, comm, NULL, NULL);
+                MPI_Status status;
+                starpu_mpi_recv(data_handle, rank, tag, comm, &status);
         }
         else if (me == rank)
         {
-                starpu_mpi_isend_detached(data_handle, node, 42, comm, NULL, NULL);
+                starpu_mpi_send(data_handle, node, tag, comm);
         }
-        starpu_task_wait_for_all();
 }
 
 void starpu_mpi_redux_data(MPI_Comm comm, starpu_data_handle_t data_handle)

+ 2 - 1
mpi/starpu_mpi_insert_task_cache.c

@@ -89,6 +89,7 @@ void _starpu_mpi_clear_cache_request(starpu_data_handle_t data_handle, int rank,
 
         task->callback_func = _starpu_mpi_clear_cache_callback;
         task->callback_arg = clear_cache;
-        starpu_task_submit(task);
+        int ret = starpu_task_submit(task);
+        STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 }
 

+ 4 - 7
mpi/starpu_mpi_private.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010  Université de Bordeaux 1
+ * Copyright (C) 2010, 2012  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -31,8 +31,7 @@
 #ifdef STARPU_MPI_VERBOSE
 #  define _STARPU_MPI_DEBUG(fmt, args ...) do { if (!getenv("STARPU_SILENT")) { \
     						int _debug_rank; MPI_Comm_rank(MPI_COMM_WORLD, &_debug_rank);       \
-                                                int yyy; for(yyy=0 ; yyy<=_debug_rank ; yyy++) fprintf(stderr, "    ");    \
-                                                fprintf(stderr, "[%d][starpu_mpi][%s] " fmt , _debug_rank, __func__ ,##args); \
+                                                fprintf(stderr, "%*s[%d][starpu_mpi][%s] " fmt , (_debug_rank+1)*4, "", _debug_rank, __func__ ,##args); \
                                                 fflush(stderr); }} while(0);
 #else
 #  define _STARPU_MPI_DEBUG(fmt, args ...)
@@ -41,13 +40,11 @@
 #ifdef STARPU_MPI_VERBOSE0
 #  define _STARPU_MPI_LOG_IN()             do { if (!getenv("STARPU_SILENT")) { \
                                                int _debug_rank; MPI_Comm_rank(MPI_COMM_WORLD, &_debug_rank);                        \
-                                               int yyy; for(yyy=0 ; yyy<=_debug_rank ; yyy++) fprintf(stderr, "    ");      \
-                                               fprintf(stderr, "[%d][starpu_mpi][%s] -->\n", _debug_rank, __func__ ); \
+                                               fprintf(stderr, "%*s[%d][starpu_mpi][%s] -->\n", (_debug_rank+1)*4, "", _debug_rank, __func__ ); \
                                                fflush(stderr); }} while(0)
 #  define _STARPU_MPI_LOG_OUT()            do { if (!getenv("STARPU_SILENT")) { \
                                                int _debug_rank; MPI_Comm_rank(MPI_COMM_WORLD, &_debug_rank);                        \
-                                               int yyy; for(yyy=0 ; yyy<=rank ; yyy++) fprintf(stderr, "    ");      \
-                                               fprintf(stderr, "[%d][starpu_mpi][%s] <--\n", _debug_rank, __func__ ); \
+                                               fprintf(stderr, "%*s[%d][starpu_mpi][%s] <--\n", (_debug_rank+1)*4, "", _debug_rank, __func__ ); \
                                                fflush(stderr); }} while(0)
 #else
 #  define _STARPU_MPI_LOG_IN()

+ 18 - 19
mpi/tests/insert_task_owner2.c

@@ -59,26 +59,15 @@ int main(int argc, char **argv)
 	ret = starpu_mpi_initialize_extended(&rank, &size);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize_extended");
 
-        if (rank > 1)
-	{
-                starpu_mpi_shutdown();
-                starpu_shutdown();
-                return STARPU_TEST_SKIPPED;
-        }
-
         if (rank == 0)
 	{
                 for(i=0 ; i<3 ; i++)
 		{
                         x[i] = 10*(i+1);
                         starpu_variable_data_register(&data_handles[i], 0, (uintptr_t)&x[i], sizeof(x[i]));
-                        starpu_data_set_rank(data_handles[i], rank);
-			starpu_data_set_tag(data_handles[i], i);
                 }
                 y = -1;
                 starpu_variable_data_register(&data_handles[3], -1, (uintptr_t)NULL, sizeof(int));
-                starpu_data_set_rank(data_handles[3], 1);
-		starpu_data_set_tag(data_handles[3], 3);
         }
         else if (rank == 1)
 	{
@@ -86,16 +75,24 @@ int main(int argc, char **argv)
 		{
                         x[i] = -1;
                         starpu_variable_data_register(&data_handles[i], -1, (uintptr_t)NULL, sizeof(int));
-                        starpu_data_set_rank(data_handles[i], 0);
-			starpu_data_set_tag(data_handles[i], i);
                 }
                 y=200;
                 starpu_variable_data_register(&data_handles[3], 0, (uintptr_t)&y, sizeof(int));
-                starpu_data_set_rank(data_handles[3], rank);
-		starpu_data_set_tag(data_handles[3], 3);
-        }
+        } else
+	{
+                for(i=0 ; i<4 ; i++)
+                        starpu_variable_data_register(&data_handles[i], -1, (uintptr_t)NULL, sizeof(int));
+	}
         FPRINTF(stderr, "[%d][init] VALUES: %d %d %d %d\n", rank, x[0], x[1], x[2], y);
 
+	for(i=0 ; i<3 ; i++)
+	{
+		starpu_data_set_rank(data_handles[i], 0);
+		starpu_data_set_tag(data_handles[i], i);
+	}
+	starpu_data_set_rank(data_handles[3], 1);
+	starpu_data_set_tag(data_handles[3], 3);
+
         err = starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet,
                                      STARPU_R, data_handles[0], STARPU_RW, data_handles[1],
                                      STARPU_W, data_handles[2],
@@ -107,9 +104,11 @@ int main(int argc, char **argv)
         int *values = malloc(4 * sizeof(int *));
         for(i=0 ; i<4 ; i++)
 	{
-                starpu_mpi_get_data_on_node(MPI_COMM_WORLD, data_handles[i], 0);
-                starpu_data_acquire(data_handles[i], STARPU_R);
-                values[i] = *((int *)starpu_mpi_handle_to_ptr(data_handles[i]));
+                starpu_mpi_get_data_on_node_detached(MPI_COMM_WORLD, data_handles[i], 0, NULL, NULL);
+		if (rank == 0) {
+			starpu_data_acquire(data_handles[i], STARPU_R);
+			values[i] = *((int *)starpu_mpi_handle_to_ptr(data_handles[i]));
+		}
         }
         FPRINTF(stderr, "[%d][local ptr] VALUES: %d %d %d %d\n", rank, values[0], values[1], values[2], values[3]);
         FPRINTF(stderr, "[%d][end] VALUES: %d %d %d %d\n", rank, x[0], x[1], x[2], y);

+ 19 - 20
mpi/tests/insert_task_owner_data.c

@@ -49,33 +49,28 @@ int main(int argc, char **argv)
 	ret = starpu_mpi_initialize_extended(&rank, &size);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize_extended");
 
-        if (rank > 1)
-	{
-                starpu_mpi_shutdown();
-                starpu_shutdown();
-                return STARPU_TEST_SKIPPED;
-        }
-
         if (rank == 0)
 	{
 		x[0] = 11;
 		starpu_variable_data_register(&data_handles[0], 0, (uintptr_t)&x[0], sizeof(x[0]));
-		starpu_data_set_rank(data_handles[0], 0);
-		starpu_data_set_tag(data_handles[0], 0);
 		starpu_variable_data_register(&data_handles[1], -1, (uintptr_t)NULL, sizeof(x[1]));
-		starpu_data_set_rank(data_handles[1], 1);
-		starpu_data_set_tag(data_handles[1],10);
         }
         else if (rank == 1)
 	{
 		x[1] = 12;
 		starpu_variable_data_register(&data_handles[0], -1, (uintptr_t)NULL, sizeof(x[0]));
-		starpu_data_set_rank(data_handles[0], 0);
-		starpu_data_set_tag(data_handles[0], 0);
 		starpu_variable_data_register(&data_handles[1], 0, (uintptr_t)&x[1], sizeof(x[1]));
-		starpu_data_set_rank(data_handles[1], 1);
-		starpu_data_set_tag(data_handles[1], 1);
         }
+	else
+	{
+		starpu_variable_data_register(&data_handles[0], -1, (uintptr_t)NULL, sizeof(x[0]));
+		starpu_variable_data_register(&data_handles[1], -1, (uintptr_t)NULL, sizeof(x[1]));
+        }
+
+	starpu_data_set_rank(data_handles[0], 0);
+	starpu_data_set_tag(data_handles[0], 0);
+	starpu_data_set_rank(data_handles[1], 1);
+	starpu_data_set_tag(data_handles[1], 1);
 
         err = starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet,
                                      STARPU_RW, data_handles[0], STARPU_RW, data_handles[1],
@@ -86,16 +81,20 @@ int main(int argc, char **argv)
 
         for(i=0 ; i<2 ; i++)
 	{
-                starpu_mpi_get_data_on_node(MPI_COMM_WORLD, data_handles[i], 0);
-                starpu_data_acquire(data_handles[i], STARPU_R);
-                values[i] = *((int *)starpu_mpi_handle_to_ptr(data_handles[i]));
+                starpu_mpi_get_data_on_node_detached(MPI_COMM_WORLD, data_handles[i], 0, NULL, NULL);
+		if (rank == 0) {
+			starpu_data_acquire(data_handles[i], STARPU_R);
+			values[i] = *((int *)starpu_mpi_handle_to_ptr(data_handles[i]));
+		}
         }
-	assert(values[0] == 12 && values[1] == 144);
         FPRINTF(stderr, "[%d][local ptr] VALUES: %d %d\n", rank, values[0], values[1]);
+	ret = 0;
+	if (rank == 0 && (values[0] != 12 || values[1] != 144))
+		ret = EXIT_FAILURE;
 
 	starpu_mpi_shutdown();
 	starpu_shutdown();
 
-	return 0;
+	return ret;
 }
 

+ 2 - 1
mpi/tests/ring.c

@@ -52,7 +52,8 @@ void increment_token(void)
 	task->handles[0] = token_handle;
 	task->synchronous = 1;
 
-	starpu_task_submit(task);
+	int ret = starpu_task_submit(task);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 }
 
 int main(int argc, char **argv)

+ 2 - 1
mpi/tests/ring_async.c

@@ -52,7 +52,8 @@ void increment_token(void)
 	task->handles[0] = token_handle;
 	task->synchronous = 1;
 
-	starpu_task_submit(task);
+	int ret = starpu_task_submit(task);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 }
 
 int main(int argc, char **argv)

+ 2 - 1
mpi/tests/ring_async_implicit.c

@@ -51,7 +51,8 @@ void increment_token(void)
 	task->cl = &increment_cl;
 	task->handles[0] = token_handle;
 
-	starpu_task_submit(task);
+	int ret = starpu_task_submit(task);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 }
 
 int main(int argc, char **argv)

+ 2 - 0
socl/src/init.c

@@ -27,6 +27,8 @@ __attribute__((constructor)) static void socl_init() {
   starpu_conf_init(&conf);
   conf.ncuda = 0;
   putenv("STARPU_NCUDA=0");
+  putenv("STARPU_NOPENCL=1");
+  putenv("STARPU_NCPUS=0");
 
   mem_object_init();
 

+ 1 - 1
src/Makefile.am

@@ -118,7 +118,7 @@ noinst_HEADERS = 						\
 	top/starpu_top_connection.h				\
 	top/starpu_top_core.h
 
-libstarpu_@STARPU_EFFECTIVE_VERSION@_la_SOURCES = 		\
+libstarpu_@STARPU_EFFECTIVE_VERSION@_la_SOURCES = 						\
 	common/barrier.c					\
 	common/barrier_counter.c				\
 	common/hash.c 						\

+ 2 - 2
src/core/dependencies/htable.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2011  Université de Bordeaux 1
+ * Copyright (C) 2009-2012  Université de Bordeaux 1
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -170,7 +170,7 @@ void *_starpu_htbl_remove_tag(struct _starpu_htbl_node **htbl, starpu_tag_t tag)
 				break;
 
 			/* we remove this node */
-			//free(path[level]);
+			free(path[level]);
 			*(path_parent[level]) = NULL;
 		}
 	}

+ 6 - 4
src/core/perfmodel/perfmodel.c

@@ -277,8 +277,10 @@ double starpu_task_expected_conversion_time(struct starpu_task *task,
 		else if (arch >= STARPU_OPENCL_DEFAULT && arch < STARPU_GORDON_DEFAULT)
 			node = opencl_node;
 #endif
-		else
+		else {
+			node = -EINVAL;
 			STARPU_ASSERT(0);
+		}
 
 		if (!_starpu_handle_needs_conversion_task(handle, node))
 			continue;
@@ -337,7 +339,7 @@ double starpu_task_expected_data_transfer_time(uint32_t memory_node, struct star
 }
 
 /* Return the expected duration of the entire task bundle in µs */
-double _starpu_task_bundle_expected_length(starpu_task_bundle_t bundle, enum starpu_perf_archtype arch, unsigned nimpl)
+double starpu_task_bundle_expected_length(starpu_task_bundle_t bundle, enum starpu_perf_archtype arch, unsigned nimpl)
 {
 	double expected_length = 0.0;
 
@@ -365,7 +367,7 @@ double _starpu_task_bundle_expected_length(starpu_task_bundle_t bundle, enum sta
 }
 
 /* Return the expected power consumption of the entire task bundle in J */
-double _starpu_task_bundle_expected_power(starpu_task_bundle_t bundle, enum starpu_perf_archtype arch, unsigned nimpl)
+double starpu_task_bundle_expected_power(starpu_task_bundle_t bundle, enum starpu_perf_archtype arch, unsigned nimpl)
 {
 	double expected_power = 0.0;
 
@@ -393,7 +395,7 @@ double _starpu_task_bundle_expected_power(starpu_task_bundle_t bundle, enum star
 }
 
 /* Return the time (in µs) expected to transfer all data used within the bundle */
-double _starpu_task_bundle_expected_data_transfer_time(starpu_task_bundle_t bundle, unsigned memory_node)
+double starpu_task_bundle_expected_data_transfer_time(starpu_task_bundle_t bundle, unsigned memory_node)
 {
 	_STARPU_PTHREAD_MUTEX_LOCK(&bundle->mutex);
 

+ 0 - 6
src/core/perfmodel/perfmodel.h

@@ -66,12 +66,6 @@ void _starpu_create_sampling_directory_if_needed(void);
 void _starpu_load_bus_performance_files(void);
 double _starpu_predict_transfer_time(unsigned src_node, unsigned dst_node, size_t size);
 
-/* Return the expected duration of the entire task bundle in µs. */
-double _starpu_task_bundle_expected_length(starpu_task_bundle_t bundle, enum starpu_perf_archtype arch, unsigned nimpl);
-/* Return the time (in µs) expected to transfer all data used within the bundle */
-double _starpu_task_bundle_expected_data_transfer_time(starpu_task_bundle_t bundle, unsigned memory_node);
-/* Return the expected power consumption of the entire task bundle in J. */
-double _starpu_task_bundle_expected_power(starpu_task_bundle_t bundle, enum starpu_perf_archtype arch, unsigned nimpl);
 
 void _starpu_set_calibrate_flag(unsigned val);
 unsigned _starpu_get_calibrate_flag(void);

+ 2 - 2
src/core/perfmodel/perfmodel_bus.c

@@ -1111,8 +1111,8 @@ static void check_bus_config_file()
         else
 	{
                 FILE *f;
-                int ret, read_cuda, read_opencl;
-                unsigned read_cpus;
+                int ret, read_cuda = -1, read_opencl = -1;
+                unsigned read_cpus = -1;
                 struct _starpu_machine_config *config = _starpu_get_machine_config();
 
                 // Loading configuration from file

+ 2 - 1
src/core/task.c

@@ -228,7 +228,6 @@ int _starpu_submit_job(struct _starpu_job *j)
 	j->submitted = 1;
 
 	int ret = _starpu_enforce_deps_and_schedule(j);
-	_STARPU_PTHREAD_MUTEX_UNLOCK(&j->sync_mutex);
 
         _STARPU_LOG_OUT();
         return ret;
@@ -733,6 +732,8 @@ _starpu_handle_needs_conversion_task(starpu_data_handle_t handle,
 		default:
 			STARPU_ASSERT(0);
 	}
+	/* that instruction should never be reached */
+	return -EINVAL;
 }
 
 starpu_cpu_func_t _starpu_task_get_cpu_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)

+ 3 - 3
src/datawizard/interfaces/bcsr_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010-2011  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -261,8 +261,8 @@ static size_t bcsr_interface_get_size(starpu_data_handle_t handle)
 /* returns the size of the allocated area */
 static ssize_t allocate_bcsr_buffer_on_node(void *data_interface_, uint32_t dst_node)
 {
-	uintptr_t addr_nzval;
-	uint32_t *addr_colind, *addr_rowptr;
+	uintptr_t addr_nzval = 0;
+	uint32_t *addr_colind = NULL, *addr_rowptr = NULL;
 	ssize_t allocated_memory;
 
 	/* we need the 3 arrays to be allocated */

+ 2 - 2
src/datawizard/interfaces/csr_interface.c

@@ -238,8 +238,8 @@ static size_t csr_interface_get_size(starpu_data_handle_t handle)
 /* returns the size of the allocated area */
 static ssize_t allocate_csr_buffer_on_node(void *data_interface_, uint32_t dst_node)
 {
-	uintptr_t addr_nzval;
-	uint32_t *addr_colind, *addr_rowptr;
+	uintptr_t addr_nzval = 0;
+	uint32_t *addr_colind = NULL, *addr_rowptr = NULL;
 	ssize_t allocated_memory;
 
 	/* we need the 3 arrays to be allocated */

+ 4 - 1
src/datawizard/interfaces/data_interface.c

@@ -475,7 +475,7 @@ static void _starpu_data_unregister(starpu_data_handle_t handle, unsigned cohere
 			void *buffers[1];
 			struct starpu_multiformat_interface *format_interface;
 			format_interface = (struct starpu_multiformat_interface *) starpu_data_get_interface_on_node(handle, 0);
-			struct starpu_codelet *cl;
+			struct starpu_codelet *cl = NULL;
 			enum starpu_node_kind node_kind = starpu_node_get_kind(handle->mf_node);
 
 			struct starpu_multiformat_data_interface_ops *mf_ops;
@@ -520,6 +520,7 @@ static void _starpu_data_unregister(starpu_data_handle_t handle, unsigned cohere
 	_STARPU_PTHREAD_MUTEX_LOCK(&handle->busy_mutex);
 	while (handle->busy_count)
 		_STARPU_PTHREAD_COND_WAIT(&handle->busy_cond, &handle->busy_mutex);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&handle->busy_mutex);
 
 	/* Wait for finished requests to release the handle */
 	_starpu_spin_lock(&handle->header_lock);
@@ -536,6 +537,8 @@ static void _starpu_data_unregister(starpu_data_handle_t handle, unsigned cohere
 	_starpu_data_requester_list_delete(handle->req_list);
 	_starpu_data_requester_list_delete(handle->reduction_req_list);
 
+	_starpu_spin_unlock(&handle->header_lock);
+
 	free(handle);
 }
 

+ 2 - 9
src/datawizard/interfaces/multiformat_interface.c

@@ -129,6 +129,7 @@ static void *multiformat_handle_to_pointer(starpu_data_handle_t handle, uint32_t
 		default:
 			STARPU_ASSERT(0);
 	}
+	return NULL;
 }
 
 static void register_multiformat_handle(starpu_data_handle_t handle, uint32_t home_node, void *data_interface)
@@ -173,24 +174,16 @@ void starpu_multiformat_data_register(starpu_data_handle_t *handleptr,
 				      uint32_t nobjects,
 				      struct starpu_multiformat_data_interface_ops *format_ops)
 {
-#ifdef STARPU_USE_OPENCL
 	_starpu_codelet_check_deprecated_fields(format_ops->cpu_to_opencl_cl);
 	_starpu_codelet_check_deprecated_fields(format_ops->opencl_to_cpu_cl);
-#endif
-#ifdef STARPU_USE_CUDA
 	_starpu_codelet_check_deprecated_fields(format_ops->cpu_to_cuda_cl);
 	_starpu_codelet_check_deprecated_fields(format_ops->cuda_to_cpu_cl);
-#endif
 
 	struct starpu_multiformat_interface multiformat =
 	{
 		.cpu_ptr    = ptr,
-#ifdef STARPU_USE_CUDA
 		.cuda_ptr   = NULL,
-#endif
-#ifdef STARPu_USE_OPENCL
 		.opencl_ptr = NULL,
-#endif
 		.nx         = nobjects,
 		.ops        = format_ops
 	};
@@ -288,7 +281,7 @@ static ssize_t allocate_multiformat_buffer_on_node(void *data_interface_, uint32
 	multiformat_interface = (struct starpu_multiformat_interface *) data_interface_;
 	unsigned fail = 0;
 	uintptr_t addr = 0;
-	ssize_t allocated_memory;
+	ssize_t allocated_memory = 0;
 
 	enum starpu_node_kind kind = starpu_node_get_kind(dst_node);
 	switch(kind)

+ 1 - 0
src/top/starpu_top_connection.c

@@ -96,6 +96,7 @@ void * message_to_ui(void * p)
 			}
 		}
 	}
+	return NULL;
 }
 
 void _starpu_top_communications_threads_launcher()

+ 1 - 1
tests/Makefile.am

@@ -96,7 +96,7 @@ if !STARPU_HAVE_WINDOWS
 ## test loader program
 LOADER			=	loader
 LOADER_BIN		=	$(abs_top_builddir)/tests/$(LOADER)
-TESTS_ENVIRONMENT	=	top_builddir="$(abs_top_builddir)" $(LOADER_BIN)
+TESTS_ENVIRONMENT	=	top_builddir="$(abs_top_builddir)" top_srcdir="$(abs_top_srcdir)" $(LOADER_BIN)
 endif
 
 TESTS = $(noinst_PROGRAMS)

+ 0 - 2
tests/datawizard/acquire_cb_insert.c

@@ -18,8 +18,6 @@
 #include <starpu.h>
 #include "../helper.h"
 
-#warning memory leak
-
 #define N 16
 #define M 4
 #define X 2

+ 3 - 3
tests/datawizard/acquire_release2.c

@@ -18,8 +18,6 @@
 #include <starpu.h>
 #include "../helper.h"
 
-#warning memory leak
-
 static unsigned ntasks = 40000;
 
 #ifdef STARPU_USE_CUDA
@@ -62,7 +60,9 @@ void callback(void *arg __attribute__ ((unused)))
         starpu_data_release(token_handle);
 }
 
-#warning TODO add threads
+#ifdef STARPU_DEVEL
+#  warning TODO add threads
+#endif
 
 int main(int argc, char **argv)
 {

+ 2 - 2
tests/datawizard/critical_section_with_void_interface.c

@@ -78,11 +78,11 @@ int main(int argc, char **argv)
 
 	starpu_data_unregister(void_handle);
 
-	STARPU_ASSERT(critical_var == ntasks);
+	ret = (critical_var == ntasks) ? EXIT_SUCCESS : EXIT_FAILURE;
 
 	starpu_shutdown();
 
-	return EXIT_SUCCESS;
+	STARPU_RETURN(ret);
 
 enodev:
 	fprintf(stderr, "WARNING: No one can execute this task\n");

+ 0 - 2
tests/datawizard/increment_redux.c

@@ -26,8 +26,6 @@
 #include <starpu_opencl.h>
 #endif
 
-#warning memory leak
-
 static unsigned var = 0;
 static starpu_data_handle_t handle;
 

+ 0 - 2
tests/datawizard/increment_redux_lazy.c

@@ -25,8 +25,6 @@
 #include <starpu_opencl.h>
 #endif
 
-#warning memory leak
-
 static starpu_data_handle_t handle;
 
 /*

+ 0 - 2
tests/datawizard/increment_redux_v2.c

@@ -25,8 +25,6 @@
 #include <starpu_opencl.h>
 #endif
 
-#warning memory leak
-
 static unsigned var = 0;
 static starpu_data_handle_t handle;
 

+ 2 - 0
tests/datawizard/interfaces/test_interfaces.c

@@ -194,6 +194,8 @@ get_field(struct data_interface_test_summary *s, int async, enum operation op)
 		default:
 			STARPU_ASSERT(0);
 	}
+	/* that instruction should never be reached */
+	return NULL;
 }
 
 static void

+ 0 - 2
tests/datawizard/mpi_like.c

@@ -24,8 +24,6 @@
 #define NTHREADS	4
 #define NITER		2
 
-#warning memory leak
-
 //static pthread_cond_t cond;
 //static pthread_mutex_t mutex;
 

+ 3 - 4
tests/datawizard/mpi_like_async.c

@@ -26,8 +26,6 @@
 static int nthreads = NTHREADS_DEFAULT;
 static int niter = NITER_DEFAULT;
 
-#warning memory leaks
-
 //#define DEBUG_MESSAGES	1
 
 //static pthread_cond_t cond;
@@ -359,10 +357,11 @@ int main(int argc, char **argv)
 	/* We check that the value in the "last" thread is valid */
 	starpu_data_handle_t last_handle = problem_data[nthreads - 1].handle;
 	starpu_data_acquire(last_handle, STARPU_R);
+	ret = EXIT_SUCCESS;
 	if (problem_data[nthreads - 1].val != (nthreads * niter))
 	{
 		FPRINTF(stderr, "Final value : %u should be %d\n", problem_data[nthreads - 1].val, (nthreads * niter));
-		STARPU_ABORT();
+		ret = EXIT_FAILURE;
 	}
 	starpu_data_release(last_handle);
 
@@ -373,5 +372,5 @@ int main(int argc, char **argv)
 
 	starpu_shutdown();
 
-	return EXIT_SUCCESS;
+	STARPU_RETURN(ret);
 }

+ 0 - 2
tests/datawizard/scratch.c

@@ -23,8 +23,6 @@
 #include <stdlib.h>
 #include "../helper.h"
 
-#warning memory leaks
-
 #define NLOOPS		128
 #define VECTORSIZE	1024
 

+ 0 - 2
tests/datawizard/sync_with_data_with_mem.c

@@ -22,8 +22,6 @@
 #include <stdlib.h>
 #include "../helper.h"
 
-#warning memory leak
-
 #define NBUFFERS_DEF	64
 #define NITER_DEF	128
 #define VECTORSIZE_DEF	1024

+ 0 - 2
tests/datawizard/sync_with_data_with_mem_non_blocking.c

@@ -23,8 +23,6 @@
 #include <pthread.h>
 #include "../helper.h"
 
-#warning memory leak
-
 #define NBUFFERS_DEF	64
 #define NITER_DEF	128
 #define VECTORSIZE_DEF	1024

+ 0 - 2
tests/datawizard/sync_with_data_with_mem_non_blocking_implicit.c

@@ -23,8 +23,6 @@
 #include <pthread.h>
 #include "../helper.h"
 
-#warning memory leak
-
 #define NBUFFERS_DEF	64
 #define NITER_DEF	128
 #define VECTORSIZE_DEF	1024

+ 1 - 0
tests/errorcheck/invalid_tasks.c

@@ -17,6 +17,7 @@
 
 #include <starpu.h>
 #include "../helper.h"
+#include <common/config.h>
 
 #if !defined(STARPU_HAVE_UNSETENV) || !defined(STARPU_USE_CPU)
 #warning unsetenv is not defined or no cpu are available. Skipping test

+ 2 - 2
tests/errorcheck/starpu_init_noworker.c

@@ -20,10 +20,10 @@
 #include <errno.h>
 #include <starpu.h>
 #include <stdlib.h>
+#include "../helper.h"
 
 #if !defined(STARPU_HAVE_UNSETENV)
 #warning unsetenv is not defined. Skipping test
-#include "../helper.h"
 int main(int argc, char **argv)
 {
 	return STARPU_TEST_SKIPPED;
@@ -38,7 +38,7 @@ static void unset_env_variables(void)
 
 int main(int argc, char **argv)
 {
-	int ret;	
+	int ret;
 
 	unset_env_variables();
 

+ 1 - 1
tests/helper.h

@@ -40,7 +40,7 @@
 #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
 
 #ifdef STARPU_HAVE_VALGRIND_H
-static int _starpu_valgrind_print_once = 0;
+static int _starpu_valgrind_print_once STARPU_ATTRIBUTE_UNUSED = 0;
 
 #  define STARPU_SKIP_IF_VALGRIND \
 	do \

+ 21 - 0
tests/loader.c

@@ -120,6 +120,24 @@ static void test_cleaner(int sig)
 	exit(EXIT_FAILURE);
 }
 
+static void decode(char **src, char *motif, char *value)
+{
+     if (*src) {
+	  char *y = strstr(*src, motif);
+	  while (y) {
+	       char *neo = malloc((strlen(*src)-strlen(motif)+strlen(value)) * sizeof(char));
+	       char *to = neo;
+
+	       to = strncpy(to, *src, strlen(*src)-strlen(y)); to += strlen(*src)-strlen(y);
+	       to = strcpy(to, value); to += strlen(value);
+	       to = stpcpy(to, y+strlen(motif));
+
+	       *src = strdup(neo);
+	       y = strstr(*src, motif);
+	  }
+     }
+}
+
 int main(int argc, char *argv[])
 {
 	int   child_exit_status;
@@ -128,6 +146,7 @@ int main(int argc, char *argv[])
 	int   status;
 	char *launcher;
 	char *launcher_args;
+	char *top_srcdir;
 	struct sigaction sa;
 
 	test_args = NULL;
@@ -149,6 +168,8 @@ int main(int argc, char *argv[])
 	/* get launcher program */
 	launcher=getenv("STARPU_CHECK_LAUNCHER");
 	launcher_args=getenv("STARPU_CHECK_LAUNCHER_ARGS");
+	top_srcdir = getenv("top_srcdir");
+	decode(&launcher_args, "@top_srcdir@", top_srcdir);
 
 	/* get user-defined iter_max value */
 	if (getenv("STARPU_TIMEOUT_ENV"))

+ 0 - 2
tests/main/empty_task_chain.c

@@ -20,8 +20,6 @@
 
 #define N	4
 
-#warning memory leaks
-
 int main(int argc, char **argv)
 {
 	int i, ret;

+ 0 - 2
tests/main/empty_task_sync_point_tasks.c

@@ -18,8 +18,6 @@
 #include <starpu.h>
 #include "../helper.h"
 
-#warning memory leaks
-
 static void dummy_func(void *descr[] __attribute__ ((unused)), void *arg __attribute__ ((unused)))
 {
 }

+ 0 - 2
tests/main/multithreaded_init.c

@@ -22,8 +22,6 @@
 
 #define NUM_THREADS 5
 
-#warning memory leaks
-
 void *launch_starpu(void *id)
 {
 	int ret;

+ 2 - 1
tests/main/subgraph_repeat_regenerate.c

@@ -62,19 +62,20 @@ static struct starpu_codelet dummy_codelet =
 
 static void callback_task_D(void *arg __attribute__((unused)))
 {
+	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	loop_cnt++;
 
 	if (loop_cnt == niter)
 	{
 		/* We are done */
 		taskD.regenerate = 0;
-		_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 		_STARPU_PTHREAD_COND_SIGNAL(&cond);
 		_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 	}
 	else
 	{
 		int ret;
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 		/* Let's go for another iteration */
 		ret = starpu_task_submit(&taskA);
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");

+ 87 - 0
tools/dev/experimental/name_codelets.cocci

@@ -0,0 +1,87 @@
+/*
+ * StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2012 inria
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+/*
+ * Codelets have a "name" attribute that is really useful for debugging
+ * purposes. Lots of codelets do not use this attribute though, mostly because
+ * they were written when it was not available.
+ *
+ * This semantic patch tries to add a "name" attribute when it is necessary.
+ * The chosen name is the name of the codelet variable : it should be good
+ * enough for debugging.
+ */
+virtual context
+virtual org
+virtual patch
+virtual report
+
+@initialize:python depends on org || report@
+msg = "Warning: %s has no attribute name"
+
+@found@
+identifier cl;
+position p;
+@@
+struct starpu_codelet cl@p = {
+...
+};
+
+@named depends on found@
+position found.p;
+identifier found.cl;
+expression E;
+@@
+struct starpu_codelet cl@p = {
+    .name = E,
+};
+
+// Context mode.
+@depends on found && !named && context@
+identifier found.cl;
+position found.p;
+@@
+*struct starpu_codelet cl@p = {...};
+
+// Org mode.
+@script:python depends on found && !named && org@
+cl << found.cl;
+p << found.p;
+@@
+coccilib.org.print_todo(p[0], msg % cl)
+
+// Patch mode.
+@script:python stringify depends on found && !named && patch@
+cl_name << found.cl;
+guess;
+@@
+coccinelle.guess = '"' + str(cl_name) + '"'
+
+@depends on found && !named && patch@
+position found.p;
+identifier found.cl;
+identifier stringify.guess;
+@@
+struct starpu_codelet cl@p = {
++.name = guess,
+};
+
+// Report mode.
+@script:python depends on found && !named && report@
+cl << found.cl;
+p << found.p;
+@@
+coccilib.report.print_report(p[0], msg % cl)

+ 40 - 0
tools/dev/experimental/name_codelets_test.c

@@ -0,0 +1,40 @@
+/*
+ * StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2012 inria
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+struct starpu_codelet good_beginning = {
+	.where = STARPU_CPU,
+	.name = "lol"
+};
+
+struct starpu_codelet good_middle = { 
+	.where = STARPU_CPU,
+	.name = "lol",
+	.cpu_funcs = { foo, NULL }
+};
+struct starpu_codelet good_end = {
+	.where = STARPU_CPU,
+	.name = "lol"
+};
+
+struct starpu_codelet bad =
+{
+	.where = STARPU_CPU,
+};
+
+static struct starpu_codelet bad_static =
+{
+	.where = STARPU_CPU,
+};

+ 126 - 0
tools/dev/experimental/unchecked_starpu_function_calls.cocci

@@ -0,0 +1,126 @@
+/*
+ * StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2012 inria
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+/*
+ * The return values of functions such as starpu_init(), starpu_task_submit(),
+ * starpu_task_wait() should _always_ be checked.
+ */
+
+virtual context
+virtual org
+virtual patch
+virtual report
+
+@initialize:python depends on report || org@
+msg = "Unchecked call to %s"
+
+@unchecked_starpu_func_call@
+identifier f;
+position p;
+identifier starpu_function =~ "\bstarpu_(init|task_(submit|wait))\b";
+@@
+f(...)
+{
+<+...
+starpu_function@p(...);
+...+>
+}
+
+
+// Context mode.
+@depends on unchecked_starpu_func_call && context@
+position unchecked_starpu_func_call.p;
+identifier unchecked_starpu_func_call.starpu_function;
+identifier unchecked_starpu_func_call.f;
+@@
+f(...)
+{
+<+...
+* starpu_function@p(...);
+...+>
+}
+
+// Org mode.
+@script:python depends on unchecked_starpu_func_call && org@
+f << unchecked_starpu_func_call.starpu_function;
+p << unchecked_starpu_func_call.p;
+@@
+coccilib.org.print_todo(p[0], msg % f)
+
+// Patch mode.
+@has_ret depends on unchecked_starpu_func_call@
+identifier unchecked_starpu_func_call.f;
+identifier ret;
+identifier starpu_func =~ "^starpu_";
+@@
+f(...)
+{
+...
+int ret;
+...
+ret = starpu_func(...);
+...
+}
+
+@script:python stringify depends on patch@
+function_name << unchecked_starpu_func_call.starpu_function;
+starpu_function_name;
+@@
+coccinelle.starpu_function_name = '"'+str(function_name)+'"'
+
+
+// In this rule, "ret" is probably a good choice. This should be checked when
+// reviewing the patches, though.
+@depends on unchecked_starpu_func_call && has_ret && patch@
+identifier unchecked_starpu_func_call.f;
+identifier has_ret.ret;
+identifier unchecked_starpu_func_call.starpu_function;
+identifier stringify.starpu_function_name;
+@@
+f(...)
+{
+<...
+- starpu_function(
++ ret = starpu_function(
+...);
++ STARPU_CHECK_RETURN_VALUE(ret, starpu_function_name);
+...>
+}
+
+// In this rule, we use a variable called "ret" that is probably not declared.
+// Obviously, the patches should be read before being committed !
+@depends on unchecked_starpu_func_call && !has_ret && patch@
+identifier unchecked_starpu_func_call.f;
+identifier unchecked_starpu_func_call.starpu_function;
+identifier stringify.starpu_function_name;
+@@
+f(...)
+{
+<...
+- starpu_function(
++ ret = starpu_function(
+...);
++ STARPU_CHECK_RETURN_VALUE(ret, starpu_function_name);
+...>
+}
+
+// Report mode.
+@script:python depends on unchecked_starpu_func_call && report@
+f << unchecked_starpu_func_call.starpu_function;
+p << unchecked_starpu_func_call.p;
+@@
+coccilib.report.print_report(p[0], msg % f)

+ 19 - 0
tools/dev/experimental/unchecked_starpu_function_calls_test.c

@@ -0,0 +1,19 @@
+static void
+f(void)
+{
+	int err;
+	err = starpu_task_submit(task1);
+
+	starpu_task_submit(task2);
+	return;
+}
+
+static void
+g(void)
+{
+
+	starpu_init(NULL);
+	starpu_task_submit(task);
+
+	starpu_task_wait(task);
+}

+ 9 - 0
tools/valgrind/fscanf.suppr

@@ -0,0 +1,9 @@
+{
+   fscanf error
+   Memcheck:Cond
+   fun:__GI___strncasecmp_l
+   fun:____strtod_l_internal
+   fun:_IO_vfscanf
+   fun:fscanf
+   fun:scan_reg_model
+}

+ 27 - 0
tools/valgrind/starpu.suppr

@@ -0,0 +1,27 @@
+{
+   config.running is not racy from starpu_shutdown
+   Helgrind:Race
+   fun:starpu_shutdown
+   fun:main
+}
+
+{
+   config.running is not racy from _starpu_machine_is_running
+   Helgrind:Race
+   fun:_starpu_machine_is_running
+   ...
+}
+
+{
+   don't care about cache hit stats
+   Helgrind:Race
+   fun:_starpu_msi_cache_hit
+   ...
+}
+
+{
+   don't care about cache miss stats
+   Helgrind:Race
+   fun:_starpu_msi_cache_miss
+   ...
+}