1
1

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: #7186

Signed-off-by: Michael Lass <bevan@bi-co.net>
(cherry picked from commit 67490118adb8372d2aefe1d2d923432e51e100cd)
Этот коммит содержится в:
Michael Lass 2019-11-22 19:49:11 +01:00 коммит произвёл Michael Lass
родитель 8df9f53bdc
Коммит ff85c82151

Просмотреть файл

@ -240,7 +240,7 @@ getfactors(int num, int *nfactors, int **factors) {
}
/* determine all occurences of uneven prime numbers up to sqrt(num) */
d = 3;
for(d = 3; (num > 1) && (d < sqrtnum); d += 2) {
for(d = 3; (num > 1) && (d <= sqrtnum); d += 2) {
while((num % d) == 0) {
num /= d;
(*factors)[i++] = d;