Browse Source

starpu-mpi: simplification of branches

Nathalie Furmento 14 years ago
parent
commit
dae745d5da
2 changed files with 27 additions and 28 deletions
  1. 14 15
      doc/starpu.texi
  2. 13 13
      mpi/examples/scatter_gather/mpi_scatter_gather.c

+ 14 - 15
doc/starpu.texi

@@ -2294,23 +2294,22 @@ if (rank == root)
 data_handles = malloc(nblocks*sizeof(starpu_data_handle *));
 for(x = 0; x < nblocks ;  x++)
 @{
-    int mpi_rank = my_distrib(x, y, nodes);
-    if (rank == root)
+    int mpi_rank = my_distrib(x, nodes);
+    if (rank == root) @{
         starpu_vector_data_register(&data_handles[x], 0, (uintptr_t)vector[x],
                                     blocks_size, sizeof(float));
-    else  @{
-        if ((mpi_rank == rank) || ((rank == mpi_rank+1 || rank == mpi_rank-1))) @{
-            /* I own that index, or i will need it for my computations */
-            starpu_vector_data_register(&data_handles[x], -1, (uintptr_t)NULL,
-                                        block_size, sizeof(float));
-        @}
-        else @{
-            /* I know it's useless to allocate anything for this */
-            data_handles[x] = NULL;
-        @}
-        if (data_handles[x]) @{
-            starpu_data_set_rank(data_handles[x], mpi_rank);
-        @}
+    @}
+    else if ((mpi_rank == rank) || ((rank == mpi_rank+1 || rank == mpi_rank-1))) @{
+        /* I own that index, or i will need it for my computations */
+        starpu_vector_data_register(&data_handles[x], -1, (uintptr_t)NULL,
+                                   block_size, sizeof(float));
+    @}
+    else @{
+        /* I know it's useless to allocate anything for this */
+        data_handles[x] = NULL;
+    @}
+    if (data_handles[x]) @{
+        starpu_data_set_rank(data_handles[x], mpi_rank);
     @}
 @}
 

+ 13 - 13
mpi/examples/scatter_gather/mpi_scatter_gather.c

@@ -124,21 +124,21 @@ int main(int argc, char **argv)
 		{
 			int mpi_rank = my_distrib(x, y, nodes);
 			if (rank == 0)
+			{
 				starpu_matrix_data_register(&data_handles[x+y*nblocks], 0, (uintptr_t)bmat[x][y],
 							    ld, size/nblocks, size/nblocks, sizeof(float));
-			else {
-				if ((mpi_rank == rank) || ((rank == mpi_rank+1 || rank == mpi_rank-1)))
-				{
-					/* I own that index, or i will need it for my computations */
-					//fprintf(stderr, "[%d] Owning or neighbor of data[%d][%d]\n", rank, x, y);
-					starpu_matrix_data_register(&data_handles[x+y*nblocks], -1, (uintptr_t)NULL,
-								    ld, size/nblocks, size/nblocks, sizeof(float));
-				}
-				else
-				{
-					/* I know it's useless to allocate anything for this */
-					data_handles[x+y*nblocks] = NULL;
-				}
+			}
+			else if ((mpi_rank == rank) || ((rank == mpi_rank+1 || rank == mpi_rank-1)))
+			{
+				/* I own that index, or i will need it for my computations */
+				//fprintf(stderr, "[%d] Owning or neighbor of data[%d][%d]\n", rank, x, y);
+				starpu_matrix_data_register(&data_handles[x+y*nblocks], -1, (uintptr_t)NULL,
+							    ld, size/nblocks, size/nblocks, sizeof(float));
+			}
+			else
+			{
+				/* I know it's useless to allocate anything for this */
+				data_handles[x+y*nblocks] = NULL;
 			}
                         if (data_handles[x+y*nblocks])
 			{