Skip to content

Commit 27e4389

Browse files
committed
* comment on communicator creation in mca_topo_base_dist_graph_create(...)
* use accesors to retrieve topo info
1 parent 76204df commit 27e4389

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

ompi/mca/coll/basic/coll_basic_module.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,27 @@ mca_coll_basic_comm_query(struct ompi_communicator_t *comm,
7676
}
7777
size *= 2;
7878
if (OMPI_COMM_IS_CART(comm)) {
79-
int cart_size;
80-
mca_topo_base_comm_cart_2_2_0_t *cart;
79+
int cart_size, ndims;
8180
assert (NULL != comm->c_topo);
82-
cart = comm->c_topo->mtc.cart;
83-
cart_size = cart->ndims * 4;
81+
comm->c_topo->topo.cart.cartdim_get(comm, &ndims);
82+
cart_size = ndims * 4;
8483
if (cart_size > size) {
8584
size = cart_size;
8685
}
8786
} else if (OMPI_COMM_IS_GRAPH(comm)) {
8887
int rank, degree;
8988
assert (NULL != comm->c_topo);
9089
rank = ompi_comm_rank (comm);
91-
mca_topo_base_graph_neighbors_count (comm, rank, &degree);
90+
comm->c_topo->topo.graph.graph_neighbors_count (comm, rank, &degree);
9291
degree *= 2;
9392
if (degree > size) {
9493
size = degree;
9594
}
9695
} else if (OMPI_COMM_IS_DIST_GRAPH(comm)) {
97-
int dist_graph_size;
98-
mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph;
96+
int dist_graph_size, inneighbors, outneighbors, weighted;
9997
assert (NULL != comm->c_topo);
100-
dist_graph = comm->c_topo->mtc.dist_graph;
101-
dist_graph_size = dist_graph->indegree + dist_graph->outdegree;
98+
comm->c_topo->topo.dist_graph.dist_graph_neighbors_count(comm, &inneighbors, &outneighbors, &weighted);
99+
dist_graph_size = inneighbors + outneighbors;
102100
if (dist_graph_size > size) {
103101
size = dist_graph_size;
104102
}

ompi/mca/topo/base/topo_base_dist_graph_create.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,23 +287,16 @@ int mca_topo_base_dist_graph_create(mca_topo_base_module_t* module,
287287
ompi_communicator_t **newcomm)
288288
{
289289
int err;
290-
291290
ompi_proc_t **topo_procs = NULL;
292291
int num_procs, ret, rank, i;
293292
ompi_communicator_t *new_comm;
294293
mca_topo_base_comm_dist_graph_2_2_0_t* topo;
295-
num_procs = ompi_comm_size(comm_old);
296-
rank = ompi_comm_rank(comm_old);
294+
297295
topo_procs = (ompi_proc_t**)malloc(num_procs * sizeof(ompi_proc_t *));
298-
if(OMPI_GROUP_IS_DENSE(comm_old->c_local_group)) {
299-
memcpy(topo_procs,
300-
comm_old->c_local_group->grp_proc_pointers,
301-
num_procs * sizeof(ompi_proc_t *));
302-
} else {
303-
for(i = 0 ; i < num_procs; i++) {
304-
topo_procs[i] = ompi_group_peer_lookup(comm_old->c_local_group,i);
305-
}
296+
if (NULL == topo_procs) {
297+
return OMPI_ERR_OUT_OF_RESOURCE;
306298
}
299+
num_procs = ompi_comm_size(comm_old);
307300
new_comm = ompi_comm_allocate(num_procs, 0);
308301
if (NULL == new_comm) {
309302
free(topo_procs);
@@ -317,10 +310,22 @@ int mca_topo_base_dist_graph_create(mca_topo_base_module_t* module,
317310
&topo);
318311
if( OMPI_SUCCESS != err ) {
319312
free(topo_procs);
320-
ompi_comm_free(newcomm);
313+
ompi_comm_free(&new_comm);
321314
return err;
322315
}
323316

317+
/* we cannot simply call ompi_comm_create because c_topo
318+
must be set before invoking ompi_comm_enable */
319+
rank = ompi_comm_rank(comm_old);
320+
if(OMPI_GROUP_IS_DENSE(comm_old->c_local_group)) {
321+
memcpy(topo_procs,
322+
comm_old->c_local_group->grp_proc_pointers,
323+
num_procs * sizeof(ompi_proc_t *));
324+
} else {
325+
for(i = 0 ; i < num_procs; i++) {
326+
topo_procs[i] = ompi_group_peer_lookup(comm_old->c_local_group,i);
327+
}
328+
}
324329
assert(NULL == new_comm->c_topo);
325330
new_comm->c_topo = module;
326331
new_comm->c_topo->reorder = reorder;

0 commit comments

Comments
 (0)