diff options
-rw-r--r-- | MANIFEST | 1 | ||||
-rwxr-xr-x | configure | 49 | ||||
-rw-r--r-- | configure.in | 37 | ||||
-rw-r--r-- | src/H5Dio.c | 41 | ||||
-rw-r--r-- | src/H5Dmpio.c | 270 | ||||
-rw-r--r-- | src/H5Dpkg.h | 2 | ||||
-rw-r--r-- | src/H5Dprivate.h | 36 | ||||
-rw-r--r-- | src/H5Fprivate.h | 2 | ||||
-rw-r--r-- | src/H5S.c | 8 | ||||
-rw-r--r-- | src/H5Smpio.c | 449 | ||||
-rw-r--r-- | src/H5Spkg.h | 16 | ||||
-rw-r--r-- | src/H5Sprivate.h | 8 | ||||
-rw-r--r-- | src/H5config.h.in | 4 | ||||
-rw-r--r-- | src/Makefile.in | 2 | ||||
-rw-r--r-- | testpar/t_coll_chunk.c | 137 | ||||
-rw-r--r-- | testpar/testphdf5.c | 2 | ||||
-rw-r--r-- | testpar/testphdf5.h | 22 |
17 files changed, 597 insertions, 489 deletions
@@ -777,6 +777,7 @@ ./src/H5Dcompact.c ./src/H5Dio.c ./src/H5Distore.c +./src/H5Dmpio.c ./src/H5Dprivate.h ./src/H5Dpublic.h ./src/H5Dpkg.h @@ -1033,6 +1033,8 @@ Optional Features: debug is disabled. --enable-trace Enable API tracing capability. Default=no if debug is disabled. + --enable-instrument Enable library instrumentation of optimization + tracing. Default=no if debug is disabled. --enable-parallel Search for MPI-IO and MPI support files --enable-fphdf5 Enable the Flexible Parallel HDF5 interface [default=no] @@ -4016,7 +4018,7 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes case $host in *-*-irix6*) # Find out which ABI we are using. - echo '#line 4019 "configure"' > conftest.$ac_ext + echo '#line 4021 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -4557,7 +4559,7 @@ chmod -w . save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" compiler_c_o=no -if { (eval echo configure:4560: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then +if { (eval echo configure:4562: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings if test -s out/conftest.err; then @@ -6364,7 +6366,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 6367 "configure" +#line 6369 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -6462,7 +6464,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 6465 "configure" +#line 6467 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -31611,6 +31613,41 @@ echo "${ECHO_T}no" >&6 ;; esac + +echo "$as_me:$LINENO: checking for instrumented library" >&5 +echo $ECHO_N "checking for instrumented library... $ECHO_C" >&6; +# Check whether --enable-instrument or --disable-instrument was given. +if test "${enable_instrument+set}" = set; then + enableval="$enable_instrument" + INSTRUMENT=$enableval +fi; + +if test "X-$INSTRUMENT" = X- ; then + if test -z "$DEBUG_PKG" ; then + INSTRUMENT=no + else + INSTRUMENT=yes + fi +fi + +case "X-$INSTRUMENT" in + X-yes) + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + INSTRUMENT_LIBRARY=yes + +cat >>confdefs.h <<\_ACEOF +#define HAVE_INSTRUMENTED_LIBRARY 1 +_ACEOF + + ;; + X-no|*) + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + INSTRUMENT_LIBRARY=no + ;; +esac + cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -34470,6 +34507,7 @@ s,@PDB2HDF@,$PDB2HDF,;t t s,@PTHREAD@,$PTHREAD,;t t s,@DEBUG_PKG@,$DEBUG_PKG,;t t s,@TRACE_API@,$TRACE_API,;t t +s,@INSTRUMENT_LIBRARY@,$INSTRUMENT_LIBRARY,;t t s,@PARALLEL@,$PARALLEL,;t t s,@RUNSERIAL@,$RUNSERIAL,;t t s,@RUNPARALLEL@,$RUNPARALLEL,;t t @@ -35136,6 +35174,9 @@ IF_YES_NO "$STATIC_EXEC" PRINT_N " Tracing" IF_YES_NO "$TRACE_API" +PRINT_N " Optimization Instrumentation" +IF_YES_NO "$INSTRUMENT" + PRINT "Languages:" PRINT_N " C++" diff --git a/configure.in b/configure.in index 2fb57d7..d916de2 100644 --- a/configure.in +++ b/configure.in @@ -1901,6 +1901,40 @@ case "X-$TRACE" in ;; esac +dnl ---------------------------------------------------------------------- +dnl Enable instrumenting of the library's internal operations +dnl This must come after the enable-debug since it depends on debug. +dnl +AC_SUBST([INSTRUMENT_LIBRARY]) +AC_MSG_CHECKING([for instrumented library]); +AC_ARG_ENABLE([instrument], + [AC_HELP_STRING([--enable-instrument], + [Enable library instrumentation of optimization + tracing. Default=no if debug is disabled.])], + INSTRUMENT=$enableval) + +dnl Default to no if debug is disabled +if test "X-$INSTRUMENT" = X- ; then + if test -z "$DEBUG_PKG" ; then + INSTRUMENT=no + else + INSTRUMENT=yes + fi +fi + +case "X-$INSTRUMENT" in + X-yes) + AC_MSG_RESULT([yes]) + INSTRUMENT_LIBRARY=yes + AC_DEFINE([HAVE_INSTRUMENTED_LIBRARY], [1], + [Define if library will contain instrumentation to detect correct optimization operation]) + ;; + X-no|*) + AC_MSG_RESULT([no]) + INSTRUMENT_LIBRARY=no + ;; +esac + dnl Checkpoint the cache AC_CACHE_SAVE @@ -2990,6 +3024,9 @@ IF_YES_NO "$STATIC_EXEC" PRINT_N " Tracing" IF_YES_NO "$TRACE_API" +PRINT_N " Optimization Instrumentation" +IF_YES_NO "$INSTRUMENT" + PRINT "Languages:" PRINT_N " C++" diff --git a/src/H5Dio.c b/src/H5Dio.c index 9a1403f..5c84efe 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -751,26 +751,29 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert from file to memory data space") #ifdef H5_HAVE_PARALLEL +#ifdef H5_HAVE_INSTRUMENTED_LIBRARY /**** Test for collective chunk IO notice the following code should be removed after a more general collective chunk IO algorithm is applied. */ - if(dataset->layout.type == H5D_CHUNKED) { /*only check for chunking storage */ - check_prop = H5Pexist(dxpl_id,"__test__ccfoo___"); - if(check_prop < 0) - HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to check property list"); - if(check_prop > 0) { - if(H5Pget(dxpl_id,"__test__ccfoo___",&prop_value)<0) - HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to get property value"); - if(!use_par_opt_io) { - new_value = 0; - if(H5Pset(dxpl_id,"__test__ccfoo___",&new_value)<0) - HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to set property value"); - } - } - } - /* end Test for collective chunk IO */ + if(dataset->layout.type == H5D_CHUNKED) { /*only check for chunking storage */ + check_prop = H5Pexist(dxpl_id,H5D_XFER_COLL_CHUNK_NAME); + if(check_prop < 0) + HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to check property list"); + if(check_prop > 0) { + if(H5Pget(dxpl_id,H5D_XFER_COLL_CHUNK_NAME,&prop_value)<0) + HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to get property value"); + if(!use_par_opt_io) { + new_value = 0; + if(H5Pset(dxpl_id,H5D_XFER_COLL_CHUNK_NAME,&new_value)<0) + HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to set property value"); + } + } + } + /* end Test for collective chunk IO */ +#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ + /* Don't reset the transfer mode if we can't or won't use it */ if(!use_par_opt_io || !H5T_path_noop(tpath)) H5D_io_assist_mpio(dxpl_id, dxpl_cache, &xfer_mode_changed); @@ -989,6 +992,7 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert from memory to file data space") #ifdef H5_HAVE_PARALLEL +#ifdef H5_HAVE_INSTRUMENTED_LIBRARY /**** Test for collective chunk IO notice the following code should be removed after a more general collective chunk IO algorithm is applied. @@ -996,19 +1000,20 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, if(dataset->layout.type == H5D_CHUNKED) { /*only check for chunking storage */ - check_prop = H5Pexist(dxpl_id,"__test__ccfoo___"); + check_prop = H5Pexist(dxpl_id,H5D_XFER_COLL_CHUNK_NAME); if(check_prop < 0) HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to check property list"); if(check_prop > 0) { - if(H5Pget(dxpl_id,"__test__ccfoo___",&prop_value)<0) + if(H5Pget(dxpl_id,H5D_XFER_COLL_CHUNK_NAME,&prop_value)<0) HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to get property value"); if(!use_par_opt_io) { new_value = 0; - if(H5Pset(dxpl_id,"__test__ccfoo___",&new_value)<0) + if(H5Pset(dxpl_id,H5D_XFER_COLL_CHUNK_NAME,&new_value)<0) HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to set property value"); } } } +#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ /* end Test for collective chunk IO */ /* Don't reset the transfer mode if we can't or won't use it */ diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c new file mode 100644 index 0000000..517838d --- /dev/null +++ b/src/H5Dmpio.c @@ -0,0 +1,270 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: rky 980813 + * + * Purpose: Functions to read/write directly between app buffer and file. + * + * Beware of the ifdef'ed print statements. + * I didn't make them portable. + */ + +#define H5D_PACKAGE /*suppress error about including H5Dpkg */ + + +/* Pablo information */ +/* (Put before include files to avoid problems with inline functions) */ +#define PABLO_MASK H5D_mpio_mask + +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ + +#ifdef H5_HAVE_PARALLEL + +static herr_t +H5D_mpio_spaces_xfer(H5F_t *f, const H5D_t *dset, size_t elmt_size, + const H5S_t *file_space, const H5S_t *mem_space, + hid_t dxpl_id, void *buf/*out*/, + const H5D_storage_t *store, + hbool_t do_write); + + +/*------------------------------------------------------------------------- + * Function: H5D_mpio_spaces_xfer + * + * Purpose: Use MPI-IO to transfer data efficiently + * directly between app buffer and file. + * + * Return: non-negative on success, negative on failure. + * + * Programmer: rky 980813 + * + * Notes: + * For collective data transfer only since this would eventually call + * H5FD_mpio_setup to do setup to eveually call MPI_File_set_view in + * H5FD_mpio_read or H5FD_mpio_write. MPI_File_set_view is a collective + * call. Letting independent data transfer use this route would result in + * hanging. + * + * The preconditions for calling this routine are located in the + * H5S_mpio_opt_possible() routine, which determines whether this routine + * can be called for a given dataset transfer. + * + * Modifications: + * rky 980918 + * Added must_convert parameter to let caller know we can't optimize + * the xfer. + * + * Albert Cheng, 001123 + * Include the MPI_type freeing as part of cleanup code. + * + * QAK - 2002/04/02 + * Removed the must_convert parameter and move preconditions to + * H5S_mpio_opt_possible() routine + * + * QAK - 2002/06/17 + * Removed 'disp' parameter from H5FD_mpio_setup routine and use the + * address of the dataset in MPI_File_set_view() calls, as necessary. + * + * QAK - 2002/06/18 + * Removed 'dc_plist' parameter, since it was not used. Also, switch to + * getting the 'extra_offset' setting for each selection. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_mpio_spaces_xfer(H5F_t *f, const H5D_t *dset, size_t elmt_size, + const H5S_t *file_space, const H5S_t *mem_space, + hid_t dxpl_id, void *_buf /*out*/, + const H5D_storage_t *store, + hbool_t do_write ) +{ + haddr_t addr; /* Address of dataset (or selection) within file */ + size_t mpi_buf_count, mpi_file_count; /* Number of "objects" to transfer */ + hsize_t mpi_buf_offset, mpi_file_offset; /* Offset within dataset where selection (ie. MPI type) begins */ + MPI_Datatype mpi_buf_type, mpi_file_type; /* MPI types for buffer (memory) and file */ + hbool_t mbt_is_derived=0, /* Whether the buffer (memory) type is derived and needs to be free'd */ + mft_is_derived=0; /* Whether the file type is derived and needs to be free'd */ + hbool_t plist_is_setup=0; /* Whether the dxpl has been customized */ + uint8_t *buf=(uint8_t *)_buf; /* Alias for pointer arithmetic */ + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5D_mpio_spaces_xfer); + + /* Check args */ + assert (f); + assert (dset); + assert (file_space); + assert (mem_space); + assert (buf); + assert (IS_H5FD_MPIO(f)); + /* Make certain we have the correct type of property list */ + assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); + + /* create the MPI buffer type */ + if (H5S_mpio_space_type( mem_space, elmt_size, + /* out: */ + &mpi_buf_type, + &mpi_buf_count, + &mpi_buf_offset, + &mbt_is_derived )<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't create MPI buf type"); + + /* create the MPI file type */ + if ( H5S_mpio_space_type( file_space, elmt_size, + /* out: */ + &mpi_file_type, + &mpi_file_count, + &mpi_file_offset, + &mft_is_derived )<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't create MPI file type"); + + + if(dset->layout.type == H5D_CONTIGUOUS) + addr = H5D_contig_get_addr(dset) + mpi_file_offset; + else { + haddr_t chunk_addr; /* for collective chunk IO */ + + assert(dset->layout.type == H5D_CHUNKED); + chunk_addr=H5D_istore_get_addr(f,dxpl_id,&(dset->layout),store->chunk.offset,NULL); + addr = H5F_BASE_ADDR(f) + chunk_addr + mpi_file_offset; + } + + /* + * Pass buf type, file type to the file driver. Request an MPI type + * transfer (instead of an elementary byteblock transfer). + */ + if(H5FD_mpi_setup_collective(dxpl_id, mpi_buf_type, mpi_file_type)<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI-I/O properties"); + plist_is_setup=1; + + /* Adjust the buffer pointer to the beginning of the selection */ + buf+=mpi_buf_offset; + + /* transfer the data */ + if (do_write) { + if (H5F_block_write(f, H5FD_MEM_DRAW, addr, mpi_buf_count, dxpl_id, buf) <0) + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,"MPI write failed"); + } else { + if (H5F_block_read (f, H5FD_MEM_DRAW, addr, mpi_buf_count, dxpl_id, buf) <0) + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL,"MPI read failed"); + } + +done: + /* Reset the dxpl settings */ + if(plist_is_setup) { + if(H5FD_mpi_teardown_collective(dxpl_id)<0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to reset dxpl values"); + } /* end if */ + + /* free the MPI buf and file types */ + if (mbt_is_derived) { + if (MPI_SUCCESS != (mpi_code= MPI_Type_free( &mpi_buf_type ))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code); + } + if (mft_is_derived) { + if (MPI_SUCCESS != (mpi_code= MPI_Type_free( &mpi_file_type ))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code); + } + + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5D_mpio_spaces_xfer() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_mpio_spaces_read + * + * Purpose: MPI-IO function to read directly from app buffer to file. + * + * Return: non-negative on success, negative on failure. + * + * Programmer: rky 980813 + * + * Modifications: + * + * rky 980918 + * Added must_convert parameter to let caller know we can't optimize the xfer. + * + * QAK - 2002/04/02 + * Removed the must_convert parameter and move preconditions to + * H5S_mpio_opt_possible() routine + * + *------------------------------------------------------------------------- + */ +herr_t +H5D_mpio_spaces_read(H5F_t *f, const H5D_dxpl_cache_t UNUSED *dxpl_cache, hid_t dxpl_id, + H5D_t *dset, const H5D_storage_t *store, + size_t UNUSED nelmts, size_t elmt_size, + const H5S_t *file_space, const H5S_t *mem_space, + void *buf/*out*/) +{ + herr_t ret_value; + + FUNC_ENTER_NOAPI_NOFUNC(H5D_mpio_spaces_read); + + ret_value = H5D_mpio_spaces_xfer(f, dset, elmt_size, file_space, + mem_space, dxpl_id, buf,store, 0/*read*/); + + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5D_mpio_spaces_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_mpio_spaces_write + * + * Purpose: MPI-IO function to write directly from app buffer to file. + * + * Return: non-negative on success, negative on failure. + * + * Programmer: rky 980813 + * + * Modifications: + * + * rky 980918 + * Added must_convert parameter to let caller know we can't optimize the xfer. + * + * QAK - 2002/04/02 + * Removed the must_convert parameter and move preconditions to + * H5S_mpio_opt_possible() routine + * + *------------------------------------------------------------------------- + */ +herr_t +H5D_mpio_spaces_write(H5F_t *f, const H5D_dxpl_cache_t UNUSED *dxpl_cache, hid_t dxpl_id, + H5D_t *dset, const H5D_storage_t *store, + size_t UNUSED nelmts, size_t elmt_size, + const H5S_t *file_space, const H5S_t *mem_space, + const void *buf) +{ + herr_t ret_value; + + FUNC_ENTER_NOAPI_NOFUNC(H5D_mpio_spaces_write); + + /*OKAY: CAST DISCARDS CONST QUALIFIER*/ + ret_value = H5D_mpio_spaces_xfer(f, dset, elmt_size, file_space, + mem_space, dxpl_id, (void*)buf, store,1/*write*/); + + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5D_mpio_spaces_write() */ + +#endif /* H5_HAVE_PARALLEL */ + diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index e1d4b71..30183c3 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -33,7 +33,7 @@ /* Other private headers needed by this file */ #include "H5Gprivate.h" /* Groups */ #include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspace functions */ +#include "H5Sprivate.h" /* Dataspaces */ #include "H5Tprivate.h" /* Datatype functions */ /**************************/ diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 6ca207e..409cb3f 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -153,6 +153,12 @@ #define H5D_XFER_CONV_CB_NAME "type_conv_cb" #define H5D_XFER_CONV_CB_SIZE sizeof(H5T_conv_cb_t) #define H5D_XFER_CONV_CB_DEF {NULL,NULL} +#ifdef H5_HAVE_INSTRUMENTED_LIBRARY +/* Definitions for collective chunk I/O property */ +#define H5D_XFER_COLL_CHUNK_NAME "coll_chunk" +#define H5D_XFER_COLL_CHUNK_SIZE sizeof(unsigned) +#define H5D_XFER_COLL_CHUNK_DEF 1 +#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ /****************************/ /* Library Private Typedefs */ @@ -193,8 +199,6 @@ typedef struct H5D_dcpl_cache_t { H5D_fill_time_t fill_time; /* Fill time (H5D_CRT_FILL_TIME_NAME) */ } H5D_dcpl_cache_t; -/* forward reference for collective-chunk IO use */ -struct H5D_istore_ud1_t; /*define at H5Distore.c*/ /* Library-private functions defined in H5D package */ H5_DLL herr_t H5D_init(void); H5_DLL hid_t H5D_open(H5G_entry_t *ent, hid_t dxpl_id); @@ -249,6 +253,9 @@ H5_DLL ssize_t H5D_compact_writevv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[], const void *buf); +/* forward reference for collective-chunk IO use */ +struct H5D_istore_ud1_t; /*define at H5Distore.c*/ + /* Functions that operate on indexed storage */ H5_DLL herr_t H5D_istore_delete(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout); @@ -262,12 +269,29 @@ H5_DLL ssize_t H5D_istore_writevv(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], const void *buf); +H5_DLL haddr_t H5D_istore_get_addr(H5F_t *f, hid_t dxpl_id, + const H5O_layout_t *layout, const hssize_t offset[], + struct H5D_istore_ud1_t *_udata); H5_DLL herr_t H5D_istore_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth, int ndims); -/* Functions that obtain the dataset address */ -H5_DLL haddr_t H5D_istore_get_addr(H5F_t *f, hid_t dxpl_id, - const H5O_layout_t *layout,const hssize_t offset[], - struct H5D_istore_ud1_t *_udata); +#ifdef H5_HAVE_PARALLEL +/* Forward references */ +struct H5S_t; + +/* MPI-IO function to read directly from app buffer to file rky980813 */ +H5_DLL herr_t H5D_mpio_spaces_read(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, + H5D_t *dset, const H5D_storage_t *store, + size_t nelmts, size_t elmt_size, + const struct H5S_t *file_space, const struct H5S_t *mem_space, + void *buf/*out*/); + +/* MPI-IO function to write directly from app buffer to file rky980813 */ +H5_DLL herr_t H5D_mpio_spaces_write(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, + H5D_t *dset, const H5D_storage_t *store, + size_t nelmts, size_t elmt_size, + const struct H5S_t *file_space, const struct H5S_t *mem_space, + const void *buf); +#endif /* H5_HAVE_PARALLEL */ #endif diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index d516dc5..7b3c9e1 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -224,7 +224,7 @@ typedef struct H5F_t H5F_t; #define H5F_RDCC_W0(F) (H5F_rdcc_w0(F)) #define H5F_HAS_FEATURE(F,FL) (H5F_has_feature(F,FL)) #define H5F_GRP_BTREE_SHARED(F) (H5F_grp_btree_shared(F)) -#define H5F_BASE_ADDR(F) (H5F_base_addr(F)) +#define H5F_BASE_ADDR(F) (H5F_get_base_addr(F)) #endif /* H5F_PACKAGE */ @@ -1479,8 +1479,8 @@ const H5O_layout_t *layout /* Check if we can use the optimized parallel I/O routines */ if(opt==TRUE) { /* Set the pointers to the MPI-specific routines */ - H5S_conv_g[i]->read = H5S_mpio_spaces_read; - H5S_conv_g[i]->write = H5S_mpio_spaces_write; + H5S_conv_g[i]->read = H5D_mpio_spaces_read; + H5S_conv_g[i]->write = H5D_mpio_spaces_write; /* Indicate that the I/O will be parallel */ *use_par_opt_io=TRUE; @@ -1521,8 +1521,8 @@ const H5O_layout_t *layout /* Check if we can use the optimized parallel I/O routines */ if(opt==TRUE) { /* Set the pointers to the MPI-specific routines */ - path->read = H5S_mpio_spaces_read; - path->write = H5S_mpio_spaces_write; + path->read = H5D_mpio_spaces_read; + path->write = H5D_mpio_spaces_write; /* Indicate that the I/O will be parallel */ *use_par_opt_io=TRUE; diff --git a/src/H5Smpio.c b/src/H5Smpio.c index 5701b9c..6c7ddd1 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -21,26 +21,22 @@ * I didn't make them portable. */ -#define H5F_PACKAGE /*suppress error about including H5Fpkg */ #define H5S_PACKAGE /*suppress error about including H5Spkg */ -#define H5D_PACKAGE /* Pablo information */ /* (Put before include files to avoid problems with inline functions) */ #define PABLO_MASK H5S_mpio_mask #include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5Dpkg.h" +#include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ #include "H5Spkg.h" /* Dataspaces */ -#include "H5Oprivate.h" -#include "H5Dprivate.h" - #ifdef H5_HAVE_PARALLEL static herr_t @@ -64,19 +60,6 @@ H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, size_t *count, hsize_t *extra_offset, hbool_t *is_derived_type ); -static herr_t -H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, - /* out: */ - MPI_Datatype *new_type, - size_t *count, - hsize_t *extra_offset, - hbool_t *is_derived_type ); -static herr_t -H5S_mpio_spaces_xfer(H5F_t *f, const H5D_t *dset, size_t elmt_size, - const H5S_t *file_space, const H5S_t *mem_space, - hid_t dxpl_id, void *buf/*out*/, - const H5D_storage_t *store, - hbool_t do_write); /*------------------------------------------------------------------------- @@ -525,7 +508,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, @@ -590,233 +573,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5S_mpio_spaces_xfer - * - * Purpose: Use MPI-IO to transfer data efficiently - * directly between app buffer and file. - * - * Return: non-negative on success, negative on failure. - * - * Programmer: rky 980813 - * - * Notes: - * For collective data transfer only since this would eventually call - * H5FD_mpio_setup to do setup to eveually call MPI_File_set_view in - * H5FD_mpio_read or H5FD_mpio_write. MPI_File_set_view is a collective - * call. Letting independent data transfer use this route would result in - * hanging. - * - * The preconditions for calling this routine are located in the - * H5S_mpio_opt_possible() routine, which determines whether this routine - * can be called for a given dataset transfer. - * - * Modifications: - * rky 980918 - * Added must_convert parameter to let caller know we can't optimize - * the xfer. - * - * Albert Cheng, 001123 - * Include the MPI_type freeing as part of cleanup code. - * - * QAK - 2002/04/02 - * Removed the must_convert parameter and move preconditions to - * H5S_mpio_opt_possible() routine - * - * QAK - 2002/06/17 - * Removed 'disp' parameter from H5FD_mpio_setup routine and use the - * address of the dataset in MPI_File_set_view() calls, as necessary. - * - * QAK - 2002/06/18 - * Removed 'dc_plist' parameter, since it was not used. Also, switch to - * getting the 'extra_offset' setting for each selection. - * - *------------------------------------------------------------------------- - */ -static herr_t -H5S_mpio_spaces_xfer(H5F_t *f, const H5D_t *dset, size_t elmt_size, - const H5S_t *file_space, const H5S_t *mem_space, - hid_t dxpl_id, void *_buf /*out*/, - const H5D_storage_t *store, - hbool_t do_write ) -{ - haddr_t addr; /* Address of dataset (or selection) within file */ - size_t mpi_buf_count, mpi_file_count; /* Number of "objects" to transfer */ - hsize_t mpi_buf_offset, mpi_file_offset; /* Offset within dataset where selection (ie. MPI type) begins */ - MPI_Datatype mpi_buf_type, mpi_file_type; /* MPI types for buffer (memory) and file */ - hbool_t mbt_is_derived=0, /* Whether the buffer (memory) type is derived and needs to be free'd */ - mft_is_derived=0; /* Whether the file type is derived and needs to be free'd */ - hbool_t plist_is_setup=0; /* Whether the dxpl has been customized */ - uint8_t *buf=(uint8_t *)_buf; /* Alias for pointer arithmetic */ - int mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; /* Return value */ - - haddr_t chunk_addr; /* for collective chunk IO */ - - - FUNC_ENTER_NOAPI_NOINIT(H5S_mpio_spaces_xfer); - - /* Check args */ - assert (f); - assert (dset); - assert (file_space); - assert (mem_space); - assert (buf); - assert (IS_H5FD_MPIO(f)); - /* Make certain we have the correct type of property list */ - assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); - - /* create the MPI buffer type */ - if (H5S_mpio_space_type( mem_space, elmt_size, - /* out: */ - &mpi_buf_type, - &mpi_buf_count, - &mpi_buf_offset, - &mbt_is_derived )<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't create MPI buf type"); - - /* create the MPI file type */ - if ( H5S_mpio_space_type( file_space, elmt_size, - /* out: */ - &mpi_file_type, - &mpi_file_count, - &mpi_file_offset, - &mft_is_derived )<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't create MPI file type"); - - -/* Adding comments for chunk collective IO */ - if(dset->layout.type == H5D_CONTIGUOUS) { - addr = H5D_contig_get_addr(dset) + mpi_file_offset; - } - else { - assert(dset->layout.type == H5D_CHUNKED); - chunk_addr=H5D_istore_get_addr(f,dxpl_id,&(dset->layout),store->chunk.offset,NULL); - addr = f->shared->base_addr + chunk_addr + mpi_file_offset; - } - -#ifdef H5Smpi_DEBUG - HDfprintf(stderr, "spaces_xfer: relative addr=%a\n", addr ); -#endif - - /* - * Pass buf type, file type to the file driver. Request an MPI type - * transfer (instead of an elementary byteblock transfer). - */ - if(H5FD_mpi_setup_collective(dxpl_id, mpi_buf_type, mpi_file_type)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI-I/O properties"); - plist_is_setup=1; - - /* Adjust the buffer pointer to the beginning of the selection */ - buf+=mpi_buf_offset; - - /* transfer the data */ - if (do_write) { - if (H5F_block_write(f, H5FD_MEM_DRAW, addr, mpi_buf_count, dxpl_id, buf) <0) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,"MPI write failed"); - } else { - if (H5F_block_read (f, H5FD_MEM_DRAW, addr, mpi_buf_count, dxpl_id, buf) <0) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL,"MPI read failed"); - } - -done: - /* Reset the dxpl settings */ - if(plist_is_setup) { - if(H5FD_mpi_teardown_collective(dxpl_id)<0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to reset dxpl values"); - } /* end if */ - - /* free the MPI buf and file types */ - if (mbt_is_derived) { - if (MPI_SUCCESS != (mpi_code= MPI_Type_free( &mpi_buf_type ))) - HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code); - } - if (mft_is_derived) { - if (MPI_SUCCESS != (mpi_code= MPI_Type_free( &mpi_file_type ))) - HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code); - } - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5S_mpio_spaces_xfer() */ - - -/*------------------------------------------------------------------------- - * Function: H5S_mpio_spaces_read - * - * Purpose: MPI-IO function to read directly from app buffer to file. - * - * Return: non-negative on success, negative on failure. - * - * Programmer: rky 980813 - * - * Modifications: - * - * rky 980918 - * Added must_convert parameter to let caller know we can't optimize the xfer. - * - * QAK - 2002/04/02 - * Removed the must_convert parameter and move preconditions to - * H5S_mpio_opt_possible() routine - * - *------------------------------------------------------------------------- - */ -herr_t -H5S_mpio_spaces_read(H5F_t *f, const H5D_dxpl_cache_t UNUSED *dxpl_cache, hid_t dxpl_id, - H5D_t *dset, const H5D_storage_t *store, - size_t UNUSED nelmts, size_t elmt_size, - const H5S_t *file_space, const H5S_t *mem_space, - void *buf/*out*/) -{ - herr_t ret_value; - - FUNC_ENTER_NOAPI_NOFUNC(H5S_mpio_spaces_read); - - ret_value = H5S_mpio_spaces_xfer(f, dset, elmt_size, file_space, - mem_space, dxpl_id, buf,store, 0/*read*/); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5S_mpio_spaces_read() */ - - -/*------------------------------------------------------------------------- - * Function: H5S_mpio_spaces_write - * - * Purpose: MPI-IO function to write directly from app buffer to file. - * - * Return: non-negative on success, negative on failure. - * - * Programmer: rky 980813 - * - * Modifications: - * - * rky 980918 - * Added must_convert parameter to let caller know we can't optimize the xfer. - * - * QAK - 2002/04/02 - * Removed the must_convert parameter and move preconditions to - * H5S_mpio_opt_possible() routine - * - *------------------------------------------------------------------------- - */ -herr_t -H5S_mpio_spaces_write(H5F_t *f, const H5D_dxpl_cache_t UNUSED *dxpl_cache, hid_t dxpl_id, - H5D_t *dset, const H5D_storage_t *store, - size_t UNUSED nelmts, size_t elmt_size, - const H5S_t *file_space, const H5S_t *mem_space, - const void *buf) -{ - herr_t ret_value; - - FUNC_ENTER_NOAPI_NOFUNC(H5S_mpio_spaces_write); - - /*OKAY: CAST DISCARDS CONST QUALIFIER*/ - ret_value = H5S_mpio_spaces_xfer(f, dset, elmt_size, file_space, - mem_space, dxpl_id, (void*)buf, store,1/*write*/); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5S_mpio_spaces_write() */ - - -/*------------------------------------------------------------------------- * Function: H5S_mpio_opt_possible * * Purpose: Checks if an direct I/O transfer is possible between memory and @@ -837,17 +593,6 @@ H5S_mpio_opt_possible( const H5F_t *file, const H5S_t *mem_space, const H5S_t *f { htri_t c1,c2; /* Flags whether a selection is optimizable */ htri_t ret_value=TRUE; - hsize_t chunk_dim[H5S_MAX_RANK+1]; - hssize_t startf[H5S_MAX_RANK],endf[H5S_MAX_RANK],startm[H5S_MAX_RANK],endm[H5S_MAX_RANK]; - int fnum_chunk[H5S_MAX_RANK],mnum_chunk[H5S_MAX_RANK]; - int rank,i,dim_rankm,dim_rankf; - int pcheck_hyper,check_hyper,check_num_chunkm,check_num_chunkf; - int tnum_chunkf,manum_chunkf,minum_chunkf; - int tnum_chunkm,manum_chunkm,minum_chunkm; - H5S_sel_type fsel_type,msel_type; - MPI_Comm comm; - - FUNC_ENTER_NOAPI(H5S_mpio_opt_possible, FAIL); @@ -856,33 +601,14 @@ H5S_mpio_opt_possible( const H5F_t *file, const H5S_t *mem_space, const H5S_t *f assert(file_space); /* Parallel I/O conversion flag must be set, if it is not collective IO, go to false. */ - if(!(flags&H5S_CONV_PAR_IO_POSSIBLE)) - HGOTO_DONE(FALSE); - - /*getting MPI communicator and rank */ - - comm = H5F_mpi_get_comm(file); - rank = H5F_mpi_get_rank(file); - -#if 0 - for (i =0;i<H5S_MAX_RANK;i++){ - chunk_dim[i] = 1; - startf[i] = 1; - endf[i] = 1; - startm[i] = 1; - endm[i] = 1; - fnum_chunk[i] = 1; - mnum_chunk[i] = 1; - } -#endif + if(!(flags&H5S_CONV_PAR_IO_POSSIBLE)) + HGOTO_DONE(FALSE); /* Check whether these are both simple or scalar dataspaces */ if (!((H5S_SIMPLE==H5S_GET_EXTENT_TYPE(mem_space) || H5S_SCALAR==H5S_GET_EXTENT_TYPE(mem_space)) - && (H5S_SIMPLE==H5S_GET_EXTENT_TYPE(file_space) || H5S_SCALAR==H5S_GET_EXTENT_TYPE(file_space)))) + && (H5S_SIMPLE==H5S_GET_EXTENT_TYPE(file_space) || H5S_SCALAR==H5S_GET_EXTENT_TYPE(file_space)))) HGOTO_DONE(FALSE); - - /* Check whether both selections are "regular" */ c1=H5S_SELECT_IS_REGULAR(file_space); c2=H5S_SELECT_IS_REGULAR(mem_space); @@ -895,14 +621,32 @@ H5S_mpio_opt_possible( const H5F_t *file, const H5S_t *mem_space, const H5S_t *f if (H5S_SEL_POINTS==H5S_GET_SELECT_TYPE(mem_space) || H5S_SEL_POINTS==H5S_GET_SELECT_TYPE(file_space)) HGOTO_DONE(FALSE); - -/* Dataset storage must be contiguous or special chunk storage */ - /* KMY Adding conditions for chunk storage */ + /* Dataset storage must be contiguous or chunked */ if ((flags&H5S_CONV_STORAGE_MASK)!=H5S_CONV_STORAGE_CONTIGUOUS && - (flags&H5S_CONV_STORAGE_MASK)!=H5S_CONV_STORAGE_CHUNKED) + (flags&H5S_CONV_STORAGE_MASK)!=H5S_CONV_STORAGE_CHUNKED) HGOTO_DONE(FALSE); if ((flags&H5S_CONV_STORAGE_MASK)==H5S_CONV_STORAGE_CHUNKED) { + hsize_t chunk_dim[H5O_LAYOUT_NDIMS]; /* Chunk dimensions */ + hssize_t startf[H5S_MAX_RANK], /* Selection start bounds */ + endf[H5S_MAX_RANK]; /* Selection end bounds */ + unsigned dim_rankf; /* Number of dimensions of file dataspace */ + int pcheck_hyper,check_hyper, /* Flags for checking if selection is in one chunk */ + tnum_chunkf, /* Number of chunks selection overlaps */ + max_chunkf, /* Maximum number of chunks selection overlaps */ + min_chunkf, /* Minimum number of chunks selection overlaps */ + num_chunks_same; /* Flag indicating whether all processes have the same # of chunks to operate on */ + unsigned dim_chunks; /* Temporary number of chunks in a dimension */ + MPI_Comm comm; /* MPI communicator for file */ + int mpi_rank; /* Rank in MPI communicator */ + int mpi_code; /* MPI return code */ + unsigned u; /* Local index variable */ + + /* Getting MPI communicator and rank */ + if((comm = H5F_mpi_get_comm(file))==MPI_COMM_NULL) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve MPI communicator") + if((mpi_rank = H5F_mpi_get_rank(file))<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve MPI rank") /* Currently collective chunking storage inside HDF5 is supported for either one of the following two cases: @@ -913,92 +657,87 @@ H5S_mpio_opt_possible( const H5F_t *file, const H5S_t *mem_space, const H5S_t *f */ /* Quincey, please read. - This is maybe redundent, I think only when both memory and file space be SCALAR + This is maybe redundant, I think only when both memory and file space be SCALAR space, the collective IO can work. Otherwise, SELECT_POINT will be reached,collective IO shouldn't work. Please clarify and correct the code on the following, Quincey said that it was probably okay if only one data space is SCALAR, Still keep the code here until we added more tests later. Kent */ - if(H5S_SCALAR==mem_space->extent.type || H5S_SCALAR ==file_space->extent.type) { - if(!(H5S_SCALAR==mem_space->extent.type && H5S_SCALAR ==file_space->extent.type)){ - HGOTO_DONE(FALSE); - } - else{ - HGOTO_DONE(TRUE); - } - } - - dim_rankf = file_space->extent.rank; - fsel_type = file_space->select.type->type; - - /* Assure that selection type of either data space is not H5S_SEL_NONE */ -/* Not necessary according to Quincey, commented out for the time being. - if(fsel_type == H5S_SEL_NONE || msel_type == H5S_SEL_NONE) - HGOTO_DONE(FALSE); -*/ - - if(H5S_SELECT_BOUNDS(file_space,startf,endf)==FAIL) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE,FAIL, "invalid check for single selection blocks"); - - - for(i = 0; i < layout->u.chunk.ndims;i++) - chunk_dim[i] = layout->u.chunk.dim[i]; - - /* Case 1: check whether all hyperslab in this process is inside one chunk. - Note: we don't handle when starting point is less than zero since that may cover - two chunks. */ - - /*for file space checking*/ - pcheck_hyper = 1; - for (i=0; i<dim_rankf; i++){ - if(endf[i]/chunk_dim[i]!=startf[i]/chunk_dim[i]) { - pcheck_hyper = 0; - break; - } - } - - - MPI_Reduce(&pcheck_hyper,&check_hyper,1,MPI_INT,MPI_LAND,0,comm); - MPI_Bcast(&check_hyper,1,MPI_INT,0,comm); + if(H5S_SCALAR==mem_space->extent.type || H5S_SCALAR ==file_space->extent.type) { + if(!(H5S_SCALAR==mem_space->extent.type && H5S_SCALAR ==file_space->extent.type)) + HGOTO_DONE(FALSE) + else + HGOTO_DONE(TRUE) + } /* end if */ + + dim_rankf = file_space->extent.rank; + + if(H5S_SELECT_BOUNDS(file_space,startf,endf)==FAIL) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE,FAIL, "invalid check for single selection blocks"); + + for(u=0; u < layout->u.chunk.ndims; u++) + chunk_dim[u] = layout->u.chunk.dim[u]; + + /* Case 1: check whether all hyperslab in this process is inside one chunk. + Note: we don't handle when starting point is less than zero since that may cover + two chunks. */ - /*if check_hyper is true, condition for collective IO case is fulfilled, no - need to do further test. */ - if(check_hyper) HGOTO_DONE(TRUE); + /*for file space checking*/ + pcheck_hyper = 1; + for (u=0; u<dim_rankf; u++) + if(endf[u]/chunk_dim[u]!=startf[u]/chunk_dim[u]) { + pcheck_hyper = 0; + break; + } + + if (MPI_SUCCESS != (mpi_code= MPI_Reduce(&pcheck_hyper,&check_hyper,1,MPI_INT,MPI_LAND,0,comm))) + HMPI_GOTO_ERROR(FAIL, "MPI_Reduce failed", mpi_code) + if (MPI_SUCCESS != (mpi_code= MPI_Bcast(&check_hyper,1,MPI_INT,0,comm))) + HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_code) + + /*if check_hyper is true, condition for collective IO case is fulfilled, no + need to do further test. */ + if(check_hyper) + HGOTO_DONE(TRUE); /* Case 2:Check whether the number of chunks that covered the single hyperslab is the same. - If not,no collective chunk IO. We need to check both file and memeory space + If not,no collective chunk IO. KY, 2004/7/14 */ - c1 = H5S_SELECT_IS_SINGLE(file_space); - c2 = H5S_SELECT_IS_SINGLE(mem_space); - - if(c1==FAIL || c2 ==FAIL) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "invalid check for single selection blocks"); - if(c1==FALSE || c2 ==FALSE) - HGOTO_DONE(FALSE); - - tnum_chunkf = 1; - for (i = 0; i<dim_rankf;i++){ - fnum_chunk[i] = endf[i]/chunk_dim[i]-startf[i]/chunk_dim[i]+1; - tnum_chunkf = fnum_chunk[i]*tnum_chunkf; - } + c1 = H5S_SELECT_IS_SINGLE(file_space); + c2 = H5S_SELECT_IS_SINGLE(mem_space); + + if(c1==FAIL || c2 ==FAIL) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "invalid check for single selection blocks"); + if(c1==FALSE || c2 ==FALSE) + HGOTO_DONE(FALSE); + + /* Compute the number of chunks covered by the selection on this process */ + tnum_chunkf = 1; + for (u=0; u<dim_rankf; u++) { + dim_chunks = (endf[u]/chunk_dim[u]-startf[u]/chunk_dim[u])+1; + tnum_chunkf = dim_chunks*tnum_chunkf; + } - MPI_Reduce(&tnum_chunkf,&manum_chunkf,1,MPI_INT,MPI_MAX,0,comm); - MPI_Reduce(&tnum_chunkf,&minum_chunkf,1,MPI_INT,MPI_MIN,0,comm); + /* Determine the minimum and maximum # of chunks for all processes */ + if (MPI_SUCCESS != (mpi_code= MPI_Reduce(&tnum_chunkf,&max_chunkf,1,MPI_INT,MPI_MAX,0,comm))) + HMPI_GOTO_ERROR(FAIL, "MPI_Reduce failed", mpi_code) + if (MPI_SUCCESS != (mpi_code= MPI_Reduce(&tnum_chunkf,&min_chunkf,1,MPI_INT,MPI_MIN,0,comm))) + HMPI_GOTO_ERROR(FAIL, "MPI_Reduce failed", mpi_code) - if(rank == 0) { - if(manum_chunkf!=minum_chunkf) - check_num_chunkf = 0; - else - check_num_chunkf = 1; - } + /* Let the rank==0 process determine if the same number of chunks will be operated on by all processes */ + if(mpi_rank == 0) + num_chunks_same = (max_chunkf==min_chunkf); - MPI_Bcast(&check_num_chunkf,1,MPI_INT,0,comm); - - if(!check_num_chunkf) HGOTO_DONE(FALSE); + /* Broadcast the flag indicating the number of chunks are the same */ + if (MPI_SUCCESS != (mpi_code= MPI_Bcast(&num_chunks_same,1,MPI_INT,0,comm))) + HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_code) + /* Can't handle case when number of chunks is different (yet) */ + if(!num_chunks_same) + HGOTO_DONE(FALSE); } done: diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 83eb041..ce93770 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -224,24 +224,10 @@ H5_DLL herr_t H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src); /* Operations on selections */ #ifdef H5_HAVE_PARALLEL -/* MPI-IO function to read directly from app buffer to file rky980813 */ -H5_DLL herr_t H5S_mpio_spaces_read(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, - H5D_t *dset, const H5D_storage_t *store, - size_t nelmts, size_t elmt_size, - const H5S_t *file_space, const H5S_t *mem_space, - void *buf/*out*/); - -/* MPI-IO function to write directly from app buffer to file rky980813 */ -H5_DLL herr_t H5S_mpio_spaces_write(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, - H5D_t *dset, const H5D_storage_t *store, - size_t nelmts, size_t elmt_size, - const H5S_t *file_space, const H5S_t *mem_space, - const void *buf); - /* MPI-IO function to check if a direct I/O transfer is possible between * memory and the file */ H5_DLL htri_t H5S_mpio_opt_possible(const H5F_t *file, const H5S_t *mem_space, - const H5S_t *file_space, const unsigned flags, const H5O_layout_t *layout); + const H5S_t *file_space, const unsigned flags, const H5O_layout_t *layout); #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 9e4028b..195a172 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -313,6 +313,14 @@ H5_DLL herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter); /* (Defined in H5S.c) */ H5_DLLVAR hbool_t H5S_mpi_opt_types_g; #endif /* _H5S_IN_H5S_C */ + +H5_DLL herr_t +H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, + /* out: */ + MPI_Datatype *new_type, + size_t *count, + hsize_t *extra_offset, + hbool_t *is_derived_type ); #endif /* H5_HAVE_PARALLEL */ #endif /* _H5Sprivate_H */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 2aa53c4..6695396 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -99,6 +99,10 @@ /* Define to 1 if you have the <gpfs.h> header file. */ #undef HAVE_GPFS_H +/* Define if library will contain instrumentation to detect correct + optimization operation */ +#undef HAVE_INSTRUMENTED_LIBRARY + /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H diff --git a/src/Makefile.in b/src/Makefile.in index 4c05597..56a8ca4 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -31,7 +31,7 @@ DISTCLEAN=libhdf5.settings ## Source and object files for the library (lexicographically)... LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5C.c H5D.c H5Dcontig.c H5Dcompact.c H5Dio.c \ - H5Distore.c H5Dseq.c H5Dtest.c H5E.c H5F.c H5Fdbg.c H5FD.c \ + H5Distore.c H5Dmpio.c H5Dseq.c H5Dtest.c H5E.c H5F.c H5Fdbg.c H5FD.c \ H5FDcore.c H5FDfamily.c H5FDfphdf5.c H5FDgass.c H5FDlog.c H5FDmpi.c \ H5FDmpio.c H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDsrb.c \ H5FDstdio.c H5FDstream.c H5FL.c H5FO.c H5FP.c H5FPclient.c \ diff --git a/testpar/t_coll_chunk.c b/testpar/t_coll_chunk.c index cafb784..8c2373b 100644 --- a/testpar/t_coll_chunk.c +++ b/testpar/t_coll_chunk.c @@ -13,6 +13,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "testphdf5.h" +#include "H5Dprivate.h" /*#define SPACE_DIM1 256 #define SPACE_DIM2 256 @@ -21,8 +22,20 @@ #define DSET_COLLECTIVE_CHUNK_NAME "coll_chunk_name" */ +/* some commonly used routines for collective chunk IO tests*/ +static void ccslab_set(int mpi_rank,int mpi_size,hssize_t start[],hsize_t count[], + hsize_t stride[],hsize_t block[],int mode); + +static void ccdataset_fill(hssize_t start[],hsize_t count[], + hsize_t stride[],hsize_t block[],DATATYPE*dataset); + +static void ccdataset_print(hssize_t start[],hsize_t block[],DATATYPE*dataset); + +static int ccdataset_vrfy(hssize_t start[], hsize_t count[], hsize_t stride[], + hsize_t block[], DATATYPE *dataset, DATATYPE *original); + +static void coll_chunktest(char* filename,int chunk_factor,int select_factor); -void coll_chunktest(char* filename,int chunk_factor,int select_factor); /*------------------------------------------------------------------------- * Function: coll_chunk1 * @@ -40,7 +53,8 @@ void coll_chunktest(char* filename,int chunk_factor,int select_factor); *------------------------------------------------------------------------- */ void -coll_chunk1(){ +coll_chunk1(void) +{ char *filename; filename = (char *) GetTestParameters(); @@ -49,7 +63,8 @@ coll_chunk1(){ } void -coll_chunk2(){ +coll_chunk2(void) +{ char *filename; filename = (char *) GetTestParameters(); @@ -59,7 +74,8 @@ coll_chunk2(){ void -coll_chunk3(){ +coll_chunk3(void) +{ char *filename; filename = (char *) GetTestParameters(); @@ -67,40 +83,37 @@ coll_chunk3(){ } - void -coll_chunk4(){ +coll_chunk4(void) +{ char *filename; filename = (char *) GetTestParameters(); coll_chunktest(filename,4,BYROW_DISCONT); } -void + +static void coll_chunktest(char* filename,int chunk_factor,int select_factor) { hid_t file,dataset, file_dataspace; hid_t acc_plist,xfer_plist,crp_plist; hsize_t dims[RANK], chunk_dims[RANK]; - int i,j; int* data_array1 = NULL; int* data_origin1 = NULL; herr_t status; hssize_t start[RANK]; hsize_t count[RANK],stride[RANK],block[RANK]; - int prop_value; - - /* char * filename;*/ +#ifdef H5_HAVE_INSTRUMENTED_LIBRARY + unsigned prop_value; +#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ int mpi_size,mpi_rank; - MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; - /* filename = (char *) GetTestParameters();*/ - /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(comm,&mpi_size); + MPI_Comm_rank(comm,&mpi_rank); /* Create the data space */ acc_plist = H5Pcreate(H5P_FILE_ACCESS); @@ -174,34 +187,39 @@ coll_chunktest(char* filename,int chunk_factor,int select_factor) { status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((status>= 0),"MPIO collective transfer property succeeded"); - prop_value = 1; - status = H5Pinsert(xfer_plist,PROP_NAME,sizeof(int),&prop_value, +#ifdef H5_HAVE_INSTRUMENTED_LIBRARY + prop_value = H5D_XFER_COLL_CHUNK_DEF; +#ifdef H5_WANT_H5_V1_6_COMPAT + status = H5Pinsert(xfer_plist,H5D_XFER_COLL_CHUNK_NAME,H5D_XFER_COLL_CHUNK_SIZE,&prop_value, NULL,NULL,NULL,NULL,NULL); +#else /* H5_WANT_H5_V1_6_COMPAT */ + status = H5Pinsert(xfer_plist,H5D_XFER_COLL_CHUNK_NAME,H5D_XFER_COLL_CHUNK_SIZE,&prop_value, + NULL,NULL,NULL,NULL,NULL,NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ VRFY((status >= 0),"testing property list inserted succeeded"); +#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ /* write data collectively */ status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, file_dataspace, xfer_plist, data_array1); VRFY((status >= 0),"dataset write succeeded"); - status = H5Pget(xfer_plist,PROP_NAME,&prop_value); +#ifdef H5_HAVE_INSTRUMENTED_LIBRARY + status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_NAME,&prop_value); VRFY((status >= 0),"testing property list get succeeded"); if(chunk_factor == 4 && select_factor == BYROW_DISCONT) { /* suppose to use independent */ - if(prop_value == 1) - printf("H5Dwrite shouldn't use MPI Collective IO call, something is wrong \n"); + VRFY((prop_value == 0), "H5Dwrite shouldn't use MPI Collective IO call"); } else { - if(prop_value == 0) - printf("H5Dwrite doesn't use MPI Collective IO call, something is wrong \n"); + VRFY((prop_value == 1), "H5Dwrite didn't use MPI Collective IO call"); } +#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ status = H5Dclose(dataset); - VRFY((status >= 0),""); + VRFY((status >= 0),""); /* check whether using collective IO */ /* Should use H5Pget and H5Pinsert to handle this test. */ - status = H5Premove(xfer_plist,PROP_NAME); - VRFY((status >= 0),"property list removed"); status = H5Pclose(xfer_plist); VRFY((status >= 0),"property list closed"); @@ -255,34 +273,39 @@ coll_chunktest(char* filename,int chunk_factor,int select_factor) { VRFY((xfer_plist >= 0),""); status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((status>= 0),"MPIO collective transfer property succeeded"); - prop_value = 1; - status = H5Pinsert(xfer_plist,PROP_NAME,sizeof(int),&prop_value, +#ifdef H5_HAVE_INSTRUMENTED_LIBRARY + prop_value = H5D_XFER_COLL_CHUNK_DEF; +#ifdef H5_WANT_H5_V1_6_COMPAT + status = H5Pinsert(xfer_plist,H5D_XFER_COLL_CHUNK_NAME,H5D_XFER_COLL_CHUNK_SIZE,&prop_value, NULL,NULL,NULL,NULL,NULL); +#else /* H5_WANT_H5_V1_6_COMPAT */ + status = H5Pinsert(xfer_plist,H5D_XFER_COLL_CHUNK_NAME,H5D_XFER_COLL_CHUNK_SIZE,&prop_value, + NULL,NULL,NULL,NULL,NULL,NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ VRFY((status >= 0),"testing property list inserted succeeded"); +#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, file_dataspace, xfer_plist, data_array1); VRFY((status >=0),"dataset read succeeded"); - status = H5Pget(xfer_plist,PROP_NAME,&prop_value); +#ifdef H5_HAVE_INSTRUMENTED_LIBRARY + status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_NAME,&prop_value); VRFY((status >= 0),"testing property list get succeeded"); if(chunk_factor == 4 && select_factor == BYROW_DISCONT) { /* suppose to use independent */ - if(prop_value == 1) - printf("H5Dread shouldn't use MPI Collective IO call, something is wrong \n"); + VRFY((prop_value == 0), "H5Dread shouldn't use MPI Collective IO call"); } else { - if(prop_value == 0) - printf("H5Dread doesn't use MPI Collective IO call, something is wrong \n"); + VRFY((prop_value == 1), "H5Dread didn't use MPI Collective IO call"); } +#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ /* verify the read data with original expected data */ status = ccdataset_vrfy(start, count, stride, block, data_array1, data_origin1); if (status) nerrors++; - status = H5Premove(xfer_plist,PROP_NAME); - VRFY((status >= 0),"property list removed"); + status = H5Pclose(xfer_plist); + VRFY((status >= 0),"property list closed"); - status = H5Pclose(xfer_plist); - VRFY((status >= 0),"property list closed"); /* close dataset collectively */ status=H5Dclose(dataset); VRFY((status >= 0), ""); @@ -300,7 +323,7 @@ coll_chunktest(char* filename,int chunk_factor,int select_factor) { } -void +static void ccslab_set(int mpi_rank, int mpi_size, hssize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], int mode) { @@ -357,44 +380,27 @@ if (VERBOSE_MED){ * Fill the dataset with trivial data for testing. * Assume dimension rank is 2 and data is stored contiguous. */ -void -ccdataset_fill(hssize_t start[], hsize_t stride[], hsize_t count[],hsize_t block[], DATATYPE * dataset) +static void +ccdataset_fill(hssize_t start[], hsize_t stride[], hsize_t count[], hsize_t block[], DATATYPE * dataset) { - DATATYPE *tmptr; DATATYPE *dataptr = dataset; - DATATYPE temp; - int i, j,k1,k2; + DATATYPE *tmptr; + hsize_t i, j,k1,k2; /* put some trivial data in the data_array */ - tmptr = dataptr; - /*for(i=0;i<SPACE_DIM1;i++){ - for(j=0;j<SPACE_DIM2;j++){ - *dataptr = 0; - dataptr++; - } - }*/ - - dataptr = tmptr; /* assign the disjoint block (two-dimensional)data array value through the pointer */ - for (k1 = 0; k1 < count[0];k1++) { - for(i = 0;i < block[0];i++) { - for(k2 = 0; k2<count[1];k2++) { - for(j=0;j<block[1];j++) { + for (k1 = 0; k1 < count[0]; k1++) { + for(i = 0;i < block[0]; i++) { + for(k2 = 0; k2<count[1]; k2++) { + for(j=0;j<block[1]; j++) { dataptr = tmptr + ((start[0]+k1*stride[0]+i)*SPACE_DIM2+ start[1]+k2*stride[1]+j); - /* printf("i,j,k1,k2 %lu %lu %lu %lu \n",i,j,k1,k2); - printf("Address of dataptr"); - printf("= 0x%p\n",dataptr); - */ *dataptr = (DATATYPE)(k1+k2+i+j); - /*temp = *dataptr; - printf("data %03d\n",temp); - */ } } } @@ -405,7 +411,7 @@ ccdataset_fill(hssize_t start[], hsize_t stride[], hsize_t count[],hsize_t block /* * Print the first block of the content of the dataset. */ -void +static void ccdataset_print(hssize_t start[], hsize_t block[], DATATYPE * dataset) { DATATYPE *dataptr = dataset; @@ -433,7 +439,8 @@ ccdataset_print(hssize_t start[], hsize_t block[], DATATYPE * dataset) /* * Print the content of the dataset. */ -int ccdataset_vrfy(hssize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], DATATYPE *dataset, DATATYPE *original) +static int +ccdataset_vrfy(hssize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], DATATYPE *dataset, DATATYPE *original) { hsize_t i, j,k1,k2; int vrfyerrs; diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c index 0403b26..26642bf 100644 --- a/testpar/testphdf5.c +++ b/testpar/testphdf5.c @@ -475,7 +475,7 @@ int main(int argc, char **argv) AddTest("coll. chunked 2", coll_chunk2,NULL, "noncontiguous collective chunk io",filenames[11]); AddTest("coll. chunked 3", coll_chunk3,NULL, - "muliti-chunk collective chunk io",filenames[12]); + "multi-chunk collective chunk io",filenames[12]); AddTest("coll. chunked 4", coll_chunk4,NULL, "collective to independent chunk io",filenames[13]); /* Display testing information */ diff --git a/testpar/testphdf5.h b/testpar/testphdf5.h index e0e9001..379fd1e 100644 --- a/testpar/testphdf5.h +++ b/testpar/testphdf5.h @@ -12,8 +12,6 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id$ */ - #ifndef PHDF5TEST_H #define PHDF5TEST_H @@ -129,7 +127,6 @@ #define BYROW_CONT 1 #define BYROW_DISCONT 2 #define DSET_COLLECTIVE_CHUNK_NAME "coll_chunk_name" -#define PROP_NAME "__test__ccfoo___" /* type definitions */ typedef struct H5Ptest_param_t /* holds extra test parameters */ { @@ -170,22 +167,11 @@ void compact_dataset(void); void null_dataset(void); void big_dataset(void); void dataset_fillvalue(void); +void coll_chunk1(void); +void coll_chunk2(void); +void coll_chunk3(void); +void coll_chunk4(void); -void coll_chunk1(); -void coll_chunk2(); -void coll_chunk3(); -void coll_chunk4(); -/* some commonly used routines for collective chunk IO tests*/ -void ccslab_set(int mpi_rank,int mpi_size,hssize_t start[],hsize_t count[], - hsize_t stride[],hsize_t block[],int mode); - -void ccdataset_fill(hssize_t start[],hsize_t count[], - hsize_t stride[],hsize_t block[],DATATYPE*dataset); - -void ccdataset_print(hssize_t start[],hsize_t block[],DATATYPE*dataset); - -int ccdataset_vrfy(hssize_t start[], hsize_t count[], hsize_t stride[], - hsize_t block[], DATATYPE *dataset, DATATYPE *original); /* commonly used prototypes */ hid_t create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type, hbool_t use_gpfs); MPI_Offset h5_mpi_get_file_size(const char *filename, MPI_Comm comm, MPI_Info info); |