1
1

[Re-]Fix #1463 with a little thing that I like to call "the right

way".

Don't modify coords in the top-level API function because coords is an
IN variable.  Instead, as Nysal noted, the real cause of the problem
was a missing ! down in topo_base_cart_rank.c.  Put a comment down in
topo_base_cart_rank.c explaining what's going on so that the code is
not so cryptic.

Refs trac:1363.

This commit was SVN r19487.

The following Trac tickets were found above:
  Ticket 1363 --> https://svn.open-mpi.org/trac/ompi/ticket/1363
Этот коммит содержится в:
Jeff Squyres 2008-09-03 08:24:27 +00:00
родитель 78c35f6d93
Коммит 9a98423bbc
2 изменённых файлов: 12 добавлений и 24 удалений

Просмотреть файл

@ -63,14 +63,18 @@ int mca_topo_base_cart_rank (MPI_Comm comm,
for (; i >= 0; --i, --c, --d, --p) {
dim = *d;
ord = *c;
if ((ord < 0) || (ord >= dim)) {
if (*p) {
return MPI_ERR_ARG;
}
ord %= dim;
if (ord < 0) {
ord += dim;
}
/* Per MPI-2.1 7.5.4 (description of MPI_CART_RANK), if the
dimension is periodic and the coordinate is outside of 0 <=
coord(i) < dim, then normalize it. If the dimension is not
periodic, it's an error. */
if ((ord < 0) || (ord >= dim)) {
if (!*p) {
return MPI_ERR_ARG;
}
ord %= dim;
if (ord < 0) {
ord += dim;
}
}
prank += factor * ord;
factor *= dim;

Просмотреть файл

@ -79,22 +79,6 @@ int MPI_Cart_rank(MPI_Comm comm, int *coords, int *rank)
OPAL_CR_ENTER_LIBRARY();
/* Normalize any coords[i] that is outside the appropriate range
for dimensions that are periodic */
for (i = 0; i < comm->c_topo_comm->mtc_ndims_or_nnodes; ++i) {
if (comm->c_topo_comm->mtc_periods_or_edges[i] &&
(coords[i] < 0 ||
coords[i] >= comm->c_topo_comm->mtc_dims_or_index[i])) {
if (coords[i] < 0) {
coords[i] = (-coords[i]) %
comm->c_topo_comm->mtc_dims_or_index[i];
coords[i] = comm->c_topo_comm->mtc_dims_or_index[i] - coords[i];
} else {
coords[i] = coords[i] % comm->c_topo_comm->mtc_dims_or_index[i];
}
}
}
/* get the function pointer on this communicator */
func = comm->c_topo->topo_cart_rank;