From b98b530ed10d60d9c350bf4919896a0c50b649f3 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Sat, 2 Sep 2017 17:28:39 +0200 Subject: [PATCH] avoid potential division by 0... But not sure 0 is right as an answer here --- src/smpi/colls/coll_tuned_topo.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/smpi/colls/coll_tuned_topo.cpp b/src/smpi/colls/coll_tuned_topo.cpp index aa797a9884..db88a997bb 100644 --- a/src/smpi/colls/coll_tuned_topo.cpp +++ b/src/smpi/colls/coll_tuned_topo.cpp @@ -52,7 +52,10 @@ 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(fanout > 1) + return ((pown(fanout,level) - 1)/(fanout - 1)); + else + return 0; // is this right ? } /* -- 2.20.1