Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
avoid potential division by 0... But not sure 0 is right as an answer here
authorAugustin Degomme <augustin.degomme@unibas.ch>
Sat, 2 Sep 2017 15:28:39 +0000 (17:28 +0200)
committerAugustin Degomme <augustin.degomme@unibas.ch>
Sat, 2 Sep 2017 15:28:39 +0000 (17:28 +0200)
src/smpi/colls/coll_tuned_topo.cpp

index aa797a9..db88a99 100644 (file)
@@ -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 ?
 }
 
 /*