Skip to content

Commit 5cae28b

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]>
1 parent 352b667 commit 5cae28b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

ompi/mca/common/ompio/common_ompio_file_read.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
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-2018 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2019 University of Houston. All rights reserved.
1313
* Copyright (c) 2018 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
@@ -33,7 +33,6 @@
3333

3434
#include "common_ompio.h"
3535
#include "common_ompio_request.h"
36-
#include "math.h"
3736
#include <unistd.h>
3837

3938
#if OPAL_CUDA_SUPPORT
@@ -67,6 +66,7 @@ int mca_common_ompio_file_read (ompio_file_t *fh,
6766
size_t bytes_per_cycle = 0; /* total read in each cycle by each process*/
6867
int index = 0;
6968
int cycles = 0;
69+
uint64_t t_cycles = 0;
7070

7171
uint32_t iov_count = 0;
7272
struct iovec *decoded_iov = NULL;
@@ -132,8 +132,9 @@ int mca_common_ompio_file_read (ompio_file_t *fh,
132132
else {
133133
bytes_per_cycle = OMPIO_MCA_GET(fh, cycle_buffer_size);
134134
}
135-
cycles = ceil((float)max_data/bytes_per_cycle);
136-
135+
t_cycles = (max_data + bytes_per_cycle - 1) / bytes_per_cycle;
136+
cycles = (int) t_cycles;
137+
137138
#if 0
138139
printf ("Bytes per Cycle: %d Cycles: %d max_data:%d \n",bytes_per_cycle, cycles, max_data);
139140
#endif

ompi/mca/common/ompio/common_ompio_file_write.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
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-2018 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2019 University of Houston. All rights reserved.
1313
* Copyright (c) 2015-2018 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
@@ -31,7 +31,6 @@
3131

3232
#include "common_ompio.h"
3333
#include "common_ompio_request.h"
34-
#include "math.h"
3534
#include <unistd.h>
3635

3736
#if OPAL_CUDA_SUPPORT
@@ -47,6 +46,7 @@ int mca_common_ompio_file_write (ompio_file_t *fh,
4746
int ret = OMPI_SUCCESS;
4847
int index = 0;
4948
int cycles = 0;
49+
uint64_t t_cycles = 0;
5050

5151
uint32_t iov_count = 0;
5252
struct iovec *decoded_iov = NULL;
@@ -116,7 +116,8 @@ int mca_common_ompio_file_write (ompio_file_t *fh,
116116
else {
117117
bytes_per_cycle = OMPIO_MCA_GET(fh, cycle_buffer_size);
118118
}
119-
cycles = ceil((float)max_data/bytes_per_cycle);
119+
t_cycles = (max_data + bytes_per_cycle - 1) / bytes_per_cycle;
120+
cycles = (int) t_cycles;
120121

121122
#if 0
122123
printf ("Bytes per Cycle: %d Cycles: %d\n", bytes_per_cycle, cycles);
@@ -409,7 +410,7 @@ int mca_common_ompio_file_iwrite_at_all (ompio_file_t *fp,
409410
/**************************************************************/
410411

411412
int mca_common_ompio_build_io_array ( ompio_file_t *fh, int index, int cycles,
412-
size_t bytes_per_cycle, int max_data, uint32_t iov_count,
413+
size_t bytes_per_cycle, int max_data, uint32_t iov_count,
413414
struct iovec *decoded_iov, int *ii, int *jj, size_t *tbw,
414415
size_t *spc)
415416
{

0 commit comments

Comments
 (0)