Skip to content

Commit 431b19a

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 387b2ff commit 431b19a

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

ompi/mca/common/ompio/common_ompio_file_read.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -132,7 +131,7 @@ int mca_common_ompio_file_read (ompio_file_t *fh,
132131
else {
133132
bytes_per_cycle = OMPIO_MCA_GET(fh, cycle_buffer_size);
134133
}
135-
cycles = ceil((float)max_data/bytes_per_cycle);
134+
cycles = (max_data + bytes_per_cycle - 1) / bytes_per_cycle;
136135

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

ompi/mca/common/ompio/common_ompio_file_write.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -116,7 +115,7 @@ int mca_common_ompio_file_write (ompio_file_t *fh,
116115
else {
117116
bytes_per_cycle = OMPIO_MCA_GET(fh, cycle_buffer_size);
118117
}
119-
cycles = ceil((float)max_data/bytes_per_cycle);
118+
cycles = (max_data + bytes_per_cycle - 1) / bytes_per_cycle;
120119

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

0 commit comments

Comments
 (0)