From 7c921910d079b49107e50bf7dda97c73cb66b19d Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 21 Apr 2011 06:53:45 -0500 Subject: [svn-r20587] Description: Initial commit of John Biddescomb's VFD & MPI tweaks. Tested on: None (yet) (h5committest not required for this branch) --- src/H5AC.c | 2 +- src/H5C.c | 2 +- src/H5Dchunk.c | 2 +- src/H5Dcontig.c | 2 +- src/H5Dint.c | 6 +++--- src/H5Dio.c | 7 ++++--- src/H5F.c | 2 +- src/H5FD.c | 35 ++++------------------------------- src/H5FDcore.c | 1 + src/H5FDfamily.c | 1 + src/H5FDlog.c | 1 + src/H5FDmpi.h | 4 ---- src/H5FDmpio.c | 5 ++++- src/H5FDmpiposix.c | 5 ++++- src/H5FDmulti.c | 1 + src/H5FDpublic.h | 19 +++++++++++++++++-- src/H5FDsec2.c | 1 + src/H5FDstdio.c | 1 + src/H5FDwindows.c | 1 + 19 files changed, 48 insertions(+), 50 deletions(-) diff --git a/src/H5AC.c b/src/H5AC.c index cfb8a17..011e40f 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -485,7 +485,7 @@ H5AC_create(const H5F_t *f, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad cache configuration") #ifdef H5_HAVE_PARALLEL - if(IS_H5FD_MPI(f)) { + if ( H5F_HAS_FEATURE(f,H5FD_FEAT_HAS_MPI) ) { MPI_Comm mpi_comm; int mpi_rank; int mpi_size; diff --git a/src/H5C.c b/src/H5C.c index aed2b90..7a04005 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -8133,7 +8133,7 @@ H5C_flush_single_entry(H5F_t * f, */ if ( ( ! clear_only ) && ( entry_ptr->is_dirty ) && - ( IS_H5FD_MPI(f) ) ) { + ( H5F_HAS_FEATURE(f,H5FD_FEAT_HAS_MPI) ) ) { H5P_genplist_t *dxpl; /* Dataset transfer property list */ H5FD_mpio_xfer_t xfer_mode; /* I/O xfer mode property value */ diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 64efc8a..1f09c97 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -3164,7 +3164,7 @@ H5D_chunk_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, #ifdef H5_HAVE_PARALLEL /* Retrieve MPI parameters */ - if(IS_H5FD_MPI(dset->oloc.file)) { + if(H5F_HAS_FEATURE(dset->oloc.file,H5FD_FEAT_HAS_MPI)) { /* Get the MPI communicator */ if(MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(dset->oloc.file))) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI communicator") diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 9a6e08f..ffa275d 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -225,7 +225,7 @@ H5D_contig_fill(H5D_t *dset, hid_t dxpl_id) #ifdef H5_HAVE_PARALLEL /* Retrieve MPI parameters */ - if(IS_H5FD_MPI(dset->oloc.file)) { + if(H5F_HAS_FEATURE(dset->oloc.file,H5FD_FEAT_HAS_MPI)) { /* Get the MPI communicator */ if(MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(dset->oloc.file))) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI communicator") diff --git a/src/H5Dint.c b/src/H5Dint.c index 8c73888..b0e8827 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1003,7 +1003,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "compact dataset must have early space allocation") /* If MPI VFD is used, no filter support yet. */ - if(IS_H5FD_MPI(file) && pline->nused > 0) + if(H5F_HAS_FEATURE(file,H5FD_FEAT_HAS_MPI) && pline->nused > 0) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "Parallel I/O does not support filters yet") /* Get the dataset's external file list information */ @@ -1023,7 +1023,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, } /* end if */ /* Check if this dataset is going into a parallel file and set space allocation time */ - if(IS_H5FD_MPI(file)) + if(H5F_HAS_FEATURE(file,H5FD_FEAT_ALLOCATE_EARLY)) new_dset->shared->dcpl_cache.fill.alloc_time = H5D_ALLOC_TIME_EARLY; /* Set the dataset's I/O operations */ @@ -1305,7 +1305,7 @@ H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) */ if((H5F_INTENT(dataset->oloc.file) & H5F_ACC_RDWR) && !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage) - && IS_H5FD_MPI(dataset->oloc.file)) { + && H5F_HAS_FEATURE(dataset->oloc.file,H5FD_FEAT_ALLOCATE_EARLY)) { if(H5D_alloc_storage(dataset, dxpl_id, H5D_ALLOC_OPEN, FALSE, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file storage") } /* end if */ diff --git a/src/H5Dio.c b/src/H5Dio.c index b7c2ecb..028f1b0 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -339,7 +339,8 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, #ifdef H5_HAVE_PARALLEL /* Collective access is not permissible without a MPI based VFD */ - if(dxpl_cache->xfer_mode == H5FD_MPIO_COLLECTIVE && !IS_H5FD_MPI(dataset->oloc.file)) + if(dxpl_cache->xfer_mode == H5FD_MPIO_COLLECTIVE && + !(H5F_HAS_FEATURE(dataset->oloc.file,H5FD_FEAT_HAS_MPI))) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "collective access for MPI-based drivers only") #endif /*H5_HAVE_PARALLEL*/ @@ -543,7 +544,7 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* Various MPI based checks */ #ifdef H5_HAVE_PARALLEL - if(IS_H5FD_MPI(dataset->oloc.file)) { + if H5F_HAS_FEATURE(dataset->oloc.file,H5FD_FEAT_HAS_MPI) { /* If MPI based VFD is used, no VL datatype support yet. */ /* This is because they use the global heap in the file and we don't */ /* support parallel access of that yet */ @@ -768,7 +769,7 @@ H5D_ioinfo_init(H5D_t *dset, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, #ifdef H5_HAVE_PARALLEL /* Determine if the file was opened with an MPI VFD */ - io_info->using_mpi_vfd = IS_H5FD_MPI(dset->oloc.file); + io_info->using_mpi_vfd = H5F_HAS_FEATURE(dset->oloc.file,H5FD_FEAT_HAS_MPI); #endif /* H5_HAVE_PARALLEL */ FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5F.c b/src/H5F.c index 5b3c84b..dac276c 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -934,7 +934,7 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) * merged into the trunk and journaling is enabled, at least until * we make it work. - QAK) */ - f->shared->use_tmp_space = !(IS_H5FD_MPI(f)); + f->shared->use_tmp_space = !H5F_HAS_FEATURE(f,H5FD_FEAT_HAS_MPI); /* * Create a metadata cache with the specified number of elements. diff --git a/src/H5FD.c b/src/H5FD.c index d0683e1..000d267 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -43,17 +43,6 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FDpkg.h" /* File Drivers */ -#include "H5FDcore.h" /* Files stored entirely in memory */ -#include "H5FDfamily.h" /* File families */ -#include "H5FDlog.h" /* sec2 driver with I/O logging (for debugging) */ -#include "H5FDmpi.h" /* MPI-based file drivers */ -#include "H5FDmulti.h" /* Usage-partitioned file family */ -#include "H5FDsec2.h" /* POSIX unbuffered file I/O */ -#include "H5FDstdio.h" /* Standard C buffered I/O */ -#ifdef H5_HAVE_WINDOWS -#include "H5FDwindows.h" /* Windows buffered I/O */ -#endif -#include "H5FDdirect.h" /* Direct file I/O */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ @@ -201,26 +190,6 @@ H5FD_term_interface(void) if(H5_interface_initialize_g) { if((n=H5I_nmembers(H5I_VFL))!=0) { H5I_clear_type(H5I_VFL, FALSE, FALSE); - - /* Reset the VFL drivers, if they've been closed */ - if(H5I_nmembers(H5I_VFL)==0) { - H5FD_sec2_term(); -#ifdef H5_HAVE_DIRECT - H5FD_direct_term(); -#endif - H5FD_log_term(); - H5FD_stdio_term(); -#ifdef H5_HAVE_WINDOWS - H5FD_windows_term(); -#endif - H5FD_family_term(); - H5FD_core_term(); - H5FD_multi_term(); -#ifdef H5_HAVE_PARALLEL - H5FD_mpio_term(); - H5FD_mpiposix_term(); -#endif /* H5_HAVE_PARALLEL */ - } /* end if */ } else { H5I_dec_type_ref(H5I_VFL); H5_interface_initialize_g = 0; @@ -254,6 +223,10 @@ H5FD_free_cls(H5FD_class_t *cls) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_free_cls) + // Give the File driver a chance to free singletons or other objects + // which will become invalid once the class structure is freed + if (cls && cls->terminate) cls->terminate(); + H5MM_xfree(cls); FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5FDcore.c b/src/H5FDcore.c index b3cc84d..68a1e93 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -149,6 +149,7 @@ static const H5FD_class_t H5FD_core_g = { NULL, /*get_type_map */ NULL, /*alloc */ NULL, /*free */ + H5FD_core_term, /*terminate */ H5FD_core_get_eoa, /*get_eoa */ H5FD_core_set_eoa, /*set_eoa */ H5FD_core_get_eof, /*get_eof */ diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 5fd0294..89cb53f 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -136,6 +136,7 @@ static const H5FD_class_t H5FD_family_g = { NULL, /*get_type_map */ NULL, /*alloc */ NULL, /*free */ + H5FD_family_term, /*terminate */ H5FD_family_get_eoa, /*get_eoa */ H5FD_family_set_eoa, /*set_eoa */ H5FD_family_get_eof, /*get_eof */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 96df596..a2e8546 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -201,6 +201,7 @@ static const H5FD_class_t H5FD_log_g = { NULL, /*get_type_map */ H5FD_log_alloc, /*alloc */ NULL, /*free */ + H5FD_log_term, /*terminate */ H5FD_log_get_eoa, /*get_eoa */ H5FD_log_set_eoa, /*set_eoa */ H5FD_log_get_eof, /*get_eof */ diff --git a/src/H5FDmpi.h b/src/H5FDmpi.h index b9998dd..2b7ac98 100644 --- a/src/H5FDmpi.h +++ b/src/H5FDmpi.h @@ -73,10 +73,6 @@ typedef struct H5FD_class_mpi_t { /* Macros */ -/* Single macro to check for all file drivers that use MPI */ -#define IS_H5FD_MPI(file) \ - (IS_H5FD_MPIO(file) || IS_H5FD_MPIPOSIX(file)) - #ifdef H5_HAVE_PARALLEL /* ======== Temporary data transfer properties ======== */ /* Definitions for memory MPI type property */ diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index b382fb4..0564d49 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -115,6 +115,7 @@ static const H5FD_class_mpi_t H5FD_mpio_g = { NULL, /*get_type_map */ NULL, /*alloc */ NULL, /*free */ + H5FD_mpio_term, /*terminate */ H5FD_mpio_get_eoa, /*get_eoa */ H5FD_mpio_set_eoa, /*set_eoa */ H5FD_mpio_get_eof, /*get_eof */ @@ -1163,8 +1164,10 @@ H5FD_mpio_query(const H5FD_t UNUSED *_file, unsigned long *flags /* out */) /* Set the VFL feature flags that this driver supports */ if(flags) { *flags=0; - *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags|=H5FD_FEAT_HAS_MPI; /* This driver uses MPI */ + *flags|=H5FD_FEAT_ALLOCATE_EARLY; /* Allocate space early instead of late */ } /* end if */ done: diff --git a/src/H5FDmpiposix.c b/src/H5FDmpiposix.c index 7ca38cc..6328ef7 100644 --- a/src/H5FDmpiposix.c +++ b/src/H5FDmpiposix.c @@ -224,6 +224,7 @@ static const H5FD_class_mpi_t H5FD_mpiposix_g = { NULL, /*get_type_map */ NULL, /*alloc */ NULL, /*free */ + H5FD_mpiposix_term, /*terminate */ H5FD_mpiposix_get_eoa, /*get_eoa */ H5FD_mpiposix_set_eoa, /*set_eoa */ H5FD_mpiposix_get_eof, /*get_eof */ @@ -931,8 +932,10 @@ H5FD_mpiposix_query(const H5FD_t UNUSED *_file, unsigned long *flags /* out */) /* Set the VFL feature flags that this driver supports */ if(flags) { *flags=0; - *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags|=H5FD_FEAT_HAS_MPI; /* This driver uses MPI */ + *flags|=H5FD_FEAT_ALLOCATE_EARLY; /* Allocate space early instead of late */ } /* end if */ done: diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 328b530..354f05c 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -167,6 +167,7 @@ static const H5FD_class_t H5FD_multi_g = { H5FD_multi_get_type_map, /*get_type_map */ H5FD_multi_alloc, /*alloc */ H5FD_multi_free, /*free */ + H5FD_multi_term, /*terminate */ H5FD_multi_get_eoa, /*get_eoa */ H5FD_multi_set_eoa, /*set_eoa */ H5FD_multi_get_eof, /*get_eof */ diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index c8ec658..2a22958 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -25,6 +25,7 @@ #define H5_HAVE_VFL 1 /*define a convenient app feature test*/ #define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */ +#define H5_HAVE_VFD_EXTENSIONS 1 /*Extensions to VFD to allow external VFD linking */ /* Types of allocation requests: see H5Fpublic.h */ typedef enum H5F_mem_t H5FD_mem_t; @@ -209,8 +210,19 @@ typedef enum H5F_mem_t H5FD_mem_t; * the handle for the VFD (returned with the 'get_handle' callback) is * of type 'int' and is compatible with POSIX I/O calls. */ -#define H5FD_FEAT_POSIX_COMPAT_HANDLE 0x00000080 - +#define H5FD_FEAT_POSIX_COMPAT_HANDLE 0x00000080 + /* + * Defining the H5FD_FEAT_HAS_MPI for a VFL driver means that + * the driver makes use of MPI communication and code may retrieve + * communicator/rank information from it + */ +#define H5FD_FEAT_HAS_MPI 0x00000100 + /* + * Defining the H5FD_FEAT_ALLOCATE_EARLY for a VFL driver means that + * the library will use the H5D_ALLOC_TIME_EARLY on dataset create + * instead of the default H5D_ALLOC_TIME_LATE + */ +#define H5FD_FEAT_ALLOCATE_EARLY 0x00000200 /* Forward declaration */ typedef struct H5FD_t H5FD_t; @@ -240,6 +252,9 @@ typedef struct H5FD_class_t { haddr_t (*alloc)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); herr_t (*free)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); +#ifdef H5_HAVE_VFD_EXTENSIONS + void (*terminate)(); +#endif haddr_t (*get_eoa)(const H5FD_t *file, H5FD_mem_t type); herr_t (*set_eoa)(H5FD_t *file, H5FD_mem_t type, haddr_t addr); haddr_t (*get_eof)(const H5FD_t *file); diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 1153df7..c37e052 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -163,6 +163,7 @@ static const H5FD_class_t H5FD_sec2_g = { NULL, /*get_type_map */ NULL, /*alloc */ NULL, /*free */ + H5FD_sec2_term, /*terminate */ H5FD_sec2_get_eoa, /*get_eoa */ H5FD_sec2_set_eoa, /*set_eoa */ H5FD_sec2_get_eof, /*get_eof */ diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 9bc4161..a11dfa8 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -208,6 +208,7 @@ static const H5FD_class_t H5FD_stdio_g = { NULL, /*get_type_map */ H5FD_stdio_alloc, /*alloc */ NULL, /*free */ + H5FD_stdio_term, /*terminate */ H5FD_stdio_get_eoa, /*get_eoa */ H5FD_stdio_set_eoa, /*set_eoa */ H5FD_stdio_get_eof, /*get_eof */ diff --git a/src/H5FDwindows.c b/src/H5FDwindows.c index 47c7f2d..864a958 100644 --- a/src/H5FDwindows.c +++ b/src/H5FDwindows.c @@ -166,6 +166,7 @@ static const H5FD_class_t H5FD_windows_g = { NULL, /*get_type_map */ NULL, /*alloc */ NULL, /*free */ + H5FD_windows_term, /*terminate */ H5FD_windows_get_eoa, /*get_eoa */ H5FD_windows_set_eoa, /*set_eoa */ H5FD_windows_get_eof, /*get_eof */ -- cgit v0.12