diff --git a/ompi/mca/coll/basic/coll_basic_module.c b/ompi/mca/coll/basic/coll_basic_module.c index 574a0e4f98..80fb7b584e 100644 --- a/ompi/mca/coll/basic/coll_basic_module.c +++ b/ompi/mca/coll/basic/coll_basic_module.c @@ -76,11 +76,10 @@ mca_coll_basic_comm_query(struct ompi_communicator_t *comm, } size *= 2; if (OMPI_COMM_IS_CART(comm)) { - int cart_size; - mca_topo_base_comm_cart_2_2_0_t *cart; + int cart_size, ndims; assert (NULL != comm->c_topo); - cart = comm->c_topo->mtc.cart; - cart_size = cart->ndims * 4; + comm->c_topo->topo.cart.cartdim_get(comm, &ndims); + cart_size = ndims * 4; if (cart_size > size) { size = cart_size; } @@ -88,17 +87,16 @@ mca_coll_basic_comm_query(struct ompi_communicator_t *comm, int rank, degree; assert (NULL != comm->c_topo); rank = ompi_comm_rank (comm); - mca_topo_base_graph_neighbors_count (comm, rank, °ree); + comm->c_topo->topo.graph.graph_neighbors_count (comm, rank, °ree); degree *= 2; if (degree > size) { size = degree; } } else if (OMPI_COMM_IS_DIST_GRAPH(comm)) { - int dist_graph_size; - mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph; + int dist_graph_size, inneighbors, outneighbors, weighted; assert (NULL != comm->c_topo); - dist_graph = comm->c_topo->mtc.dist_graph; - dist_graph_size = dist_graph->indegree + dist_graph->outdegree; + comm->c_topo->topo.dist_graph.dist_graph_neighbors_count(comm, &inneighbors, &outneighbors, &weighted); + dist_graph_size = inneighbors + outneighbors; if (dist_graph_size > size) { size = dist_graph_size; } diff --git a/ompi/mca/topo/base/topo_base_dist_graph_create.c b/ompi/mca/topo/base/topo_base_dist_graph_create.c index 641b62ab83..37e2b4adf8 100644 --- a/ompi/mca/topo/base/topo_base_dist_graph_create.c +++ b/ompi/mca/topo/base/topo_base_dist_graph_create.c @@ -287,23 +287,16 @@ int mca_topo_base_dist_graph_create(mca_topo_base_module_t* module, ompi_communicator_t **newcomm) { int err; - ompi_proc_t **topo_procs = NULL; int num_procs, ret, rank, i; ompi_communicator_t *new_comm; mca_topo_base_comm_dist_graph_2_2_0_t* topo; - num_procs = ompi_comm_size(comm_old); - rank = ompi_comm_rank(comm_old); + topo_procs = (ompi_proc_t**)malloc(num_procs * sizeof(ompi_proc_t *)); - if(OMPI_GROUP_IS_DENSE(comm_old->c_local_group)) { - memcpy(topo_procs, - comm_old->c_local_group->grp_proc_pointers, - num_procs * sizeof(ompi_proc_t *)); - } else { - for(i = 0 ; i < num_procs; i++) { - topo_procs[i] = ompi_group_peer_lookup(comm_old->c_local_group,i); - } + if (NULL == topo_procs) { + return OMPI_ERR_OUT_OF_RESOURCE; } + num_procs = ompi_comm_size(comm_old); new_comm = ompi_comm_allocate(num_procs, 0); if (NULL == new_comm) { free(topo_procs); @@ -317,10 +310,22 @@ int mca_topo_base_dist_graph_create(mca_topo_base_module_t* module, &topo); if( OMPI_SUCCESS != err ) { free(topo_procs); - ompi_comm_free(newcomm); + ompi_comm_free(&new_comm); return err; } + /* we cannot simply call ompi_comm_create because c_topo + must be set before invoking ompi_comm_enable */ + rank = ompi_comm_rank(comm_old); + if(OMPI_GROUP_IS_DENSE(comm_old->c_local_group)) { + memcpy(topo_procs, + comm_old->c_local_group->grp_proc_pointers, + num_procs * sizeof(ompi_proc_t *)); + } else { + for(i = 0 ; i < num_procs; i++) { + topo_procs[i] = ompi_group_peer_lookup(comm_old->c_local_group,i); + } + } assert(NULL == new_comm->c_topo); new_comm->c_topo = module; new_comm->c_topo->reorder = reorder;