2004-03-07 01:40:26 +03:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "mca/topo/base/base.h"
|
2004-04-17 00:54:48 +04:00
|
|
|
#include "communicator/communicator.h"
|
|
|
|
#include "mca/topo/topo.h"
|
2004-03-07 01:40:26 +03:00
|
|
|
|
2004-03-08 09:48:24 +03:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* function - makes a new communicator to which topology information
|
|
|
|
* has been attached
|
|
|
|
*
|
|
|
|
* @param comm_old input communicator without topology (handle)
|
|
|
|
* @param nnodes number of nodes in graph (integer)
|
|
|
|
* @param index array of integers describing node degrees (see below)
|
|
|
|
* @param edges array of integers describing graph edges (see below)
|
|
|
|
* @param reorder ranking may be reordered (true) or not (false) (logical)
|
|
|
|
* @param comm_graph communicator with graph topology added (handle)
|
|
|
|
*
|
|
|
|
* @retval MPI_SUCCESS
|
|
|
|
* @retval MPI_ERR_OUT_OF_RESOURCE
|
|
|
|
*/
|
|
|
|
|
2004-04-17 00:54:48 +04:00
|
|
|
int topo_base_graph_create (MPI_Comm comm_old,
|
2004-03-08 09:48:24 +03:00
|
|
|
int nnodes,
|
|
|
|
int *index,
|
|
|
|
int *edges,
|
|
|
|
int reorder,
|
2004-04-17 00:54:48 +04:00
|
|
|
MPI_Comm *comm_graph) {
|
|
|
|
#if 0
|
|
|
|
MPI_Group newgroup;
|
|
|
|
#endif
|
2004-03-08 09:48:24 +03:00
|
|
|
int nedges;
|
|
|
|
int size;
|
|
|
|
int err;
|
|
|
|
int range[1][3];
|
|
|
|
int i;
|
|
|
|
int *topo;
|
|
|
|
int *p;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create and error check the topology information.
|
|
|
|
*/
|
|
|
|
nedges = index[nnodes - 1];
|
|
|
|
topo = (int *) malloc((unsigned) (nnodes + nedges) * sizeof(int));
|
|
|
|
if (topo == 0) {
|
|
|
|
printf ("Out of resources\n");
|
2004-04-17 00:54:48 +04:00
|
|
|
return MPI_ERR_SYSRESOURCE;
|
2004-03-08 09:48:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0, p = topo; i < nnodes; ++i, ++p) {
|
|
|
|
*p = *index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < nedges; ++i, ++p) {
|
|
|
|
*p = *edges++;
|
|
|
|
if (*p < 0 || *p >= nnodes) {
|
|
|
|
free((char *) topo);
|
|
|
|
return MPI_ERR_TOPOLOGY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Create the group for the new communicator.
|
|
|
|
*/
|
2004-04-17 00:54:48 +04:00
|
|
|
#if 0
|
2004-06-07 19:33:53 +04:00
|
|
|
err = ompi_comm_size (comm_old, &size);
|
2004-04-17 00:54:48 +04:00
|
|
|
#endif
|
2004-03-08 09:48:24 +03:00
|
|
|
if (err != MPI_SUCCESS) {
|
|
|
|
free((char *) topo);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nnodes > size) {
|
|
|
|
free((char *) topo);
|
|
|
|
return MPI_ERR_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nnodes == size) {
|
2004-04-17 00:54:48 +04:00
|
|
|
#if 0
|
2004-06-07 19:33:53 +04:00
|
|
|
err = ompi_comm_group (comm_old, &newgroup);
|
2004-04-17 00:54:48 +04:00
|
|
|
#endif
|
2004-03-08 09:48:24 +03:00
|
|
|
} else {
|
|
|
|
range[0][0] = 0;
|
|
|
|
range[0][1] = nnodes - 1;
|
|
|
|
range[0][2] = 1;
|
2004-04-17 00:54:48 +04:00
|
|
|
#if 0
|
2004-06-07 19:33:53 +04:00
|
|
|
err = ompi_group_range_incl(comm_old->c_group, 1, range, &newgroup);
|
2004-04-17 00:54:48 +04:00
|
|
|
#endif
|
2004-03-08 09:48:24 +03:00
|
|
|
}
|
|
|
|
if (err != MPI_SUCCESS) {
|
|
|
|
free((char *) topo);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Create the new communicator.
|
|
|
|
*/
|
2004-04-17 00:54:48 +04:00
|
|
|
#if 0
|
2004-06-07 19:33:53 +04:00
|
|
|
err = ompi_comm_create (comm_old, newgroup, comm_graph);
|
2004-04-17 00:54:48 +04:00
|
|
|
#endif
|
2004-03-08 09:48:24 +03:00
|
|
|
if (err != MPI_SUCCESS) {
|
|
|
|
free((char *) topo);
|
2004-04-17 00:54:48 +04:00
|
|
|
#if 0
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_group_free (&newgroup);
|
2004-04-17 00:54:48 +04:00
|
|
|
#endif
|
2004-03-08 09:48:24 +03:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Set the communicator topology information.
|
|
|
|
*/
|
|
|
|
if (*comm_graph != MPI_COMM_NULL) {
|
2004-06-07 19:33:53 +04:00
|
|
|
(*comm_graph)->c_flags |= OMPI_COMM_GRAPH;
|
2004-04-17 00:54:48 +04:00
|
|
|
(*comm_graph)->c_topo_comm->mtc_type = MPI_GRAPH;
|
|
|
|
(*comm_graph)->c_topo_comm->mtc_nprocs = nnodes;
|
|
|
|
(*comm_graph)->c_topo_comm->mtc_nedges = nedges;
|
|
|
|
(*comm_graph)->c_topo_comm->mtc_index = topo;
|
|
|
|
(*comm_graph)->c_topo_comm->mtc_edges = topo + nnodes;
|
2004-03-08 09:48:24 +03:00
|
|
|
}
|
|
|
|
|
2004-04-17 00:54:48 +04:00
|
|
|
#if 0
|
2004-06-07 19:33:53 +04:00
|
|
|
err = ompi_group_free (&newgroup);
|
2004-04-17 00:54:48 +04:00
|
|
|
#endif
|
2004-03-08 09:48:24 +03:00
|
|
|
if (err != MPI_SUCCESS) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(MPI_SUCCESS);
|
|
|
|
}
|