Skip to content

Commit fbb1112

Browse files
committed
common/ompio: fix a floating point division problem
This commit fixes a problem reported on the mailing list with individual writes larger than 512 MB. The culprit is a floating point division of two large, close values. Changing the datatypes from float to double (which is what is being used in the fcoll components) fixes the problem. See issue #6285 and https://forum.hdfgroup.org/t/cannot-write-more-than-512-mb-in-1d/5118 Thanks for Axel Huebl and René Widera for reporting the issue. Signed-off-by: Edgar Gabriel <[email protected]> (cherry picked from commit c0f8ce0)
1 parent 6705cd9 commit fbb1112

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

ompi/mca/common/ompio/common_ompio_file_read.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2019 University of Houston. All rights reserved.
13+
* Copyright (c) 2018 Research Organization for Information Science
14+
* and Technology (RIST). All rights reserved.
1315
* $COPYRIGHT$
1416
*
1517
* Additional copyrights may follow
@@ -34,6 +36,7 @@
3436
#include "ompi/mca/io/ompio/io_ompio_request.h"
3537
#include "math.h"
3638
#include <unistd.h>
39+
#include <math.h>
3740

3841
/* Read and write routines are split into two interfaces.
3942
** The
@@ -99,8 +102,8 @@ int mca_common_ompio_file_read (mca_io_ompio_file_t *fh,
99102
else {
100103
bytes_per_cycle = mca_io_ompio_cycle_buffer_size;
101104
}
102-
cycles = ceil((float)max_data/bytes_per_cycle);
103-
105+
cycles = ceil((double)max_data/bytes_per_cycle);
106+
104107
#if 0
105108
printf ("Bytes per Cycle: %d Cycles: %d max_data:%d \n",bytes_per_cycle, cycles, max_data);
106109
#endif

ompi/mca/common/ompio/common_ompio_file_write.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
13-
* Copyright (c) 2015-2017 Research Organization for Information Science
12+
* Copyright (c) 2008-2019 University of Houston. All rights reserved.
13+
* Copyright (c) 2015-2018 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
@@ -34,6 +34,7 @@
3434
#include "ompi/mca/io/ompio/io_ompio_request.h"
3535
#include "math.h"
3636
#include <unistd.h>
37+
#include <math.h>
3738

3839
int mca_common_ompio_file_write (mca_io_ompio_file_t *fh,
3940
const void *buf,
@@ -76,7 +77,7 @@ int mca_common_ompio_file_write (mca_io_ompio_file_t *fh,
7677
else {
7778
bytes_per_cycle = mca_io_ompio_cycle_buffer_size;
7879
}
79-
cycles = ceil((float)max_data/bytes_per_cycle);
80+
cycles = ceil((double)max_data/bytes_per_cycle);
8081

8182
#if 0
8283
printf ("Bytes per Cycle: %d Cycles: %d\n", bytes_per_cycle, cycles);

0 commit comments

Comments
 (0)