From 92f6c7c1e210c559471a05aaac9b19e0bd3d71bb Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Thu, 30 Apr 2015 18:56:53 +0900 Subject: [PATCH] ROMIO 3.1.4 refresh: apply post romio-3.1.4 patches --- .../romio/adio/ad_lustre/ad_lustre_rwcontig.c | 5 ---- .../romio/adio/ad_pvfs2/ad_pvfs2_aio.c | 10 +++++++ .../io/romio314/romio/adio/ad_xfs/ad_xfs.h | 5 ---- .../io/romio314/romio/adio/common/ad_read.c | 5 ---- .../io/romio314/romio/adio/common/ad_write.c | 5 ---- .../mca/io/romio314/romio/adio/common/utils.c | 30 ++++++++++++++++++- .../io/romio314/romio/adio/include/adioi.h | 7 +++++ ompi/mca/io/romio314/romio/configure.ac | 8 +++++ ompi/mca/io/romio314/romio/mpi-io/mpioimpl.h | 7 ++++- 9 files changed, 60 insertions(+), 22 deletions(-) diff --git a/ompi/mca/io/romio314/romio/adio/ad_lustre/ad_lustre_rwcontig.c b/ompi/mca/io/romio314/romio/adio/ad_lustre/ad_lustre_rwcontig.c index 5f1c2321ed..cb187a39e9 100644 --- a/ompi/mca/io/romio314/romio/adio/ad_lustre/ad_lustre_rwcontig.c +++ b/ompi/mca/io/romio314/romio/adio/ad_lustre/ad_lustre_rwcontig.c @@ -8,11 +8,6 @@ * Copyright (C) 2008 Sun Microsystems, Lustre group */ -#ifdef _STDC_C99 -#define _XOPEN_SOURCE 600 -#else -#define _XOPEN_SOURCE 500 -#endif #include #include diff --git a/ompi/mca/io/romio314/romio/adio/ad_pvfs2/ad_pvfs2_aio.c b/ompi/mca/io/romio314/romio/adio/ad_pvfs2/ad_pvfs2_aio.c index 88be6f1eaf..f4d78497e3 100644 --- a/ompi/mca/io/romio314/romio/adio/ad_pvfs2/ad_pvfs2_aio.c +++ b/ompi/mca/io/romio314/romio/adio/ad_pvfs2/ad_pvfs2_aio.c @@ -121,6 +121,7 @@ void ADIOI_PVFS2_AIO_contig(ADIO_File fd, void *buf, int count, } /* --END ERROR HANDLING-- */ +#ifdef HAVE_MPI_GREQUEST_EXTENSIONS /* posted. defered completion */ if (ret == 0) { if (ADIOI_PVFS2_greq_class == 0) { @@ -132,6 +133,15 @@ void ADIOI_PVFS2_AIO_contig(ADIO_File fd, void *buf, int count, MPIX_Grequest_class_allocate(ADIOI_PVFS2_greq_class, aio_req, request); memcpy(&(aio_req->req), request, sizeof(*request)); } +#else + /* if generalized request extensions not available, we will have to process + * this operation right here */ + int error; + ret = PVFS_sys_wait(aio_req->op_id, "ADIOI_PVFS2_AIO_Contig", &error); + if (ret == 0) { + MPIO_Completed_request_create(&fd, len, error_code, request); + } +#endif /* immediate completion */ if (ret == 1) { diff --git a/ompi/mca/io/romio314/romio/adio/ad_xfs/ad_xfs.h b/ompi/mca/io/romio314/romio/adio/ad_xfs/ad_xfs.h index 1a4d4ccc1b..d14858d4aa 100644 --- a/ompi/mca/io/romio314/romio/adio/ad_xfs/ad_xfs.h +++ b/ompi/mca/io/romio314/romio/adio/ad_xfs/ad_xfs.h @@ -8,11 +8,6 @@ #ifndef AD_XFS_INCLUDE #define AD_XFS_INCLUDE -#ifdef _STDC_C99 -#define _XOPEN_SOURCE 600 -#else -#define _XOPEN_SOURCE 500 -#endif #include #include #include diff --git a/ompi/mca/io/romio314/romio/adio/common/ad_read.c b/ompi/mca/io/romio314/romio/adio/common/ad_read.c index 544ccf41f3..19f2908614 100644 --- a/ompi/mca/io/romio314/romio/adio/common/ad_read.c +++ b/ompi/mca/io/romio314/romio/adio/common/ad_read.c @@ -6,11 +6,6 @@ */ -#ifdef _STDC_C99 -#define _XOPEN_SOURCE 600 -#else -#define _XOPEN_SOURCE 500 -#endif #include #include "adio.h" diff --git a/ompi/mca/io/romio314/romio/adio/common/ad_write.c b/ompi/mca/io/romio314/romio/adio/common/ad_write.c index ad318e4117..34a31d963f 100644 --- a/ompi/mca/io/romio314/romio/adio/common/ad_write.c +++ b/ompi/mca/io/romio314/romio/adio/common/ad_write.c @@ -6,11 +6,6 @@ */ -#ifdef _STDC_C99 -#define _XOPEN_SOURCE 600 -#else -#define _XOPEN_SOURCE 500 -#endif #include #include "adio.h" diff --git a/ompi/mca/io/romio314/romio/adio/common/utils.c b/ompi/mca/io/romio314/romio/adio/common/utils.c index eef48cb0dc..d5c8e8bad0 100644 --- a/ompi/mca/io/romio314/romio/adio/common/utils.c +++ b/ompi/mca/io/romio314/romio/adio/common/utils.c @@ -8,7 +8,6 @@ #include #include - /* utility function for creating large contiguous types: algorithim from BigMPI * https://github.com/jeffhammond/BigMPI */ @@ -105,6 +104,35 @@ int ADIOI_Type_create_hindexed_x(int count, return ret; } +/* some systems do not have pread/pwrite, or requrie XOPEN_SOURCE set higher + * than we would like. see #1973 */ +#if (HAVE_DECL_PWRITE == 0) + +#include +#include + +ssize_t pread(int fd, void *buf, size_t count, off_t offset); +ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset); + +ssize_t pread(int fd, void *buf, size_t count, off_t offset) { + off_t lseek_ret; + + lseek_ret = lseek(fd, offset, SEEK_SET); + if (lseek_ret == -1) + return lseek_ret; + return (read(fd, buf, count)); +} + +ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) { + off_t lseek_ret; + + lseek_ret = lseek(fd, offset, SEEK_SET); + if (lseek_ret == -1) + return lseek_ret; + return (write(fd, buf, count)); +} +#endif + /* * vim: ts=8 sts=4 sw=4 noexpandtab */ diff --git a/ompi/mca/io/romio314/romio/adio/include/adioi.h b/ompi/mca/io/romio314/romio/adio/include/adioi.h index 3fddbdabf6..2801abcbd4 100644 --- a/ompi/mca/io/romio314/romio/adio/include/adioi.h +++ b/ompi/mca/io/romio314/romio/adio/include/adioi.h @@ -916,3 +916,10 @@ void *ADIOI_IO_Thread_Func(void *vptr_args); #endif + +#if (HAVE_DECL_PWRITE == 0) +#include +#include +ssize_t pread(int fd, void *buf, size_t count, off_t offset); +ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset); +#endif diff --git a/ompi/mca/io/romio314/romio/configure.ac b/ompi/mca/io/romio314/romio/configure.ac index a543bf1160..4d51a3ef79 100644 --- a/ompi/mca/io/romio314/romio/configure.ac +++ b/ompi/mca/io/romio314/romio/configure.ac @@ -1476,6 +1476,14 @@ if test "$ac_cv_header_unistd_h" = "yes" ; then fi fi +# pread and pwrite are useful to ROMIO: if implemented well, they help us avoid +# an extra system call. But --enable-strict or CFLAGS="--std=c99" does not +# expose this feature. If we define XOPEN_SOURCE in ROMIO, we cause headaches +# for some versions of lustre, quota.h, and caddr_t. see if we need to provide +# our own pread/pwrite + +AC_CHECK_DECLS([pwrite]) + #################################################################### # We're about to mess with CC etc. No more feature tests past here, diff --git a/ompi/mca/io/romio314/romio/mpi-io/mpioimpl.h b/ompi/mca/io/romio314/romio/mpi-io/mpioimpl.h index 77b18cba93..8f67bcea70 100644 --- a/ompi/mca/io/romio314/romio/mpi-io/mpioimpl.h +++ b/ompi/mca/io/romio314/romio/mpi-io/mpioimpl.h @@ -36,7 +36,12 @@ of correct programs */ #define MPIU_THREAD_CS_ENTER(x,y) #define MPIU_THREAD_CS_EXIT(x,y) -#define MPIO_DATATYPE_ISCOMMITTED(dtype_, err_) do {} while (0) +/* The MPI_DATATYPE_ISCOMMITTED macro now always sets err_=0. + This is an optimistic approach for Open MPI, but it is likely other + upper layers already checked the datatype was committed. + Not setting err_ is incorrect since it can lead to use of + uninitialized variable.*/ +#define MPIO_DATATYPE_ISCOMMITTED(dtype_, err_) do { err_ = 0; } while (0) #ifdef HAVE_WINDOWS_H #define MPIU_UNREFERENCED_ARG(a) a #else