1
1
openmpi/src/mpi/c/cart_shift.c

65 строки
2.1 KiB
C
Исходник Обычный вид История

/*
* $HEADERS$
*/
#include "ompi_config.h"
#include <stdio.h>
#include "mpi.h"
#include "mpi/c/bindings.h"
#include "communicator/communicator.h"
#include "mca/topo/topo.h"
#include "errhandler/errhandler.h"
#if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
#pragma weak MPI_Cart_shift = PMPI_Cart_shift
#endif
#if OMPI_PROFILING_DEFINES
#include "mpi/c/profile/defines.h"
#endif
int MPI_Cart_shift(MPI_Comm comm, int direction, int disp,
int *rank_source, int *rank_dest) {
int err;
mca_topo_base_cart_shift_fn_t func;
/* check the arguments */
if (MPI_PARAM_CHECK) {
if (MPI_COMM_NULL == comm) {
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_COMM,
"MPI_Cart_shift");
}
if (OMPI_COMM_IS_INTER(comm)) {
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_COMM,
"MPI_Cart_shift");
}
if (!OMPI_COMM_IS_CART(comm)) {
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_TOPOLOGY,
"MPI_Cart_shift");
}
if (0 > direction) { /* yet to detect direction >= comm->c_topo_ndims */
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_DIMS,
"MPI_Cart_shift");
}
if (NULL == rank_source || NULL == rank_dest) {
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_ARG,
"MPI_Cart_shift");
}
}
/* get the function pointer on this communicator */
func = comm->c_topo.topo_cart_shift;
if (NULL == func) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER,
"MPI_Cart_shift");
}
/* call the function */
if ( MPI_SUCCESS !=
(err = func(comm, direction, disp, rank_source, rank_dest))) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, err, "MPI_Cart_shift");
}
/* all done */
return MPI_SUCCESS;
}