Browse Source

round up number of nodes to a power of two

Samuel Thibault 12 years ago
parent
commit
1ac34472e6
1 changed files with 9 additions and 4 deletions
  1. 9 4
      configure.ac

+ 9 - 4
configure.ac

@@ -1052,18 +1052,23 @@ if test x$enable_simgrid = xyes ; then
 	maxnodes=16
 else
 	# We have one memory node shared by all CPU workers, one node per GPU
-	maxnodes=1
+	nodes=1
 	if test x$enable_cuda = xyes ; then
 		# we could have used nmaxcudadev + 1, but this would certainly give an
 		# odd number.
-		maxnodes=`expr $nodes + $nmaxcudadev`
+		nodes=`expr $nodes + $nmaxcudadev`
 	fi
 	if test x$enable_opencl = xyes ; then
 		# we could have used nmaxcudadev + 1, but this would certainly give an
 		# odd number.
-		maxnodes=`expr $nodes + $nmaxopencldev`
+		nodes=`expr $nodes + $nmaxopencldev`
 	fi
-	# todo: set maxnodes to the next power of 2 greater than maxnodes
+	# set maxnodes to the next power of 2 greater than nodes
+	maxnodes=1
+	while test "$maxnodes" -lt "$nodes"
+	do
+		maxnodes=`expr $maxnodes \* 2`
+	done
 fi
 
 AC_MSG_CHECKING(maximum number of memory nodes)