int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm) { int rc; if ( MPI_PARAM_CHECK ) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid (comm)) return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); if ( MPI_GROUP_NULL == group ) return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_GROUP, FUNC_NAME); if ( NULL == newcomm ) return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } rc = ompi_comm_create ( (ompi_communicator_t*)comm, (ompi_group_t*)group, (ompi_communicator_t**)newcomm ); OMPI_ERRHANDLER_RETURN ( rc, comm, rc, FUNC_NAME); }
int mca_topo_base_dist_graph_create_adjacent(mca_topo_base_module_t* module, ompi_communicator_t *comm_old, int indegree, int sources[], int sourceweights[], int outdegree, int destinations[], int destweights[], ompi_info_t *info, int reorder, ompi_communicator_t **newcomm) { mca_topo_base_comm_dist_graph_2_2_0_t *topo = NULL; int err; if( OMPI_SUCCESS != (err = ompi_comm_create(comm_old, comm_old->c_local_group, newcomm)) ) { return err; } err = OMPI_ERR_OUT_OF_RESOURCE; /* suppose by default something bad will happens */ assert( NULL == (*newcomm)->c_topo ); topo = OBJ_NEW(mca_topo_base_comm_dist_graph_2_2_0_t); if( NULL == topo ) { goto bail_out; } topo->in = topo->inw = NULL; topo->out = topo->outw = NULL; topo->indegree = indegree; topo->outdegree = outdegree; topo->weighted = !((MPI_UNWEIGHTED == sourceweights) && (MPI_UNWEIGHTED == destweights)); if (topo->indegree > 0) { topo->in = (int*)malloc(sizeof(int) * topo->indegree); if (NULL == topo->in) { goto bail_out; } memcpy(topo->in, sources, sizeof(int) * topo->indegree); if (MPI_UNWEIGHTED != sourceweights) { topo->inw = (int*)malloc(sizeof(int) * topo->indegree); if( NULL == topo->inw ) { goto bail_out; } memcpy( topo->inw, sourceweights, sizeof(int) * topo->indegree ); } } if (topo->outdegree > 0) { topo->out = (int*)malloc(sizeof(int) * topo->outdegree); if (NULL == topo->out) { goto bail_out; } memcpy(topo->out, destinations, sizeof(int) * topo->outdegree); topo->outw = NULL; if (MPI_UNWEIGHTED != destweights) { if (topo->outdegree > 0) { topo->outw = (int*)malloc(sizeof(int) * topo->outdegree); if (NULL == topo->outw) { goto bail_out; } memcpy(topo->outw, destweights, sizeof(int) * topo->outdegree); } } } (*newcomm)->c_topo = module; (*newcomm)->c_topo->mtc.dist_graph = topo; (*newcomm)->c_topo->reorder = reorder; (*newcomm)->c_flags |= OMPI_COMM_DIST_GRAPH; return OMPI_SUCCESS; bail_out: if( NULL != topo->in ) free(topo->in); if( MPI_UNWEIGHTED != sourceweights ) { if( NULL != topo->inw ) free(topo->inw); } if( NULL != topo->out ) free(topo->out); if( MPI_UNWEIGHTED != destweights ) { if( NULL != topo->outw ) free(topo->outw); } if( NULL != topo ) { free(topo); } ompi_comm_free(newcomm); return err; }