diff options
Diffstat (limited to 'src/H5Dchunk.c')
-rw-r--r-- | src/H5Dchunk.c | 121 |
1 files changed, 53 insertions, 68 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 35773b6..917602f 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1100,14 +1100,10 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf H5D_chunk_map_t *fm) { const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ - H5S_t *tmp_mspace = NULL; /* Temporary memory dataspace */ hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset */ htri_t file_space_normalized = FALSE; /* File dataspace was normalized */ - H5T_t *file_type = NULL; /* Temporary copy of file datatype for iteration */ - hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ unsigned f_ndims; /* The number of dimensions of the file's dataspace */ int sm_ndims; /* The number of dimensions of the memory buffer's dataspace (signed) */ - char bogus; /* "bogus" buffer to pass to selection iterator */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1268,22 +1264,22 @@ H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_ else sel_hyper_flag = TRUE; - /* Check if file selection is a not a hyperslab selection */ - if(sel_hyper_flag) { - /* Build the file selection for each chunk */ - if(H5S_SEL_ALL == fm->fsel_type) { - if(H5D__create_chunk_file_map_all(fm, io_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") - } /* end if */ - else { - /* Sanity check */ - HDassert(fm->fsel_type == H5S_SEL_HYPERSLABS); - - if(H5D__create_chunk_file_map_hyper(fm, io_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") - } /* end else */ + /* Check if file selection is a not a hyperslab selection */ + if(sel_hyper_flag) { + /* Build the file selection for each chunk */ + if(H5S_SEL_ALL == fm->fsel_type) { + if(H5D__create_chunk_file_map_all(fm, io_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") } /* end if */ else { + /* Sanity check */ + HDassert(fm->fsel_type == H5S_SEL_HYPERSLABS); + + if(H5D__create_chunk_file_map_hyper(fm, io_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") + } /* end else */ + } /* end if */ + else { H5S_sel_iter_op_t iter_op; /* Operator for iteration */ H5D_chunk_file_iter_ud_t udata; /* User data for iteration */ @@ -1320,14 +1316,12 @@ H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_ if(H5D__create_chunk_mem_map_hyper(fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create memory chunk selections") } /* end if */ - else if(sel_hyper_flag && - fm->f_ndims == 1 && fm->m_ndims == 1 && + else if(sel_hyper_flag && fm->f_ndims == 1 && fm->m_ndims == 1 && H5S_SELECT_IS_REGULAR(fm->mem_space) && H5S_SELECT_IS_SINGLE(fm->mem_space)) { - if(H5D__create_chunk_mem_map_1d(fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") - - } else { + } /* end else-if */ + else { H5S_sel_iter_op_t iter_op; /* Operator for iteration */ size_t elmt_size; /* Memory datatype size */ @@ -1343,8 +1337,8 @@ H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_ fm->mchunk_tmpl = tmp_mspace; /* Create temporary datatypes for selection iteration */ - if(!file_type) - if(NULL == (file_type = H5T_copy(dataset->shared->type, H5T_COPY_ALL))) + if(!file_type) + if(NULL == (file_type = H5T_copy(dataset->shared->type, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy file datatype") /* Create selection iterator for memory selection */ @@ -1366,11 +1360,9 @@ H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_ done: /* Release the [potentially partially built] chunk mapping information if an error occurs */ if(ret_value < 0) { - if(tmp_mspace && !fm->mchunk_tmpl) { + if(tmp_mspace && !fm->mchunk_tmpl) if(H5S_close(tmp_mspace) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template") - } /* end if */ - if(H5D__chunk_io_term(fm) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release chunk mapping") } /* end if */ @@ -2139,13 +2131,7 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) { H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ H5SL_node_t *curr_node; /* Current node in skip list */ - hsize_t file_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ - hsize_t file_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ - hsize_t mem_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ - hsize_t mem_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ - hssize_t adjust[H5S_MAX_RANK]; /* Adjustment to make to all file chunks */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2173,6 +2159,8 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) hsize_t mem_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ HDassert(fm->m_ndims == 1); + HDassert(fm->m_ndims == 1); + if(H5S_SELECT_BOUNDS(fm->mem_space, mem_sel_start, mem_sel_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") @@ -5037,8 +5025,7 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, blocks++; } - /* MSC - * should use this if MPI_type_create_hindexed block is working + /* MSC - should use this if MPI_type_create_hindexed block is working: * mpi_code = MPI_Type_create_hindexed_block(blocks, block_len, chunk_disp_array, MPI_BYTE, &file_type); */ mpi_code = MPI_Type_create_hindexed(blocks, block_lens, chunk_disp_array, MPI_BYTE, &file_type); @@ -5512,7 +5499,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) } /* end if */ else dims_outside_fill[u] = FALSE; - } /* end if */ + } /* end else */ carry = FALSE; while(!carry) { @@ -5969,11 +5956,10 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Check for an edge chunk that is not filtered */ if(pline && pline->nused) { must_filter = TRUE; - if( (udata->common.layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && - (H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, udata->common.layout->dim, - chunk_rec->scaled, udata->dset_dims)) ) + if((udata->common.layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && + H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, udata->common.layout->dim, chunk_rec->scaled, udata->dset_dims)) must_filter = FALSE; - } + } /* end if */ /* Check parameter for type conversion */ if(udata->do_convert) { @@ -6011,7 +5997,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDassert(!H5F_addr_defined(chunk_rec->chunk_addr)); H5MM_memcpy(buf, udata->chunk, nbytes); udata->chunk = NULL; - } + } /* end if */ else { H5D_rdcc_ent_t *ent = NULL; /* Cache entry */ unsigned idx; /* Index of chunk in cache, if present */ @@ -6044,13 +6030,13 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) H5_CHECKED_ASSIGN(nbytes, size_t, shared_fo->layout.u.chunk.size, uint32_t); H5MM_memcpy(buf, ent->chunk, nbytes); - } + } /* end if */ else { /* read chunk data from the source file */ if(H5F_block_read(udata->file_src, H5FD_MEM_DRAW, chunk_rec->chunk_addr, nbytes, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk") - } - } + } /* end else */ + } /* end else */ /* Need to uncompress filtered variable-length & reference data elements that are not found in chunk cache */ if(must_filter && (is_vlen || fix_ref) && !udata->chunk_in_cache) { @@ -7088,7 +7074,7 @@ H5D__chunk_format_convert(H5D_t *dset, H5D_chk_idx_info_t *idx_info, H5D_chk_idx udata.dset_ndims = dset->shared->ndims; udata.dset_dims = dset->shared->curr_dims; - /* terate over the chunks in the current index and insert the chunk addresses into version 1 B-tree index */ + /* Iterate over the chunks in the current index and insert the chunk addresses into version 1 B-tree index */ if((idx_info->storage->ops->iterate)(idx_info, H5D__chunk_format_convert_cb, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk index to chunk info") @@ -7152,7 +7138,6 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ hsize_t num_chunks = 0; /* Number of written chunks */ H5D_rdcc_ent_t *ent; /* Cache entry */ const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ - const H5O_layout_t *layout; /* Dataset layout */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -7162,7 +7147,6 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ HDassert(space); HDassert(nchunks); - layout = &(dset->shared->layout); /* Dataset layout */ rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */ HDassert(rdcc); @@ -7179,15 +7163,14 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ idx_info.storage = &dset->shared->layout.storage.u.chunk; /* If the dataset is not written, number of chunks will be 0 */ - if(!H5F_addr_defined(idx_info.storage->idx_addr)) { + if(!H5F_addr_defined(idx_info.storage->idx_addr)) *nchunks = 0; - } else { /* Iterate over the allocated chunks */ if((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_num_chunks_cb, &num_chunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve allocated chunk information from index") *nchunks = num_chunks; - } + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -7212,7 +7195,6 @@ static int H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { H5D_chunk_info_iter_ud_t *chunk_info = (H5D_chunk_info_iter_ud_t *)_udata; - hsize_t ii = 0; /* Dimension index */ int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC_NOERR @@ -7222,17 +7204,20 @@ H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDassert(chunk_info); /* If this is the queried chunk, retrieve its info and stop iterating */ - if (chunk_info->curr_idx == chunk_info->chunk_idx) { + if(chunk_info->curr_idx == chunk_info->chunk_idx) { + hsize_t ii = 0; /* Dimension index */ + + /* Copy info */ chunk_info->filter_mask = chunk_rec->filter_mask; chunk_info->chunk_addr = chunk_rec->chunk_addr; chunk_info->nbytes = chunk_rec->nbytes; - for (ii = 0; ii < chunk_info->ndims; ii++) + for(ii = 0; ii < chunk_info->ndims; ii++) chunk_info->scaled[ii] = chunk_rec->scaled[ii]; chunk_info->found = TRUE; /* Stop iterating */ ret_value = H5_ITER_STOP; - } + } /* end if */ /* Go to the next chunk */ else chunk_info->curr_idx++; @@ -7291,9 +7276,9 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Set addr & size for when dset is not written or queried chunk is not found */ - if (addr) + if(addr) *addr = HADDR_UNDEF; - if (size) + if(size) *size = 0; /* If the chunk is written, get its info, otherwise, return without error */ @@ -7322,7 +7307,7 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ if(offset) for(ii = 0; ii < udata.ndims; ii++) offset[ii] = udata.scaled[ii] * dset->shared->layout.u.chunk.dim[ii]; - } + } /* end if */ } /* end if H5F_addr_defined */ done: @@ -7347,9 +7332,9 @@ done: static int H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - hsize_t ii; H5D_chunk_info_iter_ud_t *chunk_info = (H5D_chunk_info_iter_ud_t *)_udata; hbool_t different = FALSE; /* TRUE when a scaled value pair mismatch */ + hsize_t ii; /* Local index value */ int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC_NOERR @@ -7359,12 +7344,12 @@ H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDassert(chunk_info); /* Going through the scaled, stop when a mismatch is found */ - for (ii = 0; ii < chunk_info->ndims && !different; ii++) - if (chunk_info->scaled[ii] != chunk_rec->scaled[ii]) + for(ii = 0; ii < chunk_info->ndims && !different; ii++) + if(chunk_info->scaled[ii] != chunk_rec->scaled[ii]) different = TRUE; /* Same scaled coords means the chunk is found, copy the chunk info */ - if (!different) { + if(!different) { chunk_info->nbytes = chunk_rec->nbytes; chunk_info->filter_mask = chunk_rec->filter_mask; chunk_info->chunk_addr = chunk_rec->chunk_addr; @@ -7372,7 +7357,7 @@ H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Stop iterating */ ret_value = H5_ITER_STOP; - } + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5D__get_chunk_info_by_coord_cb() */ @@ -7423,9 +7408,9 @@ H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *offset, unsigned* HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") /* Set addr & size for when dset is not written or queried chunk is not found */ - if (addr) + if(addr) *addr = HADDR_UNDEF; - if (size) + if(size) *size = 0; /* Compose chunked index info struct */ @@ -7452,14 +7437,14 @@ H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *offset, unsigned* HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve information of the chunk by its scaled coordinates") /* Obtain requested info if the chunk is found */ - if (udata.found) { + if(udata.found) { if(filter_mask) *filter_mask = udata.filter_mask; if(addr) *addr = udata.chunk_addr; if(size) *size = udata.nbytes; - } + } /* end if */ } /* end if H5F_addr_defined */ done: |