Sfoglia il codice sorgente

merge trunk@7271:7296

Nathalie Furmento 12 anni fa
parent
commit
2d5cee21db
29 ha cambiato i file con 290 aggiunte e 70 eliminazioni
  1. 9 3
      configure.ac
  2. 4 4
      examples/filters/custom_mf/custom_interface.c
  3. 3 3
      examples/heat/dw_factolu_kernels.c
  4. 2 4
      examples/interface/complex_interface.c
  5. 3 3
      examples/lu/xlu_kernels.c
  6. 2 1
      gcc-plugin/examples/cholesky/cholesky_kernels.c
  7. 7 1
      gcc-plugin/src/starpu.c
  8. 1 0
      gcc-plugin/tests/Makefile.am
  9. 2 2
      mpi/Makefile.am
  10. 2 1
      mpi/examples/cholesky/mpi_cholesky_kernels.c
  11. 3 3
      mpi/examples/mpi_lu/pxlu_kernels.c
  12. 3 2
      src/core/perfmodel/perfmodel.c
  13. 2 0
      src/core/perfmodel/perfmodel.h
  14. 2 0
      src/core/perfmodel/perfmodel_bus.c
  15. 61 0
      src/core/perfmodel/perfmodel_history.c
  16. 6 6
      src/top/starpu_top.c
  17. 0 2
      src/top/starpu_top_connection.c
  18. 5 5
      tests/datawizard/interfaces/bcsr/bcsr_interface.c
  19. 3 3
      tests/datawizard/interfaces/block/block_interface.c
  20. 2 2
      tests/datawizard/interfaces/csr/csr_interface.c
  21. 2 2
      tests/datawizard/interfaces/matrix/matrix_interface.c
  22. 2 2
      tests/datawizard/interfaces/multiformat/multiformat_interface.c
  23. 0 14
      tests/datawizard/interfaces/test_interfaces.c
  24. 17 2
      tests/datawizard/interfaces/test_interfaces.h
  25. 2 2
      tests/datawizard/interfaces/variable/variable_interface.c
  26. 2 2
      tests/datawizard/interfaces/vector/test_vector_interface.c
  27. 1 1
      tests/datawizard/interfaces/void/void_interface.c
  28. 102 0
      tools/dev/experimental/use_starpu_cublas_report_error.cocci
  29. 40 0
      tools/dev/experimental/use_starpu_cublas_report_error_test.c

+ 9 - 3
configure.ac

@@ -1120,6 +1120,12 @@ AC_MSG_RESULT($mpicc_path)
 AC_SUBST(MPICC, $mpicc_path)
 if test x$use_mpi = xyes; then
 	cc_or_mpicc=$mpicc_path
+        # For some reason, libtool uses gcc instead of mpicc when linking
+        # libstarpumpi.
+        # On Darwin (and maybe other systems ?) the linker will fail (undefined
+        # references to MPI_*). We manually add the required flags to fix this
+        # issue.
+        AC_SUBST(MPICC_LDFLAGS, `$mpicc_path --showme:link`)
 else
 	cc_or_mpicc=$CC
 fi
@@ -1429,9 +1435,9 @@ fi
 #                                                                             #
 ###############################################################################
 
-AC_ARG_ENABLE(build-examples, [AS_HELP_STRING([--enable-build-examples],
-			[enable building of examples])],
-			enable_build_examples=$enableval, enable_build_examples=no)
+AC_ARG_ENABLE(build-examples, [AS_HELP_STRING([--disable-build-examples],
+			[disable building of examples])],
+			enable_build_examples=$enableval, enable_build_examples=yes)
 # check stuff for examples (todo)
 AM_CONDITIONAL(BUILD_EXAMPLES, [test x$enable_build_examples != xno])
 AC_ARG_ENABLE(opengl-render, [AS_HELP_STRING([--enable-opengl-render],

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

@@ -40,10 +40,10 @@ static int copy_opencl_to_opencl(void *src_interface, unsigned src_node,
 				 void *dst_interface, unsigned dst_node);
 static int copy_ram_to_opencl_async(void *src_interface, unsigned src_node,
 				    void *dst_interface, unsigned dst_node,
-				    void *event);
+				    cl_event *event);
 static int copy_opencl_to_ram_async(void *src_interface, unsigned src_node,
 				    void *dst_interface, unsigned dst_node,
-				    void *event);
+				    cl_event *event);
 #endif /* !STARPU_USE_OPENCL */
 
 static struct starpu_data_copy_methods custom_copy_data_methods_s =
@@ -477,7 +477,7 @@ static int copy_opencl_to_opencl(void *src_interface, unsigned src_node,
 
 static int copy_ram_to_opencl_async(void *src_interface, unsigned src_node,
 				    void *dst_interface, unsigned dst_node,
-				    void *event)
+				    cl_event *event)
 {
 	ssize_t size;
 	struct custom_data_interface *src_custom, *dst_custom;
@@ -520,7 +520,7 @@ static int copy_ram_to_opencl_async(void *src_interface, unsigned src_node,
 
 static int copy_opencl_to_ram_async(void *src_interface, unsigned src_node,
 				    void *dst_interface, unsigned dst_node,
-				    void *event)
+				    cl_event *event)
 {
 	ssize_t size;
 	struct custom_data_interface *src_custom, *dst_custom;

+ 3 - 3
examples/heat/dw_factolu_kernels.c

@@ -135,7 +135,7 @@ static inline void dw_common_cpu_codelet_update_u22(void *descr[], int s, __attr
 					right, ld12, 1.0f, center, ld22);
 			status = cublasGetError();
 			if (status != CUBLAS_STATUS_SUCCESS)
-				STARPU_ABORT();
+				STARPU_CUBLAS_REPORT_ERROR(status);
 
 			cudaStreamSynchronize(starpu_cuda_get_local_stream());
 
@@ -200,7 +200,7 @@ static inline void dw_common_codelet_update_u12(void *descr[], int s, __attribut
 					1.0f, sub11, ld11, sub12, ld12);
 			status = cublasGetError();
 			if (status != CUBLAS_STATUS_SUCCESS)
-				STARPU_ABORT();
+				STARPU_CUBLAS_REPORT_ERROR(status);
 
 			cudaStreamSynchronize(starpu_cuda_get_local_stream());
 
@@ -262,7 +262,7 @@ static inline void dw_common_codelet_update_u21(void *descr[], int s, __attribut
 			cublasStrsm('R', 'U', 'N', 'U', ny21, nx21, 1.0f, sub11, ld11, sub21, ld21);
 			status = cublasGetError();
 			if (status != CUBLAS_STATUS_SUCCESS)
-				STARPU_ABORT();
+				STARPU_CUBLAS_REPORT_ERROR(status);
 
 			cudaStreamSynchronize(starpu_cuda_get_local_stream());
 

+ 2 - 4
examples/interface/complex_interface.c

@@ -238,11 +238,10 @@ static int copy_cuda_to_ram_async(void *src_interface, unsigned src_node, void *
 #endif
 
 #ifdef STARPU_USE_OPENCL
-static int copy_ram_to_opencl_async(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, void *_event)
+static int copy_ram_to_opencl_async(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cl_event *event)
 {
 	struct starpu_complex_interface *src_complex = src_interface;
 	struct starpu_complex_interface *dst_complex = dst_interface;
-	cl_event *event = (cl_event *)_event;
 	cl_int err;
 	int ret;
 
@@ -278,11 +277,10 @@ static int copy_ram_to_opencl(void *src_interface, unsigned src_node, void *dst_
         return copy_ram_to_opencl_async(src_interface, src_node, dst_interface, dst_node, NULL);
 }
 
-static int copy_opencl_to_ram_async(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, void *_event)
+static int copy_opencl_to_ram_async(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cl_event *event)
 {
 	struct starpu_complex_interface *src_complex = src_interface;
 	struct starpu_complex_interface *dst_complex = dst_interface;
-	cl_event *event = (cl_event *)_event;
 	cl_int err;
 	int ret;
 

+ 3 - 3
examples/lu/xlu_kernels.c

@@ -68,7 +68,7 @@ static inline void STARPU_LU(common_u22)(void *descr[],
 
 			status = cublasGetError();
 			if (STARPU_UNLIKELY(status != CUBLAS_STATUS_SUCCESS))
-				STARPU_ABORT();
+				STARPU_CUBLAS_REPORT_ERROR(status);
 
 			if (STARPU_UNLIKELY((cures = cudaStreamSynchronize(starpu_cuda_get_local_stream())) != cudaSuccess))
 				STARPU_CUDA_REPORT_ERROR(cures);
@@ -156,7 +156,7 @@ static inline void STARPU_LU(common_u12)(void *descr[],
 
 			status = cublasGetError();
 			if (STARPU_UNLIKELY(status != CUBLAS_STATUS_SUCCESS))
-				STARPU_ABORT();
+				STARPU_CUBLAS_REPORT_ERROR(status);
 
 			if (STARPU_UNLIKELY((cures = cudaStreamSynchronize(starpu_cuda_get_local_stream())) != cudaSuccess))
 				STARPU_CUDA_REPORT_ERROR(cures);
@@ -241,7 +241,7 @@ static inline void STARPU_LU(common_u21)(void *descr[],
 
 			status = cublasGetError();
 			if (status != CUBLAS_STATUS_SUCCESS)
-				STARPU_ABORT();
+				STARPU_CUBLAS_REPORT_ERROR(status);
 
 			cudaStreamSynchronize(starpu_cuda_get_local_stream());
 

+ 2 - 1
gcc-plugin/examples/cholesky/cholesky_kernels.c

@@ -51,7 +51,8 @@ static inline void chol_common_cpu_codelet_update_u22(const float *left, const f
 					-1.0f, left, ld21, right, ld12,
 					 1.0f, center, ld22);
 			st = cublasGetError();
-			STARPU_ASSERT(!st);
+			if (STARPU_UNLIKELY(st != CUBLAS_STATUS_SUCCESS))
+				STARPU_CUBLAS_REPORT_ERROR(st);
 
 			cudaStreamSynchronize(starpu_cuda_get_local_stream());
 

+ 7 - 1
gcc-plugin/src/starpu.c

@@ -2044,7 +2044,13 @@ handle_heap_allocated_attribute (tree *node, tree name, tree args,
 	  tree parent, try_finally, registration;
 
 #ifdef stmt_list_stack
-	  parent = VEC_last (tree, stmt_list_stack);
+# ifdef VEC_index /* 4.7 */
+	  gcc_assert (VEC_length (tree, stmt_list_stack) > 1);
+	  parent = VEC_index (tree, stmt_list_stack,
+			      VEC_length (tree, stmt_list_stack) - 2);
+# else
+#  error not ported to 4.8!
+# endif
 #else  /* 4.6 and before */
 	  parent = TREE_CHAIN (cur_stmt_list);
 #endif

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

@@ -70,6 +70,7 @@ CLEANFILES = *.gimple *.o			\
   base						\
   pointers					\
   register					\
+  registered					\
   release					\
   scalar-tasks					\
   pointer-tasks					\

+ 2 - 2
mpi/Makefile.am

@@ -75,8 +75,8 @@ lib_LTLIBRARIES = libstarpumpi-@STARPU_EFFECTIVE_VERSION@.la
 
 libstarpumpi_@STARPU_EFFECTIVE_VERSION@_la_LIBADD = $(top_builddir)/src/libstarpu-@STARPU_EFFECTIVE_VERSION@.la
 libstarpumpi_@STARPU_EFFECTIVE_VERSION@_la_LDFLAGS = $(ldflags) -no-undefined					\
-  -version-info $(LIBSTARPUMPI_INTERFACE_CURRENT):$(LIBSTARPUMPI_INTERFACE_REVISION):$(LIBSTARPUMPI_INTERFACE_AGE)
-
+  -version-info $(LIBSTARPUMPI_INTERFACE_CURRENT):$(LIBSTARPUMPI_INTERFACE_REVISION):$(LIBSTARPUMPI_INTERFACE_AGE) \
+  $(MPICC_LDFLAGS)
 noinst_HEADERS =					\
 	src/starpu_mpi_private.h				\
 	src/starpu_mpi_fxt.h				\

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

@@ -63,7 +63,8 @@ static inline void chol_common_cpu_codelet_update_u22(void *descr[], int s, __at
 					-1.0f, left, ld21, right, ld12,
 					 1.0f, center, ld22);
 			st = cublasGetError();
-			STARPU_ASSERT(!st);
+			if (STARPU_UNLIKELY(st != CUBLAS_STATUS_SUCCESS))
+				STARPU_CUBLAS_REPORT_ERROR(st);
 
 			cudaStreamSynchronize(starpu_cuda_get_local_stream());
 

+ 3 - 3
mpi/examples/mpi_lu/pxlu_kernels.c

@@ -68,7 +68,7 @@ static inline void STARPU_PLU(common_u22)(void *descr[],
 
 			status = cublasGetError();
 			if (STARPU_UNLIKELY(status != CUBLAS_STATUS_SUCCESS))
-				STARPU_ABORT();
+				STARPU_CUBLAS_REPORT_ERROR(status);
 
 			if (STARPU_UNLIKELY((cures = cudaStreamSynchronize(starpu_cuda_get_local_stream())) != cudaSuccess))
 				STARPU_CUDA_REPORT_ERROR(cures);
@@ -173,7 +173,7 @@ static inline void STARPU_PLU(common_u12)(void *descr[],
 
 			status = cublasGetError();
 			if (STARPU_UNLIKELY(status != CUBLAS_STATUS_SUCCESS))
-				STARPU_ABORT();
+				STARPU_CUBLAS_REPORT_ERROR(status);
 
 			if (STARPU_UNLIKELY((cures = cudaStreamSynchronize(starpu_cuda_get_local_stream())) != cudaSuccess))
 				STARPU_CUDA_REPORT_ERROR(cures);
@@ -280,7 +280,7 @@ static inline void STARPU_PLU(common_u21)(void *descr[],
 
 			status = cublasGetError();
 			if (status != CUBLAS_STATUS_SUCCESS)
-				STARPU_ABORT();
+				STARPU_CUBLAS_REPORT_ERROR(status);
 
 			cudaStreamSynchronize(starpu_cuda_get_local_stream());
 

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

@@ -155,14 +155,15 @@ void _starpu_load_perfmodel(struct starpu_perfmodel *model)
 	switch (model->type)
 	{
 		case STARPU_PER_ARCH:
+			_starpu_load_per_arch_based_model(model);
+			break;
 		case STARPU_COMMON:
+			_starpu_load_common_based_model(model);
 			break;
-
 		case STARPU_HISTORY_BASED:
 		case STARPU_NL_REGRESSION_BASED:
 			_starpu_load_history_based_model(model, 1);
 			break;
-
 		case STARPU_REGRESSION_BASED:
 			_starpu_load_history_based_model(model, 0);
 			break;

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

@@ -43,6 +43,8 @@ void _starpu_get_perf_model_dir_debug(char *path, size_t maxlen);
 
 double _starpu_history_based_job_expected_perf(struct starpu_perfmodel *model, enum starpu_perf_archtype arch, struct _starpu_job *j, unsigned nimpl);
 int _starpu_register_model(struct starpu_perfmodel *model);
+void _starpu_load_per_arch_based_model(struct starpu_perfmodel *model);
+void _starpu_load_common_based_model(struct starpu_perfmodel *model);
 void _starpu_load_history_based_model(struct starpu_perfmodel *model, unsigned scan_history);
 void _starpu_load_perfmodel(struct starpu_perfmodel *model);
 void _starpu_initialize_registered_performance_models(void);

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

@@ -520,7 +520,9 @@ static void measure_bandwidth_between_host_and_dev(int dev, double *dev_timing_h
 
 static void benchmark_all_gpu_devices(void)
 {
+#if defined(STARPU_USE_CUDA) || defined(STARPU_USE_OPENCL)
 	int i;
+#endif
 #ifdef HAVE_CUDA_MEMCPY_PEER
 	int j;
 #endif

+ 61 - 0
src/core/perfmodel/perfmodel_history.c

@@ -751,6 +751,67 @@ void _starpu_deinitialize_registered_performance_models(void)
 	_STARPU_PTHREAD_RWLOCK_DESTROY(&registered_models_rwlock);
 }
 
+/*
+ * XXX: We should probably factorize the beginning of the _starpu_load_*_model
+ * functions. This is a bit tricky though, because we must be sure to unlock
+ * registered_models_rwlock at the right place.
+ */
+void _starpu_load_per_arch_based_model(struct starpu_perfmodel *model)
+{
+	STARPU_ASSERT(model && model->symbol);
+
+	int already_loaded;
+
+	_STARPU_PTHREAD_RWLOCK_RDLOCK(&registered_models_rwlock);
+	already_loaded = model->is_loaded;
+	_STARPU_PTHREAD_RWLOCK_UNLOCK(&registered_models_rwlock);
+
+	if (already_loaded)
+		return;
+
+	/* The model is still not loaded so we grab the lock in write mode, and
+	 * if it's not loaded once we have the lock, we do load it. */
+	_STARPU_PTHREAD_RWLOCK_WRLOCK(&registered_models_rwlock);
+
+	/* Was the model initialized since the previous test ? */
+	if (model->is_loaded)
+	{
+		_STARPU_PTHREAD_RWLOCK_UNLOCK(&registered_models_rwlock);
+		return;
+	}
+
+	_STARPU_PTHREAD_RWLOCK_INIT(&model->model_rwlock, NULL);
+	_STARPU_PTHREAD_RWLOCK_UNLOCK(&registered_models_rwlock);
+}
+
+void _starpu_load_common_based_model(struct starpu_perfmodel *model)
+{
+	STARPU_ASSERT(model && model->symbol);
+
+	int already_loaded;
+
+	_STARPU_PTHREAD_RWLOCK_RDLOCK(&registered_models_rwlock);
+	already_loaded = model->is_loaded;
+	_STARPU_PTHREAD_RWLOCK_UNLOCK(&registered_models_rwlock);
+
+	if (already_loaded)
+		return;
+
+	/* The model is still not loaded so we grab the lock in write mode, and
+	 * if it's not loaded once we have the lock, we do load it. */
+	_STARPU_PTHREAD_RWLOCK_WRLOCK(&registered_models_rwlock);
+
+	/* Was the model initialized since the previous test ? */
+	if (model->is_loaded)
+	{
+		_STARPU_PTHREAD_RWLOCK_UNLOCK(&registered_models_rwlock);
+		return;
+	}
+
+	_STARPU_PTHREAD_RWLOCK_INIT(&model->model_rwlock, NULL);
+	_STARPU_PTHREAD_RWLOCK_UNLOCK(&registered_models_rwlock);
+}
+
 /* We first try to grab the global lock in read mode to check whether the model
  * was loaded or not (this is very likely to have been already loaded). If the
  * model was not loaded yet, we take the lock in write mode, and if the model

+ 6 - 6
src/top/starpu_top.c

@@ -157,7 +157,7 @@ void starpu_top_init_and_wait(const char* server_name)
 	sprintf(message, "%s\n", server_name);
 	_starpu_top_message_add(_starpu_top_mt,message);
 	message = (char *) malloc(25);
-	sprintf(message, "%lld\n", current_timestamp());
+	sprintf(message, "%llu\n", current_timestamp());
 	_starpu_top_message_add(_starpu_top_mt,message);
 	message = (char *) malloc(strlen("/SERVERINFO\n")+1);
 	sprintf(message,"%s", "/SERVERINFO\n");
@@ -490,7 +490,7 @@ void starpu_top_update_data_boolean(const struct starpu_top_data* data, int valu
 	{
 		char*message = (char *) malloc(256+strlen(data->name));
 		sprintf(message,
-				"U;%u;%d;%lld\n",
+				"U;%u;%d;%llu\n",
 				data->id,
 				(value?1:0),
 				current_timestamp());
@@ -506,7 +506,7 @@ void starpu_top_update_data_integer(const struct starpu_top_data* data, int valu
 	{
 		char*message = (char *) malloc(256+strlen(data->name));
 		sprintf(message,
-				"U;%u;%d;%lld\n",
+				"U;%u;%d;%llu\n",
 				data->id,
 				value,
 				current_timestamp());
@@ -522,7 +522,7 @@ void starpu_top_update_data_float(const struct starpu_top_data* data, double val
 	{
 		char*message = (char *) malloc(256+strlen(data->name));
 		sprintf(message,
-				"U;%u;%f;%lld\n",
+				"U;%u;%f;%llu\n",
 				data->id, value,
 				current_timestamp());
 		_starpu_top_message_add(_starpu_top_mt,message);
@@ -541,7 +541,7 @@ void starpu_top_update_parameter(const struct starpu_top_param* param)
 		case STARPU_TOP_PARAM_INTEGER:
 		case STARPU_TOP_PARAM_ENUM:
 			sprintf(message,
-					"SET;%u;%d;%lld\n",
+					"SET;%u;%d;%llu\n",
 					param->id,
 					*((int*)param->value),
 					current_timestamp());
@@ -549,7 +549,7 @@ void starpu_top_update_parameter(const struct starpu_top_param* param)
 
 		case STARPU_TOP_PARAM_FLOAT:
 			sprintf(message,
-					"SET;%u;%f;%lld\n",
+					"SET;%u;%f;%llu\n",
 					param->id,
 					*((double*)param->value),
 					current_timestamp());

+ 0 - 2
src/top/starpu_top_connection.c

@@ -41,8 +41,6 @@
 const char *STARPU_TOP_PORT = "2011";
 const int STARPU_TOP_BUFFER_SIZE=1024;
 
-extern struct _starpu_top_message_queue*  _starpu_top_mt;
-
 //client socket after fopen
 FILE* starpu_top_socket_fd_read;
 FILE* starpu_top_socket_fd_write;

+ 5 - 5
tests/datawizard/interfaces/bcsr/bcsr_interface.c

@@ -83,7 +83,7 @@ struct test_config bcsr_config =
 #endif /* !STARPU_USE_OPENCL */
 	.handle        = &bcsr_handle,
 	.dummy_handle  = &bcsr2_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "bcsr_interface"
 };
 
@@ -136,7 +136,7 @@ test_bcsr_cpu_func(void *buffers[], void *args)
  	uint32_t c   = ((struct starpu_bcsr_interface *)buffers[0])->c;
 	if (r != R || c != C)
 	{
-		bcsr_config.copy_failed = 1;
+		bcsr_config.copy_failed = FAILURE;
 		return;
 	}
 	nnz *= (r*c);
@@ -148,7 +148,7 @@ test_bcsr_cpu_func(void *buffers[], void *args)
 	{
 		if (val[i] != i * factor)
 		{
-			bcsr_config.copy_failed = 1;
+			bcsr_config.copy_failed = FAILURE;
 			return;
 		}
 		val[i] *= -1;
@@ -160,13 +160,13 @@ test_bcsr_cpu_func(void *buffers[], void *args)
 	uint32_t *col = STARPU_BCSR_GET_COLIND(buffers[0]);
 	for (i = 0; i < NNZ_BLOCKS; i++)
 		if (col[i] != colind[i])
-			bcsr_config.copy_failed = 1;
+			bcsr_config.copy_failed = FAILURE;
 
 	/* Check rowptr */
 	uint32_t *row = STARPU_BCSR_GET_ROWPTR(buffers[0]);
 	for (i = 0; i < 1 + WIDTH/R; i++)
 		if (row[i] != rowptr[i])
-			bcsr_config.copy_failed = 1;
+			bcsr_config.copy_failed = FAILURE;
 #endif
 }
 

+ 3 - 3
tests/datawizard/interfaces/block/block_interface.c

@@ -48,7 +48,7 @@ struct test_config block_config =
 #endif
 	.handle        = &block_handle,
 	.dummy_handle  = &block2_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "block_interface"
 };
 
@@ -107,7 +107,7 @@ static void test_block_cpu_func(void *buffers[], void *args)
 	int *block = (int *) STARPU_BLOCK_GET_PTR(buffers[0]);
 	unsigned int i, j, k;
 	int val = 0;
-	block_config.copy_failed = 0;
+	block_config.copy_failed = SUCCESS;
 	for (k = 0; k < nz; k++)
 	{
 		for (j = 0; j < ny; j++)
@@ -116,7 +116,7 @@ static void test_block_cpu_func(void *buffers[], void *args)
 			{
                                 if (block[(k*ldz)+(j*ldy)+i] != factor * val)
 				{
-					block_config.copy_failed = 1;
+					block_config.copy_failed = FAILURE;
 					return;
 				}
 				else

+ 2 - 2
tests/datawizard/interfaces/csr/csr_interface.c

@@ -59,7 +59,7 @@ struct test_config csr_config =
 #endif
 	.handle        = &csr_handle,
 	.dummy_handle  = &csr2_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "csr_interface"
 };
 
@@ -130,7 +130,7 @@ test_csr_cpu_func(void *buffers[], void *args)
 	{
 		if (val[i] != (i+1) * factor)
 		{
-			csr_config.copy_failed = 1;
+			csr_config.copy_failed = FAILURE;
 			return;
 		}
 		val[i] *= -1;

+ 2 - 2
tests/datawizard/interfaces/matrix/matrix_interface.c

@@ -48,7 +48,7 @@ struct test_config matrix_config =
 #endif
 	.handle        = &matrix_handle,
 	.dummy_handle  = &matrix2_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "matrix_interface"
 };
 
@@ -105,7 +105,7 @@ test_matrix_cpu_func(void *buffers[], void *args)
 	{
 		if (val[i] != i * factor)
 		{
-			matrix_config.copy_failed = 1;
+			matrix_config.copy_failed = FAILURE;
 			return;
 		}
 		val[i] *= -1;

+ 2 - 2
tests/datawizard/interfaces/multiformat/multiformat_interface.c

@@ -44,7 +44,7 @@ struct test_config multiformat_config =
 #endif
 	.handle        = &multiformat_handle,
 	.dummy_handle  = &multiformat_dummy_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "multiformat_interface"
 };
 
@@ -66,7 +66,7 @@ test_multiformat_cpu_func(void *buffers[], void *args)
 			FPRINTF(stderr, "(%d %d) [%d]", aos[i].x, aos[i].y, factor);
 		if (aos[i].x != i * factor || aos[i].y != i * factor)
 		{
-			multiformat_config.copy_failed = 1;
+			multiformat_config.copy_failed = FAILURE;
 		}
 		aos[i].x = -aos[i].x;
 		aos[i].y = -aos[i].y;

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

@@ -33,20 +33,6 @@ static struct test_config *current_config;
 - OpenCL to OpenCL support
 */
 
-/*
- * Users do not know about this enum. They only know that SUCCESS is 0, and
- * FAILURE is 1. Therefore, the values of SUCCESS and FAILURE shall not be
- * changed.
- */
-enum exit_code
-{
-	SUCCESS                 = 0,
-	FAILURE                 = 1,
-	UNTESTED                = 2,
-	TASK_CREATION_FAILURE   = 3,
-	TASK_SUBMISSION_FAILURE = 4
-};
-
 static char *
 enum_to_string(int exit_code)
 {

+ 17 - 2
tests/datawizard/interfaces/test_interfaces.h

@@ -18,6 +18,21 @@
 
 #include "../../helper.h"
 
+/*
+ * Users do not know about this enum. They only know that SUCCESS is 0, and
+ * FAILURE is 1. Therefore, the values of SUCCESS and FAILURE shall not be
+ * changed.
+ */
+enum exit_code
+{
+	SUCCESS                 = 0,
+	FAILURE                 = 1,
+	UNTESTED                = 2,
+	TASK_CREATION_FAILURE   = 3,
+	TASK_SUBMISSION_FAILURE = 4
+};
+
+
 struct test_config
 {
 	/* A pointer to a registered handle */
@@ -41,8 +56,8 @@ struct test_config
 #endif
 
 	/* The previous codelets must update this field at the end of their
-	 * execution. copy_failed must be 1 if the copy failed, 0 otherwise. */
-	int copy_failed;
+	 * execution. copy_failed must be FAILURE if the copy failed, SUCCESS otherwise. */
+	enum exit_code copy_failed;
 
 	/* A human-readable name for the test */
 	const char *name;

+ 2 - 2
tests/datawizard/interfaces/variable/variable_interface.c

@@ -46,7 +46,7 @@ struct test_config variable_config =
 #endif
 	.handle       = &variable_handle,
 	.dummy_handle = &variable2_handle,
-	.copy_failed  = 0,
+	.copy_failed  = SUCCESS,
 	.name         = "variable_interface"
 };
 
@@ -62,7 +62,7 @@ test_variable_cpu_func(void *buffers[], void *args)
 	factor = *(int *)args;
 
 	if (*val != 42 * factor)
-		variable_config.copy_failed = 1;
+		variable_config.copy_failed = FAILURE;
 	else
 		*val *= -1;
 }

+ 2 - 2
tests/datawizard/interfaces/vector/test_vector_interface.c

@@ -44,7 +44,7 @@ struct test_config vector_config =
 #endif
 	.handle        = &vector_handle,
 	.dummy_handle  = &vector2_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "vector_interface"
 };
 
@@ -92,7 +92,7 @@ static void test_vector_cpu_func(void *buffers[], void *args)
 	{
 		if (val[i] != i*factor)
 		{
-			vector_config.copy_failed = 1;
+			vector_config.copy_failed = FAILURE;
 			return;
 		}
 		val[i] = -val[i];

+ 1 - 1
tests/datawizard/interfaces/void/void_interface.c

@@ -37,7 +37,7 @@ struct test_config void_config =
 #endif
 	.handle        = &void_handle,
 	.dummy_handle  = &void2_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "void_interface"
 };
 

+ 102 - 0
tools/dev/experimental/use_starpu_cublas_report_error.cocci

@@ -0,0 +1,102 @@
+// 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.
+
+// When using the CUBLAS library, we call cublasGetError() from times to times.
+// If it does not return CUBLAS_STATUS_SUCCESS, we should not immediatly abort:
+// first, we need to print a useful piece of information to make it easier to
+// debug the program.
+
+virtual context
+virtual org
+virtual patch
+virtual report
+
+
+// Pattern:
+//	status = cubalsGetError();
+// 	if (status != CUBLAS_STATUS_SUCCESS)
+// 		STARPU_ABORT();
+//
+@starpu_abort@
+cublasStatus status;
+position p;
+@@
+status = cublasGetError();
+(
+if (status != CUBLAS_STATUS_SUCCESS)
+  STARPU_ABORT@p();
+|
+if (STARPU_UNLIKELY(status != CUBLAS_STATUS_SUCCESS))
+  STARPU_ABORT@p();
+)
+
+@depends on starpu_abort && context@
+position starpu_abort.p;
+@@
+* STARPU_ABORT@p();
+
+@script:python depends on starpu_abort && org@
+p << starpu_abort.p;
+@@
+coccilib.org.print_todo(p[0], "Use STARPU_CUBLAS_REPORT_ERROR() instead of STARPU_ABORT().")
+
+@depends on starpu_abort && patch@
+cublasStatus starpu_abort.status;
+position starpu_abort.p;
+@@
+- STARPU_ABORT@p();
++ STARPU_CUBLAS_REPORT_ERROR(status);
+
+@script:python depends on starpu_abort && report@
+p << starpu_abort.p;
+@@
+coccilib.report.print_report(p[0], "Use STARPU_CUBLAS_REPORT_ERROR() instead of STARPU_ABORT().")
+
+
+
+
+// Pattern:
+// 	status = cublasGetError();
+// 	STARPU_ASSERT(!status);
+@starpu_assert@
+cublasStatus status;
+position p;
+@@
+status = cublasGetError();
+STARPU_ASSERT@p(!status);
+
+@depends on starpu_assert && context@
+position starpu_assert.p;
+@@
+* STARPU_ASSERT@p(...);
+
+@script:python depends on starpu_assert && org@
+p << starpu_assert.p;
+@@
+coccilib.org.print_todo(p[0], "Use STARPU_CUBLAS_REPORT_ERROR() instead of STARPU_ASSERT().")
+
+
+@depends on starpu_assert && patch@
+position starpu_assert.p;
+cublasStatus starpu_assert.status;
+@@
+- STARPU_ASSERT@p(!status);
++ if (STARPU_UNLIKELY(status != CUBLAS_STATUS_SUCCESS))
++ 	STARPU_CUBLAS_REPORT_ERROR(status);
+
+@script:python depends on starpu_assert && report@
+p << starpu_assert.p;
+@@
+coccilib.report.print_report(p[0], "Use STARPU_CUBLAS_REPORT_ERROR() instead of STARPU_ASSERT().")

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

@@ -0,0 +1,40 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2011  Institut National de Recherche en Informatique et Automatique
+ *
+ * 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.
+ */
+
+static cublasStatus st;
+
+static void
+bad_0(void)
+{
+	st = cublasGetError();
+	if (STARPU_UNLIKELY(st != CUBLAS_STATUS_SUCCESS))
+		STARPU_ABORT();
+}
+
+static void
+bad_1(void)
+{
+	st = cublasGetError();
+	if (st != CUBLAS_STATUS_SUCCESS)
+		STARPU_ABORT();
+}
+
+static void
+bad_2(void)
+{
+	st = cublasGetError();
+	STARPU_ASSERT(!st);
+}