From c59b09a6a7183a4103fcde45dd77756d8d8d51b9 Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Fri, 15 Apr 2005 15:15:29 +0000 Subject: [PATCH] minor fix in graph_map and cart_map: in case the communicator passed to the functions does not have a topo-modules assigned (yet), we return as newrank their rank in the original commmunicator. This is the solution suggested by the MPI spec. This commit was SVN r5380. --- src/mpi/c/cart_map.c | 26 +++++++++++++++----------- src/mpi/c/graph_map.c | 24 +++++++++++++++++------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/mpi/c/cart_map.c b/src/mpi/c/cart_map.c index 5a01f140d2..f230f2e0e9 100644 --- a/src/mpi/c/cart_map.c +++ b/src/mpi/c/cart_map.c @@ -50,23 +50,27 @@ int MPI_Cart_map(MPI_Comm comm, int ndims, int *dims, return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } - if(!OMPI_COMM_IS_CART(comm)) { - return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_TOPOLOGY, - FUNC_NAME); - } if ((NULL == dims) || (NULL == periods) || (NULL == newrank)) { return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME); } } - /* get the function pointer on this communicator */ - func = comm->c_topo->topo_cart_map; - - /* call the function */ - if ( MPI_SUCCESS != - (err = func(comm, ndims, dims, periods, newrank))) { - return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, err, FUNC_NAME); + if(!OMPI_COMM_IS_CART(comm)) { + /* In case the communicator has no topo-module attached to + it, we just return the "default" value suggested by MPI: + newrank = rank */ + *newrank = ompi_comm_rank(comm); + } + else { + /* get the function pointer on this communicator */ + func = comm->c_topo->topo_cart_map; + + /* call the function */ + if ( MPI_SUCCESS != + (err = func(comm, ndims, dims, periods, newrank))) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, err, FUNC_NAME); + } } return MPI_SUCCESS; diff --git a/src/mpi/c/graph_map.c b/src/mpi/c/graph_map.c index b857ff0825..b96d399f00 100644 --- a/src/mpi/c/graph_map.c +++ b/src/mpi/c/graph_map.c @@ -55,15 +55,25 @@ int MPI_Graph_map(MPI_Comm comm, int nnodes, int *index, int *edges, FUNC_NAME); } } - /* map the function pointer to do the right thing */ - func = comm->c_topo->topo_graph_map; - /* call the function */ - if ( MPI_SUCCESS != - (err = func(comm, nnodes, index, edges, newrank))) { - return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, err, FUNC_NAME); + + if(!OMPI_COMM_IS_GRAPH(comm)) { + /* In case the communicator has no topo-module attached to + it, we just return the "default" value suggested by MPI: + newrank = rank */ + *newrank = ompi_comm_rank(comm); } - + else { + /* map the function pointer to do the right thing */ + func = comm->c_topo->topo_graph_map; + + /* call the function */ + if ( MPI_SUCCESS != + (err = func(comm, nnodes, index, edges, newrank))) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, err, FUNC_NAME); + } + } + /* All done */ return MPI_SUCCESS; }