Browse Source

tests/: improve error checking

Nathalie Furmento 13 years ago
parent
commit
ec44ab2026
53 changed files with 843 additions and 383 deletions
  1. 1 0
      tests/Makefile.am
  2. 35 0
      tests/common/helper.h
  3. 10 7
      tests/core/declare_deps_after_submission.c
  4. 2 0
      tests/core/execute_on_a_specific_worker.c
  5. 24 20
      tests/core/tag_wait_api.c
  6. 31 18
      tests/core/task_wait_api.c
  7. 18 4
      tests/core/wait_all_regenerable_tasks.c
  8. 4 1
      tests/datawizard/acquire_cb.c
  9. 9 3
      tests/datawizard/acquire_cb_insert.c
  10. 23 6
      tests/datawizard/acquire_release.c
  11. 23 5
      tests/datawizard/acquire_release2.c
  12. 18 13
      tests/datawizard/copy.c
  13. 7 4
      tests/datawizard/critical_section_with_void_interface.c
  14. 29 7
      tests/datawizard/data_implicit_deps.c
  15. 16 14
      tests/datawizard/data_invalidation.c
  16. 18 12
      tests/datawizard/data_lookup.c
  17. 23 5
      tests/datawizard/dining_philosophers.c
  18. 18 5
      tests/datawizard/dsm_stress.c
  19. 25 12
      tests/datawizard/increment_redux.c
  20. 24 11
      tests/datawizard/increment_redux_v2.c
  21. 17 5
      tests/datawizard/lazy_allocation.c
  22. 13 8
      tests/datawizard/manual_reduction.c
  23. 19 4
      tests/datawizard/readers_and_writers.c
  24. 16 4
      tests/datawizard/reclaim.c
  25. 18 7
      tests/datawizard/scratch.c
  26. 17 7
      tests/datawizard/sync_and_notify_data.c
  27. 17 8
      tests/datawizard/sync_and_notify_data_implicit.c
  28. 28 15
      tests/datawizard/sync_with_data_with_mem.c
  29. 27 15
      tests/datawizard/sync_with_data_with_mem_non_blocking.c
  30. 27 15
      tests/datawizard/sync_with_data_with_mem_non_blocking_implicit.c
  31. 24 17
      tests/datawizard/unpartition.c
  32. 11 5
      tests/datawizard/user_interaction_implicit.c
  33. 11 10
      tests/datawizard/write_only_tmp_buffer.c
  34. 5 1
      tests/helper/cublas_init.c
  35. 7 3
      tests/helper/execute_on_all.c
  36. 8 3
      tests/helper/pinned_memory.c
  37. 19 10
      tests/helper/starpu_create_sync_task.c
  38. 7 2
      tests/helper/starpu_data_cpy.c
  39. 15 3
      tests/microbenchs/async_tasks_overhead.c
  40. 5 1
      tests/microbenchs/local_pingpong.c
  41. 14 6
      tests/microbenchs/prefetch_data_on_node.c
  42. 10 4
      tests/microbenchs/redundant_buffer.c
  43. 20 7
      tests/microbenchs/sync_tasks_overhead.c
  44. 20 5
      tests/microbenchs/tasks_overhead.c
  45. 20 9
      tests/opt/datawizard/wt_broadcast.c
  46. 17 5
      tests/opt/datawizard/wt_host.c
  47. 10 6
      tests/overlap/overlap.c
  48. 12 11
      tests/parallel_tasks/explicit_combined_worker.c
  49. 12 11
      tests/parallel_tasks/parallel_kernels.c
  50. 12 12
      tests/parallel_tasks/parallel_kernels_spmd.c
  51. 5 3
      tests/parallel_tasks/spmd_pgreedy.c
  52. 10 6
      tests/perfmodels/non_linear_regression_based.c
  53. 12 8
      tests/perfmodels/regression_based.c

+ 1 - 0
tests/Makefile.am

@@ -21,6 +21,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include/ -I$(top_builddir)/src -I$(top_srcdir)/src
 AM_LDFLAGS = $(STARPU_CUDA_LDFLAGS) $(STARPU_OPENCL_LDFLAGS)
 
 EXTRA_DIST =					\
+	common/helper.h				\
 	microbenchs/null_kernel_gordon.c	\
 	datawizard/sync_and_notify_data_gordon_kernels.c \
 	datawizard/sync_and_notify_data_opencl_codelet.cl\

+ 35 - 0
tests/common/helper.h

@@ -0,0 +1,35 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2011  Centre National de la Recherche Scientifique
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * 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.
+ */
+
+#include <errno.h>
+
+#define STARPU_TEST_SKIPPED 77
+
+//void *ALL_IS_OK = (void *)123456789L;
+//void *ALL_IS_NOT_OK = (void *)987654321L;
+//
+//#define STARPU_CHECK_MALLOC(ptr) {if (!ptr) { fprintf(stderr, "starpu_malloc failed\n"); return 1; }}
+//#define STARPU_CHECK_MALLOC_HAS_FAILED(ptr) {if (ptr) { fprintf(stderr, "starpu_malloc should have failed\n"); return 1; }}
+#define STARPU_CHECK_RETURN_VALUE(err, message) {if (err < 0) { perror(message); return 1; }}
+#define STARPU_CHECK_RETURN_VALUE_IS(err, value, message) {if (err != value) { perror(message); return 1; }}
+//
+//#define STARPU_CHECK_MALLOC_THREAD(ptr) {if (!ptr) { fprintf(stderr, "starpu_malloc failed\n"); return ALL_IS_NOT_OK; }}
+//#define STARPU_CHECK_MALLOC_HAS_FAILED_THREAD(ptr) {if (ptr) { fprintf(stderr, "starpu_malloc should have failed\n"); return ALL_IS_NOT_OK; }}
+//#define STARPU_CHECK_RETURN_VALUE_THREAD(err, message) {if (err < 0) { perror(message); return ALL_IS_NOT_OK; }}
+//#define STARPU_CHECK_RETURN_VALUE_IS_THREAD(err, value, message) {if (err >= 0 || errno != value) { perror(message); return ALL_IS_NOT_OK; }}
+
+//#define STARPU_TEST_OUTPUT
+#define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)

+ 10 - 7
tests/core/declare_deps_after_submission.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -20,6 +20,7 @@
 #include <unistd.h>
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 #define NLOOPS	128
 
@@ -51,7 +52,8 @@ int main(int argc, char **argv)
 	int ret;
 	unsigned loop;
 
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	struct starpu_task *taskA, *taskB;
 
@@ -70,21 +72,22 @@ int main(int argc, char **argv)
 		taskB->detach = 0;
 
 		ret = starpu_task_submit(taskA);
-		STARPU_ASSERT(!ret);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
 		starpu_task_declare_deps_array(taskB, 1, &taskA);
 
 		ret = starpu_task_submit(taskB);
-		STARPU_ASSERT(!ret);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
 		ret = starpu_task_wait(taskB);
-		STARPU_ASSERT(!ret);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
 		ret = starpu_task_wait(taskA);
-		STARPU_ASSERT(!ret);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	starpu_shutdown();
 

+ 2 - 0
tests/core/execute_on_a_specific_worker.c

@@ -84,6 +84,8 @@ static starpu_codelet cl = {
 
 int main(int argc, char **argv)
 {
+	int ret;
+
 	starpu_init(NULL);
 
 	starpu_malloc((void **)&v, VECTORSIZE*sizeof(unsigned));

+ 24 - 20
tests/core/tag_wait_api.c

@@ -20,6 +20,7 @@
 #include <unistd.h>
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
 
@@ -27,7 +28,7 @@ static void dummy_func(void *descr[] __attribute__ ((unused)), void *arg __attri
 {
 }
 
-static starpu_codelet dummy_codelet = 
+static starpu_codelet dummy_codelet =
 {
 	.where = STARPU_CPU|STARPU_CUDA|STARPU_OPENCL,
 	.cpu_func = dummy_func,
@@ -76,24 +77,27 @@ static struct starpu_task *create_dummy_task(starpu_tag_t tag)
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	FPRINTF(stderr, "{ A } -> { B }\n");
 	fflush(stderr);
 
 	struct starpu_task *taskA, *taskB;
-	
+
 	taskA = create_dummy_task(tagA);
 	taskB = create_dummy_task(tagB);
 
 	/* B depends on A */
 	starpu_tag_declare_deps(tagB, 1, tagA);
 
-	starpu_task_submit(taskB);
-	starpu_task_submit(taskA);
+	ret = starpu_task_submit(taskB); STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
+	ret = starpu_task_submit(taskA); STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
+
+	ret = starpu_tag_wait(tagB); STARPU_CHECK_RETURN_VALUE(ret, "starpu_wait");
 
-	starpu_tag_wait(tagB);
-	
 	FPRINTF(stderr, "{ C, D, E, F } -> { G }\n");
 
 	struct starpu_task *taskC, *taskD, *taskE, *taskF, *taskG;
@@ -107,16 +111,16 @@ int main(int argc, char **argv)
 	/* NB: we could have used starpu_tag_declare_deps_array instead */
 	starpu_tag_declare_deps(tagG, 4, tagC, tagD, tagE, tagF);
 
-	starpu_task_submit(taskC);
-	starpu_task_submit(taskD);
-	starpu_task_submit(taskG);
-	starpu_task_submit(taskE);
-	starpu_task_submit(taskF);
+	ret = starpu_task_submit(taskC); STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
+	ret = starpu_task_submit(taskD); STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
+	ret = starpu_task_submit(taskG); STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
+	ret = starpu_task_submit(taskE); STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
+	ret = starpu_task_submit(taskF); STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
 
-	starpu_tag_wait(tagG);
+	ret = starpu_tag_wait(tagG); STARPU_CHECK_RETURN_VALUE(ret, "starpu_tag_wait");
 
 	FPRINTF(stderr, "{ H, I } -> { J, K, L }\n");
-	
+
 	struct starpu_task *taskH, *taskI, *taskJ, *taskK, *taskL;
 
 	taskH = create_dummy_task(tagH);
@@ -131,13 +135,13 @@ int main(int argc, char **argv)
 
 	starpu_tag_t tagJKL[3] = {tagJ, tagK, tagL};
 
-	starpu_task_submit(taskH);
-	starpu_task_submit(taskI);
-	starpu_task_submit(taskJ);
-	starpu_task_submit(taskK);
-	starpu_task_submit(taskL);
+	ret = starpu_task_submit(taskH); STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
+	ret = starpu_task_submit(taskI); STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
+	ret = starpu_task_submit(taskJ); STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
+	ret = starpu_task_submit(taskK); STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
+	ret = starpu_task_submit(taskL); STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
 
-	starpu_tag_wait_array(3, tagJKL);
+	ret = starpu_tag_wait_array(3, tagJKL); STARPU_CHECK_RETURN_VALUE(ret, "starpu_tag_wait_array");
 
 	starpu_shutdown();
 

+ 31 - 18
tests/core/task_wait_api.c

@@ -20,6 +20,7 @@
 #include <unistd.h>
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
 
@@ -50,7 +51,10 @@ static struct starpu_task *create_dummy_task(void)
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	FPRINTF(stderr, "{ A } -> { B }\n");
 	fflush(stderr);
@@ -63,10 +67,12 @@ int main(int argc, char **argv)
 	/* B depends on A */
 	starpu_task_declare_deps_array(taskB, 1, &taskA);
 
-	starpu_task_submit(taskB);
-	starpu_task_submit(taskA);
+	ret = starpu_task_submit(taskB);
+	if (ret == -ENODEV) goto enodev;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+	ret = starpu_task_submit(taskA); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
-	starpu_task_wait(taskB);
+	ret = starpu_task_wait(taskB); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
 
 	FPRINTF(stderr, "{ C, D, E, F } -> { G }\n");
 
@@ -81,13 +87,13 @@ int main(int argc, char **argv)
 	struct starpu_task *tasksCDEF[4] = {taskC, taskD, taskE, taskF};
 	starpu_task_declare_deps_array(taskG, 4, tasksCDEF);
 
-	starpu_task_submit(taskC);
-	starpu_task_submit(taskD);
-	starpu_task_submit(taskG);
-	starpu_task_submit(taskE);
-	starpu_task_submit(taskF);
+	ret = starpu_task_submit(taskC); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+	ret = starpu_task_submit(taskD); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+	ret = starpu_task_submit(taskG); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+	ret = starpu_task_submit(taskE); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+	ret = starpu_task_submit(taskF); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
-	starpu_task_wait(taskG);
+	ret = starpu_task_wait(taskG); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
 
 	FPRINTF(stderr, "{ H, I } -> { J, K, L }\n");
 
@@ -105,17 +111,24 @@ int main(int argc, char **argv)
 	starpu_task_declare_deps_array(taskK, 2, tasksHI);
 	starpu_task_declare_deps_array(taskL, 2, tasksHI);
 
-	starpu_task_submit(taskH);
-	starpu_task_submit(taskI);
-	starpu_task_submit(taskJ);
-	starpu_task_submit(taskK);
-	starpu_task_submit(taskL);
+	ret = starpu_task_submit(taskH); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+	ret = starpu_task_submit(taskI); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+	ret = starpu_task_submit(taskJ); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+	ret = starpu_task_submit(taskK); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+	ret = starpu_task_submit(taskL); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
-	starpu_task_wait(taskJ);
-	starpu_task_wait(taskK);
-	starpu_task_wait(taskL);
+	ret = starpu_task_wait(taskJ); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
+	ret = starpu_task_wait(taskK); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
+	ret = starpu_task_wait(taskL); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
 
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 18 - 4
tests/core/wait_all_regenerable_tasks.c

@@ -20,6 +20,7 @@
 #include <unistd.h>
 #include <pthread.h>
 #include <starpu.h>
+#include "../common/helper.h"
 
 #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
 
@@ -65,13 +66,15 @@ static void parse_args(int argc, char **argv)
 
 int main(int argc, char **argv)
 {
+	int ret;
 	double timing;
 	struct timeval start;
 	struct timeval end;
 
 	parse_args(argc, argv);
 
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	struct starpu_task task[K];
 	unsigned cnt[K];;
@@ -94,10 +97,14 @@ int main(int argc, char **argv)
 
 	gettimeofday(&start, NULL);
 	
-	for (i = 0; i < K; i++)
-		starpu_task_submit(&task[i]);
+	for (i = 0; i < K; i++) {
+		ret = starpu_task_submit(&task[i]);
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	gettimeofday(&end, NULL);
 
@@ -117,4 +124,11 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 4 - 1
tests/datawizard/acquire_cb.c

@@ -15,6 +15,7 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
 
@@ -29,7 +30,9 @@ void callback(void *arg __attribute__ ((unused)))
 
 int main(int argc, char **argv)
 {
-        starpu_init(NULL);
+	int ret;
+        ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	starpu_variable_data_register(&token_handle, 0, (uintptr_t)&token, sizeof(unsigned));
         starpu_data_acquire_cb(token_handle, STARPU_RW, callback, NULL);

+ 9 - 3
tests/datawizard/acquire_cb_insert.c

@@ -15,6 +15,7 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 #define N 16
 #define M 4
@@ -64,13 +65,15 @@ int main(int argc, char **argv)
         int i, ret;
 	float *f;
 
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* Declare x */
 	starpu_variable_data_register(&x_handle, 0, (uintptr_t)&x, sizeof(x));
 
 	/* Allocate and Declare f */
-	starpu_malloc((void**)&f, N * sizeof(*f));
+	ret = starpu_malloc((void**)&f, N * sizeof(*f));
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_malloc");
 	memset(f, 0, N * sizeof(*f));
 	starpu_vector_data_register(&f_handle, 0, (uintptr_t)f, N, sizeof(*f));
 
@@ -84,6 +87,7 @@ int main(int argc, char **argv)
 	/* Compute which portion we will work on */
         ret = starpu_insert_task(&which_index, STARPU_W, x_handle, 0);
 	if (ret == -ENODEV) goto enodev;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_insert_task");
 
 	/* And submit the corresponding task */
 #ifdef __GCC__
@@ -96,7 +100,8 @@ int main(int argc, char **argv)
 	starpu_data_acquire_cb(x_handle, STARPU_W, callback, NULL);
 #endif
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 	starpu_data_unpartition(f_handle, 0);
 	starpu_data_unregister(f_handle);
 	starpu_data_unregister(x_handle);
@@ -121,5 +126,6 @@ enodev:
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
 	return 77;
 }

+ 23 - 6
tests/datawizard/acquire_release.c

@@ -16,6 +16,7 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
 
@@ -43,14 +44,14 @@ static starpu_codelet increment_cl = {
 unsigned token = 0;
 starpu_data_handle token_handle;
 
-void increment_token()
+int increment_token()
 {
 	struct starpu_task *task = starpu_task_create();
         task->synchronous = 1;
 	task->cl = &increment_cl;
 	task->buffers[0].handle = token_handle;
 	task->buffers[0].mode = STARPU_RW;
-	starpu_task_submit(task);
+	return starpu_task_submit(task);
 }
 
 void callback(void *arg __attribute__ ((unused)))
@@ -61,8 +62,11 @@ void callback(void *arg __attribute__ ((unused)))
 int main(int argc, char **argv)
 {
 	int i;
+	int ret;
+
+        ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
-        starpu_init(NULL);
 	starpu_variable_data_register(&token_handle, 0, (uintptr_t)&token, sizeof(unsigned));
 
         FPRINTF(stderr, "Token: %u\n", token);
@@ -70,13 +74,18 @@ int main(int argc, char **argv)
 	for(i=0; i<ntasks; i++)
 	{
 		/* synchronize data in RAM */
-                starpu_data_acquire(token_handle, STARPU_R);
+                ret = starpu_data_acquire(token_handle, STARPU_R);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
+
                 token ++;
                 starpu_data_release(token_handle);
 
-                increment_token();
+                ret = increment_token();
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
-                starpu_data_acquire_cb(token_handle, STARPU_RW, callback, NULL);
+                ret = starpu_data_acquire_cb(token_handle, STARPU_RW, callback, NULL);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire_cb");
 	}
 
 	starpu_data_unregister(token_handle);
@@ -87,4 +96,12 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	starpu_data_unregister(token_handle);
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 23 - 5
tests/datawizard/acquire_release2.c

@@ -15,6 +15,7 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
 
@@ -42,14 +43,14 @@ static starpu_codelet increment_cl = {
 unsigned token = 0;
 starpu_data_handle token_handle;
 
-void increment_token(int synchronous)
+int increment_token(int synchronous)
 {
 	struct starpu_task *task = starpu_task_create();
         task->synchronous = synchronous;
 	task->cl = &increment_cl;
 	task->buffers[0].handle = token_handle;
 	task->buffers[0].mode = STARPU_RW;
-	starpu_task_submit(task);
+	return starpu_task_submit(task);
 }
 
 void callback(void *arg __attribute__ ((unused)))
@@ -62,8 +63,11 @@ void callback(void *arg __attribute__ ((unused)))
 int main(int argc, char **argv)
 {
 	int i;
+	int ret;
+
+        ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
-        starpu_init(NULL);
 	starpu_variable_data_register(&token_handle, 0, (uintptr_t)&token, sizeof(unsigned));
 
         FPRINTF(stderr, "Token: %u\n", token);
@@ -74,9 +78,15 @@ int main(int argc, char **argv)
 
 	for(i=0; i<ntasks; i++)
 	{
-                starpu_data_acquire_cb(token_handle, STARPU_W, callback, NULL);  // recv
-                increment_token(0);
+                ret = starpu_data_acquire_cb(token_handle, STARPU_W, callback, NULL);  // recv
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire_cb");
+
+                ret = increment_token(0);
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+
                 starpu_data_acquire_cb(token_handle, STARPU_R, callback, NULL);  // send
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire_cb");
 	}
 
 	starpu_data_unregister(token_handle);
@@ -86,4 +96,12 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	starpu_data_unregister(token_handle);
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 18 - 13
tests/datawizard/copy.c

@@ -16,6 +16,7 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
 
@@ -47,9 +48,10 @@ int main(int argc, char **argv)
 {
         float foo;
 	starpu_data_handle float_array_handle;
-        int i;
+        int i, ret;
 
-        starpu_init(NULL);
+        ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	if (starpu_worker_get_count_by_type(STARPU_CUDA_WORKER) == 0 && starpu_worker_get_count_by_type(STARPU_OPENCL_WORKER) == 0)
 	{
@@ -80,23 +82,26 @@ int main(int argc, char **argv)
 		task_gpu->buffers[0].mode = STARPU_RW;
 
 		ret = starpu_task_submit(task_cpu);
-		if (STARPU_UNLIKELY(ret == -ENODEV))
-		{
-			FPRINTF(stderr, "No worker may execute this task\n");
-			exit(0);
-		}
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
 		ret = starpu_task_submit(task_gpu);
-		if (STARPU_UNLIKELY(ret == -ENODEV))
-		{
-			FPRINTF(stderr, "No worker may execute this task\n");
-			exit(0);
-		}
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
         }
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 	starpu_data_unregister(float_array_handle);
         starpu_shutdown();
 
         return 0;
+
+enodev:
+	starpu_data_unregister(float_array_handle);
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 7 - 4
tests/datawizard/critical_section_with_void_interface.c

@@ -19,6 +19,7 @@
 #include <errno.h>
 #include <starpu.h>
 #include <stdlib.h>
+#include "../common/helper.h"
 
 starpu_data_handle void_handle;
 
@@ -48,7 +49,8 @@ int main(int argc, char **argv)
 	ntasks /= 10;
 #endif
 
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	critical_var = 0;
 
@@ -62,10 +64,10 @@ int main(int argc, char **argv)
 			task->cl = &cl;
 			task->buffers[0].handle = void_handle;
 			task->buffers[0].mode = STARPU_RW;
-	
+
 		ret = starpu_task_submit(task);
-		if (ret == -ENODEV)
-			goto enodev;
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
 	starpu_data_unregister(void_handle);
@@ -80,5 +82,6 @@ enodev:
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
 	return 77;
 }

+ 29 - 7
tests/datawizard/data_implicit_deps.c

@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <starpu.h>
 #include <stdlib.h>
+#include "../common/helper.h"
 
 #define VECTORSIZE	1024
 #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
@@ -69,7 +70,10 @@ static starpu_codelet cl_h = {
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	A = (unsigned *) malloc(VECTORSIZE*sizeof(unsigned));
 	B = (unsigned *) malloc(VECTORSIZE*sizeof(unsigned));
@@ -81,12 +85,12 @@ int main(int argc, char **argv)
 	starpu_vector_data_register(&C_handle, 0, (uintptr_t)C, VECTORSIZE, sizeof(unsigned));
 	starpu_vector_data_register(&D_handle, 0, (uintptr_t)D, VECTORSIZE, sizeof(unsigned));
 
-	#if 0
+#if 0
 	starpu_data_set_sequential_consistency_flag(A_handle, 0);
 	starpu_data_set_sequential_consistency_flag(B_handle, 0);
 	starpu_data_set_sequential_consistency_flag(C_handle, 0);
 	starpu_data_set_sequential_consistency_flag(D_handle, 0);
-	#endif
+#endif
 
 	/* 	f(Ar, Brw): sleep 
 	 *	g(Br; Crw); sleep, var = 42
@@ -98,7 +102,9 @@ int main(int argc, char **argv)
 	task_f->buffers[0].mode = STARPU_R;
 	task_f->buffers[1].handle = B_handle;
 	task_f->buffers[1].mode = STARPU_RW;
-	starpu_task_submit(task_f);
+	ret = starpu_task_submit(task_f);
+	if (ret == -ENODEV) goto enodev;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
 	struct starpu_task *task_g = starpu_task_create();
 	task_g->cl = &cl_g;
@@ -106,7 +112,9 @@ int main(int argc, char **argv)
 	task_g->buffers[0].mode = STARPU_R;
 	task_g->buffers[1].handle = C_handle;
 	task_g->buffers[1].mode = STARPU_RW;
-	starpu_task_submit(task_g);
+	ret = starpu_task_submit(task_g);
+	if (ret == -ENODEV) goto enodev;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
 	struct starpu_task *task_h = starpu_task_create();
 	task_h->cl = &cl_h;
@@ -114,9 +122,12 @@ int main(int argc, char **argv)
 	task_h->buffers[0].mode = STARPU_R;
 	task_h->buffers[1].handle = D_handle;
 	task_h->buffers[1].mode = STARPU_RW;
-	starpu_task_submit(task_h);
+	ret = starpu_task_submit(task_h);
+	if (ret == -ENODEV) goto enodev;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	free(A);
 	free(B);
@@ -126,4 +137,15 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	free(A);
+	free(B);
+	free(C);
+	free(D);
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 16 - 14
tests/datawizard/data_invalidation.c

@@ -20,6 +20,7 @@
 #include <starpu.h>
 #include <starpu_cuda.h>
 #include <stdlib.h>
+#include "../common/helper.h"
 
 #define NLOOPS		1000
 #define VECTORSIZE	1024
@@ -90,7 +91,8 @@ int main(int argc, char **argv)
 {
 	int ret;
 
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* The buffer should never be explicitely allocated */
 	starpu_vector_data_register(&v_handle, (uint32_t)-1, (uintptr_t)NULL, VECTORSIZE, sizeof(char));
@@ -106,28 +108,26 @@ int main(int argc, char **argv)
 		memset_task->buffers[0].handle = v_handle;
 		memset_task->buffers[0].mode = STARPU_W;
 		memset_task->detach = 0;
-	
+
 		ret = starpu_task_submit(memset_task);
-		if (ret == -ENODEV)
-				goto enodev;
-	
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+
 		ret = starpu_task_wait(memset_task);
-		if (ret)
-			exit(-1);
-		
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
+
 		check_content_task = starpu_task_create();
 		check_content_task->cl = &check_content_cl;
 		check_content_task->buffers[0].handle = v_handle;
 		check_content_task->buffers[0].mode = STARPU_R;
 		check_content_task->detach = 0;
-	
+
 		ret = starpu_task_submit(check_content_task);
-		if (ret == -ENODEV)
-				goto enodev;
-	
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+
 		ret = starpu_task_wait(check_content_task);
-		if (ret)
-			exit(-1);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
 
 		starpu_data_invalidate(v_handle);
 	}
@@ -140,8 +140,10 @@ int main(int argc, char **argv)
 	return 0;
 
 enodev:
+	starpu_data_unregister(v_handle);
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
 	return 77;
 }

+ 18 - 12
tests/datawizard/data_lookup.c

@@ -20,6 +20,7 @@
 #include <starpu.h>
 #include <stdlib.h>
 #include <sys/types.h>
+#include "../common/helper.h"
 
 static void task(void **buffers, void *args)
 {
@@ -58,11 +59,14 @@ static int test_lazy_allocation()
 				 STARPU_VALUE, &count, sizeof(size_t),
 				 0);
 	if (ret == -ENODEV) return ret;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_insert_task");
+
 	/* yes, we do not perform the computation but we did detect that no one
 	 * could perform the kernel, so this is not an error from StarPU */
 
 	/* Acquire the handle, forcing a local allocation.  */
-	starpu_data_acquire(handle, STARPU_R);
+	ret = starpu_data_acquire(handle, STARPU_R);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
 
 	/* Make sure we have a local pointer to it.  */
 	pointer = starpu_handle_get_local_ptr(handle);
@@ -91,12 +95,12 @@ static int test_lazy_allocation()
 static void test_filters()
 {
 #define CHILDREN_COUNT 10
-	int err, i;
+	int ret, i;
 	int *ptr, *children_pointers[CHILDREN_COUNT];
 	starpu_data_handle handle;
 
-	err = starpu_malloc((void**)&ptr, VECTOR_SIZE * sizeof(*ptr));
-	assert(err == 0);
+	ret = starpu_malloc((void**)&ptr, VECTOR_SIZE * sizeof(*ptr));
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_malloc");
 
 	starpu_vector_data_register(&handle, 0, (uintptr_t)ptr,
 				    VECTOR_SIZE, sizeof(*ptr));
@@ -141,20 +145,21 @@ static void test_filters()
 
 int main(int argc, char *argv[])
 {
-	int err;
+	int ret;
 	size_t i;
 	void *vectors[VECTOR_COUNT], *variables[VARIABLE_COUNT];
 	starpu_data_handle vector_handles[VECTOR_COUNT];
 	starpu_data_handle variable_handles[VARIABLE_COUNT];
 
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* Register data regions.  */
 
 	for(i = 0; i < VARIABLE_COUNT; i++)
 	{
-		err = starpu_malloc(&variables[i], sizeof(float));
-		assert(err == 0);
+		ret = starpu_malloc(&variables[i], sizeof(float));
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_malloc");
 		starpu_variable_data_register(&variable_handles[i], 0,
 					      (uintptr_t)variables[i],
 					      sizeof(float));
@@ -162,8 +167,8 @@ int main(int argc, char *argv[])
 
 	for(i = 0; i < VECTOR_COUNT; i++)
 	{
-		err = starpu_malloc(&vectors[i], VECTOR_SIZE * sizeof(float));
-		assert(err == 0);
+		ret = starpu_malloc(&vectors[i], VECTOR_SIZE * sizeof(float));
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_malloc");
 		starpu_vector_data_register(&vector_handles[i], 0,
 					    (uintptr_t)vectors[i],
 					    VECTOR_SIZE, sizeof(float));
@@ -219,8 +224,8 @@ int main(int argc, char *argv[])
 		starpu_free(vectors[i]);
 	}
 
-	err = test_lazy_allocation();
-	if (err == -ENODEV) goto enodev;
+	ret = test_lazy_allocation();
+	if (ret == -ENODEV) goto enodev;
 	test_filters();
 
 	starpu_shutdown();
@@ -231,5 +236,6 @@ enodev:
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
 	return 77;
 }

+ 23 - 5
tests/datawizard/dining_philosophers.c

@@ -16,6 +16,7 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 /* number of philosophers */
 #define N	16
@@ -37,7 +38,7 @@ static starpu_codelet eating_cl = {
 	.nbuffers = 2
 };
 
-void submit_one_task(unsigned p)
+int submit_one_task(unsigned p)
 {
 	struct starpu_task *task = starpu_task_create();
 
@@ -52,12 +53,15 @@ void submit_one_task(unsigned p)
 	task->buffers[1].mode = STARPU_RW;
 
 	int ret = starpu_task_submit(task);
-	STARPU_ASSERT(!ret);
+	return ret;
 }
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* initialize the forks */
 	unsigned f;
@@ -75,10 +79,13 @@ int main(int argc, char **argv)
 	{
 		/* select one philosopher randomly */
 		unsigned philosopher = rand() % N;
-		submit_one_task(philosopher);
+		ret = submit_one_task(philosopher);
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	FPRINTF(stderr, "waiting done\n");
 	for (f = 0; f < N; f++)
@@ -89,4 +96,15 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	for (f = 0; f < N; f++)
+	{
+		starpu_data_unregister(fork_handles[f]);
+	}
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 18 - 5
tests/datawizard/dsm_stress.c

@@ -21,6 +21,7 @@
 #include <starpu.h>
 #include <stdlib.h>
 #include <pthread.h>
+#include "../common/helper.h"
 
 #define N	10000
 
@@ -91,10 +92,15 @@ static starpu_codelet cl = {
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
 
-	starpu_malloc((void **)&v, VECTORSIZE*sizeof(unsigned));
-	starpu_malloc((void **)&v2, VECTORSIZE*sizeof(unsigned));
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+
+	ret = starpu_malloc((void **)&v, VECTORSIZE*sizeof(unsigned));
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_malloc");
+	ret = starpu_malloc((void **)&v2, VECTORSIZE*sizeof(unsigned));
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_malloc");
 
 	starpu_vector_data_register(&v_handle, 0, (uintptr_t)v, VECTORSIZE, sizeof(unsigned));
 	starpu_vector_data_register(&v_handle2, 0, (uintptr_t)v2, VECTORSIZE, sizeof(unsigned));
@@ -115,8 +121,8 @@ int main(int argc, char **argv)
 		task->callback_arg = NULL;
 
 		int ret = starpu_task_submit(task);
-		if (ret == -ENODEV)
-			goto enodev;
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
 	pthread_mutex_lock(&mutex);
@@ -124,6 +130,8 @@ int main(int argc, char **argv)
 		pthread_cond_wait(&cond, &mutex);
 	pthread_mutex_unlock(&mutex);
 
+	starpu_data_unregister(v_handle);
+	starpu_data_unregister(v_handle2);
 	starpu_free(v);
 	starpu_free(v2);
 	starpu_shutdown();
@@ -131,6 +139,11 @@ int main(int argc, char **argv)
 	return 0;
 
 enodev:
+	starpu_data_unregister(v_handle);
+	starpu_data_unregister(v_handle2);
+	starpu_free(v);
+	starpu_free(v2);
+	starpu_shutdown();
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */

+ 25 - 12
tests/datawizard/increment_redux.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -16,6 +16,7 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 #ifdef STARPU_USE_CUDA
 #include <starpu_cuda.h>
@@ -79,7 +80,7 @@ static void redux_opencl_kernel(void *descr[], void *arg)
 
 	h_dst += h_src;
 
-	clEnqueueWriteBuffer(queue, d_dst, CL_TRUE, 0, sizeof(unsigned), (void *)&h_dst, 0, NULL, NULL); 
+	clEnqueueWriteBuffer(queue, d_dst, CL_TRUE, 0, sizeof(unsigned), (void *)&h_dst, 0, NULL, NULL);
 }
 
 static void neutral_opencl_kernel(void *descr[], void *arg)
@@ -90,7 +91,7 @@ static void neutral_opencl_kernel(void *descr[], void *arg)
 	cl_command_queue queue;
 	starpu_opencl_get_current_queue(&queue);
 
-	clEnqueueWriteBuffer(queue, d_dst, CL_TRUE, 0, sizeof(unsigned), (void *)&h_dst, 0, NULL, NULL); 
+	clEnqueueWriteBuffer(queue, d_dst, CL_TRUE, 0, sizeof(unsigned), (void *)&h_dst, 0, NULL, NULL);
 }
 #endif
 
@@ -149,7 +150,7 @@ static void increment_opencl_kernel(void *descr[], void *cl_arg __attribute__((u
 
 	clEnqueueReadBuffer(queue, d_token, CL_TRUE, 0, sizeof(unsigned), (void *)&h_token, 0, NULL, NULL);
 	h_token++;
-	clEnqueueWriteBuffer(queue, d_token, CL_TRUE, 0, sizeof(unsigned), (void *)&h_token, 0, NULL, NULL); 
+	clEnqueueWriteBuffer(queue, d_token, CL_TRUE, 0, sizeof(unsigned), (void *)&h_token, 0, NULL, NULL);
 }
 #endif
 
@@ -191,7 +192,10 @@ static starpu_codelet increment_cl = {
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	starpu_variable_data_register(&handle, 0, (uintptr_t)&var, sizeof(unsigned));
 
@@ -208,26 +212,35 @@ int main(int argc, char **argv)
 		for (t = 0; t < ntasks; t++)
 		{
 			struct starpu_task *task = starpu_task_create();
-	
+
 			task->cl = &increment_cl;
-	
+
 			task->buffers[0].mode = STARPU_REDUX;
 			task->buffers[0].handle = handle;
-	
-			int ret = starpu_task_submit(task);
-			STARPU_ASSERT(!ret);
 
+			int ret = starpu_task_submit(task);
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 		}
 
-		starpu_data_acquire(handle, STARPU_R);
+		ret = starpu_data_acquire(handle, STARPU_R);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
 		STARPU_ASSERT(var == ntasks*(loop + 1));
 		starpu_data_release(handle);
 	}
 
 	starpu_data_unregister(handle);
 	STARPU_ASSERT(var == ntasks*nloops);
-	
+
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	starpu_data_unregister(handle);
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 24 - 11
tests/datawizard/increment_redux_v2.c

@@ -15,6 +15,7 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 #ifdef STARPU_USE_CUDA
 #include <starpu_cuda.h>
@@ -78,7 +79,7 @@ static void redux_opencl_kernel(void *descr[], void *arg)
 
 	h_dst += h_src;
 
-	clEnqueueWriteBuffer(queue, d_dst, CL_TRUE, 0, sizeof(unsigned), (void *)&h_dst, 0, NULL, NULL); 
+	clEnqueueWriteBuffer(queue, d_dst, CL_TRUE, 0, sizeof(unsigned), (void *)&h_dst, 0, NULL, NULL);
 }
 
 static void neutral_opencl_kernel(void *descr[], void *arg)
@@ -89,7 +90,7 @@ static void neutral_opencl_kernel(void *descr[], void *arg)
 	cl_command_queue queue;
 	starpu_opencl_get_current_queue(&queue);
 
-	clEnqueueWriteBuffer(queue, d_dst, CL_TRUE, 0, sizeof(unsigned), (void *)&h_dst, 0, NULL, NULL); 
+	clEnqueueWriteBuffer(queue, d_dst, CL_TRUE, 0, sizeof(unsigned), (void *)&h_dst, 0, NULL, NULL);
 }
 #endif
 
@@ -148,7 +149,7 @@ static void increment_opencl_kernel(void *descr[], void *cl_arg __attribute__((u
 
 	clEnqueueReadBuffer(queue, d_token, CL_TRUE, 0, sizeof(unsigned), (void *)&h_token, 0, NULL, NULL);
 	h_token++;
-	clEnqueueWriteBuffer(queue, d_token, CL_TRUE, 0, sizeof(unsigned), (void *)&h_token, 0, NULL, NULL); 
+	clEnqueueWriteBuffer(queue, d_token, CL_TRUE, 0, sizeof(unsigned), (void *)&h_token, 0, NULL, NULL);
 }
 #endif
 
@@ -190,7 +191,10 @@ static starpu_codelet increment_cl = {
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	starpu_variable_data_register(&handle, 0, (uintptr_t)&var, sizeof(unsigned));
 
@@ -207,26 +211,35 @@ int main(int argc, char **argv)
 		for (t = 0; t < ntasks; t++)
 		{
 			struct starpu_task *task = starpu_task_create();
-	
+
 			task->cl = &increment_cl;
-	
+
 			task->buffers[0].mode = (t % 10 == 0)?STARPU_RW:STARPU_REDUX;
 			task->buffers[0].handle = handle;
-	
-			int ret = starpu_task_submit(task);
-			STARPU_ASSERT(!ret);
 
+			int ret = starpu_task_submit(task);
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 		}
 
-		starpu_data_acquire(handle, STARPU_R);
+		ret = starpu_data_acquire(handle, STARPU_R);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
 		STARPU_ASSERT(var == ntasks*(loop + 1));
 		starpu_data_release(handle);
 	}
 
 	starpu_data_unregister(handle);
 	STARPU_ASSERT(var == ntasks*nloops);
-	
+
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	starpu_data_unregister(handle);
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 17 - 5
tests/datawizard/lazy_allocation.c

@@ -20,6 +20,7 @@
 #include <starpu.h>
 #include <starpu_cuda.h>
 #include <stdlib.h>
+#include "../common/helper.h"
 
 #define VECTORSIZE	1024
 #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
@@ -110,16 +111,27 @@ static starpu_codelet check_content_cl = {
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+
 	starpu_vector_data_register(&v_handle, (uint32_t)-1, (uintptr_t)NULL, VECTORSIZE, sizeof(char));
 
-	starpu_insert_task(&memset_cl, STARPU_W, v_handle, 0);
-        starpu_task_wait_for_all();
+	ret = starpu_insert_task(&memset_cl, STARPU_W, v_handle, 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_insert_task");
+
+        ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
-	starpu_insert_task(&check_content_cl, STARPU_R, v_handle, 0);
-        starpu_task_wait_for_all();
+	ret = starpu_insert_task(&check_content_cl, STARPU_R, v_handle, 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_insert_task");
+
+        ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	starpu_data_unregister(v_handle);
+
 	starpu_shutdown();
 	return 0;
 }

+ 13 - 8
tests/datawizard/manual_reduction.c

@@ -15,6 +15,8 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
+
 #ifdef STARPU_USE_CUDA
 #include <cuda.h>
 #endif
@@ -36,7 +38,7 @@ static starpu_data_handle per_worker_handle[STARPU_NMAXWORKERS];
 static void initialize_per_worker_handle(void *arg __attribute__((unused)))
 {
 	int workerid = starpu_worker_get_id();
-	
+
 	/* Allocate memory on the worker, and initialize it to 0 */
 	switch (starpu_worker_get_type(workerid)) {
 		case STARPU_CPU_WORKER:
@@ -53,10 +55,10 @@ static void initialize_per_worker_handle(void *arg __attribute__((unused)))
 			cl_mem ptr = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(variable), NULL, NULL);
 			/* Poor's man memset */
 			unsigned zero = 0;
-			clEnqueueWriteBuffer(queue, ptr, CL_TRUE, 0, sizeof(variable), (void *)&zero, 0, NULL, NULL); 
+			clEnqueueWriteBuffer(queue, ptr, CL_TRUE, 0, sizeof(variable), (void *)&zero, 0, NULL, NULL);
 			per_worker[workerid] = (uintptr_t)ptr;
 			}
-			
+
 			break;
 #endif
 #ifdef STARPU_USE_CUDA
@@ -105,7 +107,7 @@ static void cpu_func_incr(void *descr[], void *cl_arg __attribute__((unused)))
 	*val = *val + 1;
 }
 
-#ifdef STARPU_USE_CUDA 
+#ifdef STARPU_USE_CUDA
 /* dummy CUDA implementation */
 static void cuda_func_incr(void *descr[], void *cl_arg __attribute__((unused)))
 {
@@ -130,7 +132,7 @@ static void opencl_func_incr(void *descr[], void *cl_arg __attribute__((unused))
 
 	clEnqueueReadBuffer(queue, d_val, CL_TRUE, 0, sizeof(unsigned), (void *)&h_val, 0, NULL, NULL);
 	h_val++;
-	clEnqueueWriteBuffer(queue, d_val, CL_TRUE, 0, sizeof(unsigned), (void *)&h_val, 0, NULL, NULL); 
+	clEnqueueWriteBuffer(queue, d_val, CL_TRUE, 0, sizeof(unsigned), (void *)&h_val, 0, NULL, NULL);
 }
 #endif
 
@@ -151,10 +153,12 @@ int main(int argc, char **argv)
 {
 	unsigned worker;
 	unsigned i;
+	int ret;
 
 	variable = INIT_VALUE;
 
-        starpu_init(NULL);
+        ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	unsigned nworkers = starpu_worker_get_count();
 
@@ -188,7 +192,7 @@ int main(int argc, char **argv)
 
 		int ret = starpu_task_submit(task);
 		if (ret == -ENODEV) goto enodev;
-		STARPU_ASSERT(!ret);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
 
@@ -206,7 +210,7 @@ int main(int argc, char **argv)
 
 		int ret = starpu_task_submit(task);
 		if (ret == -ENODEV) goto enodev;
-		STARPU_ASSERT(!ret);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
 	starpu_data_unregister(variable_handle);
@@ -225,5 +229,6 @@ enodev:
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
 	return 77;
 }

+ 19 - 4
tests/datawizard/readers_and_writers.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -16,6 +16,7 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 static unsigned book = 0;
 static starpu_data_handle book_handle;
@@ -34,7 +35,10 @@ static starpu_codelet rw_cl = {
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* initialize the resource */
 	starpu_vector_data_register(&book_handle, 0, (uintptr_t)&book, 1, sizeof(unsigned));
@@ -54,12 +58,23 @@ int main(int argc, char **argv)
 		task->buffers[0].handle = book_handle;
 
 		int ret = starpu_task_submit(task);
-		STARPU_ASSERT(!ret);
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
+	starpu_data_unregister(book_handle);
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	starpu_data_unregister(book_handle);
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 16 - 4
tests/datawizard/reclaim.c

@@ -25,6 +25,7 @@
 #ifdef STARPU_HAVE_HWLOC
 #include <hwloc.h>
 #endif
+#include "../common/helper.h"
 
 #ifdef STARPU_SLOW_MACHINE
 #  define BLOCK_SIZE (64*1024)
@@ -63,7 +64,7 @@ static int mb = 256;
 
 int main(int argc, char **argv)
 {
-	int i;
+	int i, ret;
 	int taskid;
 
 #ifdef STARPU_HAVE_HWLOC
@@ -82,7 +83,8 @@ int main(int argc, char **argv)
 
 	FPRINTF(stderr, "Allocate %d buffers and create %u tasks\n", mb, ntasks);
 
-        starpu_init(NULL);
+        ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	float **host_ptr_array;
 	starpu_data_handle *handle_array;
@@ -109,10 +111,13 @@ int main(int argc, char **argv)
 		task->buffers[1].mode = STARPU_R;
 		task->buffers[2].handle = handle_array[(taskid+2)%mb];
 		task->buffers[2].mode = STARPU_R;
-		starpu_task_submit(task);
+		ret = starpu_task_submit(task);
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	for (i = 0; i < mb; i++)
 	{
@@ -123,4 +128,11 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 18 - 7
tests/datawizard/scratch.c

@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <starpu.h>
 #include <stdlib.h>
+#include "../common/helper.h"
 
 #define NLOOPS		128
 #define VECTORSIZE	1024
@@ -40,7 +41,7 @@ static void cpu_f(void *descr[], __attribute__ ((unused)) void *_args)
 
 	unsigned nx = STARPU_VECTOR_GET_NX(descr[0]);
 	size_t elemsize = STARPU_VECTOR_GET_ELEMSIZE(descr[0]);
-	
+
 	memcpy(tmp, v, nx*elemsize);
 
 	unsigned i;
@@ -61,7 +62,10 @@ static starpu_codelet cl_f = {
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	A = (unsigned *) calloc(VECTORSIZE, sizeof(unsigned));
 
@@ -78,15 +82,17 @@ int main(int argc, char **argv)
 		task_f->buffers[1].handle = B_handle;
 		task_f->buffers[1].mode = STARPU_SCRATCH;
 
-		int ret = starpu_task_submit(task_f);
-		if (ret == -ENODEV)
-			goto enodev;
+		ret = starpu_task_submit(task_f);
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	/* Make sure that data A is in main memory */
-	starpu_data_acquire(A_handle, STARPU_R);	
+	ret = starpu_data_acquire(A_handle, STARPU_R);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
 
 	/* Check result */
 	unsigned i;
@@ -97,11 +103,16 @@ int main(int argc, char **argv)
 
 	starpu_data_release(A_handle);
 
+	starpu_data_unregister(A_handle);
+	starpu_data_unregister(B_handle);
 	starpu_shutdown();
 
 	return 0;
 
 enodev:
+	starpu_data_unregister(A_handle);
+	starpu_data_unregister(B_handle);
+	starpu_shutdown();
 	/* No one can execute that task, this is not a bug, just an incomplete
 	 * test :) */
 	return 77;

+ 17 - 7
tests/datawizard/sync_and_notify_data.c

@@ -24,6 +24,8 @@
 #include <gordon.h>
 #endif
 
+#include "../common/helper.h"
+
 #define N	100
 #define K	256
 #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
@@ -74,7 +76,10 @@ void cpu_codelet_incC(void *descr[], __attribute__ ((unused)) void *_args)
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 #ifdef STARPU_USE_GORDON
 	unsigned elf_id = gordon_register_elf_plugin("./datawizard/sync_and_notify_data_gordon_kernels.spuelf");
@@ -127,12 +132,13 @@ int main(int argc, char **argv)
 			task->synchronous = 1;
 
 			ret = starpu_task_submit(task);
-			if (ret == -ENODEV)
-				goto enodev;
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 		}
 
 		/* synchronize v in RAM */
-		starpu_data_acquire(v_handle, STARPU_RW);
+		ret = starpu_data_acquire(v_handle, STARPU_RW);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
 
 		/* increment b */
 		v[1]++;
@@ -166,17 +172,19 @@ int main(int argc, char **argv)
 			task->synchronous = 1;
 
 			ret = starpu_task_submit(task);
-			if (ret == -ENODEV)
-				goto enodev;
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 		}
 
 	}
 
-	starpu_data_acquire(v_handle, STARPU_RW);
+	ret = starpu_data_acquire(v_handle, STARPU_RW);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
 
 	FPRINTF(stderr, "V = {%u, %u, %u}\n", v[0], v[1], v[2]);
 
 	starpu_data_release(v_handle);
+	starpu_data_unregister(v_handle);
 
 	starpu_shutdown();
 
@@ -186,6 +194,8 @@ int main(int argc, char **argv)
 	return 0;
 
 enodev:
+	starpu_data_unregister(v_handle);
+	starpu_shutdown();
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */

+ 17 - 8
tests/datawizard/sync_and_notify_data_implicit.c

@@ -24,6 +24,8 @@
 #include <gordon.h>
 #endif
 
+#include "../common/helper.h"
+
 #define N	100
 #define K	256
 //#define N	1
@@ -108,7 +110,10 @@ starpu_codelet cl_inc_c = {
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 #ifdef STARPU_USE_GORDON
 	unsigned elf_id = gordon_register_elf_plugin("./datawizard/sync_and_notify_data_gordon_kernels.spuelf");
@@ -143,12 +148,13 @@ int main(int argc, char **argv)
 			task->buffers[0].mode = STARPU_RW;
 
 			ret = starpu_task_submit(task);
-			if (ret == -ENODEV)
-				goto enodev;
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 		}
 
 		/* synchronize v in RAM */
-		starpu_data_acquire(v_handle, STARPU_RW);
+		ret = starpu_data_acquire(v_handle, STARPU_RW);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
 
 		/* increment b */
 		v[1]++;
@@ -164,18 +170,19 @@ int main(int argc, char **argv)
 			task->buffers[0].mode = STARPU_RW;
 
 			ret = starpu_task_submit(task);
-			if (ret == -ENODEV)
-				goto enodev;
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 		}
 
 	}
 
-	starpu_data_acquire(v_handle, STARPU_RW);
+	ret = starpu_data_acquire(v_handle, STARPU_RW);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
 
 	FPRINTF(stderr, "V = {%u, %u, %u}\n", v[0], v[1], v[2]);
 
 	starpu_data_release(v_handle);
-
+	starpu_data_unregister(v_handle);
 	starpu_shutdown();
 
 	if ((v[0] != N*K) || (v[1] != K) || (v[2] != N*K))
@@ -184,6 +191,8 @@ int main(int argc, char **argv)
 	return 0;
 
 enodev:
+	starpu_data_unregister(v_handle);
+	starpu_shutdown();
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */

+ 28 - 15
tests/datawizard/sync_with_data_with_mem.c

@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <starpu.h>
 #include <stdlib.h>
+#include "../common/helper.h"
 
 #define NBUFFERS	64
 #define NITER		128
@@ -45,7 +46,7 @@ static starpu_codelet cl = {
 	.nbuffers = 1
 };
 
-void use_handle(starpu_data_handle handle)
+int use_handle(starpu_data_handle handle)
 {
 	int ret;
 	struct starpu_task *task;
@@ -57,23 +58,22 @@ void use_handle(starpu_data_handle handle)
 		task->detach = 0;
 
 	ret = starpu_task_submit(task);
-	if (ret == -ENODEV)
-	{
-		/* No one can execute such a task, but that's not a failure
-		 * of the test either. */
-		exit(0);
-	}
+	return ret;
 }
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* Allocate all buffers and register them to StarPU */
 	unsigned b;
 	for (b = 0; b < NBUFFERS; b++)
 	{
-		starpu_malloc((void **)&buffer[b], VECTORSIZE);
+		ret = starpu_malloc((void **)&buffer[b], VECTORSIZE);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_malloc");
 		starpu_vector_data_register(&v_handle[b], 0,
 				(uintptr_t)buffer[b], VECTORSIZE, sizeof(char));
 	}
@@ -83,14 +83,20 @@ int main(int argc, char **argv)
 	{
 		/* Use the buffers on the different workers so that it may not
 		 * be in main memory anymore */
-		for (b = 0; b < NBUFFERS; b++)
-			use_handle(v_handle[b]);
-	
-		starpu_task_wait_for_all();
+		for (b = 0; b < NBUFFERS; b++) {
+			ret = use_handle(v_handle[b]);
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+		}
+
+		ret = starpu_task_wait_for_all();
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 		/* Grab the different pieces of data into main memory */
-		for (b = 0; b < NBUFFERS; b++)
-			starpu_data_acquire(v_handle[b], STARPU_RW);
+		for (b = 0; b < NBUFFERS; b++) {
+			ret = starpu_data_acquire(v_handle[b], STARPU_RW);
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
+		}
 
 		/* Release them */
 		for (b = 0; b < NBUFFERS; b++)
@@ -106,4 +112,11 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 27 - 15
tests/datawizard/sync_with_data_with_mem_non_blocking.c

@@ -21,6 +21,7 @@
 #include <starpu.h>
 #include <stdlib.h>
 #include <pthread.h>
+#include "../common/helper.h"
 
 #define NBUFFERS	64
 #define NITER		128
@@ -46,7 +47,7 @@ static starpu_codelet cl = {
 	.nbuffers = 1
 };
 
-void use_handle(starpu_data_handle handle)
+int use_handle(starpu_data_handle handle)
 {
 	int ret;
 	struct starpu_task *task;
@@ -58,12 +59,7 @@ void use_handle(starpu_data_handle handle)
 		task->detach = 0;
 
 	ret = starpu_task_submit(task);
-	if (ret == -ENODEV)
-	{
-		/* No one can execute such a task, but that's not a failure
-		 * of the test either. */
-		exit(0);
-	}
+	return ret;
 }
 
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -84,13 +80,17 @@ void callback_sync_data(void *arg __attribute__ ((unused)))
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* Allocate all buffers and register them to StarPU */
 	unsigned b;
 	for (b = 0; b < NBUFFERS; b++)
 	{
-		starpu_malloc((void **)&buffer[b], VECTORSIZE);
+		ret = starpu_malloc((void **)&buffer[b], VECTORSIZE);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_malloc");
 		starpu_vector_data_register(&v_handle[b], 0,
 				(uintptr_t)buffer[b], VECTORSIZE, sizeof(char));
 		starpu_data_set_sequential_consistency_flag(v_handle[b], 0);
@@ -101,10 +101,14 @@ int main(int argc, char **argv)
 	{
 		/* Use the buffers on the different workers so that it may not
 		 * be in main memory anymore */
-		for (b = 0; b < NBUFFERS; b++)
-			use_handle(v_handle[b]);
-	
-		starpu_task_wait_for_all();
+		for (b = 0; b < NBUFFERS; b++) {
+			ret = use_handle(v_handle[b]);
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+		}
+
+		ret = starpu_task_wait_for_all();
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 		pthread_mutex_lock(&mutex);
 		n_synced_buffers = 0;
@@ -113,8 +117,9 @@ int main(int argc, char **argv)
 		/* Grab the different pieces of data into main memory */
 		for (b = 0; b < NBUFFERS; b++)
 		{
-			starpu_data_acquire_cb(v_handle[b], STARPU_RW,
-					callback_sync_data, NULL);
+			ret = starpu_data_acquire_cb(v_handle[b], STARPU_RW,
+						     callback_sync_data, NULL);
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire_cb");
 		}
 
 		/* Wait for all buffers to be available */
@@ -139,4 +144,11 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 27 - 15
tests/datawizard/sync_with_data_with_mem_non_blocking_implicit.c

@@ -21,6 +21,7 @@
 #include <starpu.h>
 #include <stdlib.h>
 #include <pthread.h>
+#include "../common/helper.h"
 
 #define NBUFFERS	64
 #define NITER		128
@@ -46,7 +47,7 @@ static starpu_codelet cl = {
 	.nbuffers = 1
 };
 
-void use_handle(starpu_data_handle handle)
+int use_handle(starpu_data_handle handle)
 {
 	int ret;
 	struct starpu_task *task;
@@ -58,12 +59,7 @@ void use_handle(starpu_data_handle handle)
 		task->detach = 0;
 
 	ret = starpu_task_submit(task);
-	if (ret == -ENODEV)
-	{
-		/* No one can execute such a task, but that's not a failure
-		 * of the test either. */
-		exit(0);
-	}
+	return ret;
 }
 
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -84,13 +80,17 @@ void callback_sync_data(void *arg __attribute__ ((unused)))
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* Allocate all buffers and register them to StarPU */
 	unsigned b;
 	for (b = 0; b < NBUFFERS; b++)
 	{
-		starpu_malloc((void **)&buffer[b], VECTORSIZE);
+		ret = starpu_malloc((void **)&buffer[b], VECTORSIZE);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_malloc");
 		starpu_vector_data_register(&v_handle[b], 0,
 				(uintptr_t)buffer[b], VECTORSIZE, sizeof(char));
 	}
@@ -100,9 +100,12 @@ int main(int argc, char **argv)
 	{
 		/* Use the buffers on the different workers so that it may not
 		 * be in main memory anymore */
-		for (b = 0; b < NBUFFERS; b++)
-			use_handle(v_handle[b]);
-	
+		for (b = 0; b < NBUFFERS; b++) {
+			ret = use_handle(v_handle[b]);
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+		}
+
 		pthread_mutex_lock(&mutex);
 		n_synced_buffers = 0;
 		pthread_mutex_unlock(&mutex);
@@ -110,8 +113,9 @@ int main(int argc, char **argv)
 		/* Grab the different pieces of data into main memory */
 		for (b = 0; b < NBUFFERS; b++)
 		{
-			starpu_data_acquire_cb(v_handle[b], STARPU_RW,
-					callback_sync_data, NULL);
+			ret = starpu_data_acquire_cb(v_handle[b], STARPU_RW,
+						     callback_sync_data, NULL);
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire_cb");
 		}
 
 		/* Wait for all buffers to be available */
@@ -127,7 +131,8 @@ int main(int argc, char **argv)
 			starpu_data_release(v_handle[b]);
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	/* do some cleanup */
 	for (b = 0; b < NBUFFERS; b++) {
@@ -138,4 +143,11 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 24 - 17
tests/datawizard/unpartition.c

@@ -21,6 +21,7 @@
 #include <errno.h>
 #include <starpu.h>
 #include <stdlib.h>
+#include "../common/helper.h"
 
 #define NITER		1000
 #define VECTORSIZE	1024
@@ -65,9 +66,11 @@ int main(int argc, char **argv)
 {
 	int ret;
 
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
-	starpu_malloc((void **)&buffer, VECTORSIZE);
+	ret = starpu_malloc((void **)&buffer, VECTORSIZE);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_malloc");
 
 	starpu_vector_data_register(&v_handle, 0, (uintptr_t)buffer, VECTORSIZE, sizeof(char));
 
@@ -83,34 +86,38 @@ int main(int argc, char **argv)
 	for (iter = 0; iter < NITER; iter++)
 	{
 		starpu_data_map_filters(v_handle, 1, &f);
-	
+
 		ret = use_handle(starpu_data_get_sub_data(v_handle, 1, 0));
-		if (ret == -ENODEV)
-			goto enodev;
-	
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+
 		ret = use_handle(starpu_data_get_sub_data(v_handle, 1, 1));
-		if (ret == -ENODEV)
-			goto enodev;
-	
-		starpu_task_wait_for_all();
-	
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+
+		ret = starpu_task_wait_for_all();
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
+
 		starpu_data_unpartition(v_handle, 0);
-	
+
 		ret = use_handle(v_handle);
-		if (ret == -ENODEV)
-			goto enodev;
-	
-		starpu_task_wait_for_all();
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+
+		ret = starpu_task_wait_for_all();
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 	}
 
 	starpu_data_unregister(v_handle);
 	starpu_free(buffer);
-
 	starpu_shutdown();
 
 	return 0;
 
 enodev:
+	starpu_data_unregister(v_handle);
+	starpu_free(buffer);
+	starpu_shutdown();
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */

+ 11 - 5
tests/datawizard/user_interaction_implicit.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -21,6 +21,7 @@
 #include <starpu.h>
 #include <stdlib.h>
 #include <pthread.h>
+#include "../common/helper.h"
 
 #define NBUFFERS	16
 #define NITER		128
@@ -44,7 +45,10 @@ void callback_sync_data(void *arg)
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	unsigned b;
 	for (b = 0; b < NBUFFERS; b++)
@@ -57,11 +61,13 @@ int main(int argc, char **argv)
 	for (iter = 0; iter < NITER; iter++)
 	for (b = 0; b < NBUFFERS; b++)
 	{
-		starpu_data_acquire_cb(buffers[b].handle, STARPU_RW,
-							callback_sync_data, &buffers[b]);
+		ret = starpu_data_acquire_cb(buffers[b].handle, STARPU_RW,
+					     callback_sync_data, &buffers[b]);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire_cb");
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	/* do some cleanup */
 	for (b = 0; b < NBUFFERS; b++)

+ 11 - 10
tests/datawizard/write_only_tmp_buffer.c

@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <starpu.h>
 #include <stdlib.h>
+#include "../common/helper.h"
 
 #define VECTORSIZE	1024
 
@@ -90,7 +91,8 @@ int main(int argc, char **argv)
 {
 	int ret;
 
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* The buffer should never be explicitely allocated */
 	starpu_vector_data_register(&v_handle, (uint32_t)-1, (uintptr_t)NULL, VECTORSIZE, sizeof(char));
@@ -102,12 +104,11 @@ int main(int argc, char **argv)
 		task->detach = 0;
 
 	ret = starpu_task_submit(task);
-	if (ret == -ENODEV)
-			goto enodev;
+	if (ret == -ENODEV) goto enodev;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
 	ret = starpu_task_wait(task);
-	if (ret)
-		exit(-1);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
 
 	task = starpu_task_create();
 		task->cl = &display_cl;
@@ -116,21 +117,21 @@ int main(int argc, char **argv)
 		task->detach = 0;
 
 	ret = starpu_task_submit(task);
-	if (ret == -ENODEV)
-			goto enodev;
+	if (ret == -ENODEV) goto enodev;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
 	ret = starpu_task_wait(task);
-	if (ret)
-		exit(-1);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
 
 	/* this should get rid of automatically allocated buffers */
 	starpu_data_unregister(v_handle);
-
 	starpu_shutdown();
 
 	return 0;
 
 enodev:
+	starpu_data_unregister(v_handle);
+	starpu_shutdown();
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */

+ 5 - 1
tests/helper/cublas_init.c

@@ -21,6 +21,7 @@
 #include <errno.h>
 #include <starpu.h>
 #include <stdlib.h>
+#include "../common/helper.h"
 
 #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
 
@@ -31,7 +32,10 @@ struct timeval end;
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	unsigned ngpus = starpu_cuda_worker_get_count();
 

+ 7 - 3
tests/helper/execute_on_all.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <starpu.h>
 #include <stdlib.h>
+#include "../common/helper.h"
 
 void func(void *arg)
 {
@@ -29,14 +30,17 @@ void func(void *arg)
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	int arg = 0x42;
 
 	starpu_execute_on_each_worker(func, &arg, STARPU_CPU|STARPU_CUDA|STARPU_OPENCL);
 
 	starpu_execute_on_each_worker(func, &arg, STARPU_CPU);
-	
+
 	starpu_execute_on_each_worker(func, &arg, STARPU_CUDA);
 
         starpu_execute_on_each_worker(func, &arg, STARPU_OPENCL);

+ 8 - 3
tests/helper/pinned_memory.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -17,6 +17,7 @@
 
 #include <stdio.h>
 #include <starpu.h>
+#include "../common/helper.h"
 
 #define NITER	10
 #define SIZE	(4*1024*1024*sizeof(float))
@@ -25,12 +26,16 @@ static float *data = NULL;
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	unsigned iter;
 	for (iter = 0; iter < NITER; iter++)
 	{
-		starpu_malloc((void **)&data, SIZE);
+		ret = starpu_malloc((void **)&data, SIZE);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_malloc");
 		starpu_free(data);
 	}
 

+ 19 - 10
tests/helper/starpu_create_sync_task.c

@@ -17,6 +17,7 @@
 
 #include <stdio.h>
 #include <starpu.h>
+#include "../common/helper.h"
 
 #define NITER	10
 
@@ -33,7 +34,7 @@ static starpu_codelet dummy_codelet =
 	.nbuffers = 0
 };
 
-static void create_dummy_task(starpu_tag_t tag)
+static int create_dummy_task(starpu_tag_t tag)
 {
 	struct starpu_task *task = starpu_task_create();
 
@@ -42,17 +43,15 @@ static void create_dummy_task(starpu_tag_t tag)
 	task->cl = &dummy_codelet;
 	
 	int ret = starpu_task_submit(task);
-	if (ret)
-	{
-		fprintf(stderr, "Warning, no worker can execute the tasks\n");
-		/* This is not a bug from StarPU so we return a valid value. */
-		exit(0);
-	}
+	return ret;
 }
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	starpu_tag_t sync_tags[NITER];
 
@@ -71,16 +70,26 @@ int main(int argc, char **argv)
 		{
 			deps[d] = sync_tag + d + 1; 
 
-			create_dummy_task(deps[d]);
+			ret = create_dummy_task(deps[d]);
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 		}
 
 		starpu_create_sync_task(sync_tag, ndeps, deps, NULL, NULL);
 	}
 
 	/* Wait all the synchronization tasks */
-	starpu_tag_wait_array(NITER, sync_tags);
+	ret = starpu_tag_wait_array(NITER, sync_tags);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_tag_wait_array");
 
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 7 - 2
tests/helper/starpu_data_cpy.c

@@ -15,13 +15,17 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 int var1, var2;
 starpu_data_handle var1_handle, var2_handle;
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	var1 = 42;
 	var2 = 0;
@@ -29,7 +33,8 @@ int main(int argc, char **argv)
 	starpu_variable_data_register(&var1_handle, 0, (uintptr_t)&var1, sizeof(var1));
 	starpu_variable_data_register(&var2_handle, 0, (uintptr_t)&var2, sizeof(var2));
 
-	starpu_data_cpy(var2_handle, var1_handle, 0, NULL, NULL);
+	ret = starpu_data_cpy(var2_handle, var1_handle, 0, NULL, NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_cpy");
 
 	starpu_data_acquire(var2_handle, STARPU_R);
 	STARPU_ASSERT(var2 == 42);

+ 15 - 3
tests/microbenchs/async_tasks_overhead.c

@@ -22,6 +22,7 @@
 
 #include <starpu.h>
 #include <starpu_profiling.h>
+#include "../common/helper.h"
 
 static unsigned ntasks = 65536;
 
@@ -112,6 +113,7 @@ static void parse_args(int argc, char **argv)
 
 int main(int argc, char **argv)
 {
+	int ret;
 	unsigned i;
 	double timing;
 	struct timeval start;
@@ -119,7 +121,8 @@ int main(int argc, char **argv)
 
 	parse_args(argc, argv);
 
-	starpu_init(&conf);
+	ret = starpu_init(&conf);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	init_gordon_kernel();
 
@@ -143,10 +146,12 @@ int main(int argc, char **argv)
 	for (i = 0; i < ntasks; i++)
 	{
 		int ret = starpu_task_submit(tasks[i]);
-		STARPU_ASSERT(!ret);
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	gettimeofday(&end, NULL);
 
@@ -197,4 +202,11 @@ int main(int argc, char **argv)
 	free(tasks);
 
 	return 0;
+
+enodev:
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 5 - 1
tests/microbenchs/local_pingpong.c

@@ -22,6 +22,7 @@
 #include <starpu.h>
 #include <stdlib.h>
 #include <debug/starpu_debug_helpers.h>
+#include "../common/helper.h"
 
 static size_t vector_size = 1;
 
@@ -43,7 +44,10 @@ struct timeval end;
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* Create a piece of data */
 	starpu_malloc((void **)&v, vector_size);

+ 14 - 6
tests/microbenchs/prefetch_data_on_node.c

@@ -21,6 +21,7 @@
 #include <starpu.h>
 #include <stdlib.h>
 #include <pthread.h>
+#include "../common/helper.h"
 
 #define N	1000
 
@@ -70,7 +71,10 @@ static starpu_codelet cl = {
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	starpu_malloc((void **)&v, VECTORSIZE*sizeof(unsigned));
 	starpu_vector_data_register(&v_handle, 0, (uintptr_t)v, VECTORSIZE, sizeof(unsigned));
@@ -84,7 +88,8 @@ int main(int argc, char **argv)
 		{
 			/* synchronous prefetch */
 			unsigned node = starpu_worker_get_memory_node(worker);
-			starpu_data_prefetch_on_node(v_handle, node, 0);
+			ret = starpu_data_prefetch_on_node(v_handle, node, 0);
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_prefetch_on_node");
 
 			/* execute a task */
 			struct starpu_task *task = starpu_task_create();
@@ -107,7 +112,8 @@ int main(int argc, char **argv)
 		{
 			/* asynchronous prefetch */
 			unsigned node = starpu_worker_get_memory_node(worker);
-			starpu_data_prefetch_on_node(v_handle, node, 1);
+			ret = starpu_data_prefetch_on_node(v_handle, node, 1);
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_prefetch_on_node");
 
 			/* execute a task */
 			struct starpu_task *task = starpu_task_create();
@@ -122,12 +128,13 @@ int main(int argc, char **argv)
 			task->synchronous = 0;
 
 			int ret = starpu_task_submit(task);
-			if (ret == -ENODEV)
-				goto enodev;
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_submit");
 		}
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	starpu_free(v);
 	starpu_shutdown();
@@ -139,5 +146,6 @@ enodev:
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
 	return 77;
 }

+ 10 - 4
tests/microbenchs/redundant_buffer.c

@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <starpu.h>
 #include <stdlib.h>
+#include "../common/helper.h"
 
 #define N	10000
 
@@ -51,7 +52,10 @@ static starpu_codelet cl = {
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	starpu_malloc((void **)&v, VECTORSIZE*sizeof(unsigned));
 
@@ -70,11 +74,12 @@ int main(int argc, char **argv)
 		task->buffers[1].mode = STARPU_R;
 
 		int ret = starpu_task_submit(task);
-		if (ret == -ENODEV)
-			goto enodev;
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	starpu_free(v);
 	starpu_shutdown();
@@ -86,5 +91,6 @@ enodev:
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
 	return 77;
 }

+ 20 - 7
tests/microbenchs/sync_tasks_overhead.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2011  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -20,6 +20,7 @@
 #include <unistd.h>
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 static unsigned ntasks = 65536;
 
@@ -55,10 +56,9 @@ static void init_gordon_kernel(void)
 #endif
 }
 
-
-
-void inject_one_task(void)
+int inject_one_task(void)
 {
+	int ret;
 	struct starpu_task *task = starpu_task_create();
 
 	task->cl = &dummy_codelet;
@@ -66,7 +66,9 @@ void inject_one_task(void)
 	task->callback_func = NULL;
 	task->synchronous = 1;
 
-	starpu_task_submit(task);
+	ret = starpu_task_submit(task);
+	return ret;
+
 }
 
 static void parse_args(int argc, char **argv)
@@ -84,6 +86,7 @@ static void parse_args(int argc, char **argv)
 
 int main(int argc, char **argv)
 {
+	int ret;
 	unsigned i;
 	double timing;
 	struct timeval start;
@@ -91,7 +94,8 @@ int main(int argc, char **argv)
 
 	parse_args(argc, argv);
 
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	init_gordon_kernel();
 
@@ -100,7 +104,9 @@ int main(int argc, char **argv)
 	gettimeofday(&start, NULL);
 	for (i = 0; i < ntasks; i++)
 	{
-		inject_one_task();
+		ret = inject_one_task();
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 	gettimeofday(&end, NULL);
 
@@ -132,4 +138,11 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 20 - 5
tests/microbenchs/tasks_overhead.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2011  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -21,6 +21,7 @@
 #include <pthread.h>
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 starpu_data_handle data_handles[8];
 float *buffers[8];
@@ -76,6 +77,7 @@ static void parse_args(int argc, char **argv)
 
 int main(int argc, char **argv)
 {
+	int ret;
 	unsigned i;
 
 	double timing_submit;
@@ -95,7 +97,8 @@ int main(int argc, char **argv)
 		starpu_vector_data_register(&data_handles[buffer], 0, (uintptr_t)buffers[buffer], 16, sizeof(float));
 	}
 
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	fprintf(stderr, "#tasks : %u\n#buffers : %u\n", ntasks, nbuffers);
 
@@ -125,17 +128,22 @@ int main(int argc, char **argv)
 	{
 		starpu_tag_declare_deps((starpu_tag_t)i, 1, (starpu_tag_t)(i-1));
 
-		starpu_task_submit(&tasks[i]);
+		ret = starpu_task_submit(&tasks[i]);
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
 	/* submit the first task */
-	starpu_task_submit(&tasks[0]);
+	ret = starpu_task_submit(&tasks[0]);
+	if (ret == -ENODEV) goto enodev;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
 	gettimeofday(&end_submit, NULL);
 
 	/* wait for the execution of the tasks */
 	gettimeofday(&start_exec, NULL);
-	starpu_tag_wait((starpu_tag_t)(ntasks - 1));
+	ret = starpu_tag_wait((starpu_tag_t)(ntasks - 1));
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_tag_wait");
 	gettimeofday(&end_exec, NULL);
 
 	timing_submit = (double)((end_submit.tv_sec - start_submit.tv_sec)*1000000 + (end_submit.tv_usec - start_submit.tv_usec));
@@ -193,4 +201,11 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 20 - 9
tests/opt/datawizard/wt_broadcast.c

@@ -15,6 +15,7 @@
  */
 
 #include <starpu.h>
+#include "../../common/helper.h"
 
 #ifdef STARPU_USE_CUDA
 #include <starpu_cuda.h>
@@ -23,7 +24,6 @@
 #include <starpu_opencl.h>
 #endif
 
-
 static unsigned var = 0;
 static starpu_data_handle handle;
 /*
@@ -42,7 +42,7 @@ static void increment_opencl_kernel(void *descr[], void *cl_arg __attribute__((u
 
 	clEnqueueReadBuffer(queue, d_token, CL_TRUE, 0, sizeof(unsigned), (void *)&h_token, 0, NULL, NULL);
 	h_token++;
-	clEnqueueWriteBuffer(queue, d_token, CL_TRUE, 0, sizeof(unsigned), (void *)&h_token, 0, NULL, NULL); 
+	clEnqueueWriteBuffer(queue, d_token, CL_TRUE, 0, sizeof(unsigned), (void *)&h_token, 0, NULL, NULL);
 }
 #endif
 
@@ -84,7 +84,10 @@ static starpu_codelet increment_cl = {
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	unsigned nworkers = starpu_worker_get_count();
 
@@ -106,22 +109,30 @@ int main(int argc, char **argv)
 		for (t = 0; t < ntasks; t++)
 		{
 			struct starpu_task *task = starpu_task_create();
-	
+
 			task->cl = &increment_cl;
-	
+
 			task->buffers[0].mode = STARPU_RW;
 			task->buffers[0].handle = handle;
-	
-			int ret = starpu_task_submit(task);
-			STARPU_ASSERT(!ret);
 
+			int ret = starpu_task_submit(task);
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 		}
 	}
 
 	starpu_data_unregister(handle);
 	STARPU_ASSERT(var == ntasks*nloops);
-	
+
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	starpu_data_unregister(handle);
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 17 - 5
tests/opt/datawizard/wt_host.c

@@ -15,6 +15,7 @@
  */
 
 #include <starpu.h>
+#include "../../common/helper.h"
 
 #ifdef STARPU_USE_CUDA
 #include <starpu_cuda.h>
@@ -42,7 +43,7 @@ static void increment_opencl_kernel(void *descr[], void *cl_arg __attribute__((u
 
 	clEnqueueReadBuffer(queue, d_token, CL_TRUE, 0, sizeof(unsigned), (void *)&h_token, 0, NULL, NULL);
 	h_token++;
-	clEnqueueWriteBuffer(queue, d_token, CL_TRUE, 0, sizeof(unsigned), (void *)&h_token, 0, NULL, NULL); 
+	clEnqueueWriteBuffer(queue, d_token, CL_TRUE, 0, sizeof(unsigned), (void *)&h_token, 0, NULL, NULL);
 }
 #endif
 
@@ -84,7 +85,10 @@ static starpu_codelet increment_cl = {
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	starpu_variable_data_register(&handle, 0, (uintptr_t)&var, sizeof(unsigned));
 
@@ -106,8 +110,8 @@ int main(int argc, char **argv)
 		task->buffers[0].handle = handle;
 
 		int ret = starpu_task_submit(task);
-		STARPU_ASSERT(!ret);
-
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
 	starpu_data_unregister(handle);
@@ -116,8 +120,16 @@ int main(int argc, char **argv)
 		fprintf(stderr, "VAR is %d should be %d\n", var, ntasks);
 
 	STARPU_ASSERT(var == ntasks);
-	
+
 	starpu_shutdown();
 
 	return 0;
+
+enodev:
+	starpu_data_unregister(handle);
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
+	return 77;
 }

+ 10 - 6
tests/overlap/overlap.c

@@ -22,6 +22,7 @@
 #include <starpu.h>
 #include <stdlib.h>
 #include <pthread.h>
+#include "../common/helper.h"
 
 #define NTASKS	10000
 #define VECTORSIZE	1024
@@ -35,9 +36,6 @@ static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
 static unsigned finished = 0;
 static unsigned cnt = NTASKS;
 
-starpu_data_handle handle;
-static float *buffer;
-
 static void callback(void *arg)
 {
 	unsigned res = STARPU_ATOMIC_ADD(&cnt, -1);
@@ -74,7 +72,12 @@ static char symbolname[128];
 
 int main(int argc, char **argv)
 {
-	starpu_init(NULL);
+	int ret;
+	starpu_data_handle handle;
+	float *buffer;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* create data */
 	starpu_malloc((void **)&buffer, NTASKS*VECTORSIZE*sizeof(char));
@@ -108,8 +111,8 @@ int main(int argc, char **argv)
 		task->callback_arg = NULL;
 
 		int ret = starpu_task_submit(task);
-		if (ret == -ENODEV)
-			goto enodev;
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
 	pthread_mutex_lock(&mutex);
@@ -127,5 +130,6 @@ enodev:
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
 	return 77;
 }

+ 12 - 11
tests/parallel_tasks/explicit_combined_worker.c

@@ -18,17 +18,11 @@
 #include <starpu.h>
 #include <limits.h>
 #include <unistd.h>
+#include "../common/helper.h"
 
 #define N	1000
 #define VECTORSIZE	1024
 
-//static pthread_mutex_t mutex;
-//static pthread_cond_t cond;
-//static unsigned finished = 0;
-
-starpu_data_handle v_handle;
-static unsigned *v;
-
 static void codelet_null(void *descr[], __attribute__ ((unused)) void *_args)
 {
 	int worker_size = starpu_combined_worker_get_size();
@@ -54,6 +48,10 @@ static starpu_codelet cl = {
 
 int main(int argc, char **argv)
 {
+	starpu_data_handle v_handle;
+	unsigned *v;
+	int ret;
+
 //        struct starpu_conf conf = {
 //                .sched_policy_name = "pheft",
 //                .ncpus = -1,
@@ -66,7 +64,8 @@ int main(int argc, char **argv)
 //                .calibrate = -1
 //        };
 
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	starpu_malloc((void **)&v, VECTORSIZE*sizeof(unsigned));
 	starpu_vector_data_register(&v_handle, 0, (uintptr_t)v, VECTORSIZE, sizeof(unsigned));
@@ -89,12 +88,13 @@ int main(int argc, char **argv)
 			task->workerid = worker;
 
 			int ret = starpu_task_submit(task);
-			if (ret == -ENODEV)
-				goto enodev;
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 		}
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	starpu_free(v);
 	starpu_shutdown();
@@ -106,5 +106,6 @@ enodev:
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
 	return 77;
 }

+ 12 - 11
tests/parallel_tasks/parallel_kernels.c

@@ -18,17 +18,11 @@
 #include <starpu.h>
 #include <limits.h>
 #include <unistd.h>
+#include "../common/helper.h"
 
 #define N	1000
 #define VECTORSIZE	1024
 
-//static pthread_mutex_t mutex;
-//static pthread_cond_t cond;
-//static unsigned finished = 0;
-
-starpu_data_handle v_handle;
-static unsigned *v;
-
 static void codelet_null(void *descr[], __attribute__ ((unused)) void *_args)
 {
 	int worker_size = starpu_combined_worker_get_size();
@@ -60,6 +54,10 @@ static starpu_codelet cl = {
 
 int main(int argc, char **argv)
 {
+	int ret;
+	starpu_data_handle v_handle;
+	unsigned *v;
+
         struct starpu_conf conf = {
                 .sched_policy_name = "pheft",
                 .ncpus = -1,
@@ -72,7 +70,8 @@ int main(int argc, char **argv)
                 .calibrate = 1
         };
 
-	starpu_init(&conf);
+	ret = starpu_init(&conf);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	starpu_malloc((void **)&v, VECTORSIZE*sizeof(unsigned));
 	starpu_vector_data_register(&v_handle, 0, (uintptr_t)v, VECTORSIZE, sizeof(unsigned));
@@ -92,12 +91,13 @@ int main(int argc, char **argv)
 			task->buffers[0].mode = STARPU_R;
 
 			int ret = starpu_task_submit(task);
-			if (ret == -ENODEV)
-				goto enodev;
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 		}
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	starpu_free(v);
 	starpu_shutdown();
@@ -109,5 +109,6 @@ enodev:
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
 	return 77;
 }

+ 12 - 12
tests/parallel_tasks/parallel_kernels_spmd.c

@@ -18,17 +18,11 @@
 #include <starpu.h>
 #include <limits.h>
 #include <unistd.h>
+#include "../common/helper.h"
 
 #define N	1000
 #define VECTORSIZE	1024
 
-//static pthread_mutex_t mutex;
-//static pthread_cond_t cond;
-//static unsigned finished = 0;
-
-starpu_data_handle v_handle;
-static unsigned *v;
-
 static void codelet_null(void *descr[], __attribute__ ((unused)) void *_args)
 {
 	int worker_size = starpu_combined_worker_get_size();
@@ -62,6 +56,10 @@ static starpu_codelet cl = {
 
 int main(int argc, char **argv)
 {
+	int ret;
+	starpu_data_handle v_handle;
+	unsigned *v;
+
         struct starpu_conf conf = {
                 .sched_policy_name = "pheft",
                 .ncpus = -1,
@@ -74,7 +72,8 @@ int main(int argc, char **argv)
                 .calibrate = 1
         };
 
-	starpu_init(&conf);
+	ret = starpu_init(&conf);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	starpu_malloc((void **)&v, VECTORSIZE*sizeof(unsigned));
 	starpu_vector_data_register(&v_handle, 0, (uintptr_t)v, VECTORSIZE, sizeof(unsigned));
@@ -94,16 +93,16 @@ int main(int argc, char **argv)
 			task->buffers[0].mode = STARPU_R;
 
 			int ret = starpu_task_submit(task);
-			if (ret == -ENODEV)
-				goto enodev;
+			if (ret == -ENODEV) goto enodev;
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 		}
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	starpu_free(v);
 	starpu_shutdown();
-
 	return 0;
 
 enodev:
@@ -111,5 +110,6 @@ enodev:
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
 	return 77;
 }

+ 5 - 3
tests/parallel_tasks/spmd_pgreedy.c

@@ -73,11 +73,12 @@ int main(int argc, char **argv)
 		task->buffers[0].mode = STARPU_R;
 
 		int ret = starpu_task_submit(task);
-		if (ret == -ENODEV)
-			goto enodev;
+		if (ret == -ENODEV) goto enodev;
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	starpu_free(v);
 	starpu_shutdown();
@@ -89,5 +90,6 @@ enodev:
 	fprintf(stderr, "WARNING: No one can execute this task\n");
 	/* yes, we do not perform the computation but we did detect that no one
  	 * could perform the kernel, so this is not an error from StarPU */
+	starpu_shutdown();
 	return 77;
 }

+ 10 - 6
tests/perfmodels/non_linear_regression_based.c

@@ -15,6 +15,7 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 #ifdef STARPU_USE_CUDA
 static void memset_cuda(void *descr[], void *arg)
@@ -40,7 +41,7 @@ static struct starpu_perfmodel_t model = {
 	.symbol = "non_linear_memset_regression_based"
 };
 
-static starpu_codelet memset_cl = 
+static starpu_codelet memset_cl =
 {
 	.where = STARPU_CUDA|STARPU_CPU,
 #ifdef STARPU_USE_CUDA
@@ -62,27 +63,30 @@ static void test_memset(int nelems)
 	for (loop = 0; loop < nloops; loop++)
 	{
 		struct starpu_task *task = starpu_task_create();
-	
+
 		task->cl = &memset_cl;
 		task->buffers[0].handle = handle;
 		task->buffers[0].mode = STARPU_W;
-	
+
 		int ret = starpu_task_submit(task);
-		assert(!ret);
-	} 
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+	}
 
 	starpu_data_unregister(handle);
 }
 
 int main(int argc, char **argv)
 {
+	int ret;
+
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
 
 	conf.sched_policy_name = "eager";
 	conf.calibrate = 2;
 
-	starpu_init(&conf);
+	ret = starpu_init(&conf);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	int slog;
 	for (slog = 8; slog < 25; slog++)

+ 12 - 8
tests/perfmodels/regression_based.c

@@ -16,6 +16,7 @@
  */
 
 #include <starpu.h>
+#include "../common/helper.h"
 
 #ifdef STARPU_USE_CUDA
 static void memset_cuda(void *descr[], void *arg)
@@ -46,7 +47,7 @@ static struct starpu_perfmodel_t nl_model = {
 	.symbol = "non_linear_memset_regression_based"
 };
 
-static starpu_codelet memset_cl = 
+static starpu_codelet memset_cl =
 {
 	.where = STARPU_CUDA|STARPU_CPU,
 #ifdef STARPU_USE_CUDA
@@ -57,7 +58,7 @@ static starpu_codelet memset_cl =
 	.nbuffers = 1
 };
 
-static starpu_codelet nl_memset_cl = 
+static starpu_codelet nl_memset_cl =
 {
 	.where = STARPU_CUDA|STARPU_CPU,
 #ifdef STARPU_USE_CUDA
@@ -80,13 +81,13 @@ static void test_memset(int nelems, starpu_codelet *codelet)
 	for (loop = 0; loop < nloops; loop++)
 	{
 		struct starpu_task *task = starpu_task_create();
-	
+
 		task->cl = codelet;
 		task->buffers[0].handle = handle;
 		task->buffers[0].mode = STARPU_W;
-	
+
 		int ret = starpu_task_submit(task);
-		assert(!ret);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
         starpu_data_unregister(handle);
@@ -110,14 +111,15 @@ int main(int argc, char **argv)
 {
 	struct starpu_conf conf;
 	starpu_data_handle handle;
-	struct starpu_task *task = starpu_task_create();
+	int ret;
 
 	starpu_conf_init(&conf);
 
 	conf.sched_policy_name = "eager";
 	conf.calibrate = 2;
 
-	starpu_init(&conf);
+	ret = starpu_init(&conf);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	int size;
 	for (size = 1024; size < 16777216; size *= 2)
@@ -129,7 +131,8 @@ int main(int argc, char **argv)
 		test_memset(size, &nl_memset_cl);
 	}
 
-	starpu_task_wait_for_all();
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
 
 	/* Now create a dummy task just to estimate its duration according to the regression */
 
@@ -137,6 +140,7 @@ int main(int argc, char **argv)
 
 	starpu_vector_data_register(&handle, -1, (uintptr_t)NULL, size, sizeof(int));
 
+	struct starpu_task *task = starpu_task_create();
 	task->cl = &memset_cl;
 	task->buffers[0].handle = handle;
 	task->buffers[0].mode = STARPU_W;