From 9daec82f17f5b204d9f64701e62473349e14b6c3 Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Thu, 30 May 2013 21:33:13 +0000 Subject: [PATCH] - make a fileview of 0 bytes work in ompio - fixes the bug reported in ticket 3619 (which is already closed) also for ompio This commit was SVN r28575. --- ompi/mca/io/ompio/io_ompio.c | 8 ++++++++ ompi/mca/io/ompio/io_ompio_file_read.c | 9 +++++++-- ompi/mca/io/ompio/io_ompio_file_set_view.c | 4 +++- ompi/mca/io/ompio/io_ompio_file_write.c | 9 ++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/ompi/mca/io/ompio/io_ompio.c b/ompi/mca/io/ompio/io_ompio.c index 415580a4f4..5faba1ae54 100644 --- a/ompi/mca/io/ompio/io_ompio.c +++ b/ompi/mca/io/ompio/io_ompio.c @@ -491,6 +491,14 @@ int ompi_io_ompio_decode_datatype (mca_io_ompio_file_t *fh, opal_output (1, "Cannot attach the datatype to a convertor\n"); return OMPI_ERROR; } + + if ( 0 == datatype->super.size ) { + *max_data = 0; + *iovec_count = 0; + *iov = NULL; + return OMPI_SUCCESS; + } + remaining_length = count * datatype->super.size; temp_count = OMPIO_IOVEC_INITIAL_SIZE; diff --git a/ompi/mca/io/ompio/io_ompio_file_read.c b/ompi/mca/io/ompio/io_ompio_file_read.c index fd31b67b96..ef1b5e61df 100644 --- a/ompi/mca/io/ompio/io_ompio_file_read.c +++ b/ompi/mca/io/ompio/io_ompio_file_read.c @@ -62,11 +62,17 @@ mca_io_ompio_file_read (ompi_file_t *fp, data = (mca_io_ompio_data_t *) fp->f_io_selected_data; fh = &data->ompio_fh; + if ( 0 == count ) { + if ( MPI_STATUS_IGNORE != status ) { + status->_ucount = max_data; + } + return ret; + } if (fh->f_amode & MPI_MODE_WRONLY){ printf("Improper use of FILE Mode, Using WRONLY for Read!\n"); ret = OMPI_ERROR; - goto exit; + return ret; } ompi_io_ompio_decode_datatype (fh, @@ -218,7 +224,6 @@ mca_io_ompio_file_read (ompi_file_t *fp, status->_ucount = max_data; } - exit: return ret; } diff --git a/ompi/mca/io/ompio/io_ompio_file_set_view.c b/ompi/mca/io/ompio/io_ompio_file_set_view.c index c4eee8b2fe..1b554d402a 100644 --- a/ompi/mca/io/ompio/io_ompio_file_set_view.c +++ b/ompi/mca/io/ompio/io_ompio_file_set_view.c @@ -167,7 +167,9 @@ OMPI_MPI_OFFSET_TYPE get_contiguous_chunk_size (mca_io_ompio_file_t *fh) } } } - avg = avg/fh->f_iov_count; + if ( 0 != fh->f_iov_count ) { + avg = avg/fh->f_iov_count; + } fh->f_comm->c_coll.coll_allreduce (&avg, &global_avg, 1, diff --git a/ompi/mca/io/ompio/io_ompio_file_write.c b/ompi/mca/io/ompio/io_ompio_file_write.c index 23b1f6bda5..f3508d5628 100644 --- a/ompi/mca/io/ompio/io_ompio_file_write.c +++ b/ompi/mca/io/ompio/io_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-2012 University of Houston. All rights reserved. + * Copyright (c) 2008-2013 University of Houston. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -59,6 +59,13 @@ mca_io_ompio_file_write (ompi_file_t *fp, size_t sum_previous_counts = 0; size_t sum_previous_length = 0; + if ( 0 == count ) { + if ( MPI_STATUS_IGNORE != status ) { + status->_ucount = 0; + } + return ret; + } + data = (mca_io_ompio_data_t *) fp->f_io_selected_data; fh = &data->ompio_fh;