From d1e8779fe3b9d1325ccee3b12d31d5c84d1a0797 Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Thu, 17 Jan 2019 11:09:41 -0600 Subject: [PATCH] common/ompio: fix a floating point division problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit c0f8ce0fff4684b670135043dd150abc9d83d988) --- ompi/mca/common/ompio/common_ompio_file_read.c | 8 ++++---- ompi/mca/common/ompio/common_ompio_file_write.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ompi/mca/common/ompio/common_ompio_file_read.c b/ompi/mca/common/ompio/common_ompio_file_read.c index 3203e2a697..452683605a 100644 --- a/ompi/mca/common/ompio/common_ompio_file_read.c +++ b/ompi/mca/common/ompio/common_ompio_file_read.c @@ -9,7 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2008-2018 University of Houston. All rights reserved. + * Copyright (c) 2008-2019 University of Houston. All rights reserved. * Copyright (c) 2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -33,8 +33,8 @@ #include "common_ompio.h" #include "common_ompio_request.h" -#include "math.h" #include +#include #if OPAL_CUDA_SUPPORT #include "common_ompio_cuda.h" @@ -132,8 +132,8 @@ int mca_common_ompio_file_read (ompio_file_t *fh, else { bytes_per_cycle = OMPIO_MCA_GET(fh, cycle_buffer_size); } - cycles = ceil((float)max_data/bytes_per_cycle); - + cycles = ceil((double)max_data/bytes_per_cycle); + #if 0 printf ("Bytes per Cycle: %d Cycles: %d max_data:%d \n",bytes_per_cycle, cycles, max_data); #endif diff --git a/ompi/mca/common/ompio/common_ompio_file_write.c b/ompi/mca/common/ompio/common_ompio_file_write.c index e53a1d080b..adb9c844d7 100644 --- a/ompi/mca/common/ompio/common_ompio_file_write.c +++ b/ompi/mca/common/ompio/common_ompio_file_write.c @@ -9,7 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2008-2018 University of Houston. All rights reserved. + * Copyright (c) 2008-2019 University of Houston. All rights reserved. * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -31,8 +31,8 @@ #include "common_ompio.h" #include "common_ompio_request.h" -#include "math.h" #include +#include #if OPAL_CUDA_SUPPORT #include "common_ompio_cuda.h" @@ -116,7 +116,7 @@ int mca_common_ompio_file_write (ompio_file_t *fh, else { bytes_per_cycle = OMPIO_MCA_GET(fh, cycle_buffer_size); } - cycles = ceil((float)max_data/bytes_per_cycle); + cycles = ceil((double)max_data/bytes_per_cycle); #if 0 printf ("Bytes per Cycle: %d Cycles: %d\n", bytes_per_cycle, cycles); @@ -409,7 +409,7 @@ int mca_common_ompio_file_iwrite_at_all (ompio_file_t *fp, /**************************************************************/ int mca_common_ompio_build_io_array ( ompio_file_t *fh, int index, int cycles, - size_t bytes_per_cycle, int max_data, uint32_t iov_count, + size_t bytes_per_cycle, int max_data, uint32_t iov_count, struct iovec *decoded_iov, int *ii, int *jj, size_t *tbw, size_t *spc) {