Browse Source

examples: check return values of starpu functions

Nathalie Furmento 13 years ago
parent
commit
b91cc2a45b

+ 4 - 2
examples/basic_examples/block.c

@@ -86,7 +86,8 @@ int main(int argc, char **argv)
         int nz=4;
         float multiplier=1.0;
 
-        starpu_init(NULL);
+        ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
         block = (float*)malloc(nx*ny*nz*sizeof(float));
         assert(block);
@@ -104,7 +105,8 @@ int main(int argc, char **argv)
         ret = execute_on(STARPU_CPU, cpu_codelet, block, nx, ny, nz, 1.0);
         if (!ret) multiplier *= 1.0;
 #ifdef STARPU_USE_OPENCL
-        starpu_opencl_load_opencl_from_file("examples/basic_examples/block_opencl_kernel.cl", &opencl_code, NULL);
+        ret = starpu_opencl_load_opencl_from_file("examples/basic_examples/block_opencl_kernel.cl", &opencl_code, NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_opencl_load_opencl_from_file");
         ret = execute_on(STARPU_OPENCL, opencl_codelet, block, nx, ny, nz, 2.0);
         if (!ret) multiplier *= 2.0;
 #endif

+ 7 - 5
examples/basic_examples/hello_world.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -65,11 +65,13 @@ int main(int argc, char **argv)
 {
 	struct starpu_task *task;
 	struct params params = {1, 2.0f};
+	int ret;
 
 	/* initialize StarPU : passing a NULL argument means that we use
  	* default configuration for the scheduling policies and the number of
 	* processors/accelerators */
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* create a new task that is non-blocking by default : the task is not
 	 * submitted to the scheduler until the starpu_task_submit function is
@@ -97,7 +99,7 @@ int main(int argc, char **argv)
 	 * argument (cl_arg) is NOT a valid synchronization medium! */
 	task->cl_arg = &params;
 	task->cl_arg_size = sizeof(params);
-		
+
 	/* once the task has been executed, callback_func(0x42)
 	 * will be called on a CPU */
 	task->callback_func = callback_func;
@@ -105,13 +107,13 @@ int main(int argc, char **argv)
 
 	/* starpu_task_submit will be a blocking call */
 	task->synchronous = 1;
-	
+
 	/* submit the task to StarPU */
 	starpu_task_submit(task);
 
 	/* destroy the task */
 	starpu_task_destroy(task);
-	
+
 	/* terminate StarPU: statistics and other debug outputs are not
 	 * guaranteed to be generated unless this function is called. Once it
 	 * is called, it is not possible to submit tasks anymore, and the user

+ 11 - 6
examples/basic_examples/multiformat.c

@@ -270,7 +270,10 @@ int
 main(void)
 {
 #ifdef STARPU_USE_CPU
-	starpu_init(NULL);
+	int ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	ncpu = starpu_cpu_worker_get_count();
 #ifdef STARPU_USE_CUDA
@@ -284,10 +287,12 @@ main(void)
 		return 77;
 
 #ifdef STARPU_USE_OPENCL
-	starpu_opencl_load_opencl_from_file("examples/basic_examples/multiformat_opencl_kernel.cl",
-					    &opencl_program, NULL);
-	starpu_opencl_load_opencl_from_file("examples/basic_examples/multiformat_conversion_codelets_opencl_kernel.cl", 
-		&opencl_conversion_program, NULL);
+	ret = starpu_opencl_load_opencl_from_file("examples/basic_examples/multiformat_opencl_kernel.cl",
+						  &opencl_program, NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_opencl_load_opencl_from_file");
+	ret = starpu_opencl_load_opencl_from_file("examples/basic_examples/multiformat_conversion_codelets_opencl_kernel.cl", 
+						  &opencl_conversion_program, NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_opencl_load_opencl_from_file");
 #endif
 	init_problem_data();
 
@@ -312,6 +317,6 @@ main(void)
 #else
 	/* Without the CPU, there is no point in using the multiformat
 	 * interface, so this test is pointless. */
-	return EXIT_SUCCESS;
+	return 77;
 #endif
 }

+ 6 - 3
examples/basic_examples/variable.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2011  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -40,8 +40,10 @@ int main(int argc, char **argv)
         float foo;
 	starpu_data_handle_t float_array_handle;
 	struct starpu_codelet cl = {};
+	int ret;
 
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 #ifdef STARPU_SLOW_MACHINE
 	niter /= 100;
@@ -53,7 +55,8 @@ int main(int argc, char **argv)
                                       (uintptr_t)&foo, sizeof(float));
 
 #ifdef STARPU_USE_OPENCL
-        starpu_opencl_load_opencl_from_file("examples/basic_examples/variable_kernels_opencl_kernel.cl", &opencl_program, NULL);
+        ret = starpu_opencl_load_opencl_from_file("examples/basic_examples/variable_kernels_opencl_kernel.cl", &opencl_program, NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_opencl_load_opencl_from_file");
 #endif
 
 	cl.where = STARPU_CPU|STARPU_CUDA|STARPU_OPENCL;

+ 3 - 2
examples/basic_examples/vector_scal.c

@@ -100,8 +100,9 @@ int main(int argc, char **argv)
 	FPRINTF(stderr, "BEFORE: Last element was %f\n", vector[NX-1]);
 
 #ifdef STARPU_USE_OPENCL
-	starpu_opencl_load_opencl_from_file("examples/basic_examples/vector_scal_opencl_kernel.cl",
-					    &opencl_program, NULL);
+	ret = starpu_opencl_load_opencl_from_file("examples/basic_examples/vector_scal_opencl_kernel.cl",
+						  &opencl_program, NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_opencl_load_opencl_from_file");
 #endif
 
 	/* Tell StaPU to associate the "vector" vector with the "vector_handle"

+ 4 - 2
examples/basic_examples/vector_scal_c.c

@@ -56,9 +56,11 @@ static struct starpu_codelet cl =
 void compute_(int *F_NX, float *vector)
 {
         int NX = *F_NX;
-	
+	int ret;
+
 	/* Initialize StarPU with default configuration */
-	starpu_init(NULL);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	/* Tell StaPU to associate the "vector" vector with the "vector_handle"
 	 * identifier. When a task needs to access a piece of data, it should