Browse Source

mpi_cholesky: Initialize and show values only on the concerned nodes

Samuel Thibault 4 years ago
parent
commit
42fb9c3b61
1 changed files with 24 additions and 8 deletions
  1. 24 8
      mpi/examples/matrix_decomposition/mpi_decomposition_matrix.c

+ 24 - 8
mpi/examples/matrix_decomposition/mpi_decomposition_matrix.c

@@ -26,17 +26,27 @@ int my_distrib(int y, int x, int nb_nodes)
 }
 
 
-void matrix_display(float ***bmat, int rank)
+void matrix_display(float ***bmat, int rank, int nodes)
 {
-	if (display)
-	{
-		unsigned y;
-		printf("[%d] Input :\n", rank);
+	int n;
+
+	if (!display)
+		return;
+
+	starpu_mpi_barrier(MPI_COMM_WORLD);
+
+	for (n = 0; n < rank; n++)
+		starpu_mpi_barrier(MPI_COMM_WORLD);
 
-		for(y=0 ; y<nblocks ; y++)
+	unsigned y;
+	printf("[%d] Input :\n", rank);
+
+	for(y=0 ; y<nblocks ; y++)
+	{
+		unsigned x;
+		for(x=0 ; x<=y ; x++)
 		{
-			unsigned x;
-			for(x=0 ; x<=y ; x++)
+			if (my_distrib(y, x, nodes) == rank)
 			{
 				unsigned j;
 				printf("Block %u,%u :\n", x, y);
@@ -59,6 +69,11 @@ void matrix_display(float ***bmat, int rank)
 			}
 		}
 	}
+
+	starpu_mpi_barrier(MPI_COMM_WORLD);
+
+	for (n = rank+1; n < nodes; n++)
+		starpu_mpi_barrier(MPI_COMM_WORLD);
 }
 
 /* Note: bmat is indexed by bmat[m][n][mm+nn*BLOCKSIZE],
@@ -78,6 +93,7 @@ void matrix_init(float ****bmat, int rank, int nodes, int alloc_everywhere)
 			if (alloc_everywhere || (mpi_rank == rank))
 			{
 				starpu_malloc((void **)&(*bmat)[m][n], BLOCKSIZE*BLOCKSIZE*sizeof(float));
+				if (mpi_rank == rank)
 				for (nn = 0; nn < BLOCKSIZE; nn++)
 				{
 					for (mm = 0; mm < BLOCKSIZE; mm++)