Browse Source

mpi: turn tests and examples silent if environment variable STARPU_SSILENT is set

Nathalie Furmento 11 years ago
parent
commit
51eea5acc3

+ 3 - 1
mpi/examples/complex/mpi_complex.c

@@ -18,10 +18,12 @@
 #include <interface/complex_interface.h>
 #include <interface/complex_codelet.h>
 
+#define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
+
 void display_foo_codelet(void *descr[], STARPU_ATTRIBUTE_UNUSED void *_args)
 {
 	int *foo = (int *)STARPU_VARIABLE_GET_PTR(descr[0]);
-	fprintf(stderr, "foo = %d\n", *foo);
+	FPRINTF(stderr, "foo = %d\n", *foo);
 }
 
 struct starpu_codelet foo_display =

+ 2 - 2
mpi/examples/matrix_decomposition/mpi_cholesky.c

@@ -64,8 +64,8 @@ int main(int argc, char **argv)
 
 	if (rank == 0)
 	{
-		fprintf(stdout, "Computation time (in ms): %2.2f\n", timing/1000);
-		fprintf(stdout, "Synthetic GFlops : %2.2f\n", (flops/timing/1000.0f));
+		FPRINTF(stdout, "Computation time (in ms): %2.2f\n", timing/1000);
+		FPRINTF(stdout, "Synthetic GFlops : %2.2f\n", (flops/timing/1000.0f));
 	}
 
 	return 0;

+ 3 - 3
mpi/examples/matrix_decomposition/mpi_cholesky_codelets.c

@@ -186,7 +186,7 @@ void dw_cholesky_check_computation(float ***matA, int rank, int nodes, int *corr
 		}
 	}
 
-	fprintf(stderr, "[%d] compute explicit LLt ...\n", rank);
+	FPRINTF(stderr, "[%d] compute explicit LLt ...\n", rank);
 	for (j = 0; j < size; j++)
 	{
 		for (i = 0; i < size; i++)
@@ -203,7 +203,7 @@ void dw_cholesky_check_computation(float ***matA, int rank, int nodes, int *corr
 	SSYRK("L", "N", size, size, 1.0f,
 			rmat, size, 0.0f, test_mat, size);
 
-	fprintf(stderr, "[%d] comparing results ...\n", rank);
+	FPRINTF(stderr, "[%d] comparing results ...\n", rank);
 	if (display)
 	{
 		for (j = 0; j < size; j++)
@@ -241,7 +241,7 @@ void dw_cholesky_check_computation(float ***matA, int rank, int nodes, int *corr
 							float err = abs(test_mat[j +i*size] - orig);
 							if (err > 0.00001)
 							{
-								fprintf(stderr, "[%d] Error[%u, %u] --> %2.2f != %2.2f (err %2.2f)\n", rank, i, j, test_mat[j +i*size], orig, err);
+								FPRINTF(stderr, "[%d] Error[%u, %u] --> %2.2f != %2.2f (err %2.2f)\n", rank, i, j, test_mat[j +i*size], orig, err);
 								*correctness = 0;
 								*flops = 0;
 								break;

+ 4 - 2
mpi/examples/matrix_decomposition/mpi_cholesky_distributed.c

@@ -22,6 +22,8 @@
 #include "mpi_decomposition_matrix.h"
 #include "mpi_decomposition_params.h"
 
+#define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
+
 int main(int argc, char **argv)
 {
 	/* create a simple definite positive symetric matrix example
@@ -56,8 +58,8 @@ int main(int argc, char **argv)
 
 	if (rank == 0)
 	{
-		fprintf(stdout, "Computation time (in ms): %2.2f\n", timing/1000);
-		fprintf(stdout, "Synthetic GFlops : %2.2f\n", (flops/timing/1000.0f));
+		FPRINTF(stdout, "Computation time (in ms): %2.2f\n", timing/1000);
+		FPRINTF(stdout, "Synthetic GFlops : %2.2f\n", (flops/timing/1000.0f));
 	}
 
 	return 0;

+ 3 - 1
mpi/examples/matrix_decomposition/mpi_cholesky_models.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2013  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,8 @@
 
 #include <starpu.h>
 
+#define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
+
 extern struct starpu_perfmodel chol_model_11;
 extern struct starpu_perfmodel chol_model_21;
 extern struct starpu_perfmodel chol_model_22;

+ 10 - 8
mpi/examples/stencil/stencil5.c

@@ -17,6 +17,8 @@
 #include <starpu_mpi.h>
 #include <math.h>
 
+#define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
+
 void stencil5_cpu(void *descr[], STARPU_ATTRIBUTE_UNUSED void *_args)
 {
 	unsigned *xy = (unsigned *)STARPU_VARIABLE_GET_PTR(descr[0]);
@@ -25,7 +27,7 @@ void stencil5_cpu(void *descr[], STARPU_ATTRIBUTE_UNUSED void *_args)
 	unsigned *xym1 = (unsigned *)STARPU_VARIABLE_GET_PTR(descr[3]);
 	unsigned *xyp1 = (unsigned *)STARPU_VARIABLE_GET_PTR(descr[4]);
 
-	//fprintf(stdout, "VALUES: %d %d %d %d %d\n", *xy, *xm1y, *xp1y, *xym1, *xyp1);
+	//FPRINTF(stdout, "VALUES: %d %d %d %d %d\n", *xy, *xm1y, *xp1y, *xym1, *xyp1);
 	*xy = (*xy + *xm1y + *xp1y + *xym1 + *xyp1) / 5;
 }
 
@@ -107,14 +109,14 @@ int main(int argc, char **argv)
 			int mpi_rank = my_distrib(x, y, size);
 			if (mpi_rank == my_rank)
 			{
-				//fprintf(stderr, "[%d] Owning data[%d][%d]\n", my_rank, x, y);
+				//FPRINTF(stderr, "[%d] Owning data[%d][%d]\n", my_rank, x, y);
 				starpu_variable_data_register(&data_handles[x][y], STARPU_MAIN_RAM, (uintptr_t)&(matrix[x][y]), sizeof(unsigned));
 			}
 			else if (my_rank == my_distrib(x+1, y, size) || my_rank == my_distrib(x-1, y, size)
 				 || my_rank == my_distrib(x, y+1, size) || my_rank == my_distrib(x, y-1, size))
 			{
 				/* I don't own that index, but will need it for my computations */
-				//fprintf(stderr, "[%d] Neighbour of data[%d][%d]\n", my_rank, x, y);
+				//FPRINTF(stderr, "[%d] Neighbour of data[%d][%d]\n", my_rank, x, y);
 				starpu_variable_data_register(&data_handles[x][y], -1, (uintptr_t)NULL, sizeof(unsigned));
 			}
 			else
@@ -143,7 +145,7 @@ int main(int argc, char **argv)
 			}
 		}
 	}
-	fprintf(stderr, "Waiting ...\n");
+	FPRINTF(stderr, "Waiting ...\n");
 	starpu_task_wait_for_all();
 
 	for(x = 0; x < X; x++)
@@ -162,15 +164,15 @@ int main(int argc, char **argv)
 
 	if (display)
 	{
-		fprintf(stdout, "[%d] mean=%d\n", my_rank, mean);
+		FPRINTF(stdout, "[%d] mean=%d\n", my_rank, mean);
 		for(x = 0; x < X; x++)
 		{
-			fprintf(stdout, "[%d] ", my_rank);
+			FPRINTF(stdout, "[%d] ", my_rank);
 			for (y = 0; y < Y; y++)
 			{
-				fprintf(stdout, "%3u ", matrix[x][y]);
+				FPRINTF(stdout, "%3u ", matrix[x][y]);
 			}
-			fprintf(stdout, "\n");
+			FPRINTF(stdout, "\n");
 		}
 	}
 

+ 1 - 1
mpi/tests/insert_task_cache.c

@@ -130,7 +130,7 @@ int main(int argc, char **argv)
 	{
 		dst = (rank == 0) ? 1 : 0;
 		result = (comm_amount_with_cache[dst] == comm_amount_without_cache[dst] * 5);
-		fprintf(stderr, "Communication cache mechanism is %sworking\n", result?"":"NOT ");
+		FPRINTF_MPI("Communication cache mechanism is %sworking\n", result?"":"NOT ");
 	}
 	else
 		result = 1;

+ 2 - 2
mpi/tests/insert_task_owner.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011, 2012  Centre National de la Recherche Scientifique
+ * Copyright (C) 2011, 2012, 2013  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
@@ -161,7 +161,7 @@ int main(int argc, char **argv)
 				     0);
 	assert(err == 0);
 
-	fprintf(stderr, "Waiting ...\n");
+	FPRINTF_MPI("Waiting ...\n");
 	starpu_task_wait_for_all();
 	starpu_data_unregister(data_handlesx0);
 	starpu_data_unregister(data_handlesx1);

+ 2 - 2
mpi/tests/mpi_earlyrecv.c

@@ -52,7 +52,7 @@ int main(int argc, char **argv)
 
 	int other_rank = rank%2 == 0 ? rank+1 : rank-1;
 
-	fprintf(stderr, "rank %d exchanging with rank %d\n", rank, other_rank);
+	FPRINTF_MPI("rank %d exchanging with rank %d\n", rank, other_rank);
 
 	if (rank%2)
 	{
@@ -80,7 +80,7 @@ int main(int argc, char **argv)
 				MPI_Status status;
 				starpu_mpi_test(&request[i], &flag, &status);
 				if (flag)
-					fprintf(stderr, "request[%d] = %d %p\n", i, flag, request[i]);
+					FPRINTF_MPI("request[%d] = %d %p\n", i, flag, request[i]);
 			}
 		}
 		finished = request[0] == NULL;

+ 5 - 4
mpi/tests/mpi_reduction.c

@@ -17,6 +17,7 @@
 
 #include <starpu_mpi.h>
 #include <math.h>
+#include "helper.h"
 
 extern void init_cpu_func(void *descr[], void *cl_arg);
 extern void redux_cpu_func(void *descr[], void *cl_arg);
@@ -147,7 +148,7 @@ int main(int argc, char **argv)
 		starpu_mpi_insert_task(MPI_COMM_WORLD, &display_codelet, STARPU_R, dot_handle, 0);
 	}
 
-	fprintf(stderr, "Waiting ...\n");
+	FPRINTF_MPI("Waiting ...\n");
 	starpu_task_wait_for_all();
 
 	for(x = 0; x < nb_elements; x+=step)
@@ -166,9 +167,9 @@ int main(int argc, char **argv)
 
 	if (my_rank == 0)
 	{
-		fprintf(stderr, "[%d] sum=%ld\n", my_rank, sum);
-		fprintf(stderr, "[%d] dot=%ld\n", my_rank, dot);
-		fprintf(stderr, "%s when computing reduction\n", (sum == dot) ? "Success" : "Error");
+		FPRINTF(stderr, "[%d] sum=%ld\n", my_rank, sum);
+		FPRINTF(stderr, "[%d] dot=%ld\n", my_rank, dot);
+		FPRINTF(stderr, "%s when computing reduction\n", (sum == dot) ? "Success" : "Error");
 	}
 
 	return 0;

+ 3 - 3
mpi/tests/mpi_reduction_kernels.c

@@ -51,14 +51,14 @@ void dot_cpu_func(void *descr[], void *cl_arg)
 
 	long int *dot = (long int *)STARPU_VARIABLE_GET_PTR(descr[1]);
 
-	FPRINTF_MPI("Before dot=%ld (adding %d elements...)\n", *dot, n);
+	//FPRINTF_MPI("Before dot=%ld (adding %d elements...)\n", *dot, n);
 	unsigned i;
 	for (i = 0; i < n; i++)
 	{
-		FPRINTF_MPI("Adding %ld\n", local_x[i]);
+		//FPRINTF_MPI("Adding %ld\n", local_x[i]);
 		*dot += local_x[i];
 	}
-	FPRINTF_MPI("After dot=%ld\n", *dot);
+	//FPRINTF_MPI("After dot=%ld\n", *dot);
 }
 
 /*

+ 1 - 1
mpi/tests/mpi_redux.c

@@ -26,7 +26,7 @@ void callback(void *arg)
 
 	STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	*received = *received + 1;
-	fprintf(stderr, "received = %d\n", *received);
+	FPRINTF_MPI("received = %d\n", *received);
 	STARPU_PTHREAD_COND_SIGNAL(&cond);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 }

+ 6 - 5
mpi/tests/mpi_scatter_gather.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011, 2012  Centre National de la Recherche Scientifique
+ * Copyright (C) 2011, 2012, 2013  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
@@ -15,6 +15,7 @@
  */
 
 #include <starpu_mpi.h>
+#include "helper.h"
 
 /* Returns the MPI node number where data indexes index is */
 int my_distrib(int x, int y, int nb_nodes)
@@ -35,12 +36,12 @@ void cpu_codelet(void *descr[], void *_args)
 	starpu_codelet_unpack_args(_args, &rank);
 	factor = block[0];
 
-	//fprintf(stderr,"rank %d factor %f\n", rank, factor);
+	//FPRINTF_MPI("rank %d factor %f\n", rank, factor);
 	for (j = 0; j < nx; j++)
 	{
 		for (i = 0; i < nx; i++)
 		{
-			//fprintf(stderr,"rank %d factor %f --> %f %f\n", rank, factor, block[j+i*ld], block[j+i*ld]*factor);
+			//FPRINTF_MPI("rank %d factor %f --> %f %f\n", rank, factor, block[j+i*ld], block[j+i*ld]*factor);
 			block[j+i*ld] *= factor;
 		}
 	}
@@ -56,13 +57,13 @@ static struct starpu_codelet cl =
 void scallback(void *arg STARPU_ATTRIBUTE_UNUSED)
 {
 	char *msg = arg;
-	fprintf(stderr, "Sending completed for <%s>\n", msg);
+	FPRINTF_MPI("Sending completed for <%s>\n", msg);
 }
 
 void rcallback(void *arg STARPU_ATTRIBUTE_UNUSED)
 {
 	char *msg = arg;
-	fprintf(stderr, "Reception completed for <%s>\n", msg);
+	FPRINTF_MPI("Reception completed for <%s>\n", msg);
 }
 
 int main(int argc, char **argv)

+ 6 - 5
mpi/tests/user_defined_datatype.c

@@ -18,6 +18,7 @@
 #include <interface/complex_interface.h>
 #include <interface/complex_codelet.h>
 #include <user_defined_datatype_value.h>
+#include "helper.h"
 
 #ifdef STARPU_QUICK_CHECK
 #  define ELEMENTS 10
@@ -100,7 +101,7 @@ int main(int argc, char **argv)
 			float foo_compare=42.0;
 			int value_compare=36;
 
-			fprintf(stderr, "\nTesting with function %p\n", f);
+			FPRINTF_MPI("\nTesting with function %p\n", f);
 
 			if (rank == 0)
 			{
@@ -153,13 +154,13 @@ int main(int argc, char **argv)
 					compare = (foo[i] == foo_compare);
 					if (compare == 0)
 					{
-						fprintf(stderr, "ERROR. foo[%d] == %f != %f\n", i, foo[i], foo_compare);
+						FPRINTF_MPI("ERROR. foo[%d] == %f != %f\n", i, foo[i], foo_compare);
 						goto end;
 					}
 					compare = (values[i] == value_compare);
 					if (compare == 0)
 					{
-						fprintf(stderr, "ERROR. value[%d] == %d != %d\n", i, values[i], value_compare);
+						FPRINTF_MPI("ERROR. value[%d] == %d != %d\n", i, values[i], value_compare);
 						goto end;
 					}
 					for(j=0 ; j<2 ; j++)
@@ -167,7 +168,7 @@ int main(int argc, char **argv)
 						compare = (real[i][j] == real_compare[j]);
 						if (compare == 0)
 						{
-							fprintf(stderr, "ERROR. real[%d][%d] == %f != %f\n", i, j, real[i][j], real_compare[j]);
+							FPRINTF_MPI("ERROR. real[%d][%d] == %f != %f\n", i, j, real[i][j], real_compare[j]);
 							goto end;
 						}
 					}
@@ -176,7 +177,7 @@ int main(int argc, char **argv)
 						compare = (imaginary[i][j] == imaginary_compare[j]);
 						if (compare == 0)
 						{
-							fprintf(stderr, "ERROR. imaginary[%d][%d] == %f != %f\n", i, j, imaginary[i][j], imaginary_compare[j]);
+							FPRINTF_MPI("ERROR. imaginary[%d][%d] == %f != %f\n", i, j, imaginary[i][j], imaginary_compare[j]);
 							goto end;
 						}
 					}