diff options
Diffstat (limited to 'src/H5Dio.c')
-rw-r--r-- | src/H5Dio.c | 135 |
1 files changed, 81 insertions, 54 deletions
diff --git a/src/H5Dio.c b/src/H5Dio.c index b978139..2134ce1 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -88,7 +88,7 @@ H5D__read(size_t count, H5D_dset_io_info_t *dset_info) /* projected to a rank equal to that of file_space. */ /* */ /* This field is only used if */ - /* H5S_select_shape_same() returns TRUE when */ + /* H5S_select_shape_same() returns true when */ /* comparing at least one mem_space and data_space, */ /* and the mem_space has a different rank. */ /* */ @@ -107,6 +107,17 @@ H5D__read(size_t count, H5D_dset_io_info_t *dset_info) FUNC_ENTER_NOAPI(FAIL) +#ifdef H5_HAVE_PARALLEL + /* Reset the actual io mode properties to the default values in case + * the DXPL (if it's non-default) was previously used in a collective + * I/O operation. + */ + if (!H5CX_is_def_dxpl()) { + H5CX_set_mpio_actual_chunk_opt(H5D_MPIO_NO_CHUNK_OPTIMIZATION); + H5CX_set_mpio_actual_io_mode(H5D_MPIO_NO_COLLECTIVE); + } /* end if */ +#endif + /* Init io_info */ if (H5D__ioinfo_init(count, H5D_IO_OP_READ, dset_info, &io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize I/O info"); @@ -189,7 +200,7 @@ H5D__read(size_t count, H5D_dset_io_info_t *dset_info) * well. */ if (dset_info[i].nelmts > 0 && - TRUE == H5S_SELECT_SHAPE_SAME(dset_info[i].mem_space, dset_info[i].file_space) && + true == H5S_SELECT_SHAPE_SAME(dset_info[i].mem_space, dset_info[i].file_space) && H5S_GET_EXTENT_NDIMS(dset_info[i].mem_space) != H5S_GET_EXTENT_NDIMS(dset_info[i].file_space)) { ptrdiff_t buf_adj = 0; @@ -222,6 +233,14 @@ H5D__read(size_t count, H5D_dset_io_info_t *dset_info) dset_info[i].buf.vp = (void *)(((uint8_t *)dset_info[i].buf.vp) + buf_adj); } /* end if */ + /* Set up I/O operation */ + if (H5D__dset_ioinfo_init(dset_info[i].dset, &(dset_info[i]), &(store[i])) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up I/O operation"); + + /* Check if any filters are applied to the dataset */ + if (dset_info[i].dset->shared->dcpl_cache.pline.nused > 0) + io_info.filtered_count++; + /* If space hasn't been allocated and not using external storage, * return fill value to buffer if fill time is upon allocation, or * do nothing if fill time is never. If the dataset is compact and @@ -255,14 +274,10 @@ H5D__read(size_t count, H5D_dset_io_info_t *dset_info) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "filling buf failed"); /* No need to perform any more I/O for this dataset */ - dset_info[i].skip_io = TRUE; - io_skipped++; + dset_info[i].skip_io = true; + io_skipped = io_skipped + 1; } /* end if */ else { - /* Set up I/O operation */ - if (H5D__dset_ioinfo_init(dset_info[i].dset, &(dset_info[i]), &(store[i])) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to set up I/O operation"); - /* Sanity check that space is allocated, if there are elements */ if (dset_info[i].nelmts > 0) assert( @@ -273,22 +288,23 @@ H5D__read(size_t count, H5D_dset_io_info_t *dset_info) dset_info[i].dset->shared->dcpl_cache.efl.nused > 0 || dset_info[i].dset->shared->layout.type == H5D_COMPACT); - /* Call storage method's I/O initialization routine */ - if (dset_info[i].layout_ops.io_init && - (dset_info[i].layout_ops.io_init)(&io_info, &(dset_info[i])) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize I/O info"); - dset_info[i].skip_io = FALSE; - io_op_init++; - - /* Reset metadata tagging */ - H5AC_tag(prev_tag, NULL); + dset_info[i].skip_io = false; } + + /* Call storage method's I/O initialization routine */ + if (dset_info[i].layout_ops.io_init && + (dset_info[i].layout_ops.io_init)(&io_info, &(dset_info[i])) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize I/O info"); + io_op_init++; + + /* Reset metadata tagging */ + H5AC_tag(prev_tag, NULL); } /* end of for loop */ - assert(io_op_init + io_skipped == count); + assert(io_op_init == count); /* If no datasets have I/O, we're done */ - if (io_op_init == 0) + if (io_skipped == count) HGOTO_DONE(SUCCEED); /* Perform second phase of type info initialization */ @@ -323,7 +339,11 @@ H5D__read(size_t count, H5D_dset_io_info_t *dset_info) } /* MDIO-specific second phase initialization */ - for (i = 0; i < count; i++) + for (i = 0; i < count; i++) { + /* Check for skipped I/O */ + if (dset_info[i].skip_io) + continue; + if (dset_info[i].layout_ops.mdio_init) { haddr_t prev_tag = HADDR_UNDEF; @@ -337,6 +357,7 @@ H5D__read(size_t count, H5D_dset_io_info_t *dset_info) /* Reset metadata tagging */ H5AC_tag(prev_tag, NULL); } + } /* Invoke correct "high level" I/O routine */ if ((*io_info.md_io_ops.multi_read_md)(&io_info) < 0) @@ -430,7 +451,7 @@ H5D__read(size_t count, H5D_dset_io_info_t *dset_info) done: /* Shut down the I/O op information */ for (i = 0; i < io_op_init; i++) - if (!dset_info[i].skip_io && dset_info[i].layout_ops.io_term && + if (dset_info[i].layout_ops.io_term && (*dset_info[i].layout_ops.io_term)(&io_info, &(dset_info[i])) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down I/O op info"); @@ -495,7 +516,7 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info) /* projected to a rank equal to that of file_space. */ /* */ /* This field is only used if */ - /* H5S_select_shape_same() returns TRUE when */ + /* H5S_select_shape_same() returns true when */ /* comparing at least one mem_space and data_space, */ /* and the mem_space has a different rank. */ /* */ @@ -512,6 +533,17 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info) FUNC_ENTER_NOAPI(FAIL) +#ifdef H5_HAVE_PARALLEL + /* Reset the actual io mode properties to the default values in case + * the DXPL (if it's non-default) was previously used in a collective + * I/O operation. + */ + if (!H5CX_is_def_dxpl()) { + H5CX_set_mpio_actual_chunk_opt(H5D_MPIO_NO_CHUNK_OPTIMIZATION); + H5CX_set_mpio_actual_io_mode(H5D_MPIO_NO_COLLECTIVE); + } /* end if */ +#endif + /* Init io_info */ if (H5D__ioinfo_init(count, H5D_IO_OP_WRITE, dset_info, &io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize I/O info"); @@ -523,7 +555,7 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info) /* iterate over all dsets and construct I/O information */ for (i = 0; i < count; i++) { - hbool_t should_alloc_space = FALSE; /* Whether or not to initialize dataset's storage */ + bool should_alloc_space = false; /* Whether or not to initialize dataset's storage */ haddr_t prev_tag = HADDR_UNDEF; /* check args */ @@ -540,7 +572,7 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info) if (H5Z_can_apply(dset_info[i].dset->shared->dcpl_id, dset_info[i].dset->shared->type_id) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters"); - dset_info[i].dset->shared->checked_filters = TRUE; + dset_info[i].dset->shared->checked_filters = true; } /* end if */ /* Check if we are allowed to write to this file */ @@ -586,7 +618,7 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info) if (NULL == dset_info[i].buf.cvp) { /* Check for any elements selected (which is invalid) */ if (dset_info[i].nelmts > 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no input buffer"); /* If the buffer is nil, and 0 element is selected, make a fake buffer. * This is for some MPI package like ChaMPIon on NCSA's tungsten which @@ -615,7 +647,7 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info) * as well. */ if (dset_info[i].nelmts > 0 && - TRUE == H5S_SELECT_SHAPE_SAME(dset_info[i].mem_space, dset_info[i].file_space) && + true == H5S_SELECT_SHAPE_SAME(dset_info[i].mem_space, dset_info[i].file_space) && H5S_GET_EXTENT_NDIMS(dset_info[i].mem_space) != H5S_GET_EXTENT_NDIMS(dset_info[i].file_space)) { ptrdiff_t buf_adj = 0; @@ -655,6 +687,10 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info) if (H5D__dset_ioinfo_init(dset_info[i].dset, &(dset_info[i]), &(store[i])) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up I/O operation"); + /* Check if any filters are applied to the dataset */ + if (dset_info[i].dset->shared->dcpl_cache.pline.nused > 0) + io_info.filtered_count++; + /* Allocate dataspace and initialize it if it hasn't been. */ should_alloc_space = dset_info[i].dset->shared->dcpl_cache.efl.nused == 0 && !(*dset_info[i].dset->shared->layout.ops->is_space_alloc)( @@ -672,7 +708,7 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info) if (should_alloc_space) { hssize_t file_nelmts; /* Number of elements in file dataset's dataspace */ - hbool_t full_overwrite; /* Whether we are over-writing all the elements */ + bool full_overwrite; /* Whether we are over-writing all the elements */ /* Get the number of elements in file dataset's dataspace */ if ((file_nelmts = H5S_GET_EXTENT_NPOINTS(dset_info[i].file_space)) < 0) @@ -680,10 +716,10 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info) "can't retrieve number of elements in file dataset"); /* Always allow fill values to be written if the dataset has a VL datatype */ - if (H5T_detect_class(dset_info[i].dset->shared->type, H5T_VLEN, FALSE)) - full_overwrite = FALSE; + if (H5T_detect_class(dset_info[i].dset->shared->type, H5T_VLEN, false)) + full_overwrite = false; else - full_overwrite = (hbool_t)((hsize_t)file_nelmts == dset_info[i].nelmts ? TRUE : FALSE); + full_overwrite = (bool)((hsize_t)file_nelmts == dset_info[i].nelmts ? true : false); /* Allocate storage */ if (H5D__alloc_storage(dset_info[i].dset, H5D_ALLOC_WRITE, full_overwrite, NULL) < 0) @@ -695,7 +731,7 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info) if (dset_info[i].layout_ops.io_init && (*dset_info[i].layout_ops.io_init)(&io_info, &(dset_info[i])) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize I/O info"); - dset_info[i].skip_io = FALSE; + dset_info[i].skip_io = false; io_op_init++; /* Reset metadata tagging */ @@ -940,7 +976,7 @@ H5D__ioinfo_init(size_t count, H5D_io_op_type_t op_type, H5D_dset_io_info_t *dse /* Check if we could potentially use in-place type conversion */ if (op_type == H5D_IO_OP_READ) /* Always on for read (modulo other restrictions that are handled in layout callbacks) */ - io_info->may_use_in_place_tconv = TRUE; + io_info->may_use_in_place_tconv = true; else /* Only enable in-place type conversion if we're allowed to modify the write buffer */ H5CX_get_modify_write_buf(&io_info->may_use_in_place_tconv); @@ -1093,7 +1129,7 @@ H5D__typeinfo_init(H5D_io_info_t *io_info, H5D_dset_io_info_t *dset_info, hid_t MAX3(io_info->max_tconv_type_size, type_info->src_type_size, type_info->dst_type_size); /* Check if we need a background buffer */ - if ((io_info->op_type == H5D_IO_OP_WRITE) && H5T_detect_class(dset->shared->type, H5T_VLEN, FALSE)) + if ((io_info->op_type == H5D_IO_OP_WRITE) && H5T_detect_class(dset->shared->type, H5T_VLEN, false)) type_info->need_bkg = H5T_BKG_YES; else { H5T_bkg_t path_bkg; /* Type conversion's background info */ @@ -1169,7 +1205,7 @@ H5D__typeinfo_init_phase2(H5D_io_info_t *io_info) /* Check if we need to fill the background buffer with the destination contents */ if (type_info->need_bkg == H5T_BKG_YES) - io_info->must_fill_bkg = TRUE; + io_info->must_fill_bkg = true; } } @@ -1183,14 +1219,14 @@ H5D__typeinfo_init_phase2(H5D_io_info_t *io_info) io_info->no_selection_io_cause |= H5D_SEL_IO_TCONV_BUF_TOO_SMALL; io_info->tconv_buf_size = 0; io_info->bkg_buf_size = 0; - io_info->must_fill_bkg = FALSE; + io_info->must_fill_bkg = false; } if (io_info->bkg_buf_size > max_temp_buf) { io_info->use_select_io = H5D_SELECTION_IO_MODE_OFF; io_info->no_selection_io_cause |= H5D_SEL_IO_BKG_BUF_TOO_SMALL; io_info->tconv_buf_size = 0; io_info->bkg_buf_size = 0; - io_info->must_fill_bkg = FALSE; + io_info->must_fill_bkg = false; } } @@ -1225,15 +1261,6 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info) dset0 = io_info->dsets_info[0].dset; assert(dset0->oloc.file); - /* Reset the actual io mode properties to the default values in case - * the DXPL (if it's non-default) was previously used in a collective - * I/O operation. - */ - if (!H5CX_is_def_dxpl()) { - H5CX_set_mpio_actual_chunk_opt(H5D_MPIO_NO_CHUNK_OPTIMIZATION); - H5CX_set_mpio_actual_io_mode(H5D_MPIO_NO_COLLECTIVE); - } /* end if */ - /* Make any parallel I/O adjustments */ if (io_info->using_mpi_vfd) { H5FD_mpio_xfer_t xfer_mode; /* Parallel transfer for this request */ @@ -1252,7 +1279,7 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "invalid check for direct IO dataspace "); /* Check if we can use the optimized parallel I/O routines */ - if (opt == TRUE) { + if (opt == true) { /* Override the I/O op pointers to the MPI-specific routines, unless * selection I/O is to be used - in this case the file driver will * handle collective I/O */ @@ -1267,7 +1294,7 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info) else { /* Fail when file sync is required, since it requires collective write */ if (io_info->op_type == H5D_IO_OP_WRITE) { - hbool_t mpi_file_sync_required = FALSE; + bool mpi_file_sync_required = false; if (H5F_shared_get_mpi_file_sync_required(io_info->f_sh, &mpi_file_sync_required) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI file_sync_required flag"); @@ -1380,7 +1407,7 @@ H5D__typeinfo_init_phase3(H5D_io_info_t *io_info) if (NULL == (io_info->tconv_buf = H5FL_BLK_MALLOC(type_conv, io_info->tconv_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); - io_info->tconv_buf_allocated = TRUE; + io_info->tconv_buf_allocated = true; } /* Allocate global background buffer (if any) */ @@ -1388,7 +1415,7 @@ H5D__typeinfo_init_phase3(H5D_io_info_t *io_info) if (NULL == (io_info->bkg_buf = H5FL_BLK_MALLOC(type_conv, io_info->bkg_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); - io_info->bkg_buf_allocated = TRUE; + io_info->bkg_buf_allocated = true; } } else { @@ -1410,11 +1437,11 @@ H5D__typeinfo_init_phase3(H5D_io_info_t *io_info) /* If the buffer is too small to hold even one element (in the dataset with the largest , try to * make it bigger */ if (target_size < io_info->max_tconv_type_size) { - hbool_t default_buffer_info; /* Whether the buffer information are the defaults */ + bool default_buffer_info; /* Whether the buffer information are the defaults */ /* Detect if we have all default settings for buffers */ - default_buffer_info = (hbool_t)((H5D_TEMP_BUF_SIZE == max_temp_buf) && (NULL == tconv_buf) && - (NULL == bkgr_buf)); + default_buffer_info = + (bool)((H5D_TEMP_BUF_SIZE == max_temp_buf) && (NULL == tconv_buf) && (NULL == bkgr_buf)); /* Check if we are using the default buffer info */ if (default_buffer_info) @@ -1434,7 +1461,7 @@ H5D__typeinfo_init_phase3(H5D_io_info_t *io_info) if (NULL == (io_info->tconv_buf = H5FL_BLK_MALLOC(type_conv, target_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); - io_info->tconv_buf_allocated = TRUE; + io_info->tconv_buf_allocated = true; } /* end if */ /* Iterate over datasets */ @@ -1455,7 +1482,7 @@ H5D__typeinfo_init_phase3(H5D_io_info_t *io_info) if (NULL == (io_info->bkg_buf = H5FL_BLK_MALLOC(type_conv, target_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion"); - io_info->bkg_buf_allocated = TRUE; + io_info->bkg_buf_allocated = true; } } } |