Skip to content

Commit 80a88a1

Browse files
authored
Merge pull request #10133 from edgargabriel/topic/cost_calc_div_fixes
common/ompio: fix a division by zero problem in cost_calc
2 parents 602f5e2 + 45b9493 commit 80a88a1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

ompi/mca/common/ompio/common_ompio_aggregators.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,8 +1459,8 @@ int mca_common_ompio_prepare_to_group(ompio_file_t *fh,
14591459
*/
14601460
static double cost_calc (int P, int P_a, size_t d_p, size_t b_c, int dim )
14611461
{
1462-
float n_as=1.0, m_s=1.0, n_s=1.0;
1463-
float n_ar=1.0;
1462+
double n_as=1.0, m_s=1.0, n_s=1.0;
1463+
double n_ar=1.0;
14641464
double t_send, t_recv, t_tot;
14651465

14661466
/* LogGP parameters based on DDR InfiniBand values */
@@ -1470,7 +1470,7 @@ static double cost_calc (int P, int P_a, size_t d_p, size_t b_c, int dim )
14701470
double G=.00000000067;
14711471

14721472
long file_domain = (P * d_p) / P_a;
1473-
float n_r = (float)file_domain/(float) b_c;
1473+
double n_r = (double)file_domain/(double) b_c;
14741474

14751475
switch (dim) {
14761476
case DIM1:
@@ -1480,10 +1480,10 @@ static double cost_calc (int P, int P_a, size_t d_p, size_t b_c, int dim )
14801480
n_ar = 1;
14811481
n_as = 1;
14821482
m_s = b_c;
1483-
n_s = (float)d_p/(float)b_c;
1483+
n_s = (double)d_p/(double)b_c;
14841484
}
14851485
else {
1486-
n_ar = (float)b_c/(float)d_p;
1486+
n_ar = (double)b_c/(double)d_p;
14871487
n_as = 1;
14881488
m_s = d_p;
14891489
n_s = 1;
@@ -1495,14 +1495,14 @@ static double cost_calc (int P, int P_a, size_t d_p, size_t b_c, int dim )
14951495
int P_x, P_y;
14961496

14971497
P_x = P_y = (int) sqrt(P);
1498-
n_as = (float) P_a / (float)P_x;
1498+
n_as = (double) P_a / (double)P_x;
14991499

1500-
n_ar = (float) P_y;
1500+
n_ar = (double) P_y;
15011501
if ( d_p > (P_a*b_c/P )) {
1502-
m_s = fmin(b_c / P_y, d_p);
1502+
m_s = fmin((double) b_c / (double)P_y, (double)d_p);
15031503
}
15041504
else {
1505-
m_s = fmin(d_p * P_x / P_a, d_p);
1505+
m_s = fmin((double) (d_p * P_x) / (double)P_a, (double)d_p);
15061506
}
15071507
break;
15081508
}
@@ -1511,7 +1511,7 @@ static double cost_calc (int P, int P_a, size_t d_p, size_t b_c, int dim )
15111511
break;
15121512
}
15131513

1514-
n_s = (float) d_p / (float)(n_as * m_s);
1514+
n_s = (double) d_p / (double)(n_as * m_s);
15151515

15161516
if( m_s < 33554432) {
15171517
g = .00000108;

0 commit comments

Comments
 (0)