Browse Source

mpi: do not fail when needed workers are unavailable

Nathalie Furmento 9 years ago
parent
commit
681f60a3ef

+ 48 - 42
mpi/examples/complex/mpi_complex.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2012, 2013, 2015  CNRS
+ * Copyright (C) 2012, 2013, 2015, 2016  CNRS
  *
  * 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
@@ -36,7 +36,7 @@ struct starpu_codelet foo_display =
 int main(int argc, char **argv)
 {
 	int rank, nodes;
-	int ret=0;
+	int ret;
 	int compare=0;
 
 	ret = starpu_init(NULL);
@@ -46,59 +46,65 @@ int main(int argc, char **argv)
 	starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
 	starpu_mpi_comm_size(MPI_COMM_WORLD, &nodes);
 
-	if (nodes < 2)
+	if (nodes < 2 || (starpu_cpu_worker_get_count() == 0))
 	{
-		fprintf(stderr, "This program needs at least 2 nodes (%d available)\n", nodes);
-		ret = 77;
+		if (rank == 0)
+		{
+			if (nodes < 2)
+				fprintf(stderr, "We need at least 2 processes.\n");
+			else
+				fprintf(stderr, "We need at least 1 CPU.\n");
+		}
+		starpu_mpi_shutdown();
+		starpu_shutdown();
+		return 77;
 	}
-	else
-	{
-		starpu_data_handle_t handle;
-		starpu_data_handle_t handle2;
-
-		double real[2] = {4.0, 2.0};
-		double imaginary[2] = {7.0, 9.0};
 
-		double real2[2] = {14.0, 12.0};
-		double imaginary2[2] = {17.0, 19.0};
+	starpu_data_handle_t handle;
+	starpu_data_handle_t handle2;
 
-		if (rank == 1)
-		{
-			real[0] = 0.0;
-			real[1] = 0.0;
-			imaginary[0] = 0.0;
-			imaginary[1] = 0.0;
-		}
+	double real[2] = {4.0, 2.0};
+	double imaginary[2] = {7.0, 9.0};
 
-		starpu_complex_data_register(&handle, STARPU_MAIN_RAM, real, imaginary, 2);
-		starpu_complex_data_register(&handle2, -1, real2, imaginary2, 2);
+	double real2[2] = {14.0, 12.0};
+	double imaginary2[2] = {17.0, 19.0};
 
-		if (rank == 0)
-		{
-			int *compare_ptr = &compare;
+	if (rank == 1)
+	{
+		real[0] = 0.0;
+		real[1] = 0.0;
+		imaginary[0] = 0.0;
+		imaginary[1] = 0.0;
+	}
 
-			starpu_task_insert(&cl_display, STARPU_VALUE, "node0 initial value", strlen("node0 initial value")+1, STARPU_R, handle, 0);
-			starpu_mpi_isend_detached(handle, 1, 10, MPI_COMM_WORLD, NULL, NULL);
-			starpu_mpi_irecv_detached(handle2, 1, 20, MPI_COMM_WORLD, NULL, NULL);
+	starpu_complex_data_register(&handle, STARPU_MAIN_RAM, real, imaginary, 2);
+	starpu_complex_data_register(&handle2, -1, real2, imaginary2, 2);
 
-			starpu_task_insert(&cl_display, STARPU_VALUE, "node0 received value", strlen("node0 received value")+1, STARPU_R, handle2, 0);
-			starpu_task_insert(&cl_compare, STARPU_R, handle, STARPU_R, handle2, STARPU_VALUE, &compare_ptr, sizeof(compare_ptr), 0);
-		}
-		else if (rank == 1)
-		{
-			starpu_mpi_irecv_detached(handle, 0, 10, MPI_COMM_WORLD, NULL, NULL);
-			starpu_task_insert(&cl_display, STARPU_VALUE, "node1 received value", strlen("node1 received value")+1, STARPU_R, handle, 0);
-			starpu_mpi_isend_detached(handle, 0, 20, MPI_COMM_WORLD, NULL, NULL);
-		}
+	if (rank == 0)
+	{
+		int *compare_ptr = &compare;
 
-		starpu_task_wait_for_all();
+		starpu_task_insert(&cl_display, STARPU_VALUE, "node0 initial value", strlen("node0 initial value")+1, STARPU_R, handle, 0);
+		starpu_mpi_isend_detached(handle, 1, 10, MPI_COMM_WORLD, NULL, NULL);
+		starpu_mpi_irecv_detached(handle2, 1, 20, MPI_COMM_WORLD, NULL, NULL);
 
-		starpu_data_unregister(handle);
-		starpu_data_unregister(handle2);
+		starpu_task_insert(&cl_display, STARPU_VALUE, "node0 received value", strlen("node0 received value")+1, STARPU_R, handle2, 0);
+		starpu_task_insert(&cl_compare, STARPU_R, handle, STARPU_R, handle2, STARPU_VALUE, &compare_ptr, sizeof(compare_ptr), 0);
 	}
+	else if (rank == 1)
+	{
+		starpu_mpi_irecv_detached(handle, 0, 10, MPI_COMM_WORLD, NULL, NULL);
+		starpu_task_insert(&cl_display, STARPU_VALUE, "node1 received value", strlen("node1 received value")+1, STARPU_R, handle, 0);
+		starpu_mpi_isend_detached(handle, 0, 20, MPI_COMM_WORLD, NULL, NULL);
+	}
+
+	starpu_task_wait_for_all();
+
+	starpu_data_unregister(handle);
+	starpu_data_unregister(handle2);
 
 	starpu_mpi_shutdown();
 	starpu_shutdown();
 
-	if (rank == 0) return !compare; else return ret;
+	if (rank == 0) return !compare; else return 0;
 }

+ 13 - 1
mpi/examples/matrix_decomposition/mpi_cholesky.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2009-2012, 2015  Université de Bordeaux
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010, 2011, 2012, 2013, 2015  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016  CNRS
  *
  * 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 "mpi_cholesky.h"
+#include "helper.h"
 
 int main(int argc, char **argv)
 {
@@ -39,6 +40,17 @@ int main(int argc, char **argv)
 	starpu_mpi_comm_size(MPI_COMM_WORLD, &nodes);
 	starpu_cublas_init();
 
+	if (starpu_cpu_worker_get_count() + starpu_cuda_worker_get_count() == 0)
+	{
+		if (rank == 0)
+		{
+			FPRINTF(stderr, "We need at least 1 CPU or CUDA worker.\n");
+		}
+		starpu_mpi_shutdown();
+		starpu_shutdown();
+		return STARPU_TEST_SKIPPED;
+	}
+
 	parse_args(argc, argv, nodes);
 
 	matrix_init(&bmat, rank, nodes, 1);

+ 10 - 1
mpi/examples/matrix_mult/mm.c

@@ -25,6 +25,7 @@
 #include <math.h>
 #include <starpu.h>
 #include <starpu_mpi.h>
+#include "helper.h"
 
 #define VERBOSE 0
 
@@ -249,7 +250,7 @@ static void cpu_mult(void *handles[], STARPU_ATTRIBUTE_UNUSED void *arg)
 	assert(n_row_C == n_row_A);
 	assert(n_col_A == n_row_B);
 
-	int i,j,k;
+	unsigned i,j,k;
 	for (k = 0; k < n_row_C; k++) {
 		for (j = 0; j < n_col_C; j++) {
 			for (i = 0; i < n_col_A; i++) {
@@ -285,6 +286,14 @@ int main(int argc, char *argv[])
 	ret = starpu_mpi_init(&argc, &argv, 1);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
 
+	if (starpu_cpu_worker_get_count() == 0)
+	{
+		FPRINTF(stderr, "We need at least 1 CPU worker.\n");
+		starpu_mpi_shutdown();
+		starpu_shutdown();
+		return STARPU_TEST_SKIPPED;
+	}
+
 	/* Parse the matrix size and block size optional args */
 	if (argc > 1) {
 		N = atoi(argv[1]);

+ 9 - 3
mpi/examples/user_datatype/user_datatype.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2015  CNRS
+ * Copyright (C) 2015, 2016  CNRS
  *
  * 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
@@ -38,9 +38,15 @@ int main(int argc, char **argv)
 	starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
 	starpu_mpi_comm_size(MPI_COMM_WORLD, &nodes);
 
-	if (nodes < 2)
+	if (nodes < 2 || (starpu_cpu_worker_get_count() == 0))
 	{
-		fprintf(stderr, "This program needs at least 2 nodes (%d available)\n", nodes);
+		if (rank == 0)
+		{
+			if (nodes < 2)
+				fprintf(stderr, "We need at least 2 processes.\n");
+			else
+				fprintf(stderr, "We need at least 1 CPU.\n");
+		}
 		starpu_mpi_shutdown();
 		starpu_shutdown();
 		return 77;

+ 11 - 1
mpi/tests/early_request.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2015  CNRS
+ * Copyright (C) 2015, 2016  CNRS
  * Copyright (C) 2015  INRIA
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -200,6 +200,16 @@ int main(int argc, char * argv[])
 	ret = starpu_mpi_init(NULL, NULL, 0);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
 
+	if (starpu_cpu_worker_get_count() == 0)
+	{
+		if (mpi_rank == 0)
+			FPRINTF(stderr, "We need at least 1 CPU worker.\n");
+		starpu_mpi_shutdown();
+		starpu_shutdown();
+		MPI_Finalize();
+		return STARPU_TEST_SKIPPED;
+	}
+
 	/*element initialization : domains are connected as a ring for this test*/
 	int num_elements=NUM_EL;
 	struct element * el_left=malloc(num_elements*sizeof(el_left[0]));

+ 8 - 4
mpi/tests/insert_task_count.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010, 2014-2015  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  *
  * 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
@@ -71,11 +71,15 @@ int main(int argc, char **argv)
 	ret = starpu_mpi_init(NULL, NULL, 0);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
 
-	if (size < 2)
+	if (size < 2 || (starpu_cpu_worker_get_count() + starpu_cuda_worker_get_count() == 0))
 	{
 		if (rank == 0)
-			FPRINTF(stderr, "We need at least 2 processes.\n");
-
+		{
+			if (size < 2)
+				FPRINTF(stderr, "We need at least 2 processes.\n");
+			else
+				FPRINTF(stderr, "We need at least 1 CPU or CUDA worker.\n");
+		}
 		starpu_mpi_shutdown();
 		starpu_shutdown();
 		MPI_Finalize();

+ 10 - 1
mpi/tests/insert_task_dyn_handles.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011, 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  *
  * 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
@@ -82,6 +82,15 @@ int main(int argc, char **argv)
 	ret = starpu_mpi_init(NULL, NULL, 0);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
 
+	if (starpu_cpu_worker_get_count() == 0)
+	{
+		if (rank == 0)
+			FPRINTF(stderr, "We need at least 1 CPU worker.\n");
+		starpu_mpi_shutdown();
+		starpu_shutdown();
+		return STARPU_TEST_SKIPPED;
+	}
+
 	x = calloc(1, (STARPU_NMAXBUFS+15) * sizeof(int));
 	data_handles = malloc((STARPU_NMAXBUFS+15) * sizeof(starpu_data_handle_t));
 	descrs = malloc((STARPU_NMAXBUFS+15) * sizeof(struct starpu_data_descr));

+ 10 - 1
mpi/tests/insert_task_owner.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011, 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  *
  * 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
@@ -96,6 +96,15 @@ int main(int argc, char **argv)
 	starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
 	starpu_mpi_comm_size(MPI_COMM_WORLD, &size);
 
+	if (starpu_cpu_worker_get_count() == 0)
+	{
+		if (rank == 0)
+			FPRINTF(stderr, "We need at least 1 CPU worker.\n");
+		starpu_mpi_shutdown();
+		starpu_shutdown();
+		return STARPU_TEST_SKIPPED;
+	}
+
 	if (rank != 0 && rank != 1) goto end;
 
 	if (rank == 0)

+ 10 - 1
mpi/tests/insert_task_owner2.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2012, 2015                    Université Bordeaux
- * Copyright (C) 2011, 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  *
  * 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
@@ -71,6 +71,15 @@ int main(int argc, char **argv)
 	starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
 	starpu_mpi_comm_size(MPI_COMM_WORLD, &size);
 
+	if (starpu_cpu_worker_get_count() == 0)
+	{
+		if (rank == 0)
+			FPRINTF(stderr, "We need at least 1 CPU worker.\n");
+		starpu_mpi_shutdown();
+		starpu_shutdown();
+		return STARPU_TEST_SKIPPED;
+	}
+
 	if (rank == 0)
 	{
 		for(i=0 ; i<3 ; i++)

+ 10 - 1
mpi/tests/insert_task_owner_data.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011, 2012, 2013, 2014  CNRS
+ * Copyright (C) 2011, 2012, 2013, 2014, 2016  CNRS
  *
  * 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
@@ -61,6 +61,15 @@ int main(int argc, char **argv)
 	starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
 	starpu_mpi_comm_size(MPI_COMM_WORLD, &size);
 
+	if (starpu_cpu_worker_get_count() == 0)
+	{
+		if (rank == 0)
+			FPRINTF(stderr, "We need at least 1 CPU worker.\n");
+		starpu_mpi_shutdown();
+		starpu_shutdown();
+		return STARPU_TEST_SKIPPED;
+	}
+
 	if (rank == 0)
 	{
 		x[0] = 11;

+ 10 - 1
mpi/tests/matrix.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2015  CNRS
+ * Copyright (C) 2015, 2016  CNRS
  *
  * 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
@@ -66,6 +66,15 @@ int main(int argc, char **argv)
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
 	starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
 
+	if (starpu_cpu_worker_get_count() == 0)
+	{
+		if (rank == 0)
+			FPRINTF(stderr, "We need at least 1 CPU worker.\n");
+		starpu_mpi_shutdown();
+		starpu_shutdown();
+		return STARPU_TEST_SKIPPED;
+	}
+
 	for(n = 0; n < N; n++)
 	{
 		A[n] = (n+1)*10;

+ 10 - 1
mpi/tests/mpi_reduction.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2013, 2015  Université de Bordeaux
- * Copyright (C) 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2012, 2013, 2014, 2015, 2016  CNRS
  *
  * 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
@@ -108,6 +108,15 @@ int main(int argc, char **argv)
 	starpu_mpi_comm_rank(MPI_COMM_WORLD, &my_rank);
 	starpu_mpi_comm_size(MPI_COMM_WORLD, &size);
 
+	if (starpu_cpu_worker_get_count() == 0)
+	{
+		if (my_rank == 0)
+			FPRINTF(stderr, "We need at least 1 CPU worker.\n");
+		starpu_mpi_shutdown();
+		starpu_shutdown();
+		return STARPU_TEST_SKIPPED;
+	}
+
 	nb_elements = size*8000;
 	step = 4;
 	loops = 5;

+ 10 - 1
mpi/tests/mpi_scatter_gather.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011, 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  *
  * 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
@@ -87,6 +87,15 @@ int main(int argc, char **argv)
 	starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
 	starpu_mpi_comm_size(MPI_COMM_WORLD, &nodes);
 
+	if (starpu_cpu_worker_get_count() == 0)
+	{
+		if (rank == 0)
+			FPRINTF(stderr, "We need at least 1 CPU worker.\n");
+		starpu_mpi_shutdown();
+		starpu_shutdown();
+		return STARPU_TEST_SKIPPED;
+	}
+
 	if (rank == 0)
 	{
 		/* Allocate the vector */

+ 8 - 4
mpi/tests/ring.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010, 2014-2015  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
  *
  * 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
@@ -84,11 +84,15 @@ int main(int argc, char **argv)
 	ret = starpu_mpi_init(NULL, NULL, 0);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
 
-	if (size < 2)
+	if (size < 2 || (starpu_cpu_worker_get_count() + starpu_cuda_worker_get_count() == 0))
 	{
 		if (rank == 0)
-			FPRINTF(stderr, "We need at least 2 processes.\n");
-
+		{
+			if (size < 2)
+				FPRINTF(stderr, "We need at least 2 processes.\n");
+			else
+				FPRINTF(stderr, "We need at least 1 CPU or CUDA worker.\n");
+		}
 		starpu_mpi_shutdown();
 		starpu_shutdown();
 		MPI_Finalize();

+ 8 - 4
mpi/tests/ring_async.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010, 2014-2015  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
  *
  * 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
@@ -84,11 +84,15 @@ int main(int argc, char **argv)
 	ret = starpu_mpi_init(NULL, NULL, 0);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
 
-	if (size < 2)
+	if (size < 2 || (starpu_cpu_worker_get_count() + starpu_cuda_worker_get_count() == 0))
 	{
 		if (rank == 0)
-			FPRINTF(stderr, "We need at least 2 processes.\n");
-
+		{
+			if (size < 2)
+				FPRINTF(stderr, "We need at least 2 processes.\n");
+			else
+				FPRINTF(stderr, "We need at least 1 CPU or CUDA worker.\n");
+		}
 		starpu_mpi_shutdown();
 		starpu_shutdown();
 		MPI_Finalize();

+ 10 - 6
mpi/tests/ring_async_implicit.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2015  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
  *
  * 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
@@ -81,16 +81,20 @@ int main(int argc, char **argv)
 	starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
 	starpu_mpi_comm_size(MPI_COMM_WORLD, &size);
 
-	if (size < 2)
+	if (size < 2 || (starpu_cpu_worker_get_count() + starpu_cuda_worker_get_count() == 0))
 	{
 		if (rank == 0)
-			FPRINTF(stderr, "We need at least 2 processes.\n");
-
-		MPI_Finalize();
+		{
+			if (size < 2)
+				FPRINTF(stderr, "We need at least 2 processes.\n");
+			else
+				FPRINTF(stderr, "We need at least 1 CPU or CUDA worker.\n");
+		}
+		starpu_mpi_shutdown();
+		starpu_shutdown();
 		return STARPU_TEST_SKIPPED;
 	}
 
-
 	starpu_vector_data_register(&token_handle, STARPU_MAIN_RAM, (uintptr_t)&token, 1, sizeof(token));
 
 	int nloops = NITER;

+ 8 - 4
mpi/tests/ring_sync.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010, 2014-2015  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2016  CNRS
  *
  * 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
@@ -84,11 +84,15 @@ int main(int argc, char **argv)
 	ret = starpu_mpi_init(NULL, NULL, 0);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
 
-	if (size < 2)
+	if (size < 2 || (starpu_cpu_worker_get_count() + starpu_cuda_worker_get_count() == 0))
 	{
 		if (rank == 0)
-			FPRINTF(stderr, "We need at least 2 processes.\n");
-
+		{
+			if (size < 2)
+				FPRINTF(stderr, "We need at least 2 processes.\n");
+			else
+				FPRINTF(stderr, "We need at least 1 CPU or CUDA worker.\n");
+		}
 		starpu_mpi_shutdown();
 		starpu_shutdown();
 		MPI_Finalize();

+ 8 - 4
mpi/tests/ring_sync_detached.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010, 2014-2015  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  *
  * 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
@@ -96,11 +96,15 @@ int main(int argc, char **argv)
 	ret = starpu_mpi_init(NULL, NULL, 0);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
 
-	if (size < 2)
+	if (size < 2 || (starpu_cpu_worker_get_count() + starpu_cuda_worker_get_count() == 0))
 	{
 		if (rank == 0)
-			FPRINTF(stderr, "We need at least 2 processes.\n");
-
+		{
+			if (size < 2)
+				FPRINTF(stderr, "We need at least 2 processes.\n");
+			else
+				FPRINTF(stderr, "We need at least 1 CPU or CUDA worker.\n");
+		}
 		starpu_mpi_shutdown();
 		starpu_shutdown();
 		MPI_Finalize();