From 390209e72e2a7e87c776be7acfc545ca29b795b4 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 14 May 2002 15:15:12 -0500 Subject: [svn-r5418] Purpose: Code cleanup/Performance enhancement Description: The code to extend the file size in H5FD_mpio_flush is getting run even when the file size doesn't change. Also, it's sort of sidestepping MPI-I/O when extending the file, instead of using MPI-I/O features to set the file's size. Solution: Only extend the file's size when the allocated size has increased. Also use MPI_File_set_size() to change the file's size. Platforms tested: IRIX64 6.5 (modi4) --- src/H5FDmpio.c | 56 ++++++++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 5c48a10..cca989b 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -40,12 +40,10 @@ static hid_t H5FD_MPIO_g = 0; #ifdef H5_HAVE_PARALLEL /* - * The description of a file belonging to this driver. If the ALLSAME - * argument is set during a write operation then only p0 will do the actual - * write (this assumes all procs would write the same data). The EOF value - * is only used just after the file is opened in order for the library to - * determine whether the file is empty, truncated, or okay. The MPIO driver - * doesn't bother to keep it updated since it's an expensive operation. + * The description of a file belonging to this driver. + * The EOF value is only used just after the file is opened in order for the + * library to determine whether the file is empty, truncated, or okay. The MPIO + * driver doesn't bother to keep it updated since it's an expensive operation. */ typedef struct H5FD_mpio_t { H5FD_t pub; /*public stuff, must be first */ @@ -58,6 +56,7 @@ typedef struct H5FD_mpio_t { unsigned closing; /* Indicate that the file is closing immediately after call to flush */ haddr_t eof; /*end-of-file marker */ haddr_t eoa; /*end-of-address marker */ + haddr_t last_eoa; /* Last known end-of-address marker */ MPI_Datatype btype; /*buffer type for xfers */ MPI_Datatype ftype; /*file type for xfers */ haddr_t disp; /*displacement for set_view in xfers */ @@ -818,14 +817,10 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id, file->info = fa->info; file->mpi_rank = mpi_rank; file->mpi_size = mpi_size; - file->mpi_round = 0; /* Start metadata writes with process 0 */ - file->closing = FALSE; /* Not closing yet */ + file->eof = MPIOff_to_haddr(size); file->btype = MPI_DATATYPE_NULL; file->ftype = MPI_DATATYPE_NULL; - - file->eof = MPIOff_to_haddr(size); - #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) { fprintf(stdout, "Leaving H5FD_mpio_open\n" ); @@ -1609,25 +1604,26 @@ H5FD_mpio_flush(H5FD_t *_file) * Unfortunately, keeping track of EOF is an expensive operation, so * we can't just check whether EOFeoa == 0) - HRETURN(SUCCEED); - if (haddr_to_MPIOff(file->eoa-1, &mpi_off)<0) { - HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, - "cannot convert from haddr_t to MPI_Offset"); - } - if (0==file->mpi_rank) { - if (MPI_SUCCESS != MPI_File_read_at(file->f, mpi_off, &byte, - 1, MPI_BYTE, &mpi_stat)) { - HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, - "MPI_File_read_at() failed"); - } - if (MPI_SUCCESS != MPI_File_write_at(file->f, mpi_off, &byte, - 1, MPI_BYTE, &mpi_stat)) { - HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, - "MPI_File_write_at() failed"); - } - } + if(file->eoa>file->last_eoa) { +#ifdef OLD_WAY + if (0==file->mpi_rank) { + if (haddr_to_MPIOff(file->eoa-1, &mpi_off)<0) + HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset"); + if (MPI_SUCCESS != MPI_File_read_at(file->f, mpi_off, &byte, 1, MPI_BYTE, &mpi_stat)) + HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_read_at() failed"); + if (MPI_SUCCESS != MPI_File_write_at(file->f, mpi_off, &byte, 1, MPI_BYTE, &mpi_stat)) + HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_write_at() failed"); + } /* end if */ +#else /* OLD_WAY */ + if (haddr_to_MPIOff(file->eoa, &mpi_off)<0) + HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset"); + if (MPI_SUCCESS != MPI_File_set_size(file->f, mpi_off)) + HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_set_size failed"); +#endif /* OLD_WAY */ + + /* Update the 'last' eoa value */ + file->last_eoa=file->eoa; + } /* end if */ /* Only sync the file if we are not going to immediately close it */ if(!file->closing) { -- cgit v0.12