diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Dio.c | 123 | ||||
-rw-r--r-- | src/H5Smpio.c | 22 | ||||
-rw-r--r-- | src/H5Spkg.h | 4 | ||||
-rw-r--r-- | src/H5Sprivate.h | 8 | ||||
-rw-r--r-- | src/H5Sselect.c | 48 |
5 files changed, 86 insertions, 119 deletions
diff --git a/src/H5Dio.c b/src/H5Dio.c index 21f01d4b..37e95a3 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -43,6 +43,7 @@ /* Structure holding information about a chunk's selection for mapping */ typedef struct H5D_chunk_info_t { hsize_t index; /* "Index" of chunk in dataset (must be first for TBBT routines) */ + hsize_t chunk_points; /* Number of elements selected in chunk */ H5S_t *fspace; /* Dataspace describing chunk & selection in it */ hssize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of chunk in file dataset's dataspace */ H5S_t *mspace; /* Dataspace describing selection in memory corresponding to this chunk */ @@ -53,11 +54,11 @@ typedef struct H5D_chunk_info_t { typedef struct fm_map { H5TB_TREE *fsel; /* TBBT containing file dataspaces for all chunks */ hsize_t last_index; /* Index of last chunk operated on */ + H5D_chunk_info_t *last_chunk_info; /* Pointer to last chunk's info */ const H5S_t *file_space; /* Pointer to the file dataspace */ const H5S_t *mem_space; /* Pointer to the memory dataspace */ unsigned mem_space_copy; /* Flag to indicate that the memory dataspace must be copied */ hsize_t f_dims[H5O_LAYOUT_NDIMS]; /* File dataspace dimensions */ - H5S_t *last_chunk; /* Pointer to last memory chunk's dataspace */ H5S_t *mchunk_tmpl; /* Dataspace template for new memory chunks */ unsigned f_ndims; /* Number of dimensions for file dataspace */ H5S_sel_iter_t mem_iter; /* Iterator for elements in memory selection */ @@ -883,7 +884,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, if (!file_space) file_space = dataset->space; if (!mem_space) - mem_space = file_space; + mem_space = file_space; if((snelmts = H5S_get_select_npoints(mem_space))<0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection"); H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,hsize_t); @@ -1074,8 +1075,9 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, /* Sanity check dataset, then read it */ assert(dataset->layout.addr!=HADDR_UNDEF || dataset->efl.nused>0 || dataset->layout.type==H5D_COMPACT); + H5_CHECK_OVERFLOW(nelmts,hsize_t,size_t); status = (sconv->read)(dataset->ent.file, &(dataset->layout), - &dataset->dcpl_cache, (H5D_storage_t *)&(dataset->efl), H5T_get_size(dataset->type), + &dataset->dcpl_cache, (H5D_storage_t *)&(dataset->efl), (size_t)nelmts, H5T_get_size(dataset->type), file_space, mem_space, dxpl_cache, dxpl_id, buf/*out*/); #ifdef H5S_DEBUG H5_timer_end(&(sconv->stats[1].read_timer), &timer); @@ -1297,8 +1299,9 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5 #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif + H5_CHECK_OVERFLOW(nelmts,hsize_t,size_t); status = (sconv->write)(dataset->ent.file, &(dataset->layout), - &dataset->dcpl_cache, (H5D_storage_t *)&(dataset->efl), H5T_get_size(dataset->type), + &dataset->dcpl_cache, (H5D_storage_t *)&(dataset->efl), (size_t)nelmts, H5T_get_size(dataset->type), file_space, mem_space, dxpl_cache, dxpl_id, buf); #ifdef H5S_DEBUG H5_timer_end(&(sconv->stats[0].write_timer), &timer); @@ -1505,8 +1508,6 @@ UNUSED size_t dst_type_size; /*size of destination type*/ size_t target_size; /*desired buffer size */ hsize_t request_nelmts; /*requested strip mine */ - hssize_t schunk_nelmts; /* Number of elements selected in current chunk */ - hsize_t chunk_nelmts; /* Number of elements selected in current chunk */ hsize_t smine_start; /*strip mine start loc */ hsize_t n, smine_nelmts; /*elements per strip */ H5S_sel_iter_t mem_iter; /*memory selection iteration info*/ @@ -1549,20 +1550,12 @@ UNUSED /* Get the actual chunk information from the tree node */ chunk_info=chunk_node->data; -#ifdef H5S_DEBUG - /* Get the number of elements selected in this chunk */ - if((schunk_nelmts=H5S_get_select_npoints(chunk_info->fspace))<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "bad # of elements in selection") - H5_ASSIGN_OVERFLOW(chunk_nelmts,schunk_nelmts,hssize_t,hsize_t); - assert(chunk_nelmts<=nelmts); -#endif /* H5S_DEBUG */ - /* Pass in chunk's coordinates in a union. */ store.chunk_coords = chunk_info->coords; /* Perform the actual read operation */ status = (sconv->read)(dataset->ent.file, &(dataset->layout), - &dataset->dcpl_cache, &store, H5T_get_size(dataset->type), + &dataset->dcpl_cache, &store, chunk_info->chunk_points, H5T_get_size(dataset->type), chunk_info->fspace, chunk_info->mspace, dxpl_cache, dxpl_id, buf); /* Check return value from optimized read */ @@ -1645,12 +1638,6 @@ UNUSED /* Get the actual chunk information from the tree nodes */ chunk_info=chunk_node->data; - /* Get the number of elements selected in this chunk */ - if((schunk_nelmts=H5S_get_select_npoints(chunk_info->fspace))<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "bad # of elements in selection") - H5_ASSIGN_OVERFLOW(chunk_nelmts,schunk_nelmts,hssize_t,hsize_t); - assert(chunk_nelmts<=nelmts); - /* initialize selection iterator */ if (H5S_select_iter_init(&file_iter, chunk_info->fspace, src_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information"); @@ -1665,10 +1652,10 @@ UNUSED /* Pass in chunk's coordinates in a union*/ store.chunk_coords = chunk_info->coords; - for (smine_start=0; smine_start<chunk_nelmts; smine_start+=smine_nelmts) { + for (smine_start=0; smine_start<chunk_info->chunk_points; smine_start+=smine_nelmts) { /* Go figure out how many elements to read from the file */ - assert(H5S_select_iter_nelmts(&file_iter)==(chunk_nelmts-smine_start)); - smine_nelmts = MIN(request_nelmts, (chunk_nelmts-smine_start)); + assert(H5S_select_iter_nelmts(&file_iter)==(chunk_info->chunk_points-smine_start)); + smine_nelmts = MIN(request_nelmts, (chunk_info->chunk_points-smine_start)); /* * Gather the data from disk into the data type conversion @@ -1817,8 +1804,6 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, size_t dst_type_size; /*size of destination type*/ size_t target_size; /*desired buffer size */ hsize_t request_nelmts; /*requested strip mine */ - hssize_t schunk_nelmts; /* Number of elements selected in current chunk */ - hsize_t chunk_nelmts; /* Number of elements selected in current chunk */ hsize_t smine_start; /*strip mine start loc */ hsize_t n, smine_nelmts; /*elements per strip */ H5S_sel_iter_t mem_iter; /*memory selection iteration info*/ @@ -1884,20 +1869,12 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, /* Get the actual chunk information from the tree node */ chunk_info=chunk_node->data; -#ifdef H5S_DEBUG - /* Get the number of elements selected in this chunk */ - if((schunk_nelmts=H5S_get_select_npoints(chunk_info->fspace))<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "bad # of elements in selection") - H5_ASSIGN_OVERFLOW(chunk_nelmts,schunk_nelmts,hssize_t,hsize_t); - assert(chunk_nelmts<=nelmts); -#endif /* H5S_DEBUG */ - /* Pass in chunk's coordinates in a union. */ store.chunk_coords = chunk_info->coords; /* Perform the actual write operation */ status = (sconv->write)(dataset->ent.file, &(dataset->layout), - &dataset->dcpl_cache, &store, H5T_get_size(dataset->type), + &dataset->dcpl_cache, &store, chunk_info->chunk_points, H5T_get_size(dataset->type), chunk_info->fspace, chunk_info->mspace, dxpl_cache, dxpl_id, buf); /* Check return value from optimized write */ @@ -2000,12 +1977,6 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, /* Get the actual chunk information from the tree node */ chunk_info=chunk_node->data; - /* Get the number of elements selected in this chunk */ - if((schunk_nelmts=H5S_get_select_npoints(chunk_info->fspace))<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "bad # of elements in selection") - H5_ASSIGN_OVERFLOW(chunk_nelmts,schunk_nelmts,hssize_t,hsize_t); - assert(chunk_nelmts<=nelmts); - /* initialize selection iterator */ if (H5S_select_iter_init(&file_iter, chunk_info->fspace, dst_type_size)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information"); @@ -2020,10 +1991,10 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, /*pass in chunk's coordinates in a union*/ store.chunk_coords = chunk_info->coords; - for (smine_start=0; smine_start<chunk_nelmts; smine_start+=smine_nelmts) { + for (smine_start=0; smine_start<chunk_info->chunk_points; smine_start+=smine_nelmts) { /* Go figure out how many elements to read from the file */ - assert(H5S_select_iter_nelmts(&file_iter)==(chunk_nelmts-smine_start)); - smine_nelmts = MIN(request_nelmts, (chunk_nelmts-smine_start)); + assert(H5S_select_iter_nelmts(&file_iter)==(chunk_info->chunk_points-smine_start)); + smine_nelmts = MIN(request_nelmts, (chunk_info->chunk_points-smine_start)); /* * Gather the data from disk into the data type conversion @@ -2341,7 +2312,7 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp /* Initialize "last chunk" information */ fm->last_index=(hsize_t)-1; - fm->last_chunk=NULL; + fm->last_chunk_info=NULL; /* Point at the dataspaces */ fm->file_space=file_space; @@ -2366,7 +2337,7 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp /* Reset "last chunk" info */ fm->last_index=(hsize_t)-1; - fm->last_chunk=NULL; + fm->last_chunk_info=NULL; } /* end if */ else { #ifdef QAK @@ -2658,8 +2629,8 @@ H5D_create_chunk_file_map_hyper(const fm_map *fm) /* Check for intersection of temporary chunk and file selection */ if(H5S_hyper_intersect_block(fm->file_space,coords,end)==TRUE) { H5S_t *tmp_fchunk; /* Temporary file dataspace */ - H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into tree */ - hssize_t chunk_points; /* Number of elements in chunk selection */ + H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into tree */ + hssize_t schunk_points; /* Number of elements in chunk selection */ /* Create "temporary" chunk for selection operations (copy file space) */ if((tmp_fchunk = H5S_copy(fm->file_space))==NULL) @@ -2722,11 +2693,12 @@ H5D_create_chunk_file_map_hyper(const fm_map *fm) } /* end if */ /* Get number of elements selected in chunk */ - if((chunk_points=H5S_get_select_npoints(tmp_fchunk))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements"); + if((schunk_points=H5S_get_select_npoints(tmp_fchunk))<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements") + H5_ASSIGN_OVERFLOW(new_chunk_info->chunk_points,schunk_points,hssize_t,hsize_t); /* Decrement # of points left in file selection */ - sel_points-=chunk_points; + sel_points-=schunk_points; /* Leave if we are done */ if(sel_points==0) @@ -2973,7 +2945,7 @@ static herr_t H5D_chunk_file_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize_t *coords, void *_fm) { fm_map *fm = (fm_map*)_fm; /* File<->memory chunk mapping info */ - H5S_t *fspace; /* Memory chunk's dataspace */ + H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */ hssize_t coords_in_chunk[H5O_LAYOUT_NDIMS]; /* Coordinates of element in chunk */ hsize_t chunk_index; /* Chunk index */ unsigned u; /* Local index variable */ @@ -2988,9 +2960,9 @@ H5D_chunk_file_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize /* Find correct chunk in file & memory TBBTs */ if(chunk_index==fm->last_index) { /* If the chunk index is the same as the last chunk index we used, - * get the cached spaces to operate on. + * get the cached info to operate on. */ - fspace=fm->last_chunk; + chunk_info=fm->last_chunk_info; } /* end if */ else { H5TB_NODE *chunk_node; /* TBBT node holding chunk information */ @@ -3000,7 +2972,8 @@ H5D_chunk_file_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize */ /* Get the chunk node from the TBBT */ if((chunk_node=H5TB_dfind(fm->fsel,&chunk_index,NULL))==NULL) { - H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into tree */ + H5D_chunk_info_t *new_chunk_info; /* Chunk information to insert into tree */ + H5S_t *fspace; /* Memory chunk's dataspace */ /* Allocate the file & memory chunk information */ if (NULL==(new_chunk_info = H5FL_MALLOC (H5D_chunk_info_t))) @@ -3031,6 +3004,9 @@ H5D_chunk_file_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize new_chunk_info->mspace=NULL; new_chunk_info->mspace_shared=0; + /* Set the number of selected elements in chunk to zero */ + new_chunk_info->chunk_points=0; + /* Compute the chunk's coordinates */ for(u=0; u<fm->f_ndims; u++) { H5_CHECK_OVERFLOW(fm->layout->dim[u],hsize_t,hssize_t); @@ -3043,14 +3019,17 @@ H5D_chunk_file_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize H5D_free_chunk_info(new_chunk_info); HGOTO_ERROR(H5E_DATASPACE,H5E_CANTINSERT,FAIL,"can't insert chunk into TBBT") } /* end if */ + + /* Save the chunk info pointer */ + chunk_info=new_chunk_info; } /* end if */ else - /* Get the memory space information from the node */ - fspace=((H5D_chunk_info_t *)(chunk_node->data))->fspace; + /* Get the information from the node */ + chunk_info=(H5D_chunk_info_t *)(chunk_node->data); /* Update the "last chunk seen" information */ fm->last_index=chunk_index; - fm->last_chunk=fspace; + fm->last_chunk_info=chunk_info; } /* end else */ /* Get the coordinates of the element in the chunk */ @@ -3058,9 +3037,12 @@ H5D_chunk_file_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize coords_in_chunk[u]=coords[u]%fm->layout->dim[u]; /* Add point to file selection for chunk */ - if(H5S_select_elements(fspace,H5S_SELECT_APPEND,1,(const hssize_t **)coords_in_chunk)<0) + if(H5S_select_elements(chunk_info->fspace,H5S_SELECT_APPEND,1,(const hssize_t **)coords_in_chunk)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSELECT, FAIL, "unable to select element") + /* Increment the number of elemented selected in chunk */ + chunk_info->chunk_points++; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_file_cb() */ @@ -3087,7 +3069,7 @@ static herr_t H5D_chunk_mem_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize_t *coords, void *_fm) { fm_map *fm = (fm_map*)_fm; /* File<->memory chunk mapping info */ - H5S_t *mspace; /* Memory chunk's dataspace */ + H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */ hssize_t coords_in_mem[H5O_LAYOUT_NDIMS]; /* Coordinates of element in memory */ hsize_t chunk_index; /* Chunk index */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3103,7 +3085,7 @@ H5D_chunk_mem_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize_ /* If the chunk index is the same as the last chunk index we used, * get the cached spaces to operate on. */ - mspace=fm->last_chunk; + chunk_info=fm->last_chunk_info; } /* end if */ else { H5TB_NODE *chunk_node; /* TBBT node holding chunk information */ @@ -3115,22 +3097,19 @@ H5D_chunk_mem_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize_ if((chunk_node=H5TB_dfind(fm->fsel,&chunk_index,NULL))==NULL) HGOTO_ERROR(H5E_DATASPACE,H5E_NOTFOUND,FAIL,"can't locate chunk in TBBT") - /* Get the memory space information from the node */ - mspace=((H5D_chunk_info_t *)(chunk_node->data))->mspace; + /* Get the chunk info pointer */ + chunk_info=(H5D_chunk_info_t *)(chunk_node->data); /* Check if the chunk already has a memory space */ - if(mspace==NULL) { + if(chunk_info->mspace==NULL) { /* Copy the template memory chunk dataspace */ - if((mspace = H5S_copy(fm->mchunk_tmpl))==NULL) + if((chunk_info->mspace = H5S_copy(fm->mchunk_tmpl))==NULL) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy file space") - - /* Set the chunk's memory dataspace for later use */ - ((H5D_chunk_info_t *)(chunk_node->data))->mspace=mspace; } /* end else */ /* Update the "last chunk seen" information */ fm->last_index=chunk_index; - fm->last_chunk=mspace; + fm->last_chunk_info=chunk_info; } /* end else */ /* Get coordinates of selection iterator for memory */ @@ -3139,12 +3118,12 @@ H5D_chunk_mem_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize_ /* Add point to memory selection for chunk */ if(fm->msel_type==H5S_SEL_POINTS) { - if(H5S_select_elements(mspace,H5S_SELECT_APPEND,1,(const hssize_t **)coords_in_mem)<0) + if(H5S_select_elements(chunk_info->mspace,H5S_SELECT_APPEND,1,(const hssize_t **)coords_in_mem)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSELECT, FAIL, "unable to select element") } /* end if */ else { - if(H5S_hyper_add_span_element(mspace, fm->m_ndims, coords_in_mem)<0) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSELECT, FAIL, "unable to select element"); + if(H5S_hyper_add_span_element(chunk_info->mspace, fm->m_ndims, coords_in_mem)<0) + HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSELECT, FAIL, "unable to select element") } /* end else */ /* Move memory selection iterator to next element in selection */ diff --git a/src/H5Smpio.c b/src/H5Smpio.c index 08632b9..209ca91 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -105,17 +105,22 @@ H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, hbool_t *is_derived_type ) { hsize_t total_bytes; + hssize_t snelmts; /*total number of elmts (signed) */ + hsize_t nelmts; /*total number of elmts */ unsigned u; + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_mpio_all_type); + FUNC_ENTER_NOAPI_NOINIT(H5S_mpio_all_type); /* Check args */ assert (space); /* Just treat the entire extent as a block of bytes */ - total_bytes = (hsize_t)elmt_size; - for (u=0; u<space->extent.u.simple.rank; ++u) - total_bytes *= space->extent.u.simple.size[u]; + if((snelmts = H5S_get_simple_extent_npoints(space))<0) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") + H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,hsize_t); + + total_bytes = (hsize_t)elmt_size*nelmts; /* fill in the return values */ *new_type = MPI_BYTE; @@ -123,7 +128,8 @@ H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, *extra_offset = 0; *is_derived_type = 0; - FUNC_LEAVE_NOAPI(SUCCEED); +done: + FUNC_LEAVE_NOAPI(ret_value); } /* H5S_mpio_all_type() */ @@ -740,7 +746,8 @@ done: */ herr_t H5S_mpio_spaces_read(H5F_t *f, const H5O_layout_t *layout, - const H5D_dcpl_cache_t UNUSED *dcpl_cache, const H5D_storage_t UNUSED *store, size_t elmt_size, + const H5D_dcpl_cache_t UNUSED *dcpl_cache, const H5D_storage_t UNUSED *store, + size_t UNUSED nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, const H5D_dxpl_cache_t UNUSED *dxpl_cache, hid_t dxpl_id, void *buf/*out*/) { @@ -778,7 +785,8 @@ done: */ herr_t H5S_mpio_spaces_write(H5F_t *f, H5O_layout_t *layout, - const H5D_dcpl_cache_t UNUSED *dcpl_cache, const H5D_storage_t UNUSED *store, size_t elmt_size, + const H5D_dcpl_cache_t UNUSED *dcpl_cache, const H5D_storage_t UNUSED *store, + size_t UNUSED nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, const H5D_dxpl_cache_t UNUSED *dxpl_cache, hid_t dxpl_id, const void *buf) { diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 3144dab..313c206 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -252,14 +252,14 @@ H5_DLL herr_t H5S_none_get_seq_list(const H5S_t *space, unsigned flags, /* MPI-IO function to read directly from app buffer to file rky980813 */ H5_DLL herr_t H5S_mpio_spaces_read(H5F_t *f, const struct H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_cache, const H5D_storage_t *store, - size_t elmt_size, const H5S_t *file_space, + size_t nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, 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, struct H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_cache, const H5D_storage_t *store, - size_t elmt_size, const H5S_t *file_space, + size_t nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const void *buf); diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index c3dc4e2..343fa2a 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -139,7 +139,7 @@ typedef struct H5S_conv_t { /* Read from file to application w/o intermediate scratch buffer */ herr_t (*read)(H5F_t *f, const struct H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_cache, const union H5D_storage_t *store, - size_t elmt_size, const H5S_t *file_space, + size_t nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, void *buf/*out*/); @@ -147,7 +147,7 @@ typedef struct H5S_conv_t { /* Write directly from app buffer to file */ herr_t (*write)(H5F_t *f, struct H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_cache, const union H5D_storage_t *store, - size_t elmt_size, const H5S_t *file_space, + size_t nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const void *buf); @@ -217,11 +217,11 @@ H5_DLL hsize_t H5S_select_mgath (const void *_buf, const H5S_t *space, H5S_sel_iter_t *iter, hsize_t nelmts, const H5D_dxpl_cache_t *dxpl_cache, void *_tgath_buf/*out*/); H5_DLL herr_t H5S_select_read(H5F_t *f, const struct H5O_layout_t *layout, - const H5D_dcpl_cache_t *dcpl_cache, const union H5D_storage_t *store, size_t elmt_size, + const H5D_dcpl_cache_t *dcpl_cache, const union H5D_storage_t *store, size_t nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, void *buf/*out*/); H5_DLL herr_t H5S_select_write(H5F_t *f, struct H5O_layout_t *layout, - const H5D_dcpl_cache_t *dcpl_cache, const union H5D_storage_t *store, size_t elmt_size, + const H5D_dcpl_cache_t *dcpl_cache, const union H5D_storage_t *store, size_t nelmts, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const void *buf/*out*/); H5_DLL htri_t H5S_select_valid(const H5S_t *space); diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 16eaa22..2a017b1 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -1805,8 +1805,9 @@ done: */ herr_t H5S_select_read(H5F_t *f, const H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_cache, - const H5D_storage_t *store, size_t elmt_size, const H5S_t *file_space, - const H5S_t *mem_space, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, + const H5D_storage_t *store, size_t nelmts, size_t elmt_size, + const H5S_t *file_space, const H5S_t *mem_space, + const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, void *buf/*out*/) { H5S_sel_iter_t mem_iter; /* Memory selection iteration info */ @@ -1821,7 +1822,6 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, const H5D_dcpl_cache_t *dc size_t *mem_len=NULL; /* Pointer to sequence lengths in memory */ size_t _file_len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths in the file */ size_t *file_len=NULL; /* Pointer to sequence lengths in the file */ - size_t maxelem; /* Number of elements in selection */ size_t mem_nseq; /* Number of sequences generated in the file */ size_t file_nseq; /* Number of sequences generated in memory */ size_t mem_nelem; /* Number of elements used in memory sequences */ @@ -1867,26 +1867,16 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, const H5D_dcpl_cache_t *dc file_off=_file_off; } /* end else */ - /* Get number of bytes in selection */ -#ifndef NDEBUG - { - hsize_t tmp_maxelem=H5S_get_select_npoints(file_space); - H5_ASSIGN_OVERFLOW(maxelem,tmp_maxelem,hsize_t,size_t); - } -#else /* NDEBUG */ - maxelem=(size_t)H5S_get_select_npoints(file_space); -#endif /* NDEBUG */ - /* Initialize sequence counts */ curr_mem_seq=curr_file_seq=0; mem_nseq=file_nseq=0; /* Loop, until all bytes are processed */ - while(maxelem>0) { + while(nelmts>0) { /* Check if more file sequences are needed */ if(curr_file_seq>=file_nseq) { /* Get sequences for file selection */ - if((*file_space->select.get_seq_list)(file_space,H5S_GET_SEQ_LIST_SORTED,&file_iter,dxpl_cache->vec_size,maxelem,&file_nseq,&file_nelem,file_off,file_len)<0) + if((*file_space->select.get_seq_list)(file_space,H5S_GET_SEQ_LIST_SORTED,&file_iter,dxpl_cache->vec_size,nelmts,&file_nseq,&file_nelem,file_off,file_len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed"); /* Start at the beginning of the sequences again */ @@ -1896,7 +1886,7 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, const H5D_dcpl_cache_t *dc /* Check if more memory sequences are needed */ if(curr_mem_seq>=mem_nseq) { /* Get sequences for memory selection */ - if((*mem_space->select.get_seq_list)(mem_space,0,&mem_iter,dxpl_cache->vec_size,maxelem,&mem_nseq,&mem_nelem,mem_off,mem_len)<0) + if((*mem_space->select.get_seq_list)(mem_space,0,&mem_iter,dxpl_cache->vec_size,nelmts,&mem_nseq,&mem_nelem,mem_off,mem_len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed"); /* Start at the beginning of the sequences again */ @@ -1918,7 +1908,7 @@ HDfprintf(stderr,"%s: mem_off[%Zu]=%Hu, mem_len[%Zu]=%Zu\n",FUNC,curr_mem_seq,me /* Decrement number of elements left to process */ assert((tmp_file_len%elmt_size)==0); - maxelem-=(tmp_file_len/elmt_size); + nelmts-=(tmp_file_len/elmt_size); } /* end while */ done: @@ -1965,8 +1955,9 @@ done: */ herr_t H5S_select_write(H5F_t *f, H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_cache, - const H5D_storage_t *store, size_t elmt_size, const H5S_t *file_space, - const H5S_t *mem_space, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, + const H5D_storage_t *store, size_t nelmts, size_t elmt_size, + const H5S_t *file_space, const H5S_t *mem_space, + const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const void *buf/*out*/) { H5S_sel_iter_t mem_iter; /* Memory selection iteration info */ @@ -1981,7 +1972,6 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_ca size_t *mem_len=NULL; /* Pointer to sequence lengths in memory */ size_t _file_len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths in the file */ size_t *file_len=NULL; /* Pointer to sequence lengths in the file */ - size_t maxelem; /* Number of elements in selection */ size_t mem_nseq; /* Number of sequences generated in the file */ size_t file_nseq; /* Number of sequences generated in memory */ size_t mem_nelem; /* Number of elements used in memory sequences */ @@ -2036,22 +2026,12 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_ca HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator"); mem_iter_init=1; /* Memory selection iteration info has been initialized */ - /* Get number of bytes in selection */ -#ifndef NDEBUG - { - hsize_t tmp_maxelem=H5S_get_select_npoints(file_space); - H5_ASSIGN_OVERFLOW(maxelem,tmp_maxelem,hsize_t,size_t); - } -#else /* NDEBUG */ - maxelem=(size_t)H5S_get_select_npoints(file_space); -#endif /* NDEBUG */ - /* Initialize sequence counts */ curr_mem_seq=curr_file_seq=0; mem_nseq=file_nseq=0; /* Loop, until all bytes are processed */ - while(maxelem>0) { + while(nelmts>0) { /* Check if more file sequences are needed */ #ifdef QAK { @@ -2064,7 +2044,7 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_ca #endif /* QAK */ if(curr_file_seq>=file_nseq) { /* Get sequences for file selection */ - if((*file_space->select.get_seq_list)(file_space,H5S_GET_SEQ_LIST_SORTED,&file_iter,dxpl_cache->vec_size,maxelem,&file_nseq,&file_nelem,file_off,file_len)<0) + if((*file_space->select.get_seq_list)(file_space,H5S_GET_SEQ_LIST_SORTED,&file_iter,dxpl_cache->vec_size,nelmts,&file_nseq,&file_nelem,file_off,file_len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed"); /* Start at the beginning of the sequences again */ @@ -2083,7 +2063,7 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_ca /* Check if more memory sequences are needed */ if(curr_mem_seq>=mem_nseq) { /* Get sequences for memory selection */ - if((*mem_space->select.get_seq_list)(mem_space,0,&mem_iter,dxpl_cache->vec_size,maxelem,&mem_nseq,&mem_nelem,mem_off,mem_len)<0) + if((*mem_space->select.get_seq_list)(mem_space,0,&mem_iter,dxpl_cache->vec_size,nelmts,&mem_nseq,&mem_nelem,mem_off,mem_len)<0) HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed"); /* Start at the beginning of the sequences again */ @@ -2120,7 +2100,7 @@ for(u=curr_mem_seq; u<mem_nseq; u++) /* Decrement number of elements left to process */ assert((tmp_file_len%elmt_size)==0); - maxelem-=(tmp_file_len/elmt_size); + nelmts-=(tmp_file_len/elmt_size); } /* end while */ done: |