2004-01-25 04:51:49 +03:00
|
|
|
/*
|
|
|
|
* $HEADERS$
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-01-25 04:51:49 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "mpi.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "mpi/c/bindings.h"
|
2004-04-22 00:55:54 +04:00
|
|
|
#include "communicator/communicator.h"
|
|
|
|
#include "errhandler/errhandler.h"
|
|
|
|
#include "mca/topo/topo.h"
|
2004-01-25 04:51:49 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
|
2004-01-25 04:51:49 +03:00
|
|
|
#pragma weak MPI_Graph_create = PMPI_Graph_create
|
|
|
|
#endif
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#if OMPI_PROFILING_DEFINES
|
2004-04-20 22:50:43 +04:00
|
|
|
#include "mpi/c/profile/defines.h"
|
|
|
|
#endif
|
|
|
|
|
2004-07-21 02:21:47 +04:00
|
|
|
int MPI_Graph_create(MPI_Comm old_comm, int nnodes, int *index,
|
2004-01-25 04:51:49 +03:00
|
|
|
int *edges, int reorder, MPI_Comm *comm_graph) {
|
2004-04-22 00:55:54 +04:00
|
|
|
|
|
|
|
int err;
|
2004-07-21 02:21:47 +04:00
|
|
|
bool re_order = false;
|
2004-04-22 00:55:54 +04:00
|
|
|
|
|
|
|
/* check the arguments */
|
|
|
|
if (MPI_PARAM_CHECK) {
|
2004-07-21 02:21:47 +04:00
|
|
|
if (MPI_COMM_NULL == old_comm) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_COMM,
|
2004-04-22 00:55:54 +04:00
|
|
|
"MPI_Graph_create");
|
|
|
|
}
|
2004-07-21 02:21:47 +04:00
|
|
|
if (OMPI_COMM_IS_INTER(old_comm)) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_COMM,
|
2004-04-22 00:55:54 +04:00
|
|
|
"MPI_Graph_create");
|
|
|
|
}
|
|
|
|
if (1 > nnodes || NULL == index || NULL == edges) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_ARG,
|
2004-04-22 00:55:54 +04:00
|
|
|
"MPI_Graph_create");
|
|
|
|
}
|
2004-07-21 02:21:47 +04:00
|
|
|
|
|
|
|
if (nnodes > ompi_comm_size(old_comm)) {
|
|
|
|
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_ARG,
|
|
|
|
"MPI_Graph_create");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 > reorder || 1 < reorder) {
|
|
|
|
return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_ARG,
|
|
|
|
"MPI_Graph_create: boo");
|
|
|
|
}
|
2004-04-22 00:55:54 +04:00
|
|
|
}
|
|
|
|
|
2004-07-21 02:21:47 +04:00
|
|
|
/*
|
|
|
|
* everything seems to be alright with the communicator, we can go
|
|
|
|
* ahead and select a topology module for this purpose and create
|
|
|
|
* the new graph communicator
|
|
|
|
*/
|
|
|
|
|
|
|
|
re_order = (1 == reorder) ? true:false;
|
|
|
|
|
|
|
|
err = ompi_topo_create ((struct ompi_communicator_t *)old_comm,
|
|
|
|
nnodes,
|
|
|
|
index,
|
|
|
|
edges,
|
|
|
|
re_order,
|
|
|
|
(struct ompi_communicator_t **)comm_graph,
|
|
|
|
OMPI_COMM_GRAPH);
|
|
|
|
|
|
|
|
/* check the error status */
|
|
|
|
if (MPI_SUCCESS != err) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, err, "MPI_Graph_create");
|
2004-04-22 00:55:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* All done */
|
2004-01-25 04:51:49 +03:00
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|