Skip to content

Commit a74927f

Browse files
author
David Wootton
committed
Fix divide by zero error in calculate_num_nodes_up_to_level
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 <dwootton@us.ibm.com>
1 parent da92ede commit a74927f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ompi/mca/coll/adapt/coll_adapt_topocache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static ompi_coll_tree_t *create_topology(
5959
{
6060
int fanout = ompi_comm_size(comm) - 1;
6161
ompi_coll_tree_t *tree;
62-
if (fanout < 1) {
62+
if (fanout <= 1) {
6363
tree = ompi_coll_base_topo_build_chain(1, comm, root);
6464
} else if (fanout <= MAXTREEFANOUT) {
6565
tree = ompi_coll_base_topo_build_tree(ompi_comm_size(comm) - 1, comm, root);

ompi/mca/coll/base/coll_base_topo.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ static int calculate_num_nodes_up_to_level( int fanout, int level )
5959
{
6060
/* just use geometric progression formula for sum:
6161
a^0+a^1+...a^(n-1) = (a^n-1)/(a-1) */
62-
return ((pown(fanout,level) - 1)/(fanout - 1));
62+
if (1 == fanout) {
63+
return level;
64+
}
65+
else {
66+
return ((pown(fanout,level) - 1)/(fanout - 1));
67+
}
6368
}
6469

6570
/*

0 commit comments

Comments
 (0)