Преглед изворни кода

mpi/tests: various improvments
- check return value of starpu functions
- mark tests as skipped when appropriate
- update coding style

Nathalie Furmento пре 13 година
родитељ
комит
ba130c422b

+ 28 - 18
mpi/tests/block_interface.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 <starpu_mpi.h>
 #include <stdlib.h>
+#include "helper.h"
 
 #define NITER	2048
 
@@ -25,31 +26,32 @@
 
 int main(int argc, char **argv)
 {
-	MPI_Init(NULL, NULL);
-
-	int rank, size;
+	int ret, rank, size;
 
+	MPI_Init(NULL, NULL);
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	MPI_Comm_size(MPI_COMM_WORLD, &size);
 
 	if (size < 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need at least processes.\n");
+			FPRINTF(stderr, "We need at least processes.\n");
 
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
 	/* We only use 2 nodes for that test */
 	if (rank >= 2)
 	{
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
-		
-	starpu_init(NULL);
-	starpu_mpi_initialize();
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize");
 
 	/* Node 0 will allocate a big block and only register an inner part of
 	 * it as the block data, Node 1 will allocate a block of small size and
@@ -89,13 +91,17 @@ int main(int argc, char **argv)
 
 	if (rank == 0)
 	{
-		starpu_mpi_send(block_handle, 1, 0x42, MPI_COMM_WORLD);
+		ret = starpu_mpi_send(block_handle, 1, 0x42, MPI_COMM_WORLD);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_send");
 
 		MPI_Status status;
-		starpu_mpi_recv(block_handle, 1, 0x1337, MPI_COMM_WORLD, &status);
+		ret = starpu_mpi_recv(block_handle, 1, 0x1337, MPI_COMM_WORLD, &status);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_recv");
 
 		/* check the content of the block */
-		starpu_data_acquire(block_handle, STARPU_R);
+		ret = starpu_data_acquire(block_handle, STARPU_R);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
+
 		unsigned i, j, k;
 		for (k = 0; k < SIZE; k++)
 		for (j = 0; j < SIZE; j++)
@@ -104,15 +110,18 @@ int main(int argc, char **argv)
 			assert(block[i + j*BIGSIZE + k*BIGSIZE*BIGSIZE] == 33.0f);
 		}
 		starpu_data_release(block_handle);
-		
+
 	}
 	else /* rank == 1 */
 	{
 		MPI_Status status;
-		starpu_mpi_recv(block_handle, 0, 0x42, MPI_COMM_WORLD, &status);
+		ret = starpu_mpi_recv(block_handle, 0, 0x42, MPI_COMM_WORLD, &status);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_recv");
 
 		/* check the content of the block and modify it */
-		starpu_data_acquire(block_handle, STARPU_RW);
+		ret = starpu_data_acquire(block_handle, STARPU_RW);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
+
 		unsigned i, j, k;
 		for (k = 0; k < SIZE; k++)
 		for (j = 0; j < SIZE; j++)
@@ -123,10 +132,11 @@ int main(int argc, char **argv)
 		}
 		starpu_data_release(block_handle);
 
-		starpu_mpi_send(block_handle, 0, 0x1337, MPI_COMM_WORLD);
+		ret = starpu_mpi_send(block_handle, 0, 0x1337, MPI_COMM_WORLD);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_send");
 	}
 
-	fprintf(stdout, "Rank %d is done\n", rank);
+	FPRINTF(stdout, "Rank %d is done\n", rank);
 	fflush(stdout);
 
 	starpu_mpi_shutdown();

+ 29 - 18
mpi/tests/block_interface_pinned.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 <starpu_mpi.h>
 #include <stdlib.h>
+#include "helper.h"
 
 #define NITER	2048
 
@@ -25,31 +26,32 @@
 
 int main(int argc, char **argv)
 {
-	MPI_Init(NULL, NULL);
-
-	int rank, size;
+	int ret, rank, size;
 
+	MPI_Init(NULL, NULL);
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	MPI_Comm_size(MPI_COMM_WORLD, &size);
 
 	if (size < 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need at least processes.\n");
+			FPRINTF(stderr, "We need at least processes.\n");
 
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
 	/* We only use 2 nodes for that test */
 	if (rank >= 2)
 	{
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
-		
-	starpu_init(NULL);
-	starpu_mpi_initialize();
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize");
 
 	/* Node 0 will allocate a big block and only register an inner part of
 	 * it as the block data, Node 1 will allocate a block of small size and
@@ -91,10 +93,13 @@ int main(int argc, char **argv)
 
 	if (rank == 0)
 	{
-		starpu_mpi_send(block_handle, 1, 0x42, MPI_COMM_WORLD);
-
 		MPI_Status status;
-		starpu_mpi_recv(block_handle, 1, 0x1337, MPI_COMM_WORLD, &status);
+
+		ret = starpu_mpi_send(block_handle, 1, 0x42, MPI_COMM_WORLD);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_send");
+
+		ret = starpu_mpi_recv(block_handle, 1, 0x1337, MPI_COMM_WORLD, &status);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_recv");
 
 		/* check the content of the block */
 		starpu_data_acquire(block_handle, STARPU_R);
@@ -106,15 +111,19 @@ int main(int argc, char **argv)
 			assert(block[i + j*BIGSIZE + k*BIGSIZE*BIGSIZE] == 33.0f);
 		}
 		starpu_data_release(block_handle);
-		
+
 	}
 	else /* rank == 1 */
 	{
 		MPI_Status status;
-		starpu_mpi_recv(block_handle, 0, 0x42, MPI_COMM_WORLD, &status);
+
+		ret = starpu_mpi_recv(block_handle, 0, 0x42, MPI_COMM_WORLD, &status);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_recv");
 
 		/* check the content of the block and modify it */
-		starpu_data_acquire(block_handle, STARPU_RW);
+		ret = starpu_data_acquire(block_handle, STARPU_RW);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_data_acquire");
+
 		unsigned i, j, k;
 		for (k = 0; k < SIZE; k++)
 		for (j = 0; j < SIZE; j++)
@@ -125,10 +134,12 @@ int main(int argc, char **argv)
 		}
 		starpu_data_release(block_handle);
 
-		starpu_mpi_send(block_handle, 0, 0x1337, MPI_COMM_WORLD);
+		ret = starpu_mpi_send(block_handle, 0, 0x1337, MPI_COMM_WORLD);
+		STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_send");
+
 	}
 
-	fprintf(stdout, "Rank %d is done\n", rank);
+	FPRINTF(stdout, "Rank %d is done\n", rank);
 	fflush(stdout);
 
 	starpu_mpi_shutdown();

+ 29 - 0
mpi/tests/helper.h

@@ -0,0 +1,29 @@
+/* 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
+
+#define STARPU_CHECK_RETURN_VALUE(err, message) {if (err < 0) { \
+			fprintf(stderr, "StarPU function <%s> returned unexpected value: <%s>\n", message, strerror(err)); \
+			STARPU_ASSERT(0); }}
+#define STARPU_CHECK_RETURN_VALUE_IS(err, value, message) {if (err != value) { \
+			fprintf(stderr, "StarPU function <%s> returned unexpected value: <%s>\n", message, strerror(err)); \
+			STARPU_ASSERT(0); }}
+
+#define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
+

+ 50 - 30
mpi/tests/insert_task.c

@@ -16,17 +16,19 @@
 
 #include <starpu_mpi.h>
 #include <math.h>
+#include "helper.h"
 
 void func_cpu(void *descr[], __attribute__ ((unused)) void *_args)
 {
 	unsigned *x = (unsigned *)STARPU_VARIABLE_GET_PTR(descr[0]);
 	unsigned *y = (unsigned *)STARPU_VARIABLE_GET_PTR(descr[1]);
 
-        fprintf(stdout, "VALUES: %d %d\n", *x, *y);
+        FPRINTF(stdout, "VALUES: %d %d\n", *x, *y);
         *x = (*x + *y) / 2;
 }
 
-struct starpu_codelet mycodelet = {
+struct starpu_codelet mycodelet =
+{
 	.where = STARPU_CPU,
 	.cpu_func = func_cpu,
         .nbuffers = 2
@@ -36,7 +38,8 @@ struct starpu_codelet mycodelet = {
 #define Y     5
 
 /* Returns the MPI node number where data indexes index is */
-int my_distrib(int x, int y, int nb_nodes) {
+int my_distrib(int x, int y, int nb_nodes)
+{
         return x % nb_nodes;
 }
 
@@ -44,42 +47,51 @@ int my_distrib(int x, int y, int nb_nodes) {
 int main(int argc, char **argv)
 {
         int rank, size, x, y;
-        int value=0;
+        int value=0, ret;
         unsigned matrix[X][Y];
         starpu_data_handle_t data_handles[X][Y];
 
-	starpu_init(NULL);
-	starpu_mpi_initialize_extended(&rank, &size);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize_extended(&rank, &size);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize_extended");
 
-        for(x = 0; x < X; x++) {
-                for (y = 0; y < Y; y++) {
+        for(x = 0; x < X; x++)
+	{
+                for (y = 0; y < Y; y++)
+		{
                         matrix[x][y] = (rank+1)*10 + value;
                         value++;
                 }
         }
 #if 0
         for(x = 0; x < X; x++) {
-                fprintf(stdout, "[%d] ", rank);
+                FPRINTF(stdout, "[%d] ", rank);
                 for (y = 0; y < Y; y++) {
-                        fprintf(stdout, "%3d ", matrix[x][y]);
+                        FPRINTF(stdout, "%3d ", matrix[x][y]);
                 }
-                fprintf(stdout, "\n");
+                FPRINTF(stdout, "\n");
         }
 #endif
 
-        for(x = 0; x < X; x++) {
-                for (y = 0; y < Y; y++) {
+        for(x = 0; x < X; x++)
+	{
+                for (y = 0; y < Y; y++)
+		{
                         int mpi_rank = my_distrib(x, y, size);
-                        if (mpi_rank == rank) {
-                                //fprintf(stderr, "[%d] Owning data[%d][%d]\n", rank, x, y);
+                        if (mpi_rank == rank)
+			{
+                                //FPRINTF(stderr, "[%d] Owning data[%d][%d]\n", rank, x, y);
                                 starpu_variable_data_register(&data_handles[x][y], 0, (uintptr_t)&(matrix[x][y]), sizeof(unsigned));
                         }
-                        else if (rank == mpi_rank+1 || rank == mpi_rank-1) {
+                        else if (rank == mpi_rank+1 || rank == mpi_rank-1)
+			{
                                 /* I don't own that index, but will need it for my computations */
-                                //fprintf(stderr, "[%d] Neighbour of data[%d][%d]\n", rank, x, y);
+                                //FPRINTF(stderr, "[%d] Neighbour of data[%d][%d]\n", rank, x, y);
                                 starpu_variable_data_register(&data_handles[x][y], -1, (uintptr_t)NULL, sizeof(unsigned));
                         }
-                        else {
+                        else
+			{
                                 /* I know it's useless to allocate anything for this */
                                 data_handles[x][y] = NULL;
                         }
@@ -91,16 +103,22 @@ int main(int argc, char **argv)
                 }
         }
 
-        starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[1][1], STARPU_R, data_handles[0][1], 0);
-        starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[3][1], STARPU_R, data_handles[0][1], 0);
-        starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[0][1], STARPU_R, data_handles[0][0], 0);
-        starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[3][1], STARPU_R, data_handles[0][1], 0);
+        ret = starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[1][1], STARPU_R, data_handles[0][1], 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_insert_task");
+        ret = starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[3][1], STARPU_R, data_handles[0][1], 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_insert_task");
+        ret = starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[0][1], STARPU_R, data_handles[0][0], 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_insert_task");
+        ret = starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[3][1], STARPU_R, data_handles[0][1], 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_insert_task");
 
-        fprintf(stderr, "Waiting ...\n");
+        FPRINTF(stderr, "Waiting ...\n");
         starpu_task_wait_for_all();
 
-        for(x = 0; x < X; x++) {
-                for (y = 0; y < Y; y++) {
+        for(x = 0; x < X; x++)
+	{
+                for (y = 0; y < Y; y++)
+		{
                         if (data_handles[x][y])
                                 starpu_data_unregister(data_handles[x][y]);
                 }
@@ -109,12 +127,14 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 #if 0
-        for(x = 0; x < X; x++) {
-                fprintf(stdout, "[%d] ", rank);
-                for (y = 0; y < Y; y++) {
-                        fprintf(stdout, "%3d ", matrix[x][y]);
+        for(x = 0; x < X; x++)
+	{
+                FPRINTF(stdout, "[%d] ", rank);
+                for (y = 0; y < Y; y++)
+		{
+                        FPRINTF(stdout, "%3d ", matrix[x][y]);
                 }
-                fprintf(stdout, "\n");
+                FPRINTF(stdout, "\n");
         }
 #endif
 

+ 56 - 33
mpi/tests/insert_task_block.c

@@ -16,6 +16,7 @@
 
 #include <starpu_mpi.h>
 #include <math.h>
+#include "helper.h"
 
 void func_cpu(void *descr[], __attribute__ ((unused)) void *_args)
 {
@@ -27,19 +28,24 @@ void func_cpu(void *descr[], __attribute__ ((unused)) void *_args)
         int i, j;
         unsigned sum=0;
 
-	for (i = 0; i < nx; i++) {
-		for (j = 0; j < ny; j++) {
+	for (i = 0; i < nx; i++)
+	{
+		for (j = 0; j < ny; j++)
+		{
                         sum += matrix[i+j*ld];
                 }
         }
-	for (i = 0; i < nx; i++) {
-		for (j = 0; j < ny; j++) {
+	for (i = 0; i < nx; i++)
+	{
+		for (j = 0; j < ny; j++)
+		{
                         matrix[i+j*ld] = sum;///(nx*ny);
                 }
         }
 }
 
-struct starpu_codelet mycodelet = {
+struct starpu_codelet mycodelet =
+{
 	.where = STARPU_CPU,
 	.cpu_func = func_cpu,
         .nbuffers = 1
@@ -49,7 +55,8 @@ struct starpu_codelet mycodelet = {
 #define BLOCKS     3
 
 /* Returns the MPI node number where data indexes index is */
-int my_distrib(int x, int y, int nb_nodes) {
+int my_distrib(int x, int y, int nb_nodes)
+{
         return x % nb_nodes;
 }
 
@@ -57,44 +64,53 @@ int my_distrib(int x, int y, int nb_nodes) {
 int main(int argc, char **argv)
 {
         int rank, size, x, y;
-        int value=0;
+        int ret, value=0;
         unsigned matrix[SIZE*SIZE];
         starpu_data_handle_t data_handles[SIZE][SIZE];
 
-	starpu_init(NULL);
-	starpu_mpi_initialize_extended(&rank, &size);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize_extended(&rank, &size);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize_extended");
 
-        for(x = 0; x < SIZE; x++) {
-                for (y = 0; y < SIZE; y++) {
+        for(x = 0; x < SIZE; x++)
+	{
+                for (y = 0; y < SIZE; y++)
+		{
                         matrix[x+y*SIZE] = rank*100 + value;
                         value++;
                 }
         }
 #if 1
         for(x = 0; x < SIZE; x++) {
-                fprintf(stdout, "[%d] ", rank);
+                FPRINTF(stdout, "[%d] ", rank);
                 for (y = 0; y < SIZE; y++) {
-                        fprintf(stdout, "%3d ", matrix[x+y*SIZE]);
+                        FPRINTF(stdout, "%3d ", matrix[x+y*SIZE]);
                 }
-                fprintf(stdout, "\n");
+                FPRINTF(stdout, "\n");
         }
 #endif
 
-        for(x = 0; x < BLOCKS ;  x++) {
-                for (y = 0; y < BLOCKS; y++) {
+        for(x = 0; x < BLOCKS ;  x++)
+	{
+                for (y = 0; y < BLOCKS; y++)
+		{
                         int mpi_rank = my_distrib(x, y, size);
-                        if (mpi_rank == rank) {
-                                //fprintf(stderr, "[%d] Owning data[%d][%d]\n", rank, x, y);
+                        if (mpi_rank == rank)
+			{
+                                //FPRINTF(stderr, "[%d] Owning data[%d][%d]\n", rank, x, y);
                                 starpu_matrix_data_register(&data_handles[x][y], 0, (uintptr_t)&(matrix[((SIZE/BLOCKS)*x) + ((SIZE/BLOCKS)*y) * SIZE]),
                                                             SIZE, SIZE/BLOCKS, SIZE/BLOCKS, sizeof(unsigned));
                         }
-                        else if (rank == mpi_rank+1 || rank == mpi_rank-1) {
+                        else if (rank == mpi_rank+1 || rank == mpi_rank-1)
+			{
                                 /* I don't own that index, but will need it for my computations */
-                                //fprintf(stderr, "[%d] Neighbour of data[%d][%d]\n", rank, x, y);
+                                //FPRINTF(stderr, "[%d] Neighbour of data[%d][%d]\n", rank, x, y);
                                 starpu_matrix_data_register(&data_handles[x][y], -1, (uintptr_t)&(matrix[((SIZE/BLOCKS)*x) + ((SIZE/BLOCKS)*y) * SIZE]),
                                                             SIZE, SIZE/BLOCKS, SIZE/BLOCKS, sizeof(unsigned));
                         }
-                        else {
+                        else
+			{
                                 /* I know it's useless to allocate anything for this */
                                 data_handles[x][y] = NULL;
                         }
@@ -106,19 +122,25 @@ int main(int argc, char **argv)
                 }
         }
 
-        for(x = 0; x < BLOCKS; x++) {
-                for (y = 0; y < BLOCKS; y++) {
-                        starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet,
-                                               STARPU_RW, data_handles[x][y],
-                                               0);
+        for(x = 0; x < BLOCKS; x++)
+	{
+                for (y = 0; y < BLOCKS; y++)
+		{
+                        ret = starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet,
+						     STARPU_RW, data_handles[x][y],
+						     0);
+			STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_insert_task");
+
                 }
         }
 
-        fprintf(stderr, "Waiting ...\n");
+        FPRINTF(stderr, "Waiting ...\n");
         starpu_task_wait_for_all();
 
-        for(x = 0; x < BLOCKS; x++) {
-                for (y = 0; y < BLOCKS; y++) {
+        for(x = 0; x < BLOCKS; x++)
+	{
+                for (y = 0; y < BLOCKS; y++)
+		{
                         if (data_handles[x][y])
                                 starpu_data_unregister(data_handles[x][y]);
                 }
@@ -128,12 +150,13 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 #if 1
-        for(x = 0; x < SIZE; x++) {
-                fprintf(stdout, "[%d] ", rank);
+        for(x = 0; x < SIZE; x++)
+	{
+                FPRINTF(stdout, "[%d] ", rank);
                 for (y = 0; y < SIZE; y++) {
-                        fprintf(stdout, "%3d ", matrix[x+y*SIZE]);
+                        FPRINTF(stdout, "%3d ", matrix[x+y*SIZE]);
                 }
-                fprintf(stdout, "\n");
+                FPRINTF(stdout, "\n");
         }
 #endif
 

+ 54 - 32
mpi/tests/insert_task_cache.c

@@ -16,17 +16,19 @@
 
 #include <starpu_mpi.h>
 #include <math.h>
+#include "helper.h"
 
 void func_cpu(void *descr[], __attribute__ ((unused)) void *_args)
 {
 	unsigned *x = (unsigned *)STARPU_VARIABLE_GET_PTR(descr[0]);
 	unsigned *y = (unsigned *)STARPU_VARIABLE_GET_PTR(descr[1]);
 
-        fprintf(stdout, "VALUES: %d %d\n", *x, *y);
+        FPRINTF(stdout, "VALUES: %d %d\n", *x, *y);
         *x = (*x + *y) / 2;
 }
 
-struct starpu_codelet mycodelet = {
+struct starpu_codelet mycodelet =
+{
 	.where = STARPU_CPU,
 	.cpu_func = func_cpu,
         .nbuffers = 2
@@ -36,7 +38,8 @@ struct starpu_codelet mycodelet = {
 #define Y     5
 
 /* Returns the MPI node number where data indexes index is */
-int my_distrib(int x, int y, int nb_nodes) {
+int my_distrib(int x, int y, int nb_nodes)
+{
         return x % nb_nodes;
 }
 
@@ -44,42 +47,53 @@ int my_distrib(int x, int y, int nb_nodes) {
 int main(int argc, char **argv)
 {
         int rank, size, x, y;
-        int value=0;
+        int ret,value=0;
         unsigned matrix[X][Y];
         starpu_data_handle_t data_handles[X][Y];
 
-	starpu_init(NULL);
-	starpu_mpi_initialize_extended(&rank, &size);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize_extended(&rank, &size);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize_extended");
 
-        for(x = 0; x < X; x++) {
-                for (y = 0; y < Y; y++) {
+        for(x = 0; x < X; x++)
+	{
+                for (y = 0; y < Y; y++)
+		{
                         matrix[x][y] = (rank+1)*10 + value;
                         value++;
                 }
         }
 #if 0
-        for(x = 0; x < X; x++) {
-                fprintf(stdout, "[%d] ", rank);
-                for (y = 0; y < Y; y++) {
-                        fprintf(stdout, "%3d ", matrix[x][y]);
+        for(x = 0; x < X; x++)
+	{
+                FPRINTF(stdout, "[%d] ", rank);
+                for (y = 0; y < Y; y++)
+		{
+                        FPRINTF(stdout, "%3d ", matrix[x][y]);
                 }
-                fprintf(stdout, "\n");
+                FPRINTF(stdout, "\n");
         }
 #endif
 
-        for(x = 0; x < X; x++) {
-                for (y = 0; y < Y; y++) {
+        for(x = 0; x < X; x++)
+	{
+                for (y = 0; y < Y; y++)
+		{
                         int mpi_rank = my_distrib(x, y, size);
-                        if (mpi_rank == rank) {
-                                //fprintf(stderr, "[%d] Owning data[%d][%d]\n", rank, x, y);
+                        if (mpi_rank == rank)
+			{
+                                //FPRINTF(stderr, "[%d] Owning data[%d][%d]\n", rank, x, y);
                                 starpu_variable_data_register(&data_handles[x][y], 0, (uintptr_t)&(matrix[x][y]), sizeof(unsigned));
                         }
-                        else if (rank == mpi_rank+1 || rank == mpi_rank-1) {
+                        else if (rank == mpi_rank+1 || rank == mpi_rank-1)
+			{
                                 /* I don't own that index, but will need it for my computations */
-                                //fprintf(stderr, "[%d] Neighbour of data[%d][%d]\n", rank, x, y);
+                                //FPRINTF(stderr, "[%d] Neighbour of data[%d][%d]\n", rank, x, y);
                                 starpu_variable_data_register(&data_handles[x][y], -1, (uintptr_t)NULL, sizeof(unsigned));
                         }
-                        else {
+                        else
+			{
                                 /* I know it's useless to allocate anything for this */
                                 data_handles[x][y] = NULL;
                         }
@@ -91,16 +105,22 @@ int main(int argc, char **argv)
                 }
         }
 
-        starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[1][1], STARPU_R, data_handles[0][1], 0);
-        starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[3][1], STARPU_R, data_handles[0][1], 0);
-        starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[0][1], STARPU_R, data_handles[0][0], 0);
-        starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[3][1], STARPU_R, data_handles[0][1], 0);
+        ret = starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[1][1], STARPU_R, data_handles[0][1], 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_insert_task");
+        ret = starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[3][1], STARPU_R, data_handles[0][1], 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_insert_task");
+        ret = starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[0][1], STARPU_R, data_handles[0][0], 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_insert_task");
+        ret = starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet, STARPU_RW, data_handles[3][1], STARPU_R, data_handles[0][1], 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_insert_task");
 
-        fprintf(stderr, "Waiting ...\n");
+        FPRINTF(stderr, "Waiting ...\n");
         starpu_task_wait_for_all();
 
-        for(x = 0; x < X; x++) {
-                for (y = 0; y < Y; y++) {
+        for(x = 0; x < X; x++)
+	{
+                for (y = 0; y < Y; y++)
+		{
                         if (data_handles[x][y])
                                 starpu_data_unregister(data_handles[x][y]);
                 }
@@ -109,12 +129,14 @@ int main(int argc, char **argv)
 	starpu_shutdown();
 
 #if 0
-        for(x = 0; x < X; x++) {
-                fprintf(stdout, "[%d] ", rank);
-                for (y = 0; y < Y; y++) {
-                        fprintf(stdout, "%3d ", matrix[x][y]);
+        for(x = 0; x < X; x++)
+	{
+                FPRINTF(stdout, "[%d] ", rank);
+                for (y = 0; y < Y; y++)
+		{
+                        FPRINTF(stdout, "%3d ", matrix[x][y]);
                 }
-                fprintf(stdout, "\n");
+                FPRINTF(stdout, "\n");
         }
 #endif
 

+ 17 - 10
mpi/tests/insert_task_owner.c

@@ -16,6 +16,7 @@
 
 #include <starpu_mpi.h>
 #include <math.h>
+#include "helper.h"
 
 void func_cpu(void *descr[], __attribute__ ((unused)) void *_args)
 {
@@ -26,7 +27,8 @@ void func_cpu(void *descr[], __attribute__ ((unused)) void *_args)
         *y = *y + 1;
 }
 
-struct starpu_codelet mycodelet = {
+struct starpu_codelet mycodelet =
+{
 	.where = STARPU_CPU,
 	.cpu_func = func_cpu,
         .nbuffers = 2
@@ -35,7 +37,7 @@ struct starpu_codelet mycodelet = {
 #define ACQUIRE_DATA \
         if (rank == 0) starpu_data_acquire(data_handlesx0, STARPU_R);    \
         if (rank == 1) starpu_data_acquire(data_handlesx1, STARPU_R);    \
-        fprintf(stderr, "[%d] Values: %d %d\n", rank, x0, x1);
+        FPRINTF(stderr, "[%d] Values: %d %d\n", rank, x0, x1);
 
 #define RELEASE_DATA \
         if (rank == 0) starpu_data_release(data_handlesx0); \
@@ -47,22 +49,26 @@ struct starpu_codelet mycodelet = {
 
 int main(int argc, char **argv)
 {
-        int rank, size, err;
+        int ret, rank, size, err;
         int x0=0, x1=0, vx0[2] = {x0, x0}, vx1[2]={x1,x1};
         starpu_data_handle_t data_handlesx0;
         starpu_data_handle_t data_handlesx1;
 
-	starpu_init(NULL);
-	starpu_mpi_initialize_extended(&rank, &size);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize_extended(&rank, &size);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize_extended");
 
-        if (size != 2) {
-		if (rank == 0) fprintf(stderr, "We need exactly 2 processes.\n");
+        if (size != 2)
+	{
+		if (rank == 0) FPRINTF(stderr, "We need exactly 2 processes.\n");
                 starpu_mpi_shutdown();
                 starpu_shutdown();
-                return 0;
+                return STARPU_TEST_SKIPPED;
         }
 
-        if (rank == 0) {
+        if (rank == 0)
+	{
                 starpu_variable_data_register(&data_handlesx0, 0, (uintptr_t)&x0, sizeof(x0));
                 starpu_data_set_rank(data_handlesx0, rank);
 		starpu_data_set_tag(data_handlesx0, 0);
@@ -70,7 +76,8 @@ int main(int argc, char **argv)
                 starpu_data_set_rank(data_handlesx1, 1);
 		starpu_data_set_tag(data_handlesx1, 1);
         }
-        else if (rank == 1) {
+        else if (rank == 1)
+	{
                 starpu_variable_data_register(&data_handlesx1, 0, (uintptr_t)&x1, sizeof(x1));
                 starpu_data_set_rank(data_handlesx1, rank);
 		starpu_data_set_tag(data_handlesx1, 1);

+ 28 - 18
mpi/tests/insert_task_owner2.c

@@ -17,6 +17,7 @@
 #include <starpu_mpi.h>
 #include <starpu_mpi_datatype.h>
 #include <math.h>
+#include "helper.h"
 
 void func_cpu(void *descr[], __attribute__ ((unused)) void *_args)
 {
@@ -25,20 +26,21 @@ void func_cpu(void *descr[], __attribute__ ((unused)) void *_args)
 	int *x2 = (int *)STARPU_VARIABLE_GET_PTR(descr[2]);
 	int *y = (int *)STARPU_VARIABLE_GET_PTR(descr[3]);
 
-//        fprintf(stderr, "-------> CODELET VALUES: %d %d %d %d\n", *x0, *x1, *x2, *y);
+//        FPRINTF(stderr, "-------> CODELET VALUES: %d %d %d %d\n", *x0, *x1, *x2, *y);
 //
 //        *x2 = 45;
 //        *y = 144;
 //
-        fprintf(stderr, "-------> CODELET VALUES: %d %d %d %d\n", *x0, *x1, *x2, *y);
+        FPRINTF(stderr, "-------> CODELET VALUES: %d %d %d %d\n", *x0, *x1, *x2, *y);
         *y = (*x0 + *x1) * 100;
         *x1 = 12;
         *x2 = 24;
         *x0 = 36;
-        fprintf(stderr, "-------> CODELET VALUES: %d %d %d %d\n", *x0, *x1, *x2, *y);
+        FPRINTF(stderr, "-------> CODELET VALUES: %d %d %d %d\n", *x0, *x1, *x2, *y);
 }
 
-struct starpu_codelet mycodelet = {
+struct starpu_codelet mycodelet =
+{
 	.where = STARPU_CPU,
 	.cpu_func = func_cpu,
         .nbuffers = 4
@@ -48,20 +50,25 @@ int main(int argc, char **argv)
 {
         int rank, size, err;
         int x[3], y=0;
-        int i;
+        int i, ret;
         starpu_data_handle_t data_handles[4];
 
-	starpu_init(NULL);
-	starpu_mpi_initialize_extended(&rank, &size);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize_extended(&rank, &size);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize_extended");
 
-        if (rank > 1) {
+        if (rank > 1)
+	{
                 starpu_mpi_shutdown();
                 starpu_shutdown();
-                return 0;
+                return STARPU_TEST_SKIPPED;
         }
 
-        if (rank == 0) {
-                for(i=0 ; i<3 ; i++) {
+        if (rank == 0)
+	{
+                for(i=0 ; i<3 ; i++)
+		{
                         x[i] = 10*(i+1);
                         starpu_variable_data_register(&data_handles[i], 0, (uintptr_t)&x[i], sizeof(x[i]));
                         starpu_data_set_rank(data_handles[i], rank);
@@ -72,8 +79,10 @@ int main(int argc, char **argv)
                 starpu_data_set_rank(data_handles[3], 1);
 		starpu_data_set_tag(data_handles[3], 3);
         }
-        else if (rank == 1) {
-                for(i=0 ; i<3 ; i++) {
+        else if (rank == 1)
+	{
+                for(i=0 ; i<3 ; i++)
+		{
                         x[i] = -1;
                         starpu_variable_data_register(&data_handles[i], -1, (uintptr_t)NULL, sizeof(int));
                         starpu_data_set_rank(data_handles[i], 0);
@@ -84,24 +93,25 @@ int main(int argc, char **argv)
                 starpu_data_set_rank(data_handles[3], rank);
 		starpu_data_set_tag(data_handles[3], 3);
         }
-        fprintf(stderr, "[%d][init] VALUES: %d %d %d %d\n", rank, x[0], x[1], x[2], y);
+        FPRINTF(stderr, "[%d][init] VALUES: %d %d %d %d\n", rank, x[0], x[1], x[2], y);
 
         err = starpu_mpi_insert_task(MPI_COMM_WORLD, &mycodelet,
                                      STARPU_R, data_handles[0], STARPU_RW, data_handles[1],
                                      STARPU_W, data_handles[2],
                                      STARPU_W, data_handles[3],
                                      STARPU_EXECUTE_ON_NODE, 1, 0);
-        assert(err == 0);
+	STARPU_CHECK_RETURN_VALUE(err, "starpu_mpi_insert_task");
         starpu_task_wait_for_all();
 
         int *values = malloc(4 * sizeof(int *));
-        for(i=0 ; i<4 ; i++) {
+        for(i=0 ; i<4 ; i++)
+	{
                 starpu_mpi_get_data_on_node(MPI_COMM_WORLD, data_handles[i], 0);
                 starpu_data_acquire(data_handles[i], STARPU_R);
                 values[i] = *((int *)starpu_mpi_handle_to_ptr(data_handles[i]));
         }
-        fprintf(stderr, "[%d][local ptr] VALUES: %d %d %d %d\n", rank, values[0], values[1], values[2], values[3]);
-        fprintf(stderr, "[%d][end] VALUES: %d %d %d %d\n", rank, x[0], x[1], x[2], y);
+        FPRINTF(stderr, "[%d][local ptr] VALUES: %d %d %d %d\n", rank, values[0], values[1], values[2], values[3]);
+        FPRINTF(stderr, "[%d][end] VALUES: %d %d %d %d\n", rank, x[0], x[1], x[2], y);
 
 	starpu_mpi_shutdown();
 	starpu_shutdown();

+ 18 - 10
mpi/tests/insert_task_owner_data.c

@@ -17,6 +17,7 @@
 #include <starpu_mpi.h>
 #include <starpu_mpi_datatype.h>
 #include <math.h>
+#include "helper.h"
 
 void func_cpu(void *descr[], __attribute__ ((unused)) void *_args)
 {
@@ -27,7 +28,8 @@ void func_cpu(void *descr[], __attribute__ ((unused)) void *_args)
 	*x1 *= *x1;
 }
 
-struct starpu_codelet mycodelet = {
+struct starpu_codelet mycodelet =
+{
 	.where = STARPU_CPU,
 	.cpu_func = func_cpu,
         .nbuffers = 2
@@ -37,20 +39,24 @@ int main(int argc, char **argv)
 {
         int rank, size, err;
         int x[2];
-        int i;
+        int ret, i;
         starpu_data_handle_t data_handles[2];
 	int values[2];
 
-	starpu_init(NULL);
-	starpu_mpi_initialize_extended(&rank, &size);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize_extended(&rank, &size);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize_extended");
 
-        if (rank > 1) {
+        if (rank > 1)
+	{
                 starpu_mpi_shutdown();
                 starpu_shutdown();
-                return 0;
+                return STARPU_TEST_SKIPPED;
         }
 
-        if (rank == 0) {
+        if (rank == 0)
+	{
 		x[0] = 11;
 		starpu_variable_data_register(&data_handles[0], 0, (uintptr_t)&x[0], sizeof(x[0]));
 		starpu_data_set_rank(data_handles[0], 0);
@@ -59,7 +65,8 @@ int main(int argc, char **argv)
 		starpu_data_set_rank(data_handles[1], 1);
 		starpu_data_set_tag(data_handles[1],10);
         }
-        else if (rank == 1) {
+        else if (rank == 1)
+	{
 		x[1] = 12;
 		starpu_variable_data_register(&data_handles[0], -1, (uintptr_t)NULL, sizeof(x[0]));
 		starpu_data_set_rank(data_handles[0], 0);
@@ -76,13 +83,14 @@ int main(int argc, char **argv)
         assert(err == 0);
         starpu_task_wait_for_all();
 
-        for(i=0 ; i<2 ; i++) {
+        for(i=0 ; i<2 ; i++)
+	{
                 starpu_mpi_get_data_on_node(MPI_COMM_WORLD, data_handles[i], 0);
                 starpu_data_acquire(data_handles[i], STARPU_R);
                 values[i] = *((int *)starpu_mpi_handle_to_ptr(data_handles[i]));
         }
 	assert(values[0] == 12 && values[1] == 144);
-        fprintf(stderr, "[%d][local ptr] VALUES: %d %d\n", rank, values[0], values[1]);
+        FPRINTF(stderr, "[%d][local ptr] VALUES: %d %d\n", rank, values[0], values[1]);
 
 	starpu_mpi_shutdown();
 	starpu_shutdown();

+ 13 - 10
mpi/tests/mpi_detached_tag.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_mpi.h>
+#include "helper.h"
 
 #define NITER	2048
 #define SIZE	16
@@ -25,24 +26,25 @@ starpu_data_handle_t tab_handle;
 
 int main(int argc, char **argv)
 {
-	MPI_Init(NULL, NULL);
-
-	int rank, size;
+	int ret, rank, size;
 
+	MPI_Init(NULL, NULL);
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	MPI_Comm_size(MPI_COMM_WORLD, &size);
 
 	if (size != 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need exactly 2 processes.\n");
+			FPRINTF(stderr, "We need exactly 2 processes.\n");
 
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
-	starpu_init(NULL);
-	starpu_mpi_initialize();
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize");
 
 	tab = malloc(SIZE*sizeof(float));
 
@@ -61,13 +63,14 @@ int main(int argc, char **argv)
 		{
 			starpu_mpi_isend_detached_unlock_tag(tab_handle, other_rank, loop, MPI_COMM_WORLD, tag);
 		}
-		else {
+		else
+		{
 			starpu_mpi_irecv_detached_unlock_tag(tab_handle, other_rank, loop, MPI_COMM_WORLD, tag);
 		}
 
 		starpu_tag_wait(tag);
 	}
-	
+
 	starpu_mpi_shutdown();
 	starpu_shutdown();
 

+ 13 - 10
mpi/tests/mpi_irecv.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_mpi.h>
+#include "helper.h"
 
 #define NITER	2048
 #define SIZE	16
@@ -25,24 +26,25 @@ starpu_data_handle_t tab_handle;
 
 int main(int argc, char **argv)
 {
-	MPI_Init(NULL, NULL);
-
-	int rank, size;
+	int ret, rank, size;
 
+	MPI_Init(NULL, NULL);
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	MPI_Comm_size(MPI_COMM_WORLD, &size);
 
 	if (size != 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need exactly 2 processes.\n");
+			FPRINTF(stderr, "We need exactly 2 processes.\n");
 
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
-	starpu_init(NULL);
-	starpu_mpi_initialize();
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize");
 
 	tab = malloc(SIZE*sizeof(float));
 
@@ -59,14 +61,15 @@ int main(int argc, char **argv)
 		{
 			starpu_mpi_send(tab_handle, other_rank, loop, MPI_COMM_WORLD);
 		}
-		else {
+		else
+		{
 			MPI_Status status;
 			starpu_mpi_req req;
 			starpu_mpi_irecv(tab_handle, &req, other_rank, loop, MPI_COMM_WORLD);
 			starpu_mpi_wait(&req, &status);
 		}
 	}
-	
+
 	starpu_mpi_shutdown();
 	starpu_shutdown();
 

+ 13 - 10
mpi/tests/mpi_irecv_detached.c

@@ -17,6 +17,7 @@
 
 #include <starpu_mpi.h>
 #include <common/utils.h>
+#include "helper.h"
 
 #define NITER	2048
 #define SIZE	16
@@ -30,7 +31,7 @@ static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
 void callback(void *arg __attribute__((unused)))
 {
 	unsigned *received = arg;
-	
+
 	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	*received = 1;
 	_STARPU_PTHREAD_COND_SIGNAL(&cond);
@@ -40,24 +41,25 @@ void callback(void *arg __attribute__((unused)))
 
 int main(int argc, char **argv)
 {
-	MPI_Init(NULL, NULL);
-
-	int rank, size;
+	int ret, rank, size;
 
+	MPI_Init(NULL, NULL);
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	MPI_Comm_size(MPI_COMM_WORLD, &size);
 
 	if (size != 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need exactly 2 processes.\n");
+			FPRINTF(stderr, "We need exactly 2 processes.\n");
 
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
-	starpu_init(NULL);
-	starpu_mpi_initialize();
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize");
 
 	tab = malloc(SIZE*sizeof(float));
 
@@ -74,7 +76,8 @@ int main(int argc, char **argv)
 		{
 			starpu_mpi_send(tab_handle, other_rank, loop, MPI_COMM_WORLD);
 		}
-		else {
+		else
+		{
 			int received = 0;
 			starpu_mpi_irecv_detached(tab_handle, other_rank, loop, MPI_COMM_WORLD, callback, &received);
 
@@ -84,7 +87,7 @@ int main(int argc, char **argv)
 			_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 		}
 	}
-	
+
 	starpu_mpi_shutdown();
 	starpu_shutdown();
 

+ 13 - 10
mpi/tests/mpi_isend.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_mpi.h>
+#include "helper.h"
 
 #define NITER	2048
 #define SIZE	16
@@ -25,24 +26,25 @@ starpu_data_handle_t tab_handle;
 
 int main(int argc, char **argv)
 {
-	MPI_Init(NULL, NULL);
-
-	int rank, size;
+	int ret, rank, size;
 
+	MPI_Init(NULL, NULL);
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	MPI_Comm_size(MPI_COMM_WORLD, &size);
 
 	if (size != 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need exactly 2 processes.\n");
+			FPRINTF(stderr, "We need exactly 2 processes.\n");
 
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
-	starpu_init(NULL);
-	starpu_mpi_initialize();
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize");
 
 	tab = malloc(SIZE*sizeof(float));
 
@@ -62,12 +64,13 @@ int main(int argc, char **argv)
 			starpu_mpi_isend(tab_handle, &req, other_rank, loop, MPI_COMM_WORLD);
 			starpu_mpi_wait(&req, &status);
 		}
-		else {
+		else
+		{
 			MPI_Status status;
 			starpu_mpi_recv(tab_handle, other_rank, loop, MPI_COMM_WORLD, &status);
 		}
 	}
-	
+
 	starpu_mpi_shutdown();
 	starpu_shutdown();
 

+ 13 - 10
mpi/tests/mpi_isend_detached.c

@@ -18,6 +18,7 @@
 #include <starpu_mpi.h>
 #include <common/utils.h>
 #include <pthread.h>
+#include "helper.h"
 
 #define NITER	2048
 #define SIZE	16
@@ -31,7 +32,7 @@ static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
 void callback(void *arg __attribute__((unused)))
 {
 	unsigned *sent = arg;
-	
+
 	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	*sent = 1;
 	_STARPU_PTHREAD_COND_SIGNAL(&cond);
@@ -40,24 +41,25 @@ void callback(void *arg __attribute__((unused)))
 
 int main(int argc, char **argv)
 {
-	MPI_Init(NULL, NULL);
-
-	int rank, size;
+	int ret, rank, size;
 
+	MPI_Init(NULL, NULL);
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	MPI_Comm_size(MPI_COMM_WORLD, &size);
 
 	if (size != 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need exactly 2 processes.\n");
+			FPRINTF(stderr, "We need exactly 2 processes.\n");
 
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
-	starpu_init(NULL);
-	starpu_mpi_initialize();
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize");
 
 	tab = malloc(SIZE*sizeof(float));
 
@@ -80,12 +82,13 @@ int main(int argc, char **argv)
 				_STARPU_PTHREAD_COND_WAIT(&cond, &mutex);
 			_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 		}
-		else {
+		else
+		{
 			MPI_Status status;
 			starpu_mpi_recv(tab_handle, other_rank, loop, MPI_COMM_WORLD, &status);
 		}
 	}
-	
+
 	starpu_mpi_shutdown();
 	starpu_shutdown();
 

+ 17 - 12
mpi/tests/mpi_test.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_mpi.h>
+#include "helper.h"
 
 #define NITER	2048
 #define SIZE	16
@@ -25,24 +26,25 @@ starpu_data_handle_t tab_handle;
 
 int main(int argc, char **argv)
 {
-	MPI_Init(NULL, NULL);
-
-	int rank, size;
+	int ret, rank, size;
 
+	MPI_Init(NULL, NULL);
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	MPI_Comm_size(MPI_COMM_WORLD, &size);
 
 	if (size != 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need exactly 2 processes.\n");
+			FPRINTF(stderr, "We need exactly 2 processes.\n");
 
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
-	starpu_init(NULL);
-	starpu_mpi_initialize();
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize");
 
 	tab = malloc(SIZE*sizeof(float));
 
@@ -61,17 +63,20 @@ int main(int argc, char **argv)
 		{
                         starpu_mpi_isend(tab_handle, &req, other_rank, loop, MPI_COMM_WORLD);
 		}
-		else {
+		else
+		{
 			starpu_mpi_irecv(tab_handle, &req, other_rank, loop, MPI_COMM_WORLD);
 		}
 
 		int finished = 0;
-		do {
+		do
+		{
 			MPI_Status status;
 			starpu_mpi_test(&req, &finished, &status);
-		} while (!finished);
+		}
+		while (!finished);
 	}
-	
+
 	starpu_mpi_shutdown();
 	starpu_shutdown();
 

+ 24 - 14
mpi/tests/multiple_send.c

@@ -15,29 +15,32 @@
  */
 
 #include <starpu_mpi.h>
+#include "helper.h"
 
 #define NITER	2048
 
 int main(int argc, char **argv)
 {
-	int rank, size;
+	int ret, rank, size;
         unsigned send[2] = {42, 11};
         unsigned recv[2] = {33, 33};
         starpu_mpi_req req[2];
         starpu_data_handle_t send_handle[2];
         starpu_data_handle_t recv_handle[2];
 
-	starpu_init(NULL);
-	starpu_mpi_initialize_extended(&rank, &size);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize_extended(&rank, &size);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize_extended");
 
 	if (size < 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need at least 2 processes.\n");
+			FPRINTF(stderr, "We need at least 2 processes.\n");
 
                 starpu_mpi_shutdown();
                 starpu_shutdown();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
 	starpu_variable_data_register(&send_handle[0], 0, (uintptr_t)&send[0], sizeof(unsigned));
@@ -45,27 +48,34 @@ int main(int argc, char **argv)
 	starpu_variable_data_register(&recv_handle[0], 0, (uintptr_t)&recv[0], sizeof(unsigned));
 	starpu_variable_data_register(&recv_handle[1], 0, (uintptr_t)&recv[1], sizeof(unsigned));
 
-        if (rank == 0) {
+        if (rank == 0)
+	{
                 starpu_mpi_isend(send_handle[0], &(req[0]), 1, 12, MPI_COMM_WORLD);
                 starpu_mpi_isend(send_handle[1], &(req[1]), 1, 13, MPI_COMM_WORLD);
         }
-        else if (rank == 1) {
+        else if (rank == 1)
+	{
                 starpu_mpi_irecv(recv_handle[0], &(req[0]), 0, 12, MPI_COMM_WORLD);
                 starpu_mpi_irecv(recv_handle[1], &(req[1]), 0, 13, MPI_COMM_WORLD);
         }
 
-        if (rank == 0 || rank == 1) {
+        if (rank == 0 || rank == 1)
+	{
                 int nb_req=2;
-                while (nb_req) {
+                while (nb_req)
+		{
                         int r=0;
-                        for(r=0 ; r<2 ; r++) {
-                                if (req[r]) {
+                        for(r=0 ; r<2 ; r++)
+			{
+                                if (req[r])
+				{
                                         int finished = 0;
                                         MPI_Status status;
                                         starpu_mpi_test(&req[r], &finished, &status);
                                         STARPU_ASSERT(finished != -1);
-                                        if(finished) {
-                                                fprintf(stderr, "[%d] Request %d finished\n", rank, r);
+                                        if (finished)
+					{
+                                                FPRINTF(stderr, "[%d] Request %d finished\n", rank, r);
                                                 req[r] = NULL;
                                                 nb_req--;
                                         }
@@ -73,7 +83,7 @@ int main(int argc, char **argv)
                         }
                 }
         }
-        fprintf(stderr, "[%d] All requests finished\n", rank);
+        FPRINTF(stderr, "[%d] All requests finished\n", rank);
 
 	starpu_mpi_shutdown();
 	starpu_shutdown();

+ 13 - 11
mpi/tests/pingpong.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_mpi.h>
+#include "helper.h"
 
 #define NITER	2048
 #define SIZE	16
@@ -25,24 +26,25 @@ starpu_data_handle_t tab_handle;
 
 int main(int argc, char **argv)
 {
-	MPI_Init(NULL, NULL);
-
-	int rank, size;
+	int ret, rank, size;
 
+	MPI_Init(NULL, NULL);
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	MPI_Comm_size(MPI_COMM_WORLD, &size);
 
 	if (size != 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need exactly 2 processes.\n");
+			FPRINTF(stderr, "We need exactly 2 processes.\n");
 
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
-	starpu_init(NULL);
-	starpu_mpi_initialize();
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize");
 
 	tab = malloc(SIZE*sizeof(float));
 
@@ -50,7 +52,6 @@ int main(int argc, char **argv)
 
 	unsigned nloops = NITER;
 	unsigned loop;
-
 	int other_rank = (rank + 1)%2;
 
 	for (loop = 0; loop < nloops; loop++)
@@ -59,12 +60,13 @@ int main(int argc, char **argv)
 		{
 			starpu_mpi_send(tab_handle, other_rank, loop, MPI_COMM_WORLD);
 		}
-		else {
+		else
+		{
 			MPI_Status status;
 			starpu_mpi_recv(tab_handle, other_rank, loop, MPI_COMM_WORLD, &status);
 		}
 	}
-	
+
 	starpu_mpi_shutdown();
 	starpu_shutdown();
 

+ 19 - 14
mpi/tests/ring.c

@@ -16,6 +16,7 @@
  */
 
 #include <starpu_mpi.h>
+#include "helper.h"
 
 #define NITER	2048
 
@@ -32,7 +33,8 @@ void increment_cpu(void *descr[], __attribute__ ((unused)) void *_args)
 	(*tokenptr)++;
 }
 
-static struct starpu_codelet increment_cl = {
+static struct starpu_codelet increment_cl =
+{
 	.where = STARPU_CPU|STARPU_CUDA,
 #ifdef STARPU_USE_CUDA
 	.cuda_func = increment_cuda,
@@ -46,7 +48,7 @@ void increment_token(void)
 	struct starpu_task *task = starpu_task_create();
 
 	task->cl = &increment_cl;
-	
+
 	task->buffers[0].handle = token_handle;
 	task->buffers[0].mode = STARPU_RW;
 
@@ -57,24 +59,25 @@ void increment_token(void)
 
 int main(int argc, char **argv)
 {
-	MPI_Init(NULL, NULL);
-
-	int rank, size;
+	int ret, rank, size;
 
+	MPI_Init(NULL, NULL);
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	MPI_Comm_size(MPI_COMM_WORLD, &size);
 
 	if (size < 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need at least 2 processes.\n");
+			FPRINTF(stderr, "We need at least 2 processes.\n");
 
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
-	starpu_init(NULL);
-	starpu_mpi_initialize();
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize");
 
 	starpu_vector_data_register(&token_handle, 0, (uintptr_t)&token, 1, sizeof(unsigned));
 
@@ -91,22 +94,24 @@ int main(int argc, char **argv)
 		if (loop == 0 && rank == 0)
 		{
 			token = 0;
-			fprintf(stdout, "Start with token value %d\n", token);
+			FPRINTF(stdout, "Start with token value %d\n", token);
 		}
-		else {
+		else
+		{
 			MPI_Status status;
 			starpu_mpi_recv(token_handle, (rank+size-1)%size, tag, MPI_COMM_WORLD, &status);
 		}
 
 		increment_token();
-		
+
 		if (loop == last_loop && rank == last_rank)
 		{
 			starpu_data_acquire(token_handle, STARPU_R);
-			fprintf(stdout, "Finished : token value %d\n", token);
+			FPRINTF(stdout, "Finished : token value %d\n", token);
 			starpu_data_release(token_handle);
 		}
-		else {
+		else
+		{
 			starpu_mpi_send(token_handle, (rank+1)%size, tag+1, MPI_COMM_WORLD);
 		}
 	}

+ 16 - 12
mpi/tests/ring_async.c

@@ -16,6 +16,7 @@
  */
 
 #include <starpu_mpi.h>
+#include "helper.h"
 
 #define NITER	2048
 
@@ -32,7 +33,8 @@ void increment_cpu(void *descr[], __attribute__ ((unused)) void *_args)
 	(*tokenptr)++;
 }
 
-static struct starpu_codelet increment_cl = {
+static struct starpu_codelet increment_cl =
+{
 	.where = STARPU_CPU|STARPU_CUDA,
 #ifdef STARPU_USE_CUDA
 	.cuda_func = increment_cuda,
@@ -46,7 +48,7 @@ void increment_token(void)
 	struct starpu_task *task = starpu_task_create();
 
 	task->cl = &increment_cl;
-	
+
 	task->buffers[0].handle = token_handle;
 	task->buffers[0].mode = STARPU_RW;
 
@@ -57,24 +59,25 @@ void increment_token(void)
 
 int main(int argc, char **argv)
 {
-	MPI_Init(NULL, NULL);
-
-	int rank, size;
+	int ret, rank, size;
 
+	MPI_Init(NULL, NULL);
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	MPI_Comm_size(MPI_COMM_WORLD, &size);
 
 	if (size < 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need at least 2 processes.\n");
+			FPRINTF(stderr, "We need at least 2 processes.\n");
 
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
-	starpu_init(NULL);
-	starpu_mpi_initialize();
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize");
 
 	starpu_vector_data_register(&token_handle, 0, (uintptr_t)&token, 1, sizeof(unsigned));
 
@@ -91,9 +94,10 @@ int main(int argc, char **argv)
 		if (loop == 0 && rank == 0)
 		{
 			token = 0;
-			fprintf(stdout, "Start with token value %d\n", token);
+			FPRINTF(stdout, "Start with token value %d\n", token);
 		}
-		else {
+		else
+		{
 			MPI_Status status;
 			starpu_mpi_req req;
 			starpu_mpi_irecv(token_handle, &req, (rank+size-1)%size, tag, MPI_COMM_WORLD);
@@ -105,7 +109,7 @@ int main(int argc, char **argv)
 		if (loop == last_loop && rank == last_rank)
 		{
 			starpu_data_acquire(token_handle, STARPU_R);
-			fprintf(stdout, "Finished : token value %d\n", token);
+			FPRINTF(stdout, "Finished : token value %d\n", token);
 			starpu_data_release(token_handle);
 		}
 		else {

+ 15 - 10
mpi/tests/ring_async_implicit.c

@@ -16,6 +16,7 @@
  */
 
 #include <starpu_mpi.h>
+#include "helper.h"
 
 #define NITER	2048
 
@@ -32,7 +33,8 @@ void increment_cpu(void *descr[], __attribute__ ((unused)) void *_args)
 	(*tokenptr)++;
 }
 
-static struct starpu_codelet increment_cl = {
+static struct starpu_codelet increment_cl =
+{
 	.where = STARPU_CPU|STARPU_CUDA,
 #ifdef STARPU_USE_CUDA
 	.cuda_func = increment_cuda,
@@ -54,7 +56,7 @@ void increment_token(void)
 
 int main(int argc, char **argv)
 {
-	int rank, size;
+	int ret, rank, size;
 
 #if 0
 	MPI_Init(NULL, NULL);
@@ -62,16 +64,18 @@ int main(int argc, char **argv)
 	MPI_Comm_size(MPI_COMM_WORLD, &size);
 #endif
 
-	starpu_init(NULL);
-	starpu_mpi_initialize_extended(&rank, &size);
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_initialize_extended(&rank, &size);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_initialize_extended");
 
 	if (size < 2)
 	{
 		if (rank == 0)
-			fprintf(stderr, "We need at least 2 processes.\n");
+			FPRINTF(stderr, "We need at least 2 processes.\n");
 
 		MPI_Finalize();
-		return 0;
+		return STARPU_TEST_SKIPPED;
 	}
 
 
@@ -90,7 +94,7 @@ int main(int argc, char **argv)
 		if (loop == 0 && rank == 0)
 		{
 			token = 0;
-			fprintf(stdout, "Start with token value %d\n", token);
+			FPRINTF(stdout, "Start with token value %d\n", token);
 		}
 		else
 		{
@@ -102,10 +106,11 @@ int main(int argc, char **argv)
 		if (loop == last_loop && rank == last_rank)
 		{
 			starpu_data_acquire(token_handle, STARPU_R);
-			fprintf(stdout, "Finished : token value %d\n", token);
+			FPRINTF(stdout, "Finished : token value %d\n", token);
 			starpu_data_release(token_handle);
 		}
-		else {
+		else
+		{
 			starpu_mpi_isend_detached(token_handle, (rank+1)%size, tag+1, MPI_COMM_WORLD, NULL, NULL);
 		}
 	}
@@ -119,7 +124,7 @@ int main(int argc, char **argv)
 
 	if (rank == last_rank)
 	{
-                fprintf(stderr, "[%d] token = %d == %d * %d ?\n", rank, token, nloops, size);
+                FPRINTF(stderr, "[%d] token = %d == %d * %d ?\n", rank, token, nloops, size);
                 STARPU_ASSERT(token == nloops*size);
 	}