Skip to content

Commit c066dd5

Browse files
michaellasscniethammer
authored andcommitted
dims_create: fix calculation of factors for odd squares
Until now sqrt(n) was missed as a factor for odd square numbers n. This lead to suboptimal results of MPI_Dims_create for input numbers like 9, 25, 49, ... Fix the results by including sqrt(n) in the search for factors. Refs: open-mpi#7186 Signed-off-by: Michael Lass <[email protected]> (cherry picked from commit 6749011)
1 parent 9466ed5 commit c066dd5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ompi/mpi/c/dims_create.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ getfactors(int num, int *nfactors, int **factors) {
240240
}
241241
/* determine all occurences of uneven prime numbers up to sqrt(num) */
242242
d = 3;
243-
for(d = 3; (num > 1) && (d < sqrtnum); d += 2) {
243+
for(d = 3; (num > 1) && (d <= sqrtnum); d += 2) {
244244
while((num % d) == 0) {
245245
num /= d;
246246
(*factors)[i++] = d;

0 commit comments

Comments
 (0)