Skip to content

Commit

Permalink
Fix divide by zero error in calculate_num_nodes_up_to_level
Browse files Browse the repository at this point in the history
with MPI_Bcast in 2 tasks using --mca coll_adapt_bcast_algorithm 6
and --mca coll_adapt_priority 99

Resolve review comments

Signed-off-by: David Wootton <[email protected]>
(cherry picked from commit a74927f)
  • Loading branch information
David Wootton committed Nov 28, 2022
1 parent 11b872c commit 7addc83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ompi/mca/coll/adapt/coll_adapt_topocache.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static ompi_coll_tree_t *create_topology(
{
int fanout = ompi_comm_size(comm) - 1;
ompi_coll_tree_t *tree;
if (fanout < 1) {
if (fanout <= 1) {
tree = ompi_coll_base_topo_build_chain(1, comm, root);
} else if (fanout <= MAXTREEFANOUT) {
tree = ompi_coll_base_topo_build_tree(ompi_comm_size(comm) - 1, comm, root);
Expand Down
7 changes: 6 additions & 1 deletion ompi/mca/coll/base/coll_base_topo.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ static int calculate_num_nodes_up_to_level( int fanout, int level )
{
/* just use geometric progression formula for sum:
a^0+a^1+...a^(n-1) = (a^n-1)/(a-1) */
return ((pown(fanout,level) - 1)/(fanout - 1));
if (1 == fanout) {
return level;
}
else {
return ((pown(fanout,level) - 1)/(fanout - 1));
}
}

/*
Expand Down

0 comments on commit 7addc83

Please sign in to comment.