Skip to content

Commit e222a04

Browse files
committed
Suggestion to fix division by zero in file view.
In common_ompi_aggregators calc_cost routine: do not cast the real division to an int intermediately. This patch removes the obsolete int variable c and assigns the result of the P_a/P_x division directly to n_as. With the intermediate int c variable, n_as gets 0 if P_a < P_x, resulting in a division by 0 when computing n_s. Signed-off-by: Harald Klimach <harald.klimach@uni-siegen.de>
1 parent 7c3aeb3 commit e222a04

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ompi/mca/common/ompio/common_ompio_aggregators.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,13 +1491,12 @@ static double cost_calc (int P, int P_a, size_t d_p, size_t b_c, int dim )
14911491
}
14921492
case DIM2:
14931493
{
1494-
int P_x, P_y, c;
1494+
int P_x, P_y;
14951495

14961496
P_x = P_y = (int) sqrt(P);
1497-
c = (float) P_a / (float)P_x;
1497+
n_as = (float) P_a / (float)P_x;
14981498

14991499
n_ar = (float) P_y;
1500-
n_as = (float) c;
15011500
if ( d_p > (P_a*b_c/P )) {
15021501
m_s = fmin(b_c / P_y, d_p);
15031502
}

0 commit comments

Comments
 (0)