Core changes to selection code from the hyperslab_updates branch.

This commit is contained in:
Quincey Koziol 2019-03-15 20:14:41 -05:00
parent 07baf44a86
commit 9d86314f8b
20 changed files with 6676 additions and 2765 deletions

View File

@ -276,6 +276,8 @@ static hbool_t H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last,
static herr_t H5D__free_chunk_info(void *item, void *key, void *opdata); static herr_t H5D__free_chunk_info(void *item, void *key, void *opdata);
static herr_t H5D__create_chunk_map_single(H5D_chunk_map_t *fm, static herr_t H5D__create_chunk_map_single(H5D_chunk_map_t *fm,
const H5D_io_info_t *io_info); const H5D_io_info_t *io_info);
static herr_t H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm,
const H5D_io_info_t *io_info);
static herr_t H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, static herr_t H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm,
const H5D_io_info_t *io_info); const H5D_io_info_t *io_info);
static herr_t H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm); static herr_t H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm);
@ -1044,7 +1046,6 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */
unsigned f_ndims; /* The number of dimensions of the file's dataspace */ 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) */ int sm_ndims; /* The number of dimensions of the memory buffer's dataspace (signed) */
H5SL_node_t *curr_node; /* Current node in skip list */
char bogus; /* "bogus" buffer to pass to selection iterator */ char bogus; /* "bogus" buffer to pass to selection iterator */
unsigned u; /* Local index variable */ unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
@ -1168,25 +1169,17 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
/* Check if file selection is a not a hyperslab selection */ /* Check if file selection is a not a hyperslab selection */
if(sel_hyper_flag) { if(sel_hyper_flag) {
/* Build the file selection for each chunk */ /* Build the file selection for each chunk */
if(H5D__create_chunk_file_map_hyper(fm, io_info) < 0) if(H5S_SEL_ALL == fm->fsel_type) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") 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);
/* Clean file chunks' hyperslab span "scratch" information */ if(H5D__create_chunk_file_map_hyper(fm, io_info) < 0)
curr_node = H5SL_first(fm->sel_chunks); HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections")
while(curr_node) { } /* end else */
H5D_chunk_info_t *chunk_info; /* Pointer chunk information */
/* Get pointer to chunk's information */
chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node);
HDassert(chunk_info);
/* Clean hyperslab span's "scratch" information */
if(H5S_hyper_reset_scratch(chunk_info->fspace) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset span scratch info")
/* Get the next chunk node in the skip list */
curr_node = H5SL_next(curr_node);
} /* end while */
} /* end if */ } /* end if */
else { else {
H5S_sel_iter_op_t iter_op; /* Operator for iteration */ H5S_sel_iter_op_t iter_op; /* Operator for iteration */
@ -1248,7 +1241,7 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
/* Create selection iterator for memory selection */ /* Create selection iterator for memory selection */
if(0 == (elmt_size = H5T_get_size(mem_type))) if(0 == (elmt_size = H5T_get_size(mem_type)))
HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid") HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid")
if(H5S_select_iter_init(&(fm->mem_iter), mem_space, elmt_size) < 0) if(H5S_select_iter_init(&(fm->mem_iter), mem_space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
iter_init = TRUE; /* Selection iteration info has been initialized */ iter_init = TRUE; /* Selection iteration info has been initialized */
@ -1258,26 +1251,6 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
/* Spaces aren't the same shape, iterate over the memory selection directly */ /* Spaces aren't the same shape, iterate over the memory selection directly */
if(H5S_select_iterate(&bogus, file_type, file_space, &iter_op, fm) < 0) if(H5S_select_iterate(&bogus, file_type, file_space, &iter_op, fm) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create memory chunk selections") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create memory chunk selections")
/* Clean up hyperslab stuff, if necessary */
if(fm->msel_type != H5S_SEL_POINTS) {
/* Clean memory chunks' hyperslab span "scratch" information */
curr_node = H5SL_first(fm->sel_chunks);
while(curr_node) {
H5D_chunk_info_t *chunk_info; /* Pointer chunk information */
/* Get pointer to chunk's information */
chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node);
HDassert(chunk_info);
/* Clean hyperslab span's "scratch" information */
if(H5S_hyper_reset_scratch(chunk_info->mspace) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset span scratch info")
/* Get the next chunk node in the skip list */
curr_node = H5SL_next(curr_node);
} /* end while */
} /* end if */
} /* end else */ } /* end else */
} /* end else */ } /* end else */
@ -1531,6 +1504,211 @@ done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__create_chunk_map_single() */ } /* end H5D__create_chunk_map_single() */
/*-------------------------------------------------------------------------
* Function: H5D__create_chunk_file_map_all
*
* Purpose: Create all chunk selections in file, for an "all" selection.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Monday, January 21, 2019
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t
#ifndef H5_HAVE_PARALLEL
H5_ATTR_UNUSED
#endif /* H5_HAVE_PARALLEL */
*io_info)
{
H5S_t *tmp_fchunk = NULL; /* Temporary file dataspace */
hsize_t file_dims[H5S_MAX_RANK]; /* File dataspace dims */
hsize_t sel_points; /* Number of elements in file selection */
hsize_t zeros[H5S_MAX_RANK]; /* All zero vector (for start parameter to setting hyperslab on partial chunks) */
hsize_t coords[H5S_MAX_RANK]; /* Current coordinates of chunk */
hsize_t end[H5S_MAX_RANK]; /* Final coordinates of chunk */
hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */
hsize_t chunk_index; /* "Index" of chunk */
hsize_t curr_partial_clip[H5S_MAX_RANK]; /* Current partial dimension sizes to clip against */
hsize_t partial_dim_size[H5S_MAX_RANK]; /* Size of a partial dimension */
hbool_t is_partial_dim[H5S_MAX_RANK]; /* Whether a dimension is currently a partial chunk */
unsigned num_partial_dims; /* Current number of partial dimensions */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Sanity check */
HDassert(fm->f_ndims > 0);
/* Get number of elements selected in file */
sel_points = fm->nelmts;
/* Get dataspace dimensions */
if(H5S_get_simple_extent_dims(fm->file_space, file_dims, NULL) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info")
/* Set initial chunk location, partial dimensions, etc */
num_partial_dims = 0;
HDmemset(zeros, 0, sizeof(zeros));
for(u = 0; u < fm->f_ndims; u++) {
/* Validate this chunk dimension */
if(fm->layout->u.chunk.dim[u] == 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u)
/* Set up start / end coordinates for first chunk */
scaled[u] = 0;
coords[u] = 0;
end[u] = fm->chunk_dim[u] - 1;
/* Iniitialize partial chunk dimension information */
partial_dim_size[u] = file_dims[u] % fm->chunk_dim[u];
if(file_dims[u] < fm->chunk_dim[u]) {
curr_partial_clip[u] = partial_dim_size[u];
is_partial_dim[u] = TRUE;
num_partial_dims++;
} /* end if */
else {
curr_partial_clip[u] = fm->chunk_dim[u];
is_partial_dim[u] = FALSE;
} /* end else */
} /* end for */
/* Set the index of this chunk */
chunk_index = 0;
/* Create "temporary" chunk for selection operations (copy file space) */
if(NULL == (tmp_fchunk = H5S_create_simple(fm->f_ndims, fm->chunk_dim, NULL)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "unable to create dataspace for chunk")
/* Iterate through each chunk in the dataset */
while(sel_points) {
H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */
hssize_t schunk_points; /* Number of elements in chunk selection */
/* Add temporary chunk to the list of chunks */
/* Allocate the file & memory chunk information */
if(NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk info")
/* Initialize the chunk information */
/* Set the chunk index */
new_chunk_info->index = chunk_index;
#ifdef H5_HAVE_PARALLEL
/* Store chunk selection information, for multi-chunk I/O */
if(io_info->using_mpi_vfd)
fm->select_chunk[chunk_index] = new_chunk_info;
#endif /* H5_HAVE_PARALLEL */
/* Set the file chunk dataspace */
if(NULL == (new_chunk_info->fspace = H5S_copy(tmp_fchunk, TRUE, FALSE)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy chunk dataspace")
new_chunk_info->fspace_shared = FALSE;
/* If there are partial dimensions for this chunk, set the hyperslab for them */
if(num_partial_dims > 0)
if(H5S_select_hyperslab(new_chunk_info->fspace, H5S_SELECT_SET, zeros, NULL, curr_partial_clip, NULL) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't create chunk selection")
/* Set the memory chunk dataspace */
new_chunk_info->mspace = NULL;
new_chunk_info->mspace_shared = FALSE;
/* Copy the chunk's scaled coordinates */
HDmemcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims);
new_chunk_info->scaled[fm->f_ndims] = 0;
/* Insert the new chunk into the skip list */
if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) {
H5D__free_chunk_info(new_chunk_info, NULL, NULL);
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert chunk into skip list")
} /* end if */
/* Get number of elements selected in chunk */
if((schunk_points = H5S_GET_SELECT_NPOINTS(new_chunk_info->fspace)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements")
H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, schunk_points, hssize_t);
/* Decrement # of points left in file selection */
sel_points -= (hsize_t)schunk_points;
/* Advance to next chunk if we are not done */
if(sel_points > 0) {
int curr_dim; /* Current dimension to increment */
/* Increment chunk index */
chunk_index++;
/* Set current increment dimension */
curr_dim = (int)fm->f_ndims - 1;
/* Increment chunk location in fastest changing dimension */
coords[curr_dim] += fm->chunk_dim[curr_dim];
scaled[curr_dim]++;
end[curr_dim] += fm->chunk_dim[curr_dim];
/* Bring chunk location back into bounds, if necessary */
if(coords[curr_dim] >= file_dims[curr_dim]) {
do {
/* Reset current dimension's location to 0 */
coords[curr_dim] = 0;
scaled[curr_dim] = 0;
end[curr_dim] = fm->chunk_dim[curr_dim] - 1;
/* Check for previous partial chunk in this dimension */
if(is_partial_dim[curr_dim] && end[curr_dim] < file_dims[curr_dim]) {
/* Sanity check */
HDassert(num_partial_dims > 0);
/* Reset partial chunk information for this dimension */
curr_partial_clip[curr_dim] = fm->chunk_dim[curr_dim];
is_partial_dim[curr_dim] = FALSE;
num_partial_dims--;
} /* end if */
/* Decrement current dimension */
curr_dim--;
/* Check for valid current dim */
if(curr_dim >= 0) {
/* Increment chunk location in current dimension */
coords[curr_dim] += fm->chunk_dim[curr_dim];
scaled[curr_dim]++;
end[curr_dim] = (coords[curr_dim] + fm->chunk_dim[curr_dim]) - 1;
} /* end if */
} while(curr_dim >= 0 && (coords[curr_dim] >= file_dims[curr_dim]));
} /* end if */
/* Check for valid current dim */
if(curr_dim >= 0) {
/* Check for partial chunk in this dimension */
if(!is_partial_dim[curr_dim] && file_dims[curr_dim] <= end[curr_dim]) {
/* Set partial chunk information for this dimension */
curr_partial_clip[curr_dim] = partial_dim_size[curr_dim];
is_partial_dim[curr_dim] = TRUE;
num_partial_dims++;
/* Sanity check */
HDassert(num_partial_dims <= fm->f_ndims);
} /* end if */
} /* end if */
} /* end if */
} /* end while */
done:
/* Clean up */
if(tmp_fchunk && H5S_close(tmp_fchunk) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release temporary dataspace")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__create_chunk_file_map_all() */
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function: H5D__create_chunk_file_map_hyper * Function: H5D__create_chunk_file_map_hyper
@ -1551,6 +1729,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
#endif /* H5_HAVE_PARALLEL */ #endif /* H5_HAVE_PARALLEL */
*io_info) *io_info)
{ {
H5S_t *tmp_fchunk = NULL; /* Temporary file dataspace */
hsize_t sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */ hsize_t sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */
hsize_t sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */ hsize_t sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */
hsize_t sel_points; /* Number of elements in file selection */ hsize_t sel_points; /* Number of elements in file selection */
@ -1594,45 +1773,28 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
/* Check for intersection of current chunk and file selection */ /* Check for intersection of current chunk and file selection */
/* (Casting away const OK - QAK) */ /* (Casting away const OK - QAK) */
if(TRUE == H5S_hyper_intersect_block((H5S_t *)fm->file_space, coords, end)) { if(TRUE == H5S_hyper_intersect_block((H5S_t *)fm->file_space, coords, end)) {
H5S_t *tmp_fchunk; /* Temporary file dataspace */
H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */
hssize_t schunk_points; /* Number of elements in chunk selection */ hssize_t schunk_points; /* Number of elements in chunk selection */
/* Create "temporary" chunk for selection operations (copy file space) */ /* Create dataspace for chunk, 'AND'ing the overall selection with
if(NULL == (tmp_fchunk = H5S_copy(fm->file_space, TRUE, FALSE))) * the current chunk.
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") */
if(H5S_combine_hyperslab(fm->file_space, H5S_SELECT_AND, coords, NULL, fm->chunk_dim, NULL, &tmp_fchunk) < 0)
/* Make certain selections are stored in span tree form (not "optimized hyperslab" or "all") */ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to combine file space selection with chunk block")
if(H5S_hyper_convert(tmp_fchunk) < 0) {
(void)H5S_close(tmp_fchunk);
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to convert selection to span trees")
} /* end if */
/* "AND" temporary chunk and current chunk */
if(H5S_select_hyperslab(tmp_fchunk,H5S_SELECT_AND,coords,NULL,fm->chunk_dim,NULL) < 0) {
(void)H5S_close(tmp_fchunk);
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't create chunk selection")
} /* end if */
/* Resize chunk's dataspace dimensions to size of chunk */ /* Resize chunk's dataspace dimensions to size of chunk */
if(H5S_set_extent_real(tmp_fchunk,fm->chunk_dim) < 0) { if(H5S_set_extent_real(tmp_fchunk, fm->chunk_dim) < 0)
(void)H5S_close(tmp_fchunk); HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't adjust chunk dimensions")
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk dimensions")
} /* end if */
/* Move selection back to have correct offset in chunk */ /* Move selection back to have correct offset in chunk */
if(H5S_SELECT_ADJUST_U(tmp_fchunk, coords) < 0) { if(H5S_SELECT_ADJUST_U(tmp_fchunk, coords) < 0)
(void)H5S_close(tmp_fchunk); HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't adjust chunk selection")
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection")
}
/* Add temporary chunk to the list of chunks */ /* Add temporary chunk to the list of chunks */
/* Allocate the file & memory chunk information */ /* Allocate the file & memory chunk information */
if(NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) { if(NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t)))
(void)H5S_close(tmp_fchunk); HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk info")
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info")
} /* end if */
/* Initialize the chunk information */ /* Initialize the chunk information */
@ -1648,6 +1810,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
/* Set the file chunk dataspace */ /* Set the file chunk dataspace */
new_chunk_info->fspace = tmp_fchunk; new_chunk_info->fspace = tmp_fchunk;
new_chunk_info->fspace_shared = FALSE; new_chunk_info->fspace_shared = FALSE;
tmp_fchunk = NULL;
/* Set the memory chunk dataspace */ /* Set the memory chunk dataspace */
new_chunk_info->mspace = NULL; new_chunk_info->mspace = NULL;
@ -1664,7 +1827,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
} /* end if */ } /* end if */
/* Get number of elements selected in chunk */ /* Get number of elements selected in chunk */
if((schunk_points = H5S_GET_SELECT_NPOINTS(tmp_fchunk)) < 0) if((schunk_points = H5S_GET_SELECT_NPOINTS(new_chunk_info->fspace)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements")
H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, schunk_points, hssize_t); H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, schunk_points, hssize_t);
@ -1713,6 +1876,11 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
} /* end while */ } /* end while */
done: done:
/* Clean up on failure */
if(ret_value < 0)
if(tmp_fchunk && H5S_close(tmp_fchunk) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release temporary dataspace")
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__create_chunk_file_map_hyper() */ } /* end H5D__create_chunk_file_map_hyper() */
@ -1736,13 +1904,13 @@ done:
static herr_t static herr_t
H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) H5D__create_chunk_mem_map_hyper(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 */ 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_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 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_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 */ 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 */ hssize_t adjust[H5S_MAX_RANK]; /* Adjustment to make to all file chunks */
hssize_t chunk_adjust[H5S_MAX_RANK]; /* Adjustment to make to a particular chunk */
unsigned u; /* Local index variable */ unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
@ -1753,8 +1921,6 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm)
/* Check for all I/O going to a single chunk */ /* Check for all I/O going to a single chunk */
if(H5SL_count(fm->sel_chunks)==1) { if(H5SL_count(fm->sel_chunks)==1) {
H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */
/* Get the node */ /* Get the node */
curr_node = H5SL_first(fm->sel_chunks); curr_node = H5SL_first(fm->sel_chunks);
@ -1789,41 +1955,61 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm)
/* Iterate over each chunk in the chunk list */ /* Iterate over each chunk in the chunk list */
curr_node = H5SL_first(fm->sel_chunks); curr_node = H5SL_first(fm->sel_chunks);
while(curr_node) { while(curr_node) {
H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ hsize_t coords[H5S_MAX_RANK]; /* Current coordinates of chunk */
hssize_t chunk_adjust[H5S_MAX_RANK]; /* Adjustment to make to a particular chunk */
H5S_sel_type chunk_sel_type; /* Chunk's selection type */
/* Get pointer to chunk's information */ /* Get pointer to chunk's information */
chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node); chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node);
HDassert(chunk_info); HDassert(chunk_info);
/* Compute the chunk coordinates from the scaled coordinates */
for(u = 0; u < fm->f_ndims; u++)
coords[u] = chunk_info->scaled[u] * fm->layout->u.chunk.dim[u];
/* Copy the information */ /* Copy the information */
/* Copy the memory dataspace */ /* Copy the memory dataspace */
if((chunk_info->mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) if((chunk_info->mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space")
/* Release the current selection */ /* Get the chunk's selection type */
if(H5S_SELECT_RELEASE(chunk_info->mspace) < 0) if((chunk_sel_type = H5S_GET_SELECT_TYPE(chunk_info->fspace)) < H5S_SEL_NONE)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection") HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to get type of selection")
/* Copy the file chunk's selection */ /* Set memory selection for "all" chunk selections */
if(H5S_select_copy(chunk_info->mspace,chunk_info->fspace,FALSE) < 0) if(H5S_SEL_ALL == chunk_sel_type) {
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy selection") /* Adjust the chunk coordinates */
for(u = 0; u < fm->f_ndims; u++)
coords[u] -= adjust[u];
/* Compute the adjustment for this chunk */ /* Set to same shape as chunk */
for(u = 0; u < fm->f_ndims; u++) { if(H5S_select_hyperslab(chunk_info->mspace, H5S_SELECT_SET, coords, NULL, fm->chunk_dim, NULL) < 0)
hsize_t coords[H5O_LAYOUT_NDIMS]; /* Current coordinates of chunk */ HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't create chunk memory selection")
} /* end if */
else {
/* Sanity check */
HDassert(H5S_SEL_HYPERSLABS == chunk_sel_type);
/* Compute the chunk coordinates from the scaled coordinates */ /* Release the current selection */
coords[u] = chunk_info->scaled[u] * fm->layout->u.chunk.dim[u]; if(H5S_SELECT_RELEASE(chunk_info->mspace) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection")
/* Compensate for the chunk offset */ /* Copy the file chunk's selection */
H5_CHECK_OVERFLOW(coords[u], hsize_t, hssize_t); if(H5S_select_copy(chunk_info->mspace, chunk_info->fspace, FALSE) < 0)
chunk_adjust[u] = adjust[u] - (hssize_t)coords[u]; /*lint !e771 The adjust array will always be initialized */ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy selection")
} /* end for */
/* Adjust the selection */ /* Compute the adjustment for this chunk */
if(H5S_hyper_adjust_s(chunk_info->mspace, chunk_adjust) < 0) for(u = 0; u < fm->f_ndims; u++) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to adjust selection") /* Compensate for the chunk offset */
H5_CHECK_OVERFLOW(coords[u], hsize_t, hssize_t);
chunk_adjust[u] = adjust[u] - (hssize_t)coords[u]; /*lint !e771 The adjust array will always be initialized */
} /* end for */
/* Adjust the selection */
if(H5S_hyper_adjust_s(chunk_info->mspace, chunk_adjust) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to adjust selection")
} /* end else */
/* Get the next chunk node in the skip list */ /* Get the next chunk node in the skip list */
curr_node = H5SL_next(curr_node); curr_node = H5SL_next(curr_node);
@ -4821,12 +5007,12 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk)
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk selection iterator") HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk selection iterator")
/* Create a selection iterator for scattering the elements to memory buffer */ /* Create a selection iterator for scattering the elements to memory buffer */
if(H5S_select_iter_init(chunk_iter, udata->chunk_space, layout->u.chunk.dim[rank]) < 0) if(H5S_select_iter_init(chunk_iter, udata->chunk_space, layout->u.chunk.dim[rank], 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunk selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunk selection information")
chunk_iter_init = TRUE; chunk_iter_init = TRUE;
/* Scatter the data into memory */ /* Scatter the data into memory */
if(H5D__scatter_mem(udata->fb_info.fill_buf, udata->chunk_space, chunk_iter, (size_t)sel_nelmts, chunk/*out*/) < 0) if(H5D__scatter_mem(udata->fb_info.fill_buf, chunk_iter, (size_t)sel_nelmts, chunk/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed") HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed")

View File

@ -275,12 +275,12 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf,
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory selection iterator") HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory selection iterator")
/* Create a selection iterator for scattering the elements to memory buffer */ /* Create a selection iterator for scattering the elements to memory buffer */
if(H5S_select_iter_init(mem_iter, space, dst_type_size) < 0) if(H5S_select_iter_init(mem_iter, space, dst_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE; mem_iter_init = TRUE;
/* Scatter the data into memory */ /* Scatter the data into memory */
if(H5D__scatter_mem(tmp_buf, space, mem_iter, (size_t)nelmts, buf/*out*/) < 0) if(H5D__scatter_mem(tmp_buf, mem_iter, (size_t)nelmts, buf/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed") HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed")
} /* end if */ } /* end if */
else { else {

View File

@ -2864,12 +2864,12 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty
HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "unable to encode dataspace") HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "unable to encode dataspace")
/* Initialize iterator for memory selection */ /* Initialize iterator for memory selection */
if(H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size) < 0) if(H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE; mem_iter_init = TRUE;
/* Collect the modification data into the buffer */ /* Collect the modification data into the buffer */
if(0 == H5D__gather_mem(io_info->u.wbuf, chunk_info->mspace, mem_iter, (size_t)iter_nelmts, mod_data_p)) if(0 == H5D__gather_mem(io_info->u.wbuf, mem_iter, (size_t)iter_nelmts, mod_data_p))
HGOTO_ERROR(H5E_IO, H5E_CANTGATHER, FAIL, "couldn't gather from write buffer") HGOTO_ERROR(H5E_IO, H5E_CANTGATHER, FAIL, "couldn't gather from write buffer")
/* Send modification data to new owner */ /* Send modification data to new owner */
@ -3170,7 +3170,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
if (NULL == (mem_iter = (H5S_sel_iter_t *) H5MM_malloc(sizeof(H5S_sel_iter_t)))) if (NULL == (mem_iter = (H5S_sel_iter_t *) H5MM_malloc(sizeof(H5S_sel_iter_t))))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate memory iterator") HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate memory iterator")
if(H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size) < 0) if(H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE; mem_iter_init = TRUE;
@ -3185,7 +3185,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
if(NULL == (file_iter = (H5S_sel_iter_t *) H5MM_malloc(sizeof(H5S_sel_iter_t)))) if(NULL == (file_iter = (H5S_sel_iter_t *) H5MM_malloc(sizeof(H5S_sel_iter_t))))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate file iterator") HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate file iterator")
if(H5S_select_iter_init(file_iter, chunk_info->fspace, type_info->src_type_size) < 0) if(H5S_select_iter_init(file_iter, chunk_info->fspace, type_info->src_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
file_iter_init = TRUE; file_iter_init = TRUE;
@ -3195,13 +3195,13 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
if(NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) iter_nelmts * type_info->src_type_size))) if(NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) iter_nelmts * type_info->src_type_size)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer") HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer")
if(!H5D__gather_mem(chunk_entry->buf, chunk_info->fspace, file_iter, (size_t) iter_nelmts, tmp_gath_buf)) if(!H5D__gather_mem(chunk_entry->buf, file_iter, (size_t) iter_nelmts, tmp_gath_buf))
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't gather from chunk buffer") HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't gather from chunk buffer")
if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0) if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
if(H5D__scatter_mem(tmp_gath_buf, chunk_info->mspace, mem_iter, (size_t) iter_nelmts, io_info->u.rbuf) < 0) if(H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t) iter_nelmts, io_info->u.rbuf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to read buffer") HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to read buffer")
break; break;
@ -3214,7 +3214,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer") HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer")
/* Gather modification data from the application write buffer into a temporary buffer */ /* Gather modification data from the application write buffer into a temporary buffer */
if(0 == H5D__gather_mem(io_info->u.wbuf, chunk_info->mspace, mem_iter, (size_t) iter_nelmts, tmp_gath_buf)) if(0 == H5D__gather_mem(io_info->u.wbuf, mem_iter, (size_t) iter_nelmts, tmp_gath_buf))
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "couldn't gather from write buffer") HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "couldn't gather from write buffer")
if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0) if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
@ -3222,7 +3222,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
mem_iter_init = FALSE; mem_iter_init = FALSE;
/* Initialize iterator for file selection */ /* Initialize iterator for file selection */
if(H5S_select_iter_init(mem_iter, chunk_info->fspace, type_info->dst_type_size) < 0) if(H5S_select_iter_init(mem_iter, chunk_info->fspace, type_info->dst_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information")
mem_iter_init = TRUE; mem_iter_init = TRUE;
@ -3232,7 +3232,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
/* Scatter the owner's modification data into the chunk data buffer according to /* Scatter the owner's modification data into the chunk data buffer according to
* the file space. * the file space.
*/ */
if(H5D__scatter_mem(tmp_gath_buf, chunk_info->fspace, mem_iter, (size_t) iter_nelmts, chunk_entry->buf) < 0) if(H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t) iter_nelmts, chunk_entry->buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to chunk data buffer") HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to chunk data buffer")
if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0) if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
@ -3254,7 +3254,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
if(NULL == (dataspace = H5S_decode(&mod_data_p))) if(NULL == (dataspace = H5S_decode(&mod_data_p)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTDECODE, FAIL, "unable to decode dataspace") HGOTO_ERROR(H5E_DATASET, H5E_CANTDECODE, FAIL, "unable to decode dataspace")
if(H5S_select_iter_init(mem_iter, dataspace, type_info->dst_type_size) < 0) if(H5S_select_iter_init(mem_iter, dataspace, type_info->dst_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE; mem_iter_init = TRUE;
@ -3262,7 +3262,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
/* Update the chunk data with the received modification data */ /* Update the chunk data with the received modification data */
if(H5D__scatter_mem(mod_data_p, dataspace, mem_iter, (size_t) iter_nelmts, chunk_entry->buf) < 0) if(H5D__scatter_mem(mod_data_p, mem_iter, (size_t) iter_nelmts, chunk_entry->buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "couldn't scatter to write buffer") HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "couldn't scatter to write buffer")
if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0) if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0)

View File

@ -591,10 +591,10 @@ H5_DLL herr_t H5D__select_write(const H5D_io_info_t *io_info,
hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space);
/* Functions that perform scatter-gather serial I/O operations */ /* Functions that perform scatter-gather serial I/O operations */
H5_DLL herr_t H5D__scatter_mem(const void *_tscat_buf, const H5S_t *space, H5_DLL herr_t H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter,
H5S_sel_iter_t *iter, size_t nelmts, void *_buf); size_t nelmts, void *_buf);
H5_DLL size_t H5D__gather_mem(const void *_buf, const H5S_t *space, H5_DLL size_t H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter,
H5S_sel_iter_t *iter, size_t nelmts, void *_tgath_buf/*out*/); size_t nelmts, void *_tgath_buf/*out*/);
H5_DLL herr_t H5D__scatgath_read(const H5D_io_info_t *io_info, H5_DLL herr_t H5D__scatgath_read(const H5D_io_info_t *io_info,
const H5D_type_info_t *type_info, const H5D_type_info_t *type_info,
hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space);

View File

@ -43,13 +43,11 @@
/* Local Prototypes */ /* Local Prototypes */
/********************/ /********************/
static herr_t H5D__scatter_file(const H5D_io_info_t *io_info, static herr_t H5D__scatter_file(const H5D_io_info_t *io_info,
const H5S_t *file_space, H5S_sel_iter_t *file_iter, size_t nelmts, H5S_sel_iter_t *file_iter, size_t nelmts, const void *buf);
const void *buf);
static size_t H5D__gather_file(const H5D_io_info_t *io_info, static size_t H5D__gather_file(const H5D_io_info_t *io_info,
const H5S_t *file_space, H5S_sel_iter_t *file_iter, size_t nelmts, H5S_sel_iter_t *file_iter, size_t nelmts, void *buf);
void *buf); static herr_t H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter,
static herr_t H5D__compound_opt_read(size_t nelmts, const H5S_t *mem_space, const H5D_type_info_t *type_info, void *user_buf/*out*/);
H5S_sel_iter_t *iter, const H5D_type_info_t *type_info, void *user_buf/*out*/);
static herr_t H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info); static herr_t H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info);
@ -90,9 +88,8 @@ H5FL_SEQ_EXTERN(hsize_t);
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
static herr_t static herr_t
H5D__scatter_file(const H5D_io_info_t *_io_info, H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter,
const H5S_t *space, H5S_sel_iter_t *iter, size_t nelmts, size_t nelmts, const void *_buf)
const void *_buf)
{ {
H5D_io_info_t tmp_io_info; /* Temporary I/O info object */ H5D_io_info_t tmp_io_info; /* Temporary I/O info object */
hsize_t *off = NULL; /* Pointer to sequence offsets */ hsize_t *off = NULL; /* Pointer to sequence offsets */
@ -111,7 +108,6 @@ H5D__scatter_file(const H5D_io_info_t *_io_info,
/* Check args */ /* Check args */
HDassert(_io_info); HDassert(_io_info);
HDassert(space);
HDassert(iter); HDassert(iter);
HDassert(nelmts > 0); HDassert(nelmts > 0);
HDassert(_buf); HDassert(_buf);
@ -138,7 +134,7 @@ H5D__scatter_file(const H5D_io_info_t *_io_info,
/* Loop until all elements are written */ /* Loop until all elements are written */
while(nelmts > 0) { while(nelmts > 0) {
/* Get list of sequences for selection to write */ /* Get list of sequences for selection to write */
if(H5S_SELECT_GET_SEQ_LIST(space, H5S_GET_SEQ_LIST_SORTED, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Reset the current sequence information */ /* Reset the current sequence information */
@ -191,9 +187,8 @@ done:
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
static size_t static size_t
H5D__gather_file(const H5D_io_info_t *_io_info, H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter,
const H5S_t *space, H5S_sel_iter_t *iter, size_t nelmts, size_t nelmts, void *_buf/*out*/)
void *_buf/*out*/)
{ {
H5D_io_info_t tmp_io_info; /* Temporary I/O info object */ H5D_io_info_t tmp_io_info; /* Temporary I/O info object */
hsize_t *off = NULL; /* Pointer to sequence offsets */ hsize_t *off = NULL; /* Pointer to sequence offsets */
@ -214,7 +209,6 @@ H5D__gather_file(const H5D_io_info_t *_io_info,
HDassert(_io_info); HDassert(_io_info);
HDassert(_io_info->dset); HDassert(_io_info->dset);
HDassert(_io_info->store); HDassert(_io_info->store);
HDassert(space);
HDassert(iter); HDassert(iter);
HDassert(nelmts > 0); HDassert(nelmts > 0);
HDassert(_buf); HDassert(_buf);
@ -241,7 +235,7 @@ H5D__gather_file(const H5D_io_info_t *_io_info,
/* Loop until all elements are read */ /* Loop until all elements are read */
while(nelmts > 0) { while(nelmts > 0) {
/* Get list of sequences for selection to read */ /* Get list of sequences for selection to read */
if(H5S_SELECT_GET_SEQ_LIST(space, H5S_GET_SEQ_LIST_SORTED, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Reset the current sequence information */ /* Reset the current sequence information */
@ -288,8 +282,8 @@ done:
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
herr_t herr_t
H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space, H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts,
H5S_sel_iter_t *iter, size_t nelmts, void *_buf/*out*/) void *_buf/*out*/)
{ {
uint8_t *buf = (uint8_t *)_buf; /* Get local copies for address arithmetic */ uint8_t *buf = (uint8_t *)_buf; /* Get local copies for address arithmetic */
const uint8_t *tscat_buf = (const uint8_t *)_tscat_buf; const uint8_t *tscat_buf = (const uint8_t *)_tscat_buf;
@ -307,7 +301,6 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
/* Check args */ /* Check args */
HDassert(tscat_buf); HDassert(tscat_buf);
HDassert(space);
HDassert(iter); HDassert(iter);
HDassert(nelmts > 0); HDassert(nelmts > 0);
HDassert(buf); HDassert(buf);
@ -329,7 +322,7 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
/* Loop until all elements are written */ /* Loop until all elements are written */
while(nelmts > 0) { while(nelmts > 0) {
/* Get list of sequences for selection to write */ /* Get list of sequences for selection to write */
if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Loop, while sequences left to process */ /* Loop, while sequences left to process */
@ -376,8 +369,8 @@ done:
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
size_t size_t
H5D__gather_mem(const void *_buf, const H5S_t *space, H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts,
H5S_sel_iter_t *iter, size_t nelmts, void *_tgath_buf/*out*/) void *_tgath_buf/*out*/)
{ {
const uint8_t *buf = (const uint8_t *)_buf; /* Get local copies for address arithmetic */ const uint8_t *buf = (const uint8_t *)_buf; /* Get local copies for address arithmetic */
uint8_t *tgath_buf = (uint8_t *)_tgath_buf; uint8_t *tgath_buf = (uint8_t *)_tgath_buf;
@ -395,7 +388,6 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
/* Check args */ /* Check args */
HDassert(buf); HDassert(buf);
HDassert(space);
HDassert(iter); HDassert(iter);
HDassert(nelmts > 0); HDassert(nelmts > 0);
HDassert(tgath_buf); HDassert(tgath_buf);
@ -417,7 +409,7 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
/* Loop until all elements are written */ /* Loop until all elements are written */
while(nelmts > 0) { while(nelmts > 0) {
/* Get list of sequences for selection to write */ /* Get list of sequences for selection to write */
if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Loop, while sequences left to process */ /* Loop, while sequences left to process */
@ -495,13 +487,13 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator") HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator")
/* Figure out the strip mine size. */ /* Figure out the strip mine size. */
if(H5S_select_iter_init(file_iter, file_space, type_info->src_type_size) < 0) if(H5S_select_iter_init(file_iter, file_space, type_info->src_type_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information")
file_iter_init = TRUE; /*file selection iteration info has been initialized */ file_iter_init = TRUE; /*file selection iteration info has been initialized */
if(H5S_select_iter_init(mem_iter, mem_space, type_info->dst_type_size) < 0) if(H5S_select_iter_init(mem_iter, mem_space, type_info->dst_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE; /*file selection iteration info has been initialized */ mem_iter_init = TRUE; /*file selection iteration info has been initialized */
if(H5S_select_iter_init(bkg_iter, mem_space, type_info->dst_type_size) < 0) if(H5S_select_iter_init(bkg_iter, mem_space, type_info->dst_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information")
bkg_iter_init = TRUE; /*file selection iteration info has been initialized */ bkg_iter_init = TRUE; /*file selection iteration info has been initialized */
@ -522,7 +514,7 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
/* /*
* Gather data * Gather data
*/ */
n = H5D__gather_file(io_info, file_space, file_iter, smine_nelmts, type_info->tconv_buf/*out*/); n = H5D__gather_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf/*out*/);
if(n != smine_nelmts) if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed")
@ -531,12 +523,12 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
* bypass the rest of steps. * bypass the rest of steps.
*/ */
if(type_info->cmpd_subset && H5T_SUBSET_FALSE != type_info->cmpd_subset->subset) { if(type_info->cmpd_subset && H5T_SUBSET_FALSE != type_info->cmpd_subset->subset) {
if(H5D__compound_opt_read(smine_nelmts, mem_space, mem_iter, type_info, buf /*out*/) < 0) if(H5D__compound_opt_read(smine_nelmts, mem_iter, type_info, buf /*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "datatype conversion failed") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "datatype conversion failed")
} /* end if */ } /* end if */
else { else {
if(H5T_BKG_YES == type_info->need_bkg) { if(H5T_BKG_YES == type_info->need_bkg) {
n = H5D__gather_mem(buf, mem_space, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/); n = H5D__gather_mem(buf, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/);
if(n != smine_nelmts) if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "mem gather failed") HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "mem gather failed")
} /* end if */ } /* end if */
@ -562,7 +554,7 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
} }
/* Scatter the data into memory */ /* Scatter the data into memory */
if(H5D__scatter_mem(type_info->tconv_buf, mem_space, mem_iter, smine_nelmts, buf/*out*/) < 0) if(H5D__scatter_mem(type_info->tconv_buf, mem_iter, smine_nelmts, buf/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed") HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed")
} /* end else */ } /* end else */
} /* end for */ } /* end for */
@ -635,13 +627,13 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator") HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator")
/* Figure out the strip mine size. */ /* Figure out the strip mine size. */
if(H5S_select_iter_init(file_iter, file_space, type_info->dst_type_size) < 0) if(H5S_select_iter_init(file_iter, file_space, type_info->dst_type_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information")
file_iter_init = TRUE; /*file selection iteration info has been initialized */ file_iter_init = TRUE; /*file selection iteration info has been initialized */
if(H5S_select_iter_init(mem_iter, mem_space, type_info->src_type_size) < 0) if(H5S_select_iter_init(mem_iter, mem_space, type_info->src_type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE; /*file selection iteration info has been initialized */ mem_iter_init = TRUE; /*file selection iteration info has been initialized */
if(H5S_select_iter_init(bkg_iter, file_space, type_info->dst_type_size) < 0) if(H5S_select_iter_init(bkg_iter, file_space, type_info->dst_type_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information")
bkg_iter_init = TRUE; /*file selection iteration info has been initialized */ bkg_iter_init = TRUE; /*file selection iteration info has been initialized */
@ -658,7 +650,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
* buffer. Also gather data from the file into the background buffer * buffer. Also gather data from the file into the background buffer
* if necessary. * if necessary.
*/ */
n = H5D__gather_mem(buf, mem_space, mem_iter, smine_nelmts, type_info->tconv_buf/*out*/); n = H5D__gather_mem(buf, mem_iter, smine_nelmts, type_info->tconv_buf/*out*/);
if(n != smine_nelmts) if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "mem gather failed") HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "mem gather failed")
@ -675,7 +667,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
} /* end if */ } /* end if */
else { else {
if(H5T_BKG_YES == type_info->need_bkg) { if(H5T_BKG_YES == type_info->need_bkg) {
n = H5D__gather_file(io_info, file_space, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/); n = H5D__gather_file(io_info, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/);
if(n != smine_nelmts) if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed")
} /* end if */ } /* end if */
@ -705,7 +697,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
/* /*
* Scatter the data out to the file. * Scatter the data out to the file.
*/ */
if(H5D__scatter_file(io_info, file_space, file_iter, smine_nelmts, type_info->tconv_buf) < 0) if(H5D__scatter_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed") HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed")
} /* end for */ } /* end for */
@ -761,7 +753,7 @@ done:
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
static herr_t static herr_t
H5D__compound_opt_read(size_t nelmts, const H5S_t *space, H5S_sel_iter_t *iter, H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter,
const H5D_type_info_t *type_info, void *user_buf/*out*/) const H5D_type_info_t *type_info, void *user_buf/*out*/)
{ {
uint8_t *ubuf = (uint8_t *)user_buf; /* Cast for pointer arithmetic */ uint8_t *ubuf = (uint8_t *)user_buf; /* Cast for pointer arithmetic */
@ -777,7 +769,6 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space, H5S_sel_iter_t *iter,
/* Check args */ /* Check args */
HDassert(nelmts > 0); HDassert(nelmts > 0);
HDassert(space);
HDassert(iter); HDassert(iter);
HDassert(type_info); HDassert(type_info);
HDassert(type_info->cmpd_subset); HDassert(type_info->cmpd_subset);
@ -814,7 +805,7 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space, H5S_sel_iter_t *iter,
size_t elmtno; /* Element counter */ size_t elmtno; /* Element counter */
/* Get list of sequences for selection to write */ /* Get list of sequences for selection to write */
if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, vec_size, nelmts, &nseq, &elmtno, off, len) < 0) if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &elmtno, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Loop, while sequences left to process */ /* Loop, while sequences left to process */
@ -981,7 +972,7 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
/* Initialize selection iterator */ /* Initialize selection iterator */
if(H5S_select_iter_init(iter, dst_space, type_size) < 0) if(H5S_select_iter_init(iter, dst_space, type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information")
iter_init = TRUE; iter_init = TRUE;
@ -1005,7 +996,7 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned more elements than in selection") HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned more elements than in selection")
/* Scatter data */ /* Scatter data */
if(H5D__scatter_mem(src_buf, dst_space, iter, nelmts_scatter, dst_buf) < 0) if(H5D__scatter_mem(src_buf, iter, nelmts_scatter, dst_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "scatter failed") HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "scatter failed")
nelmts -= (hssize_t)nelmts_scatter; nelmts -= (hssize_t)nelmts_scatter;
@ -1091,14 +1082,14 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
/* Initialize selection iterator */ /* Initialize selection iterator */
if(H5S_select_iter_init(iter, src_space, type_size) < 0) if(H5S_select_iter_init(iter, src_space, type_size, 0) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information") HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information")
iter_init = TRUE; iter_init = TRUE;
/* Loop until all data has been scattered */ /* Loop until all data has been scattered */
while(nelmts > 0) { while(nelmts > 0) {
/* Gather data */ /* Gather data */
if(0 == (nelmts_gathered = H5D__gather_mem(src_buf, src_space, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dst_buf))) if(0 == (nelmts_gathered = H5D__gather_mem(src_buf, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dst_buf)))
HGOTO_ERROR(H5E_IO, H5E_CANTCOPY, FAIL, "gather failed") HGOTO_ERROR(H5E_IO, H5E_CANTCOPY, FAIL, "gather failed")
HDassert(nelmts_gathered == MIN(dst_buf_nelmts, (size_t)nelmts)); HDassert(nelmts_gathered == MIN(dst_buf_nelmts, (size_t)nelmts));

View File

@ -175,12 +175,12 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator") HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator")
/* Initialize file iterator */ /* Initialize file iterator */
if(H5S_select_iter_init(file_iter, file_space, elmt_size) < 0) if(H5S_select_iter_init(file_iter, file_space, elmt_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
file_iter_init = 1; /* File selection iteration info has been initialized */ file_iter_init = 1; /* File selection iteration info has been initialized */
/* Initialize memory iterator */ /* Initialize memory iterator */
if(H5S_select_iter_init(mem_iter, mem_space, elmt_size) < 0) if(H5S_select_iter_init(mem_iter, mem_space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
mem_iter_init = 1; /* Memory selection iteration info has been initialized */ mem_iter_init = 1; /* Memory selection iteration info has been initialized */
@ -193,7 +193,7 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
/* Check if more file sequences are needed */ /* Check if more file sequences are needed */
if(curr_file_seq >= file_nseq) { if(curr_file_seq >= file_nseq) {
/* Get sequences for file selection */ /* Get sequences for file selection */
if(H5S_SELECT_GET_SEQ_LIST(file_space, H5S_GET_SEQ_LIST_SORTED, file_iter, vec_size, nelmts, &file_nseq, &file_nelem, file_off, file_len) < 0) if(H5S_SELECT_ITER_GET_SEQ_LIST(file_iter, vec_size, nelmts, &file_nseq, &file_nelem, file_off, file_len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Start at the beginning of the sequences again */ /* Start at the beginning of the sequences again */
@ -203,7 +203,7 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
/* Check if more memory sequences are needed */ /* Check if more memory sequences are needed */
if(curr_mem_seq >= mem_nseq) { if(curr_mem_seq >= mem_nseq) {
/* Get sequences for memory selection */ /* Get sequences for memory selection */
if(H5S_SELECT_GET_SEQ_LIST(mem_space, 0, mem_iter, vec_size, nelmts, &mem_nseq, &mem_nelem, mem_off, mem_len) < 0) if(H5S_SELECT_ITER_GET_SEQ_LIST(mem_iter, vec_size, nelmts, &mem_nseq, &mem_nelem, mem_off, mem_len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Start at the beginning of the sequences again */ /* Start at the beginning of the sequences again */

View File

@ -51,9 +51,6 @@
/* Selection callbacks */ /* Selection callbacks */
static herr_t H5S__all_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); static herr_t H5S__all_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
static herr_t H5S__all_get_seq_list(const H5S_t *space, unsigned flags,
H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
static herr_t H5S__all_release(H5S_t *space); static herr_t H5S__all_release(H5S_t *space);
static htri_t H5S__all_is_valid(const H5S_t *space); static htri_t H5S__all_is_valid(const H5S_t *space);
static hssize_t H5S__all_serial_size(const H5S_t *space); static hssize_t H5S__all_serial_size(const H5S_t *space);
@ -66,10 +63,11 @@ static int H5S__all_unlim_dim(const H5S_t *space);
static htri_t H5S__all_is_contiguous(const H5S_t *space); static htri_t H5S__all_is_contiguous(const H5S_t *space);
static htri_t H5S__all_is_single(const H5S_t *space); static htri_t H5S__all_is_single(const H5S_t *space);
static htri_t H5S__all_is_regular(const H5S_t *space); static htri_t H5S__all_is_regular(const H5S_t *space);
static htri_t H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2);
static herr_t H5S__all_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__all_adjust_u(H5S_t *space, const hsize_t *offset);
static herr_t H5S__all_project_scalar(const H5S_t *space, hsize_t *offset); static herr_t H5S__all_project_scalar(const H5S_t *space, hsize_t *offset);
static herr_t H5S__all_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); static herr_t H5S__all_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
static herr_t H5S__all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); static herr_t H5S__all_iter_init(const H5S_t *space, H5S_sel_iter_t *iter);
/* Selection iteration callbacks */ /* Selection iteration callbacks */
static herr_t H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); static herr_t H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
@ -78,6 +76,8 @@ static hsize_t H5S__all_iter_nelmts(const H5S_sel_iter_t *iter);
static htri_t H5S__all_iter_has_next_block(const H5S_sel_iter_t *iter); static htri_t H5S__all_iter_has_next_block(const H5S_sel_iter_t *iter);
static herr_t H5S__all_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); static herr_t H5S__all_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
static herr_t H5S__all_iter_next_block(H5S_sel_iter_t *sel_iter); static herr_t H5S__all_iter_next_block(H5S_sel_iter_t *sel_iter);
static herr_t H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq,
size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
static herr_t H5S__all_iter_release(H5S_sel_iter_t *sel_iter); static herr_t H5S__all_iter_release(H5S_sel_iter_t *sel_iter);
@ -96,7 +96,6 @@ const H5S_select_class_t H5S_sel_all[1] = {{
/* Methods on selection */ /* Methods on selection */
H5S__all_copy, H5S__all_copy,
H5S__all_get_seq_list,
H5S__all_release, H5S__all_release,
H5S__all_is_valid, H5S__all_is_valid,
H5S__all_serial_size, H5S__all_serial_size,
@ -109,6 +108,7 @@ const H5S_select_class_t H5S_sel_all[1] = {{
H5S__all_is_contiguous, H5S__all_is_contiguous,
H5S__all_is_single, H5S__all_is_single,
H5S__all_is_regular, H5S__all_is_regular,
H5S__all_shape_same,
H5S__all_adjust_u, H5S__all_adjust_u,
H5S__all_project_scalar, H5S__all_project_scalar,
H5S__all_project_simple, H5S__all_project_simple,
@ -131,6 +131,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{
H5S__all_iter_has_next_block, H5S__all_iter_has_next_block,
H5S__all_iter_next, H5S__all_iter_next,
H5S__all_iter_next_block, H5S__all_iter_next_block,
H5S__all_iter_get_seq_list,
H5S__all_iter_release, H5S__all_iter_release,
}}; }};
@ -149,7 +150,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
static herr_t static herr_t
H5S__all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) H5S__all_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter)
{ {
FUNC_ENTER_STATIC_NOERR FUNC_ENTER_STATIC_NOERR
@ -157,9 +158,6 @@ H5S__all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
HDassert(space && H5S_SEL_ALL == H5S_GET_SELECT_TYPE(space)); HDassert(space && H5S_SEL_ALL == H5S_GET_SELECT_TYPE(space));
HDassert(iter); HDassert(iter);
/* Initialize the number of elements to iterate over */
iter->elmt_left = H5S_GET_SELECT_NPOINTS(space);
/* Start at the upper left location */ /* Start at the upper left location */
iter->u.all.elmt_offset = 0; iter->u.all.elmt_offset = 0;
iter->u.all.byte_offset = 0; iter->u.all.byte_offset = 0;
@ -362,13 +360,11 @@ H5S__all_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter)
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
NAME NAME
H5S__all_get_seq_list H5S__all_iter_get_seq_list
PURPOSE PURPOSE
Create a list of offsets & lengths for a selection Create a list of offsets & lengths for a selection
USAGE USAGE
herr_t H5S__all_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len) herr_t H5S__all_iter_get_seq_list(iter,maxseq,maxelem,nseq,nelem,off,len)
H5S_t *space; IN: Dataspace containing selection to use.
unsigned flags; IN: Flags for extra information about operation
H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
position of interest in selection. position of interest in selection.
size_t maxseq; IN: Maximum number of sequences to generate size_t maxseq; IN: Maximum number of sequences to generate
@ -392,16 +388,14 @@ H5S__all_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter)
REVISION LOG REVISION LOG
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
static herr_t static herr_t
H5S__all_get_seq_list(const H5S_t H5_ATTR_UNUSED *space, unsigned H5_ATTR_UNUSED flags, H5S_sel_iter_t *iter, H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t H5_ATTR_UNUSED maxseq,
size_t H5_ATTR_UNUSED maxseq, size_t maxelem, size_t *nseq, size_t *nelem, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len)
hsize_t *off, size_t *len)
{ {
size_t elem_used; /* The number of elements used */ size_t elem_used; /* The number of elements used */
FUNC_ENTER_STATIC_NOERR FUNC_ENTER_STATIC_NOERR
/* Check args */ /* Check args */
HDassert(space);
HDassert(iter); HDassert(iter);
HDassert(maxseq > 0); HDassert(maxseq > 0);
HDassert(maxelem > 0); HDassert(maxelem > 0);
@ -431,7 +425,7 @@ H5S__all_get_seq_list(const H5S_t H5_ATTR_UNUSED *space, unsigned H5_ATTR_UNUSED
iter->u.all.byte_offset += len[0]; iter->u.all.byte_offset += len[0];
FUNC_LEAVE_NOAPI(SUCCEED) FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5S__all_get_seq_list() */ } /* end H5S__all_iter_get_seq_list() */
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
@ -889,6 +883,70 @@ H5S__all_is_regular(const H5S_t H5_ATTR_UNUSED *space)
FUNC_LEAVE_NOAPI(TRUE) FUNC_LEAVE_NOAPI(TRUE)
} /* end H5S__all_is_regular() */ } /* end H5S__all_is_regular() */
/*--------------------------------------------------------------------------
NAME
H5S__all_shape_same
PURPOSE
Check if a two "all" selections are the same shape
USAGE
htri_t H5S__all_shape_same(space1, space2)
const H5S_t *space1; IN: First dataspace to check
const H5S_t *space2; IN: Second dataspace to check
RETURNS
TRUE / FALSE / FAIL
DESCRIPTION
Checks to see if the current selection in each dataspace are the same
shape.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2)
{
int space1_dim; /* Current dimension in first dataspace */
int space2_dim; /* Current dimension in second dataspace */
htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(space1);
HDassert(space2);
/* Initialize dataspace dims */
space1_dim = (int)space1->extent.rank - 1;
space2_dim = (int)space2->extent.rank - 1;
/* Recall that space1_rank >= space2_rank.
*
* In the following while loop, we test to see if space1 and space2
* have identical size in all dimensions they have in common.
*/
while(space2_dim >= 0) {
if(space1->extent.size[space1_dim] != space2->extent.size[space2_dim])
HGOTO_DONE(FALSE)
space1_dim--;
space2_dim--;
} /* end while */
/* Since we are selecting the entire space, we must also verify that space1
* has size 1 in all dimensions that it does not share with space2.
*/
while(space1_dim >= 0) {
if(space1->extent.size[space1_dim] != 1)
HGOTO_DONE(FALSE)
space1_dim--;
} /* end while */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__all_shape_same() */
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
NAME NAME

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,7 @@
#include "H5private.h" /* Generic Functions */ #include "H5private.h" /* Generic Functions */
#include "H5Dprivate.h" /* Datasets */ #include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */ #include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
#include "H5MMprivate.h" /* Memory management */ #include "H5MMprivate.h" /* Memory management */
#include "H5Spkg.h" /* Dataspaces */ #include "H5Spkg.h" /* Dataspaces */
#include "H5VMprivate.h" /* Vector and array functions */ #include "H5VMprivate.h" /* Vector and array functions */
@ -51,6 +52,18 @@
/* Local Typedefs */ /* Local Typedefs */
/******************/ /******************/
/* Node in linked list of MPI data types created during traversal of irregular hyperslab selection */
typedef struct H5S_mpio_mpitype_node_t {
MPI_Datatype type; /* MPI Datatype */
struct H5S_mpio_mpitype_node_t *next; /* Pointer to next node in list */
} H5S_mpio_mpitype_node_t;
/* List to track MPI data types generated during traversal of irregular hyperslab selection */
typedef struct H5S_mpio_mpitype_list_t {
H5S_mpio_mpitype_node_t *head; /* Pointer to head of list */
H5S_mpio_mpitype_node_t *tail; /* Pointer to tail of list */
} H5S_mpio_mpitype_list_t;
/********************/ /********************/
/* Local Prototypes */ /* Local Prototypes */
@ -71,9 +84,12 @@ static herr_t H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size,
MPI_Datatype *new_type, int *count, hbool_t *is_derived_type); MPI_Datatype *new_type, int *count, hbool_t *is_derived_type);
static herr_t H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, static herr_t H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size,
MPI_Datatype *new_type, int *count, hbool_t *is_derived_type); MPI_Datatype *new_type, int *count, hbool_t *is_derived_type);
static herr_t H5S__obtain_datatype(const hsize_t down[], H5S_hyper_span_t* span, static herr_t H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list);
const MPI_Datatype *elmt_type, MPI_Datatype *span_type, size_t elmt_size); static herr_t H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
static herr_t H5S__mpio_create_large_type(hsize_t, MPI_Aint, MPI_Datatype , MPI_Datatype *); size_t elmt_size, const MPI_Datatype *elmt_type, MPI_Datatype *span_type,
H5S_mpio_mpitype_list_t *type_list, uint64_t op_gen);
static herr_t H5S__mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes,
MPI_Datatype old_type, MPI_Datatype *new_type);
/*****************************/ /*****************************/
@ -91,6 +107,8 @@ static herr_t H5S__mpio_create_large_type(hsize_t, MPI_Aint, MPI_Datatype , MPI_
/*******************/ /*******************/
static hsize_t bigio_count = H5S_MAX_MPI_COUNT; static hsize_t bigio_count = H5S_MAX_MPI_COUNT;
/* Declare a free list to manage the H5S_mpio_mpitype_node_t struct */
H5FL_DEFINE_STATIC(H5S_mpio_mpitype_node_t);
@ -542,7 +560,7 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
/* Initialize selection iterator */ /* Initialize selection iterator */
if(H5S_select_iter_init(&sel_iter, space, elmt_size) < 0) if(H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
sel_iter_init = TRUE; /* Selection iteration info has been initialized */ sel_iter_init = TRUE; /* Selection iteration info has been initialized */
@ -559,7 +577,7 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
size_t curr_seq; /* Current sequence being worked on */ size_t curr_seq; /* Current sequence being worked on */
/* Get the sequences of bytes */ /* Get the sequences of bytes */
if(H5S_SELECT_GET_SEQ_LIST(space, 0, &sel_iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0) if(H5S_SELECT_ITER_GET_SEQ_LIST(&sel_iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Loop, while sequences left to process */ /* Loop, while sequences left to process */
@ -679,7 +697,7 @@ H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size,
HDassert(sizeof(MPI_Aint) >= sizeof(elmt_size)); HDassert(sizeof(MPI_Aint) >= sizeof(elmt_size));
/* Initialize selection iterator */ /* Initialize selection iterator */
if(H5S_select_iter_init(&sel_iter, space, elmt_size) < 0) if(H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
sel_iter_init = TRUE; /* Selection iteration info has been initialized */ sel_iter_init = TRUE; /* Selection iteration info has been initialized */
@ -979,10 +997,12 @@ static herr_t
H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size,
MPI_Datatype *new_type, int *count, hbool_t *is_derived_type) MPI_Datatype *new_type, int *count, hbool_t *is_derived_type)
{ {
H5S_mpio_mpitype_list_t type_list; /* List to track MPI data types created */
MPI_Datatype elmt_type; /* MPI datatype for an element */ MPI_Datatype elmt_type; /* MPI datatype for an element */
hbool_t elmt_type_is_derived = FALSE; /* Whether the element type has been created */ hbool_t elmt_type_is_derived = FALSE; /* Whether the element type has been created */
MPI_Datatype span_type; /* MPI datatype for overall span tree */ MPI_Datatype span_type; /* MPI datatype for overall span tree */
hsize_t down[H5S_MAX_RANK]; /* 'down' sizes for each dimension */ hsize_t down[H5S_MAX_RANK]; /* 'down' sizes for each dimension */
uint64_t op_gen; /* Operation generation value */
int mpi_code; /* MPI return code */ int mpi_code; /* MPI return code */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
@ -1008,12 +1028,21 @@ H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size,
if(H5VM_array_down(space->extent.rank, space->extent.size, down) < 0) if(H5VM_array_down(space->extent.rank, space->extent.size, down) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGETSIZE, FAIL, "couldn't compute 'down' dimension sizes") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGETSIZE, FAIL, "couldn't compute 'down' dimension sizes")
/* Obtain derived data type */ /* Acquire an operation generation value for creating MPI datatypes */
if(H5S__obtain_datatype(down, space->select.sel_info.hslab->span_lst->head, &elmt_type, &span_type, elmt_size) < 0) op_gen = H5S__hyper_get_op_gen();
/* Obtain derived MPI data type */
type_list.head = type_list.tail = NULL;
if(H5S__obtain_datatype(space->select.sel_info.hslab->span_lst, down, elmt_size, &elmt_type, &span_type, &type_list, op_gen) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type") HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type")
if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&span_type))) if(MPI_SUCCESS != (mpi_code = MPI_Type_dup(span_type, new_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)
*new_type = span_type; if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)
/* Release MPI data types generated during span tree traversal */
if(H5S__release_datatype(&type_list) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "couldn't release MPI derived data type")
/* fill in the remaining return values */ /* fill in the remaining return values */
*count = 1; *count = 1;
@ -1028,6 +1057,53 @@ done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__mpio_span_hyper_type() */ } /* end H5S__mpio_span_hyper_type() */
/*-------------------------------------------------------------------------
* Function: H5S__release_datatype
*
* Purpose: Release the MPI derived datatypes for span-tree hyperslab selection
*
* Return: Non-negative on success, negative on failure.
*
* Programmer: Quincey Koziol, February 2, 2019
*
*-------------------------------------------------------------------------
*/
static herr_t
H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list)
{
H5S_mpio_mpitype_node_t *curr; /* Pointer to head of list */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Sanity check */
HDassert(type_list);
/* Iterate over the list, freeing the MPI data types */
curr = type_list->head;
while(curr) {
H5S_mpio_mpitype_node_t *next; /* Pointer to next node in list */
int mpi_code; /* MPI return status code */
/* Release the MPI data type for this span tree */
if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&curr->type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
/* Get pointer to next node in list */
next = curr->next;
/* Free the current node */
curr = H5FL_FREE(H5S_mpio_mpitype_node_t, curr);
/* Advance to next node */
curr = next;
} /* end while */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__release_datatype() */
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function: H5S__obtain_datatype * Function: H5S__obtain_datatype
@ -1043,206 +1119,219 @@ done:
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
static herr_t static herr_t
H5S__obtain_datatype(const hsize_t *down, H5S_hyper_span_t *span, H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
const MPI_Datatype *elmt_type, MPI_Datatype *span_type, size_t elmt_size) size_t elmt_size, const MPI_Datatype *elmt_type, MPI_Datatype *span_type,
H5S_mpio_mpitype_list_t *type_list, uint64_t op_gen)
{ {
H5S_hyper_span_t *span; /* Hyperslab span to iterate with */
size_t alloc_count = 0; /* Number of span tree nodes allocated at this level */ size_t alloc_count = 0; /* Number of span tree nodes allocated at this level */
size_t outercount; /* Number of span tree nodes at this level */ size_t outercount; /* Number of span tree nodes at this level */
MPI_Datatype *inner_type = NULL; MPI_Datatype *inner_type = NULL;
hbool_t inner_types_freed = FALSE; /* Whether the inner_type MPI datatypes have been freed */ hbool_t inner_types_freed = FALSE; /* Whether the inner_type MPI datatypes have been freed */
hbool_t span_type_valid = FALSE; /* Whether the span_type MPI datatypes is valid */
hbool_t large_block = FALSE; /* Wether the block length is larger than 32 bit integer */
int *blocklen = NULL; int *blocklen = NULL;
MPI_Aint *disp = NULL; MPI_Aint *disp = NULL;
H5S_hyper_span_t *tspan = NULL; /* Temporary pointer to span tree node */ size_t u; /* Local index variable */
int mpi_code; /* MPI return status code */ int mpi_code; /* MPI return status code */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC FUNC_ENTER_STATIC
/* Sanity check */ /* Sanity check */
HDassert(span); HDassert(spans);
HDassert(type_list);
/* Allocate the initial displacement & block length buffers */ /* Check if we've visited this span tree before */
alloc_count = H5S_MPIO_INITIAL_ALLOC_COUNT; if(spans->op_gen != op_gen) {
if(NULL == (disp = (MPI_Aint *)H5MM_malloc(alloc_count * sizeof(MPI_Aint)))) H5S_mpio_mpitype_node_t *type_node; /* Pointer to new node in MPI data type list */
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
if(NULL == (blocklen = (int *)H5MM_malloc(alloc_count * sizeof(int))))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths")
/* if this is the fastest changing dimension, it is the base case for derived datatype. */ /* Allocate the initial displacement & block length buffers */
if(NULL == span->down) { alloc_count = H5S_MPIO_INITIAL_ALLOC_COUNT;
tspan = span; if(NULL == (disp = (MPI_Aint *)H5MM_malloc(alloc_count * sizeof(MPI_Aint))))
outercount = 0; HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
while(tspan) { if(NULL == (blocklen = (int *)H5MM_malloc(alloc_count * sizeof(int))))
/* Check if we need to increase the size of the buffers */ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths")
if(outercount >= alloc_count) {
MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */
int *tmp_blocklen; /* Temporary pointer to new block length buffer */
/* Double the allocation count */ /* If this is the fastest changing dimension, it is the base case for derived datatype. */
alloc_count *= 2; span = spans->head;
if(NULL == span->down) {
hbool_t large_block = FALSE; /* Wether the block length is larger than 32 bit integer */
/* Re-allocate the buffers */ outercount = 0;
if(NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint)))) while(span) {
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements") hsize_t nelmts; /* # of elements covered by current span */
disp = tmp_disp;
if(NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int)))) /* Check if we need to increase the size of the buffers */
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths") if(outercount >= alloc_count) {
blocklen = tmp_blocklen; MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */
int *tmp_blocklen; /* Temporary pointer to new block length buffer */
/* Double the allocation count */
alloc_count *= 2;
/* Re-allocate the buffers */
if(NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint))))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
disp = tmp_disp;
if(NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int))))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths")
blocklen = tmp_blocklen;
} /* end if */
/* Compute the number of elements to attempt in this span */
nelmts = (span->high - span->low) + 1;
/* Store displacement & block length */
disp[outercount] = (MPI_Aint)elmt_size * span->low;
H5_CHECK_OVERFLOW(nelmts, hsize_t, int)
blocklen[outercount] = (int)nelmts;
if(bigio_count < blocklen[outercount])
large_block = TRUE; /* at least one block type is large, so set this flag to true */
span = span->next;
outercount++;
} /* end while */
/* Everything fits into integers, so cast them and use hindexed */
if(bigio_count >= outercount && large_block == FALSE) {
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)outercount, blocklen, disp, *elmt_type, &spans->u.down_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code)
} /* end if */ } /* end if */
else { /* LARGE_DATATYPE:: Something doesn't fit into a 32 bit integer */
for(u = 0 ; u < outercount; u++) {
MPI_Datatype temp_type = MPI_DATATYPE_NULL;
/* Store displacement & block length */ /* create the block type from elmt_type while checking the 32 bit int limit */
disp[outercount] = (MPI_Aint)elmt_size * tspan->low; if(blocklen[u] > bigio_count) {
H5_CHECK_OVERFLOW(tspan->nelem, hsize_t, int) if(H5S__mpio_create_large_type(blocklen[u], 0, *elmt_type, &temp_type) < 0)
blocklen[outercount] = (int)tspan->nelem; HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection")
tspan = tspan->next; } /* end if */
else
if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)blocklen[u], *elmt_type, &temp_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
if(bigio_count < blocklen[outercount]) /* Combine the current datatype that is created with this current block type */
large_block = TRUE; /* at least one block type is large, so set this flag to true */ if(0 == u) /* first iteration, there is no combined datatype yet */
spans->u.down_type = temp_type;
else {
int bl[2] = {1, 1};
MPI_Aint ds[2] = {disp[u - 1], disp[u]};
MPI_Datatype dt[2] = {spans->u.down_type, temp_type};
outercount++; if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(2, /* count */
} /* end while */ bl, /* blocklength */
ds, /* stride in bytes*/
dt, /* old type */
&spans->u.down_type))) /* new type */
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code)
/* Everything fits into integers, so cast them and use hindexed */ /* Release previous temporary datatype */
if(bigio_count >= outercount && large_block == FALSE) { if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&temp_type)))
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)outercount, blocklen, disp, *elmt_type, span_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) } /* end else */
span_type_valid = TRUE; } /* end for */
} } /* end else (LARGE_DATATYPE::) */
else { /* LARGE_DATATYPE:: Something doesn't fit into a 32 bit integer */ } /* end if */
size_t i; else {
for (i=0 ; i<outercount ; i++) {
MPI_Datatype temp_type = MPI_DATATYPE_NULL, outer_type = MPI_DATATYPE_NULL;
/* create the block type from elmt_type while checking the 32 bit int limit */
if (blocklen[i] > bigio_count) {
if (H5S__mpio_create_large_type (blocklen[i], 0, *elmt_type, &temp_type) < 0) {
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,
"couldn't create a large element datatype in span_hyper selection")
}
}
else {
if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)blocklen[i],
*elmt_type,
&temp_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
}
/* combine the current datatype that is created with this current block type */
if (0 == i) { /* first iteration, there is no combined datatype yet */
*span_type = temp_type;
}
else {
int bl[2] = {1,1};
MPI_Aint ds[2] = {disp[i-1],disp[i]};
MPI_Datatype dt[2] = {*span_type, temp_type};
if (MPI_SUCCESS != (mpi_code = MPI_Type_create_struct (2, /* count */
bl, /* blocklength */
ds, /* stride in bytes*/
dt, /* old type */
&outer_type))){ /* new type */
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code)
}
*span_type = outer_type;
}
if (outer_type != MPI_DATATYPE_NULL)
MPI_Type_free(&outer_type);
/* temp_type shouldn't be freed here...
* Note that we have simply copied it above (not MPI_Type_dup)
* into the 'span_type' argument of the caller.
* The caller needs to deal with it there!
*/
}
} /* end (LARGE_DATATYPE::) */
} /* end if */
else {
size_t u; /* Local index variable */
if(NULL == (inner_type = (MPI_Datatype *)H5MM_malloc(alloc_count * sizeof(MPI_Datatype))))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes")
tspan = span;
outercount = 0;
while(tspan) {
MPI_Datatype down_type; /* Temporary MPI datatype for a span tree node's children */
MPI_Aint stride; /* Distance between inner MPI datatypes */ MPI_Aint stride; /* Distance between inner MPI datatypes */
/* Check if we need to increase the size of the buffers */ if(NULL == (inner_type = (MPI_Datatype *)H5MM_malloc(alloc_count * sizeof(MPI_Datatype))))
if(outercount >= alloc_count) { HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes")
MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */
int *tmp_blocklen; /* Temporary pointer to new block length buffer */
MPI_Datatype *tmp_inner_type; /* Temporary pointer to inner MPI datatype buffer */
/* Double the allocation count */
alloc_count *= 2;
/* Re-allocate the buffers */
if(NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint))))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
disp = tmp_disp;
if(NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int))))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths")
blocklen = tmp_blocklen;
if(NULL == (tmp_inner_type = (MPI_Datatype *)H5MM_realloc(inner_type, alloc_count * sizeof(MPI_Datatype))))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes")
inner_type = tmp_inner_type;
} /* end if */
/* Displacement should be in byte and should have dimension information */
/* First using MPI Type vector to build derived data type for this span only */
/* Need to calculate the disp in byte for this dimension. */
/* Calculate the total bytes of the lower dimension */ /* Calculate the total bytes of the lower dimension */
disp[outercount] = tspan->low * (*down) * elmt_size;
blocklen[outercount] = 1;
/* Generate MPI datatype for next dimension down */
if(H5S__obtain_datatype(down + 1, tspan->down->head, elmt_type, &down_type, elmt_size) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type")
/* Build the MPI datatype for this node */
stride = (*down) * elmt_size; stride = (*down) * elmt_size;
H5_CHECK_OVERFLOW(tspan->nelem, hsize_t, int)
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)tspan->nelem, 1, stride, down_type, &inner_type[outercount]))) {
MPI_Type_free(&down_type);
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
} /* end if */
/* Release MPI datatype for next dimension down */ /* Loop over span nodes */
if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&down_type))) outercount = 0;
HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code) while(span) {
MPI_Datatype down_type; /* Temporary MPI datatype for a span tree node's children */
hsize_t nelmts; /* # of elements covered by current span */
tspan = tspan->next; /* Check if we need to increase the size of the buffers */
outercount++; if(outercount >= alloc_count) {
} /* end while */ MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */
int *tmp_blocklen; /* Temporary pointer to new block length buffer */
MPI_Datatype *tmp_inner_type; /* Temporary pointer to inner MPI datatype buffer */
/* building the whole vector datatype */ /* Double the allocation count */
H5_CHECK_OVERFLOW(outercount, size_t, int) alloc_count *= 2;
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)outercount, blocklen, disp, inner_type, span_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code)
span_type_valid = TRUE;
/* Release inner node types */ /* Re-allocate the buffers */
for(u = 0; u < outercount; u++) if(NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint))))
if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u]))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code) disp = tmp_disp;
inner_types_freed = TRUE; if(NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int))))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths")
blocklen = tmp_blocklen;
if(NULL == (tmp_inner_type = (MPI_Datatype *)H5MM_realloc(inner_type, alloc_count * sizeof(MPI_Datatype))))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes")
inner_type = tmp_inner_type;
} /* end if */
/* Displacement should be in byte and should have dimension information */
/* First using MPI Type vector to build derived data type for this span only */
/* Need to calculate the disp in byte for this dimension. */
disp[outercount] = span->low * stride;
blocklen[outercount] = 1;
/* Generate MPI datatype for next dimension down */
if(H5S__obtain_datatype(span->down, down + 1, elmt_size, elmt_type, &down_type, type_list, op_gen) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type")
/* Compute the number of elements to attempt in this span */
nelmts = (span->high - span->low) + 1;
/* Build the MPI datatype for this node */
H5_CHECK_OVERFLOW(nelmts, hsize_t, int)
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)nelmts, 1, stride, down_type, &inner_type[outercount])))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
span = span->next;
outercount++;
} /* end while */
/* Building the whole vector datatype */
H5_CHECK_OVERFLOW(outercount, size_t, int)
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)outercount, blocklen, disp, inner_type, &spans->u.down_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code)
/* Release inner node types */
for(u = 0; u < outercount; u++)
if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u])))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
inner_types_freed = TRUE;
} /* end else */
/* Allocate space for the MPI data type list node */
if(NULL == (type_node = H5FL_MALLOC(H5S_mpio_mpitype_node_t)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate MPI data type list node")
/* Set up MPI type node */
type_node->type = spans->u.down_type;
type_node->next = NULL;
/* Add MPI type node to list */
if(type_list->head == NULL)
type_list->head = type_list->tail = type_node;
else {
type_list->tail->next = type_node;
type_list->tail = type_node;
} /* end else */
/* Remember that we've visited this span tree */
spans->op_gen = op_gen;
} /* end else */ } /* end else */
/* Return MPI data type for span tree */
*span_type = spans->u.down_type;
done: done:
/* General cleanup */ /* General cleanup */
if(inner_type != NULL) { if(inner_type != NULL) {
if(!inner_types_freed) { if(!inner_types_freed)
size_t u; /* Local index variable */
for(u = 0; u < outercount; u++) for(u = 0; u < outercount; u++)
if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u]))) if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u])))
HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
} /* end if */
H5MM_free(inner_type); H5MM_free(inner_type);
} /* end if */ } /* end if */
if(blocklen != NULL) if(blocklen != NULL)
@ -1250,13 +1339,6 @@ done:
if(disp != NULL) if(disp != NULL)
H5MM_free(disp); H5MM_free(disp);
/* Error cleanup */
if(ret_value < 0) {
if(span_type_valid)
if(MPI_SUCCESS != (mpi_code = MPI_Type_free(span_type)))
HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
} /* end if */
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__obtain_datatype() */ } /* end H5S__obtain_datatype() */

View File

@ -51,9 +51,6 @@
/* Selection callbacks */ /* Selection callbacks */
static herr_t H5S__none_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); static herr_t H5S__none_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
static herr_t H5S__none_get_seq_list(const H5S_t *space, unsigned flags,
H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
static herr_t H5S__none_release(H5S_t *space); static herr_t H5S__none_release(H5S_t *space);
static htri_t H5S__none_is_valid(const H5S_t *space); static htri_t H5S__none_is_valid(const H5S_t *space);
static hssize_t H5S__none_serial_size(const H5S_t *space); static hssize_t H5S__none_serial_size(const H5S_t *space);
@ -66,10 +63,11 @@ static int H5S__none_unlim_dim(const H5S_t *space);
static htri_t H5S__none_is_contiguous(const H5S_t *space); static htri_t H5S__none_is_contiguous(const H5S_t *space);
static htri_t H5S__none_is_single(const H5S_t *space); static htri_t H5S__none_is_single(const H5S_t *space);
static htri_t H5S__none_is_regular(const H5S_t *space); static htri_t H5S__none_is_regular(const H5S_t *space);
static htri_t H5S__none_shape_same(const H5S_t *space1, const H5S_t *space2);
static herr_t H5S__none_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__none_adjust_u(H5S_t *space, const hsize_t *offset);
static herr_t H5S__none_project_scalar(const H5S_t *space, hsize_t *offset); static herr_t H5S__none_project_scalar(const H5S_t *space, hsize_t *offset);
static herr_t H5S__none_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); static herr_t H5S__none_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
static herr_t H5S__none_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); static herr_t H5S__none_iter_init(const H5S_t *space, H5S_sel_iter_t *iter);
/* Selection iteration callbacks */ /* Selection iteration callbacks */
static herr_t H5S__none_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); static herr_t H5S__none_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
@ -78,6 +76,8 @@ static hsize_t H5S__none_iter_nelmts(const H5S_sel_iter_t *iter);
static htri_t H5S__none_iter_has_next_block(const H5S_sel_iter_t *iter); static htri_t H5S__none_iter_has_next_block(const H5S_sel_iter_t *iter);
static herr_t H5S__none_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); static herr_t H5S__none_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
static herr_t H5S__none_iter_next_block(H5S_sel_iter_t *sel_iter); static herr_t H5S__none_iter_next_block(H5S_sel_iter_t *sel_iter);
static herr_t H5S__none_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq,
size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
static herr_t H5S__none_iter_release(H5S_sel_iter_t *sel_iter); static herr_t H5S__none_iter_release(H5S_sel_iter_t *sel_iter);
@ -96,7 +96,6 @@ const H5S_select_class_t H5S_sel_none[1] = {{
/* Methods on selection */ /* Methods on selection */
H5S__none_copy, H5S__none_copy,
H5S__none_get_seq_list,
H5S__none_release, H5S__none_release,
H5S__none_is_valid, H5S__none_is_valid,
H5S__none_serial_size, H5S__none_serial_size,
@ -109,6 +108,7 @@ const H5S_select_class_t H5S_sel_none[1] = {{
H5S__none_is_contiguous, H5S__none_is_contiguous,
H5S__none_is_single, H5S__none_is_single,
H5S__none_is_regular, H5S__none_is_regular,
H5S__none_shape_same,
H5S__none_adjust_u, H5S__none_adjust_u,
H5S__none_project_scalar, H5S__none_project_scalar,
H5S__none_project_simple, H5S__none_project_simple,
@ -131,6 +131,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{
H5S__none_iter_has_next_block, H5S__none_iter_has_next_block,
H5S__none_iter_next, H5S__none_iter_next,
H5S__none_iter_next_block, H5S__none_iter_next_block,
H5S__none_iter_get_seq_list,
H5S__none_iter_release, H5S__none_iter_release,
}}; }};
@ -149,7 +150,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
static herr_t static herr_t
H5S__none_iter_init(H5S_sel_iter_t *iter, const H5S_t H5_ATTR_UNUSED *space) H5S__none_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter)
{ {
FUNC_ENTER_STATIC_NOERR FUNC_ENTER_STATIC_NOERR
@ -334,13 +335,11 @@ H5S__none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter)
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
NAME NAME
H5S__none_get_seq_list H5S__none_iter_get_seq_list
PURPOSE PURPOSE
Create a list of offsets & lengths for a selection Create a list of offsets & lengths for a selection
USAGE USAGE
herr_t H5S__none_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len) herr_t H5S__none_iter_get_seq_list(iter,maxseq,maxelem,nseq,nelem,off,len)
H5S_t *space; IN: Dataspace containing selection to use.
unsigned flags; IN: Flags for extra information about operation
H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
position of interest in selection. position of interest in selection.
size_t maxseq; IN: Maximum number of sequences to generate size_t maxseq; IN: Maximum number of sequences to generate
@ -364,14 +363,13 @@ H5S__none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter)
REVISION LOG REVISION LOG
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
static herr_t static herr_t
H5S__none_get_seq_list(const H5S_t H5_ATTR_UNUSED *space, unsigned H5_ATTR_UNUSED flags, H5S_sel_iter_t H5_ATTR_UNUSED *iter, H5S__none_iter_get_seq_list(H5S_sel_iter_t H5_ATTR_UNUSED *iter,
size_t H5_ATTR_UNUSED maxseq, size_t H5_ATTR_UNUSED maxelem, size_t *nseq, size_t *nelem, size_t H5_ATTR_UNUSED maxseq, size_t H5_ATTR_UNUSED maxelem, size_t *nseq,
hsize_t H5_ATTR_UNUSED *off, size_t H5_ATTR_UNUSED *len) size_t *nelem, hsize_t H5_ATTR_UNUSED *off, size_t H5_ATTR_UNUSED *len)
{ {
FUNC_ENTER_STATIC_NOERR FUNC_ENTER_STATIC_NOERR
/* Check args */ /* Check args */
HDassert(space);
HDassert(iter); HDassert(iter);
HDassert(maxseq > 0); HDassert(maxseq > 0);
HDassert(maxelem > 0); HDassert(maxelem > 0);
@ -387,7 +385,7 @@ H5S__none_get_seq_list(const H5S_t H5_ATTR_UNUSED *space, unsigned H5_ATTR_UNUSE
*nelem = 0; *nelem = 0;
FUNC_LEAVE_NOAPI(SUCCEED) FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5S__none_get_seq_list() */ } /* end H5S__none_iter_get_seq_list() */
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
@ -830,7 +828,40 @@ H5S__none_is_regular(const H5S_t H5_ATTR_UNUSED *space)
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
NAME NAME
H5S_none_adjust_u H5S__none_shape_same
PURPOSE
Check if a two "none" selections are the same shape
USAGE
htri_t H5S__none_shape_same(space1, space2)
const H5S_t *space1; IN: First dataspace to check
const H5S_t *space2; IN: Second dataspace to check
RETURNS
TRUE / FALSE / FAIL
DESCRIPTION
Checks to see if the current selection in each dataspace are the same
shape.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1,
const H5S_t H5_ATTR_UNUSED *space2)
{
FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(space1);
HDassert(space2);
FUNC_LEAVE_NOAPI(TRUE)
} /* end H5S__none_shape_same() */
/*--------------------------------------------------------------------------
NAME
H5S__none_adjust_u
PURPOSE PURPOSE
Adjust an "none" selection by subtracting an offset Adjust an "none" selection by subtracting an offset
USAGE USAGE

View File

@ -84,49 +84,97 @@ struct H5S_extent_t {
/* Node in point selection list (typedef'd in H5Sprivate.h) */ /* Node in point selection list (typedef'd in H5Sprivate.h) */
struct H5S_pnt_node_t { struct H5S_pnt_node_t {
hsize_t *pnt; /* Pointer to a selected point */ struct H5S_pnt_node_t *next; /* Pointer to next point in list */
struct H5S_pnt_node_t *next; /* pointer to next point in list */ hsize_t pnt[]; /* Selected point */
/* (NOTE: This uses the C99 "flexible array member" feature) */
}; };
/* Information about point selection list */ /* Information about point selection list (typedef'd in H5Sprivate.h) */
typedef struct { struct H5S_pnt_list_t {
/* The following two fields defines the bounding box of the whole set of points, relative to the offset */
hsize_t low_bounds[H5S_MAX_RANK]; /* The smallest element selected in each dimension */
hsize_t high_bounds[H5S_MAX_RANK]; /* The largest element selected in each dimension */
H5S_pnt_node_t *head; /* Pointer to head of point list */ H5S_pnt_node_t *head; /* Pointer to head of point list */
} H5S_pnt_list_t; H5S_pnt_node_t *tail; /* Pointer to tail of point list */
};
/* Information about hyperslab spans */ /* Information about hyperslab spans */
/* Information a particular hyperslab span (typedef'd in H5Sprivate.h) */ /* Information a particular hyperslab span (typedef'd in H5Sprivate.h) */
struct H5S_hyper_span_t { struct H5S_hyper_span_t {
hsize_t low, high; /* Low & high bounds of span */ hsize_t low, high; /* Low & high bounds of elements selected for span, inclusive */
hsize_t nelem; /* Number of elements in span (only needed during I/O) */ struct H5S_hyper_span_info_t *down; /* Pointer to list of spans in next dimension down */
hsize_t pstride; /* Pseudo-stride from start of previous span (only used during I/O) */ struct H5S_hyper_span_t *next; /* Pointer to next span in list */
struct H5S_hyper_span_info_t *down; /* Pointer to list of spans in next dimension down */
struct H5S_hyper_span_t *next; /* Pointer to next span in list */
}; };
/* Information about a list of hyperslab spans in one dimension */ /* Information about a list of hyperslab spans in one dimension (typedef'd in H5Sprivate.h) */
struct H5S_hyper_span_info_t { struct H5S_hyper_span_info_t {
unsigned count; /* Ref. count of number of spans which share this span */ unsigned count; /* Ref. count of number of spans which share this span */
struct H5S_hyper_span_info_t *scratch; /* Scratch pointer
* (used during copies, as mark /* The following two fields define the bounding box of this set of spans
* during precomputes for I/O & * and all lower dimensions, relative to the offset.
* to point to the last span in a */
* list during single element adds) /* (NOTE: The bounds arrays are _relative_ to the depth of the span_info
*/ * node in the span tree, so the top node in a 5-D span tree will
struct H5S_hyper_span_t *head; /* Pointer to list of spans in next dimension down */ * use indices 0-4 in the arrays to store it's bounds information,
* but the next level down in the span tree will use indices 0-3.
* So, each level in the span tree will have the 0th index in the
* arrays correspond to the bounds in "this" dimension, even if
* it's not the highest level in the span tree.
*/
hsize_t *low_bounds; /* The smallest element selected in each dimension */
hsize_t *high_bounds; /* The largest element selected in each dimension */
/* "Operation generation" fields */
/* (Used during copies, 'adjust', 'nelem', and 'rebuild' operations) */
uint64_t op_gen; /* Generation of the scratch info */
union {
struct H5S_hyper_span_info_t *copied; /* Pointer to already copied span tree */
hsize_t nelmts; /* # of elements */
hsize_t nblocks; /* # of blocks */
#ifdef H5_HAVE_PARALLEL
MPI_Datatype down_type; /* MPI datatype for span tree */
#endif /* H5_HAVE_PARALLEL */
}u;
struct H5S_hyper_span_t *head; /* Pointer to the first span of list of spans in the current dimension */
struct H5S_hyper_span_t *tail; /* Pointer to the last span of list of spans in the current dimension */
hsize_t bounds[]; /* Array for storing low & high bounds */
/* (NOTE: This uses the C99 "flexible array member" feature) */
}; };
/* Enum for diminfo_valid field in H5S_hyper_sel_t */
typedef enum {
H5S_DIMINFO_VALID_IMPOSSIBLE, /* 0: diminfo is not valid and can never be valid with the current selection */
H5S_DIMINFO_VALID_NO, /* 1: diminfo is not valid but may or may not be possible to constuct */
H5S_DIMINFO_VALID_YES /* 2: diminfo is valid */
} H5S_diminfo_valid_t;
/* Information about 'diminfo' form of hyperslab selection */ /* Information about 'diminfo' form of hyperslab selection */
typedef struct { typedef struct {
hbool_t diminfo_valid; /* Whether the dataset has valid diminfo */ /* 'opt' points to a [potentially] optimized version of the user's
H5S_hyper_dim_t opt_diminfo[H5S_MAX_RANK]; /* per-dim selection info */ * regular hyperslab information. 'app' points to the actual parameters
H5S_hyper_dim_t app_diminfo[H5S_MAX_RANK]; /* per-dim selection info */ * that the application used for setting the hyperslab selection.
/* 'opt_diminfo' points to a [potentially] optimized version of the user's *
* hyperslab information. 'app_diminfo' points to the actual parameters * The 'app' values are only used for regurgitating the original values
* that the application used for setting the hyperslab selection. These * used to set the hyperslab to the application when it queries the
* are only used for re-gurgitating the original values used to set the * hyperslab selection information.
* hyperslab to the application when it queries the hyperslab selection */
* information. */ H5S_hyper_dim_t app[H5S_MAX_RANK]; /* Application-set per-dim selection info */
H5S_hyper_dim_t opt[H5S_MAX_RANK]; /* Optimized per-dim selection info */
/* The following two fields defines the bounding box of the diminfo selection */
/* (relative to the offset) */
hsize_t low_bounds[H5S_MAX_RANK]; /* The smallest element selected in each dimension */
hsize_t high_bounds[H5S_MAX_RANK]; /* The largest element selected in each dimension */
} H5S_hyper_diminfo_t;
/* Information about hyperslab selection */
typedef struct {
H5S_diminfo_valid_t diminfo_valid; /* Whether the dataset has valid diminfo */
H5S_hyper_diminfo_t diminfo; /* Dimension info form of hyperslab selection */
int unlim_dim; /* Dimension where selection is unlimited, or -1 if none */ int unlim_dim; /* Dimension where selection is unlimited, or -1 if none */
hsize_t num_elem_non_unlim; /* # of elements in a "slice" excluding the unlimited dimension */ hsize_t num_elem_non_unlim; /* # of elements in a "slice" excluding the unlimited dimension */
H5S_hyper_span_info_t *span_lst; /* List of hyperslab span information of all dimensions */ H5S_hyper_span_info_t *span_lst; /* List of hyperslab span information of all dimensions */
@ -135,10 +183,6 @@ typedef struct {
/* Selection information methods */ /* Selection information methods */
/* Method to copy a selection */ /* Method to copy a selection */
typedef herr_t (*H5S_sel_copy_func_t)(H5S_t *dst, const H5S_t *src, hbool_t share_selection); typedef herr_t (*H5S_sel_copy_func_t)(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
/* Method to retrieve a list of offset/length sequences for selection */
typedef herr_t (*H5S_sel_get_seq_list_func_t)(const H5S_t *space, unsigned flags,
H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
/* Method to release current selection */ /* Method to release current selection */
typedef herr_t (*H5S_sel_release_func_t)(H5S_t *space); typedef herr_t (*H5S_sel_release_func_t)(H5S_t *space);
/* Method to determine if current selection is valid for dataspace */ /* Method to determine if current selection is valid for dataspace */
@ -165,6 +209,8 @@ typedef htri_t (*H5S_sel_is_contiguous_func_t)(const H5S_t *space);
typedef htri_t (*H5S_sel_is_single_func_t)(const H5S_t *space); typedef htri_t (*H5S_sel_is_single_func_t)(const H5S_t *space);
/* Method to determine if current selection is "regular" */ /* Method to determine if current selection is "regular" */
typedef htri_t (*H5S_sel_is_regular_func_t)(const H5S_t *space); typedef htri_t (*H5S_sel_is_regular_func_t)(const H5S_t *space);
/* Method to determine if two dataspaces' selections are the same shape */
typedef htri_t (*H5S_sel_shape_same_func_t)(const H5S_t *space1, const H5S_t *space2);
/* Method to adjust a selection by an offset */ /* Method to adjust a selection by an offset */
typedef herr_t (*H5S_sel_adjust_u_func_t)(H5S_t *space, const hsize_t *offset); typedef herr_t (*H5S_sel_adjust_u_func_t)(H5S_t *space, const hsize_t *offset);
/* Method to construct single element projection onto scalar dataspace */ /* Method to construct single element projection onto scalar dataspace */
@ -172,7 +218,7 @@ typedef herr_t (*H5S_sel_project_scalar)(const H5S_t *space, hsize_t *offset);
/* Method to construct selection projection onto/into simple dataspace */ /* Method to construct selection projection onto/into simple dataspace */
typedef herr_t (*H5S_sel_project_simple)(const H5S_t *space, H5S_t *new_space, hsize_t *offset); typedef herr_t (*H5S_sel_project_simple)(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
/* Method to initialize iterator for current selection */ /* Method to initialize iterator for current selection */
typedef herr_t (*H5S_sel_iter_init_func_t)(H5S_sel_iter_t *sel_iter, const H5S_t *space); typedef herr_t (*H5S_sel_iter_init_func_t)(const H5S_t *space, H5S_sel_iter_t *sel_iter);
/* Selection class information */ /* Selection class information */
typedef struct { typedef struct {
@ -180,7 +226,6 @@ typedef struct {
/* Methods */ /* Methods */
H5S_sel_copy_func_t copy; /* Method to make a copy of a selection */ H5S_sel_copy_func_t copy; /* Method to make a copy of a selection */
H5S_sel_get_seq_list_func_t get_seq_list; /* Method to retrieve a list of offset/length sequences for selection */
H5S_sel_release_func_t release; /* Method to release current selection */ H5S_sel_release_func_t release; /* Method to release current selection */
H5S_sel_is_valid_func_t is_valid; /* Method to determine if current selection is valid for dataspace */ H5S_sel_is_valid_func_t is_valid; /* Method to determine if current selection is valid for dataspace */
H5S_sel_serial_size_func_t serial_size; /* Method to determine number of bytes required to store current selection */ H5S_sel_serial_size_func_t serial_size; /* Method to determine number of bytes required to store current selection */
@ -193,6 +238,7 @@ typedef struct {
H5S_sel_is_contiguous_func_t is_contiguous; /* Method to determine if current selection is contiguous */ H5S_sel_is_contiguous_func_t is_contiguous; /* Method to determine if current selection is contiguous */
H5S_sel_is_single_func_t is_single; /* Method to determine if current selection is a single block */ H5S_sel_is_single_func_t is_single; /* Method to determine if current selection is a single block */
H5S_sel_is_regular_func_t is_regular; /* Method to determine if current selection is "regular" */ H5S_sel_is_regular_func_t is_regular; /* Method to determine if current selection is "regular" */
H5S_sel_shape_same_func_t shape_same; /* Method to determine if two dataspaces' selections are the same shape */
H5S_sel_adjust_u_func_t adjust_u; /* Method to adjust a selection by an offset */ H5S_sel_adjust_u_func_t adjust_u; /* Method to adjust a selection by an offset */
H5S_sel_project_scalar project_scalar; /* Method to construct scalar dataspace projection */ H5S_sel_project_scalar project_scalar; /* Method to construct scalar dataspace projection */
H5S_sel_project_simple project_simple; /* Method to construct simple dataspace projection */ H5S_sel_project_simple project_simple; /* Method to construct simple dataspace projection */
@ -235,6 +281,10 @@ typedef htri_t (*H5S_sel_iter_has_next_block_func_t)(const H5S_sel_iter_t *iter)
typedef herr_t (*H5S_sel_iter_next_func_t)(H5S_sel_iter_t *iter, size_t nelem); typedef herr_t (*H5S_sel_iter_next_func_t)(H5S_sel_iter_t *iter, size_t nelem);
/* Method to move selection iterator to the next block in the selection */ /* Method to move selection iterator to the next block in the selection */
typedef herr_t (*H5S_sel_iter_next_block_func_t)(H5S_sel_iter_t *iter); typedef herr_t (*H5S_sel_iter_next_block_func_t)(H5S_sel_iter_t *iter);
/* Method to retrieve a list of offset/length sequences for selection iterator */
typedef herr_t (*H5S_sel_iter_get_seq_list_func_t)(H5S_sel_iter_t *iter,
size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off,
size_t *len);
/* Method to release iterator for current selection */ /* Method to release iterator for current selection */
typedef herr_t (*H5S_sel_iter_release_func_t)(H5S_sel_iter_t *iter); typedef herr_t (*H5S_sel_iter_release_func_t)(H5S_sel_iter_t *iter);
@ -249,6 +299,7 @@ typedef struct H5S_sel_iter_class_t {
H5S_sel_iter_has_next_block_func_t iter_has_next_block; /* Method to query if there is another block left in the selection */ H5S_sel_iter_has_next_block_func_t iter_has_next_block; /* Method to query if there is another block left in the selection */
H5S_sel_iter_next_func_t iter_next; /* Method to move selection iterator to the next element in the selection */ H5S_sel_iter_next_func_t iter_next; /* Method to move selection iterator to the next element in the selection */
H5S_sel_iter_next_block_func_t iter_next_block; /* Method to move selection iterator to the next block in the selection */ H5S_sel_iter_next_block_func_t iter_next_block; /* Method to move selection iterator to the next block in the selection */
H5S_sel_iter_get_seq_list_func_t iter_get_seq_list; /* Method to retrieve a list of offset/length sequences for selection iterator */
H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */ H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */
} H5S_sel_iter_class_t; } H5S_sel_iter_class_t;
@ -281,14 +332,20 @@ H5_DLL herr_t H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src,
hbool_t copy_max); hbool_t copy_max);
/* Operations on hyperslab selections */ /* Operations on hyperslab selections */
H5_DLL uint64_t H5S__hyper_get_op_gen(void);
H5_DLL void H5S__hyper_rebuild(H5S_t *space);
H5_DLL herr_t H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2);
H5_DLL herr_t H5S__hyper_project_intersection(const H5S_t *src_space, H5_DLL herr_t H5S__hyper_project_intersection(const H5S_t *src_space,
const H5S_t *dst_space, const H5S_t *src_intersect_space, H5S_t *proj_space); const H5S_t *dst_space, const H5S_t *src_intersect_space, H5S_t *proj_space);
H5_DLL herr_t H5S__hyper_subtract(H5S_t *space, H5S_t *subtract_space);
/* Testing functions */ /* Testing functions */
#ifdef H5S_TESTING #ifdef H5S_TESTING
H5_DLL htri_t H5S__select_shape_same_test(hid_t sid1, hid_t sid2); H5_DLL htri_t H5S__select_shape_same_test(hid_t sid1, hid_t sid2);
H5_DLL htri_t H5S__get_rebuild_status_test(hid_t space_id); H5_DLL herr_t H5S__get_rebuild_status_test(hid_t space_id,
H5S_diminfo_valid_t *status1, H5S_diminfo_valid_t *status2);
H5_DLL herr_t H5S__get_diminfo_status_test(hid_t space_id,
H5S_diminfo_valid_t *status);
H5_DLL htri_t H5S__internal_consistency_test(hid_t space_id);
#endif /* H5S_TESTING */ #endif /* H5S_TESTING */
#endif /*_H5Spkg_H*/ #endif /*_H5Spkg_H*/

View File

@ -46,16 +46,22 @@
/* Local Typedefs */ /* Local Typedefs */
/******************/ /******************/
/* Define alias for hsize_t, for allocating H5S_pnt_node_t + point objects */
/* (Makes it easier to understand the alloc / free calls) */
typedef hsize_t hcoords_t;
/********************/ /********************/
/* Local Prototypes */ /* Local Prototypes */
/********************/ /********************/
static herr_t H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem,
const hsize_t *coord);
static H5S_pnt_list_t *H5S__copy_pnt_list(const H5S_pnt_list_t *src,
unsigned rank);
static void H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst);
/* Selection callbacks */ /* Selection callbacks */
static herr_t H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); static herr_t H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
static herr_t H5S__point_get_seq_list(const H5S_t *space, unsigned flags,
H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
static herr_t H5S__point_release(H5S_t *space); static herr_t H5S__point_release(H5S_t *space);
static htri_t H5S__point_is_valid(const H5S_t *space); static htri_t H5S__point_is_valid(const H5S_t *space);
static hssize_t H5S__point_serial_size(const H5S_t *space); static hssize_t H5S__point_serial_size(const H5S_t *space);
@ -68,11 +74,12 @@ static int H5S__point_unlim_dim(const H5S_t *space);
static htri_t H5S__point_is_contiguous(const H5S_t *space); static htri_t H5S__point_is_contiguous(const H5S_t *space);
static htri_t H5S__point_is_single(const H5S_t *space); static htri_t H5S__point_is_single(const H5S_t *space);
static htri_t H5S__point_is_regular(const H5S_t *space); static htri_t H5S__point_is_regular(const H5S_t *space);
static htri_t H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2);
static herr_t H5S__point_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__point_adjust_u(H5S_t *space, const hsize_t *offset);
static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset); static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset);
static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space, static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space,
hsize_t *offset); hsize_t *offset);
static herr_t H5S__point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); static herr_t H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter);
/* Selection iteration callbacks */ /* Selection iteration callbacks */
static herr_t H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); static herr_t H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
@ -82,6 +89,8 @@ static hsize_t H5S__point_iter_nelmts(const H5S_sel_iter_t *iter);
static htri_t H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter); static htri_t H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter);
static herr_t H5S__point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); static herr_t H5S__point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
static herr_t H5S__point_iter_next_block(H5S_sel_iter_t *sel_iter); static herr_t H5S__point_iter_next_block(H5S_sel_iter_t *sel_iter);
static herr_t H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq,
size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
static herr_t H5S__point_iter_release(H5S_sel_iter_t *sel_iter); static herr_t H5S__point_iter_release(H5S_sel_iter_t *sel_iter);
@ -100,7 +109,6 @@ const H5S_select_class_t H5S_sel_point[1] = {{
/* Methods on selection */ /* Methods on selection */
H5S__point_copy, H5S__point_copy,
H5S__point_get_seq_list,
H5S__point_release, H5S__point_release,
H5S__point_is_valid, H5S__point_is_valid,
H5S__point_serial_size, H5S__point_serial_size,
@ -113,6 +121,7 @@ const H5S_select_class_t H5S_sel_point[1] = {{
H5S__point_is_contiguous, H5S__point_is_contiguous,
H5S__point_is_single, H5S__point_is_single,
H5S__point_is_regular, H5S__point_is_regular,
H5S__point_shape_same,
H5S__point_adjust_u, H5S__point_adjust_u,
H5S__point_project_scalar, H5S__point_project_scalar,
H5S__point_project_simple, H5S__point_project_simple,
@ -135,11 +144,12 @@ static const H5S_sel_iter_class_t H5S_sel_iter_point[1] = {{
H5S__point_iter_has_next_block, H5S__point_iter_has_next_block,
H5S__point_iter_next, H5S__point_iter_next,
H5S__point_iter_next_block, H5S__point_iter_next_block,
H5S__point_iter_get_seq_list,
H5S__point_iter_release, H5S__point_iter_release,
}}; }};
/* Declare a free list to manage the H5S_pnt_node_t struct */ /* Declare a free list to manage the H5S_pnt_node_t + hcoords_t array struct */
H5FL_DEFINE_STATIC(H5S_pnt_node_t); H5FL_BARR_DEFINE_STATIC(H5S_pnt_node_t, hcoords_t, H5S_MAX_RANK);
/* Declare a free list to manage the H5S_pnt_list_t struct */ /* Declare a free list to manage the H5S_pnt_list_t struct */
H5FL_DEFINE_STATIC(H5S_pnt_list_t); H5FL_DEFINE_STATIC(H5S_pnt_list_t);
@ -159,7 +169,7 @@ H5FL_DEFINE_STATIC(H5S_pnt_list_t);
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
static herr_t static herr_t
H5S__point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter)
{ {
FUNC_ENTER_STATIC_NOERR FUNC_ENTER_STATIC_NOERR
@ -167,11 +177,11 @@ H5S__point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
HDassert(space && H5S_SEL_POINTS == H5S_GET_SELECT_TYPE(space)); HDassert(space && H5S_SEL_POINTS == H5S_GET_SELECT_TYPE(space));
HDassert(iter); HDassert(iter);
/* Initialize the number of points to iterate over */ /* Share point list for internal iterations */
iter->elmt_left = space->select.num_elem; iter->u.pnt.pnt_lst = space->select.sel_info.pnt_lst;
/* Start at the head of the list of points */ /* Start at the head of the list of points */
iter->u.pnt.curr=space->select.sel_info.pnt_lst->head; iter->u.pnt.curr = iter->u.pnt.pnt_lst->head;
/* Initialize type of selection iterator */ /* Initialize type of selection iterator */
iter->type = H5S_sel_iter_point; iter->type = H5S_sel_iter_point;
@ -371,13 +381,11 @@ H5S__point_iter_next_block(H5S_sel_iter_t *iter)
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
NAME NAME
H5S__point_get_seq_list H5S__point_iter_get_seq_list
PURPOSE PURPOSE
Create a list of offsets & lengths for a selection Create a list of offsets & lengths for a selection
USAGE USAGE
herr_t H5S__point_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len) herr_t H5S__point_iter_get_seq_list(iter,maxseq,maxelem,nseq,nelem,off,len)
H5S_t *space; IN: Dataspace containing selection to use.
unsigned flags; IN: Flags for extra information about operation
H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
position of interest in selection. position of interest in selection.
size_t maxseq; IN: Maximum number of sequences to generate size_t maxseq; IN: Maximum number of sequences to generate
@ -401,25 +409,22 @@ H5S__point_iter_next_block(H5S_sel_iter_t *iter)
REVISION LOG REVISION LOG
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
static herr_t static herr_t
H5S__point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem,
size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len)
hsize_t *off, size_t *len)
{ {
size_t io_left; /* The number of bytes left in the selection */ size_t io_left; /* The number of bytes left in the selection */
size_t start_io_left; /* The initial number of bytes left in the selection */ size_t start_io_left; /* The initial number of bytes left in the selection */
H5S_pnt_node_t *node; /* Point node */ H5S_pnt_node_t *node; /* Point node */
hsize_t dims[H5S_MAX_RANK]; /* Total size of memory buf */ unsigned ndims; /* Dimensionality of dataspace*/
int ndims; /* Dimensionality of space*/
hsize_t acc; /* Coordinate accumulator */ hsize_t acc; /* Coordinate accumulator */
hsize_t loc; /* Coordinate offset */ hsize_t loc; /* Coordinate offset */
size_t curr_seq; /* Current sequence being operated on */ size_t curr_seq; /* Current sequence being operated on */
int i; /* Local index variable */ int i; /* Local index variable */
herr_t ret_value = SUCCEED; /* return value */ herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_STATIC FUNC_ENTER_STATIC_NOERR
/* Check args */ /* Check args */
HDassert(space);
HDassert(iter); HDassert(iter);
HDassert(maxseq > 0); HDassert(maxseq > 0);
HDassert(maxelem > 0); HDassert(maxelem > 0);
@ -432,9 +437,8 @@ H5S__point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter
H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t); H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t);
start_io_left = io_left = (size_t)MIN(iter->elmt_left, maxelem); start_io_left = io_left = (size_t)MIN(iter->elmt_left, maxelem);
/* Get the dataspace dimensions */ /* Get the dataspace's rank */
if((ndims = H5S_get_simple_extent_dims (space, dims, NULL)) < 0) ndims = iter->rank;
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to retrieve dataspace dimensions")
/* Walk through the points in the selection, starting at the current */ /* Walk through the points in the selection, starting at the current */
/* location in the iterator */ /* location in the iterator */
@ -442,15 +446,15 @@ H5S__point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter
curr_seq = 0; curr_seq = 0;
while(NULL != node) { while(NULL != node) {
/* Compute the offset of each selected point in the buffer */ /* Compute the offset of each selected point in the buffer */
for(i = ndims - 1, acc = iter->elmt_size, loc = 0; i >= 0; i--) { for(i = (int)(ndims - 1), acc = iter->elmt_size, loc = 0; i >= 0; i--) {
loc += (hsize_t)((hssize_t)node->pnt[i] + space->select.offset[i]) * acc; loc += (hsize_t)((hssize_t)node->pnt[i] + iter->sel_off[i]) * acc;
acc *= dims[i]; acc *= iter->dims[i];
} /* end for */ } /* end for */
/* Check if this is a later point in the selection */ /* Check if this is a later point in the selection */
if(curr_seq > 0) { if(curr_seq > 0) {
/* If a sorted sequence is requested, make certain we don't go backwards in the offset */ /* If a sorted sequence is requested, make certain we don't go backwards in the offset */
if((flags&H5S_GET_SEQ_LIST_SORTED) && loc<off[curr_seq-1]) if((iter->flags & H5S_SEL_ITER_GET_SEQ_LIST_SORTED) && loc < off[curr_seq - 1])
break; break;
/* Check if this point extends the previous sequence */ /* Check if this point extends the previous sequence */
@ -502,9 +506,8 @@ H5S__point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter
/* Set the number of elements used */ /* Set the number of elements used */
*nelem = start_io_left - io_left; *nelem = start_io_left - io_left;
done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__point_get_seq_list() */ } /* end H5S__point_iter_get_seq_list() */
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
@ -571,14 +574,14 @@ H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *c
HDassert(op == H5S_SELECT_SET || op == H5S_SELECT_APPEND || op == H5S_SELECT_PREPEND); HDassert(op == H5S_SELECT_SET || op == H5S_SELECT_APPEND || op == H5S_SELECT_PREPEND);
for(u = 0; u < num_elem; u++) { for(u = 0; u < num_elem; u++) {
unsigned dim; /* Counter for dimensions */
/* Allocate space for the new node */ /* Allocate space for the new node */
if(NULL == (new_node = H5FL_MALLOC(H5S_pnt_node_t))) if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, space->extent.rank)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node")
/* Initialize fields in node */ /* Initialize fields in node */
new_node->next = NULL; new_node->next = NULL;
if(NULL == (new_node->pnt = (hsize_t *)H5MM_malloc(space->extent.rank * sizeof(hsize_t))))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate coordinate information")
/* Copy over the coordinates */ /* Copy over the coordinates */
HDmemcpy(new_node->pnt, coord + (u * space->extent.rank), (space->extent.rank * sizeof(hsize_t))); HDmemcpy(new_node->pnt, coord + (u * space->extent.rank), (space->extent.rank * sizeof(hsize_t)));
@ -589,6 +592,17 @@ H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *c
else else
curr->next = new_node; curr->next = new_node;
curr = new_node; curr = new_node;
/* Update bound box */
/* (Note: when op is H5S_SELECT_SET, the bound box has been reset
* inside H5S_select_elements, the only caller of this function.
* So the following bound box update procedure works correctly
* for the SET operation)
*/
for(dim = 0; dim < space->extent.rank; dim++) {
space->select.sel_info.pnt_lst->low_bounds[dim] = MIN(space->select.sel_info.pnt_lst->low_bounds[dim], curr->pnt[dim]);
space->select.sel_info.pnt_lst->high_bounds[dim] = MAX(space->select.sel_info.pnt_lst->high_bounds[dim], curr->pnt[dim]);
} /* end for */
} /* end for */ } /* end for */
new_node = NULL; new_node = NULL;
@ -600,20 +614,22 @@ H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *c
/* Put new list in point selection */ /* Put new list in point selection */
space->select.sel_info.pnt_lst->head = top; space->select.sel_info.pnt_lst->head = top;
/* Change the tail pointer if tail has not been set */
if(NULL == space->select.sel_info.pnt_lst->tail)
space->select.sel_info.pnt_lst->tail = curr;
} /* end if */ } /* end if */
else { /* op==H5S_SELECT_APPEND */ else { /* op==H5S_SELECT_APPEND */
H5S_pnt_node_t *tmp_node; /* Temporary point selection node */ H5S_pnt_node_t *tmp_node; /* Temporary point selection node */
tmp_node = space->select.sel_info.pnt_lst->head; tmp_node = space->select.sel_info.pnt_lst->head;
if(tmp_node != NULL) { if(tmp_node != NULL) {
while(tmp_node->next != NULL) HDassert(space->select.sel_info.pnt_lst->tail);
tmp_node = tmp_node->next; space->select.sel_info.pnt_lst->tail->next = top;
/* Append new list to point selection */
tmp_node->next = top;
} /* end if */ } /* end if */
else else
space->select.sel_info.pnt_lst->head = top; space->select.sel_info.pnt_lst->head = top;
space->select.sel_info.pnt_lst->tail = curr;
} /* end else */ } /* end else */
/* Set the number of elements in the new selection */ /* Set the number of elements in the new selection */
@ -626,13 +642,12 @@ done:
if(ret_value < 0) { if(ret_value < 0) {
/* Release possibly partially initialized new node */ /* Release possibly partially initialized new node */
if(new_node) if(new_node)
new_node = H5FL_FREE(H5S_pnt_node_t, new_node); new_node = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, new_node);
/* Release possible linked list of nodes */ /* Release possible linked list of nodes */
while(top) { while(top) {
curr = top->next; curr = top->next;
H5MM_xfree(top->pnt); top = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, top);
top = H5FL_FREE(H5S_pnt_node_t, top);
top = curr; top = curr;
} /* end while */ } /* end while */
} /* end if */ } /* end if */
@ -661,24 +676,16 @@ done:
static herr_t static herr_t
H5S__point_release(H5S_t *space) H5S__point_release(H5S_t *space)
{ {
H5S_pnt_node_t *curr, *next; /* Point selection nodes */
FUNC_ENTER_STATIC_NOERR FUNC_ENTER_STATIC_NOERR
/* Check args */ /* Check args */
HDassert(space); HDassert(space);
/* Delete all the nodes from the list */ /* Free the point list */
curr = space->select.sel_info.pnt_lst->head; H5S__free_pnt_list(space->select.sel_info.pnt_lst);
while(curr != NULL) {
next = curr->next;
H5MM_xfree(curr->pnt);
curr = H5FL_FREE(H5S_pnt_node_t, curr);
curr = next;
} /* end while */
/* Free & reset the point list header */ /* Reset the point list header */
space->select.sel_info.pnt_lst = H5FL_FREE(H5S_pnt_list_t, space->select.sel_info.pnt_lst); space->select.sel_info.pnt_lst = NULL;
/* Reset the number of elements in the selection */ /* Reset the number of elements in the selection */
space->select.num_elem = 0; space->select.num_elem = 0;
@ -734,10 +741,17 @@ H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem,
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release point selection") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release point selection")
/* Allocate space for the point selection information if necessary */ /* Allocate space for the point selection information if necessary */
if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS || space->select.sel_info.pnt_lst == NULL) if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS || space->select.sel_info.pnt_lst == NULL) {
hsize_t tmp = HSIZET_MAX;
if(NULL == (space->select.sel_info.pnt_lst = H5FL_CALLOC(H5S_pnt_list_t))) if(NULL == (space->select.sel_info.pnt_lst = H5FL_CALLOC(H5S_pnt_list_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate element information") HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate element information")
/* Set the bound box to the default value */
H5VM_array_fill(space->select.sel_info.pnt_lst->low_bounds, &tmp, sizeof(hsize_t), space->extent.rank);
HDmemset(space->select.sel_info.pnt_lst->high_bounds, 0, sizeof(hsize_t) * space->extent.rank);
} /* end if */
/* Add points to selection */ /* Add points to selection */
if(H5S__point_add(space, op, num_elem, coord) < 0) if(H5S__point_add(space, op, num_elem, coord) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert elements") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert elements")
@ -749,6 +763,124 @@ done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_select_elements() */ } /* end H5S_select_elements() */
/*--------------------------------------------------------------------------
NAME
H5S__copy_pnt_list
PURPOSE
Copy a point selection list
USAGE
H5S_pnt_list_t *H5S__copy_pnt_list(src)
const H5S_pnt_list_t *src; IN: Pointer to the source point list
unsigned rank; IN: # of dimensions for points
RETURNS
Non-NULL pointer to new point list on success / NULL on failure
DESCRIPTION
Copies point selection information from the source point list to newly
created point list.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static H5S_pnt_list_t *
H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank)
{
H5S_pnt_list_t *dst = NULL; /* New point list */
H5S_pnt_node_t *curr, *new_tail; /* Point information nodes */
H5S_pnt_list_t *ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
/* Sanity checks */
HDassert(src);
HDassert(rank > 0);
/* Allocate room for the head of the point list */
if(NULL == (dst = H5FL_MALLOC(H5S_pnt_list_t)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate point list node")
curr = src->head;
new_tail = NULL;
while(curr) {
H5S_pnt_node_t *new_node; /* New point information node */
/* Create new point */
if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, rank)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate point node")
new_node->next = NULL;
/* Copy over the point's coordinates */
HDmemcpy(new_node->pnt, curr->pnt, (rank * sizeof(hsize_t)));
/* Keep the order the same when copying */
if(NULL == new_tail)
new_tail = dst->head = new_node;
else {
new_tail->next = new_node;
new_tail = new_node;
} /* end else */
curr = curr->next;
} /* end while */
dst->tail = new_tail;
/* Copy the selection bounds */
HDmemcpy(dst->high_bounds, src->high_bounds, (rank * sizeof(hsize_t)));
HDmemcpy(dst->low_bounds, src->low_bounds, (rank * sizeof(hsize_t)));
/* Set return value */
ret_value = dst;
done:
if(NULL == ret_value && dst)
H5S__free_pnt_list(dst);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__copy_pnt_list() */
/*--------------------------------------------------------------------------
NAME
H5S__free_pnt_list
PURPOSE
Free a point selection list
USAGE
void H5S__free_pnt_list(pnt_lst)
H5S_pnt_list_t *pnt_lst; IN: Pointer to the point list to free
RETURNS
None
DESCRIPTION
Frees point selection information from the point list
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static void
H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst)
{
H5S_pnt_node_t *curr; /* Point information nodes */
FUNC_ENTER_STATIC_NOERR
/* Sanity checks */
HDassert(pnt_lst);
/* Traverse the list, freeing all memory */
curr = pnt_lst->head;
while(curr) {
H5S_pnt_node_t *tmp_node = curr;
curr = curr->next;
tmp_node = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, tmp_node);
} /* end while */
H5FL_FREE(H5S_pnt_list_t, pnt_lst);
FUNC_LEAVE_NOAPI_VOID
} /* end H5S__free_pnt_list() */
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
NAME NAME
@ -757,8 +889,8 @@ done:
Copy a selection from one dataspace to another Copy a selection from one dataspace to another
USAGE USAGE
herr_t H5S__point_copy(dst, src, share_selection) herr_t H5S__point_copy(dst, src, share_selection)
H5S_t *dst; OUT: Pointer to the destination dataspace H5S_t *dst; OUT: Pointer to the destination dataspace
H5S_t *src; IN: Pointer to the source dataspace H5S_t *src; IN: Pointer to the source dataspace
hbool_t share_selection; IN: Whether to share the selection between the dataspaces hbool_t share_selection; IN: Whether to share the selection between the dataspaces
RETURNS RETURNS
Non-negative on success/Negative on failure Non-negative on success/Negative on failure
@ -773,60 +905,19 @@ done:
static herr_t static herr_t
H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t H5_ATTR_UNUSED share_selection) H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t H5_ATTR_UNUSED share_selection)
{ {
H5S_pnt_node_t *curr, *new_node, *new_tail; /* Point information nodes */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC FUNC_ENTER_STATIC
/* Sanity checks */ /* Sanity check */
HDassert(src); HDassert(src);
HDassert(dst); HDassert(dst);
/* Allocate room for the head of the point list */ /* Allocate room for the head of the point list */
if(NULL == (dst->select.sel_info.pnt_lst = H5FL_MALLOC(H5S_pnt_list_t))) if(NULL == (dst->select.sel_info.pnt_lst = H5S__copy_pnt_list(src->select.sel_info.pnt_lst, src->extent.rank)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point list node") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy point list")
curr = src->select.sel_info.pnt_lst->head;
new_tail = NULL;
while(curr) {
/* Create new point */
if(NULL == (new_node = H5FL_MALLOC(H5S_pnt_node_t)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node")
new_node->next = NULL;
if(NULL == (new_node->pnt = (hsize_t *)H5MM_malloc(src->extent.rank * sizeof(hsize_t)))) {
new_node = H5FL_FREE(H5S_pnt_node_t, new_node);
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate coordinate information")
} /* end if */
/* Copy over the point's coordinates */
HDmemcpy(new_node->pnt, curr->pnt, (src->extent.rank * sizeof(hsize_t)));
/* Keep the order the same when copying */
if(NULL == new_tail)
new_tail = dst->select.sel_info.pnt_lst->head = new_node;
else {
new_tail->next = new_node;
new_tail = new_node;
} /* end else */
curr = curr->next;
} /* end while */
done: done:
if(ret_value < 0 && dst->select.sel_info.pnt_lst) {
/* Traverse the (incomplete?) dst list, freeing all memory */
curr = dst->select.sel_info.pnt_lst->head;
while(curr) {
H5S_pnt_node_t *tmp_node = curr;
curr->pnt = (hsize_t *)H5MM_xfree(curr->pnt);
curr = curr->next;
tmp_node = H5FL_FREE(H5S_pnt_node_t, tmp_node);
} /* end while */
dst->select.sel_info.pnt_lst = H5FL_FREE(H5S_pnt_list_t, dst->select.sel_info.pnt_lst);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__point_copy() */ } /* end H5S__point_copy() */
@ -854,7 +945,6 @@ done:
static htri_t static htri_t
H5S__point_is_valid(const H5S_t *space) H5S__point_is_valid(const H5S_t *space)
{ {
H5S_pnt_node_t *curr; /* Point information nodes */
unsigned u; /* Counter */ unsigned u; /* Counter */
htri_t ret_value = TRUE; /* Return value */ htri_t ret_value = TRUE; /* Return value */
@ -862,20 +952,14 @@ H5S__point_is_valid(const H5S_t *space)
HDassert(space); HDassert(space);
/* Check each point to determine whether selection+offset is within extent */ /* Check each dimension */
curr = space->select.sel_info.pnt_lst->head; for(u = 0; u < space->extent.rank; u++) {
while(curr != NULL) { /* Bounds check the selected point + offset against the extent */
/* Check each dimension */ if((space->select.sel_info.pnt_lst->high_bounds[u] + (hsize_t)space->select.offset[u]) > space->extent.size[u])
for(u = 0; u < space->extent.rank; u++) { HGOTO_DONE(FALSE)
/* Check if an offset has been defined */ if(((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0)
/* Bounds check the selected point + offset against the extent */ HGOTO_DONE(FALSE)
if(((curr->pnt[u] + (hsize_t)space->select.offset[u]) > space->extent.size[u]) } /* end for */
|| (((hssize_t)curr->pnt[u] + space->select.offset[u]) < 0))
HGOTO_DONE(FALSE)
} /* end for */
curr = curr->next;
} /* end while */
done: done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
@ -1258,8 +1342,6 @@ done:
static herr_t static herr_t
H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
{ {
H5S_pnt_node_t *node; /* Point node */
unsigned rank; /* Dataspace rank */
unsigned u; /* Local index variable */ unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
@ -1270,31 +1352,20 @@ H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
HDassert(start); HDassert(start);
HDassert(end); HDassert(end);
/* Get the dataspace extent rank */ /* Loop over dimensions */
rank = space->extent.rank; for(u = 0; u < space->extent.rank; u++) {
/* Sanity check */
HDassert(space->select.sel_info.pnt_lst->low_bounds[u] <= space->select.sel_info.pnt_lst->high_bounds[u]);
/* Set the start and end arrays up */ /* Check for offset moving selection negative */
for(u = 0; u < rank; u++) { if(((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0)
start[u] = HSIZET_MAX; HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds")
end[u] = 0;
/* Set the low & high bounds in this dimension */
start[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]);
end[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->high_bounds[u] + space->select.offset[u]);
} /* end for */ } /* end for */
/* Iterate through the node, checking the bounds on each element */
node = space->select.sel_info.pnt_lst->head;
while(node != NULL) {
for(u = 0; u < rank; u++) {
/* Check for offset moving selection negative */
if(((hssize_t)node->pnt[u] + space->select.offset[u]) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds")
if(start[u] > (hsize_t)((hssize_t)node->pnt[u] + space->select.offset[u]))
start[u] = (hsize_t)((hssize_t)node->pnt[u] + space->select.offset[u]);
if(end[u] < (hsize_t)((hssize_t)node->pnt[u] + space->select.offset[u]))
end[u] = (hsize_t)((hssize_t)node->pnt[u] + space->select.offset[u]);
} /* end for */
node = node->next;
} /* end while */
done: done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__point_bounds() */ } /* end H5S__point_bounds() */
@ -1510,6 +1581,114 @@ H5S__point_is_regular(const H5S_t *space)
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__point_is_regular() */ } /* end H5S__point_is_regular() */
/*--------------------------------------------------------------------------
NAME
H5S__point_shape_same
PURPOSE
Check if a two "point" selections are the same shape
USAGE
htri_t H5S__point_shape_same(space1, space2)
const H5S_t *space1; IN: First dataspace to check
const H5S_t *space2; IN: Second dataspace to check
RETURNS
TRUE / FALSE / FAIL
DESCRIPTION
Checks to see if the current selection in each dataspace are the same
shape.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2)
{
H5S_pnt_node_t *pnt1, *pnt2; /* Point information nodes */
hssize_t offset[H5S_MAX_RANK]; /* Offset between the selections */
unsigned space1_rank; /* Number of dimensions of first dataspace */
unsigned space2_rank; /* Number of dimensions of second dataspace */
int space1_dim; /* Current dimension in first dataspace */
int space2_dim; /* Current dimension in second dataspace */
htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_STATIC_NOERR
/* Check args */
HDassert(space1);
HDassert(space2);
/* Get dataspace ranks */
space1_rank = space1->extent.rank;
space2_rank = space2->extent.rank;
/* Sanity check */
HDassert(space1_rank >= space2_rank);
HDassert(space2_rank > 0);
/* Initialize dimensions */
space1_dim = (int)space1_rank - 1;
space2_dim = (int)space2_rank - 1;
/* Look at first point in each selection to compute the offset for common
* dimensions.
*/
pnt1 = space1->select.sel_info.pnt_lst->head;
pnt2 = space2->select.sel_info.pnt_lst->head;
while(space2_dim >= 0) {
/* Set the relative locations of the selections */
offset[space1_dim] = (hssize_t)pnt2->pnt[space2_dim] - (hssize_t)pnt1->pnt[space1_dim];
space1_dim--;
space2_dim--;
} /* end while */
/* For dimensions that appear only in space1: */
while(space1_dim >= 0) {
/* Set the absolute offset of the remaining dimensions */
offset[space1_dim] = (hssize_t)pnt1->pnt[space1_dim];
space1_dim--;
} /* end while */
/* Advance to next point */
pnt1 = pnt1->next;
pnt2 = pnt2->next;
/* Loop over remaining points */
while(pnt1 && pnt2) {
/* Initialize dimensions */
space1_dim = (int)space1_rank - 1;
space2_dim = (int)space2_rank - 1;
/* Compare locations in common dimensions, including relative offset */
while(space2_dim >= 0) {
if((hsize_t)((hssize_t)pnt1->pnt[space1_dim] + offset[space1_dim]) != pnt2->pnt[space2_dim])
HGOTO_DONE(FALSE)
space1_dim--;
space2_dim--;
} /* end while */
/* For dimensions that appear only in space1: */
while(space1_dim >= 0) {
/* Compare the absolute offset in the remaining dimensions */
if((hssize_t)pnt1->pnt[space1_dim] != offset[space1_dim])
HGOTO_DONE(FALSE)
space1_dim--;
} /* end while */
/* Advance to next point */
pnt1 = pnt1->next;
pnt2 = pnt2->next;
} /* end while */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__point_shape_same() */
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
NAME NAME
@ -1534,6 +1713,7 @@ H5S__point_adjust_u(H5S_t *space, const hsize_t *offset)
{ {
H5S_pnt_node_t *node; /* Point node */ H5S_pnt_node_t *node; /* Point node */
unsigned rank; /* Dataspace rank */ unsigned rank; /* Dataspace rank */
unsigned u; /* Local index variable */
FUNC_ENTER_STATIC_NOERR FUNC_ENTER_STATIC_NOERR
@ -1544,8 +1724,6 @@ H5S__point_adjust_u(H5S_t *space, const hsize_t *offset)
node = space->select.sel_info.pnt_lst->head; node = space->select.sel_info.pnt_lst->head;
rank = space->extent.rank; rank = space->extent.rank;
while(node) { while(node) {
unsigned u; /* Local index variable */
/* Adjust each coordinate for point node */ /* Adjust each coordinate for point node */
for(u = 0; u < rank; u++) { for(u = 0; u < rank; u++) {
/* Check for offset moving selection negative */ /* Check for offset moving selection negative */
@ -1559,6 +1737,12 @@ H5S__point_adjust_u(H5S_t *space, const hsize_t *offset)
node = node->next; node = node->next;
} /* end while */ } /* end while */
/* update the bound box of the selection */
for(u = 0; u < rank; u++) {
space->select.sel_info.pnt_lst->low_bounds[u] -= offset[u];
space->select.sel_info.pnt_lst->high_bounds[u] -= offset[u];
} /* end for */
FUNC_LEAVE_NOAPI(SUCCEED) FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5S__point_adjust_u() */ } /* end H5S__point_adjust_u() */
@ -1623,6 +1807,7 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of
H5S_pnt_node_t *new_node; /* Point node in new space */ H5S_pnt_node_t *new_node; /* Point node in new space */
H5S_pnt_node_t *prev_node; /* Previous point node in new space */ H5S_pnt_node_t *prev_node; /* Previous point node in new space */
unsigned rank_diff; /* Difference in ranks between spaces */ unsigned rank_diff; /* Difference in ranks between spaces */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC FUNC_ENTER_STATIC
@ -1657,13 +1842,9 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of
prev_node = NULL; prev_node = NULL;
while(base_node) { while(base_node) {
/* Create new point */ /* Create new point */
if(NULL == (new_node = H5FL_MALLOC(H5S_pnt_node_t))) if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, new_space->extent.rank)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node")
new_node->next = NULL; new_node->next = NULL;
if(NULL == (new_node->pnt = (hsize_t *)H5MM_malloc(new_space->extent.rank * sizeof(hsize_t)))) {
new_node = H5FL_FREE(H5S_pnt_node_t, new_node);
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate coordinate information")
} /* end if */
/* Copy over the point's coordinates */ /* Copy over the point's coordinates */
HDmemcpy(new_node->pnt, &base_node->pnt[rank_diff], (new_space->extent.rank * sizeof(hsize_t))); HDmemcpy(new_node->pnt, &base_node->pnt[rank_diff], (new_space->extent.rank * sizeof(hsize_t)));
@ -1679,6 +1860,12 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of
/* Advance to next node */ /* Advance to next node */
base_node = base_node->next; base_node = base_node->next;
} /* end while */ } /* end while */
/* Update the bounding box */
for(u = 0; u < new_space->extent.rank; u++) {
new_space->select.sel_info.pnt_lst->low_bounds[u] = base_space->select.sel_info.pnt_lst->low_bounds[u + rank_diff];
new_space->select.sel_info.pnt_lst->high_bounds[u] = base_space->select.sel_info.pnt_lst->high_bounds[u + rank_diff];
} /* end for */
} /* end if */ } /* end if */
else { else {
HDassert(new_space->extent.rank > base_space->extent.rank); HDassert(new_space->extent.rank > base_space->extent.rank);
@ -1694,13 +1881,9 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of
prev_node = NULL; prev_node = NULL;
while(base_node) { while(base_node) {
/* Create new point */ /* Create new point */
if(NULL == (new_node = H5FL_MALLOC(H5S_pnt_node_t))) if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, new_space->extent.rank)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node")
new_node->next = NULL; new_node->next = NULL;
if(NULL == (new_node->pnt = (hsize_t *)H5MM_malloc(new_space->extent.rank * sizeof(hsize_t)))) {
new_node = H5FL_FREE(H5S_pnt_node_t, new_node);
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate coordinate information")
} /* end if */
/* Copy over the point's coordinates */ /* Copy over the point's coordinates */
HDmemset(new_node->pnt, 0, sizeof(hsize_t) * rank_diff); HDmemset(new_node->pnt, 0, sizeof(hsize_t) * rank_diff);
@ -1717,6 +1900,16 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of
/* Advance to next node */ /* Advance to next node */
base_node = base_node->next; base_node = base_node->next;
} /* end while */ } /* end while */
/* Update the bounding box */
for(u = 0; u < rank_diff; u++) {
new_space->select.sel_info.pnt_lst->low_bounds[u] = 0;
new_space->select.sel_info.pnt_lst->high_bounds[u] = 0;
} /* end for */
for(; u < new_space->extent.rank; u++) {
new_space->select.sel_info.pnt_lst->low_bounds[u] = base_space->select.sel_info.pnt_lst->low_bounds[u - rank_diff];
new_space->select.sel_info.pnt_lst->high_bounds[u] = base_space->select.sel_info.pnt_lst->high_bounds[u - rank_diff];
} /* end for */
} /* end else */ } /* end else */
/* Number of elements selected will be the same */ /* Number of elements selected will be the same */

View File

@ -39,12 +39,10 @@
#define H5S_CONV_STORAGE_CHUNKED 0x0004 /* i.e. '2' */ #define H5S_CONV_STORAGE_CHUNKED 0x0004 /* i.e. '2' */
#define H5S_CONV_STORAGE_MASK 0x0006 #define H5S_CONV_STORAGE_MASK 0x0006
/* Flags for "get_seq_list" methods */
#define H5S_GET_SEQ_LIST_SORTED 0x0001
/* Forward references of package typedefs */ /* Forward references of package typedefs */
typedef struct H5S_extent_t H5S_extent_t; typedef struct H5S_extent_t H5S_extent_t;
typedef struct H5S_pnt_node_t H5S_pnt_node_t; typedef struct H5S_pnt_node_t H5S_pnt_node_t;
typedef struct H5S_pnt_list_t H5S_pnt_list_t;
typedef struct H5S_hyper_span_t H5S_hyper_span_t; typedef struct H5S_hyper_span_t H5S_hyper_span_t;
typedef struct H5S_hyper_span_info_t H5S_hyper_span_info_t; typedef struct H5S_hyper_span_info_t H5S_hyper_span_info_t;
@ -58,6 +56,7 @@ typedef struct H5S_hyper_dim_t {
/* Point selection iteration container */ /* Point selection iteration container */
typedef struct { typedef struct {
H5S_pnt_list_t *pnt_lst; /* Pointer to point list */
H5S_pnt_node_t *curr; /* Pointer to next node to output */ H5S_pnt_node_t *curr; /* Pointer to next node to output */
} H5S_point_iter_t; } H5S_point_iter_t;
@ -65,6 +64,7 @@ typedef struct {
typedef struct { typedef struct {
/* Common fields for all hyperslab selections */ /* Common fields for all hyperslab selections */
hsize_t off[H5S_MAX_RANK]; /* Offset in span node (used as position for regular hyperslabs) */ hsize_t off[H5S_MAX_RANK]; /* Offset in span node (used as position for regular hyperslabs) */
hsize_t slab[H5S_MAX_RANK]; /* Cumulative size of each dimension in bytes */
unsigned iter_rank; /* Rank of iterator information */ unsigned iter_rank; /* Rank of iterator information */
/* (This should always be the same as the dataspace /* (This should always be the same as the dataspace
* rank, except for regular hyperslab selections in * rank, except for regular hyperslab selections in
@ -80,6 +80,7 @@ typedef struct {
hbool_t flattened[H5S_MAX_RANK]; /* Whether this dimension has been flattened */ hbool_t flattened[H5S_MAX_RANK]; /* Whether this dimension has been flattened */
/* Irregular hyperslab selection fields */ /* Irregular hyperslab selection fields */
hsize_t loc_off[H5S_MAX_RANK]; /* Byte offset in buffer, for each dimension's current offset */
H5S_hyper_span_info_t *spans; /* Pointer to copy of the span tree */ H5S_hyper_span_info_t *spans; /* Pointer to copy of the span tree */
H5S_hyper_span_t *span[H5S_MAX_RANK];/* Array of pointers to span nodes */ H5S_hyper_span_t *span[H5S_MAX_RANK];/* Array of pointers to span nodes */
} H5S_hyper_iter_t; } H5S_hyper_iter_t;
@ -100,9 +101,11 @@ typedef struct H5S_sel_iter_t {
/* Information common to all iterators */ /* Information common to all iterators */
unsigned rank; /* Rank of dataspace the selection iterator is operating on */ unsigned rank; /* Rank of dataspace the selection iterator is operating on */
hsize_t *dims; /* Dimensions of dataspace the selection is operating on */ hsize_t dims[H5S_MAX_RANK]; /* Dimensions of dataspace the selection is operating on */
hssize_t sel_off[H5S_MAX_RANK]; /* Selection offset in dataspace */
hsize_t elmt_left; /* Number of elements left to iterate over */ hsize_t elmt_left; /* Number of elements left to iterate over */
size_t elmt_size; /* Size of elements to iterate over */ size_t elmt_size; /* Size of elements to iterate over */
unsigned flags; /* Flags controlling iterator behavior */
/* Information specific to each type of iterator */ /* Information specific to each type of iterator */
union { union {
@ -142,7 +145,6 @@ typedef struct H5S_sel_iter_op_t {
#define H5S_GET_EXTENT_NPOINTS(S) ((S)->extent.nelem) #define H5S_GET_EXTENT_NPOINTS(S) ((S)->extent.nelem)
#define H5S_GET_SELECT_NPOINTS(S) ((S)->select.num_elem) #define H5S_GET_SELECT_NPOINTS(S) ((S)->select.num_elem)
#define H5S_GET_SELECT_TYPE(S) ((S)->select.type->type) #define H5S_GET_SELECT_TYPE(S) ((S)->select.type->type)
#define H5S_SELECT_GET_SEQ_LIST(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) ((*(S)->select.type->get_seq_list)(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN))
#define H5S_SELECT_VALID(S) ((*(S)->select.type->is_valid)(S)) #define H5S_SELECT_VALID(S) ((*(S)->select.type->is_valid)(S))
#define H5S_SELECT_SERIAL_SIZE(S) ((*(S)->select.type->serial_size)(S)) #define H5S_SELECT_SERIAL_SIZE(S) ((*(S)->select.type->serial_size)(S))
#define H5S_SELECT_SERIALIZE(S,BUF) ((*(S)->select.type->serialize)(S,BUF)) #define H5S_SELECT_SERIALIZE(S,BUF) ((*(S)->select.type->serialize)(S,BUF))
@ -160,6 +162,7 @@ typedef struct H5S_sel_iter_op_t {
#define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_has_next_block)(ITER)) #define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_has_next_block)(ITER))
#define H5S_SELECT_ITER_NEXT(ITER,NELEM)((*(ITER)->type->iter_next)(ITER,NELEM)) #define H5S_SELECT_ITER_NEXT(ITER,NELEM)((*(ITER)->type->iter_next)(ITER,NELEM))
#define H5S_SELECT_ITER_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_next_block)(ITER)) #define H5S_SELECT_ITER_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_next_block)(ITER))
#define H5S_SELECT_ITER_GET_SEQ_LIST(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) ((*(ITER)->type->iter_get_seq_list)(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN))
#define H5S_SELECT_ITER_RELEASE(ITER) ((*(ITER)->type->iter_release)(ITER)) #define H5S_SELECT_ITER_RELEASE(ITER) ((*(ITER)->type->iter_release)(ITER))
#else /* H5S_MODULE */ #else /* H5S_MODULE */
#define H5S_GET_EXTENT_TYPE(S) (H5S_get_simple_extent_type(S)) #define H5S_GET_EXTENT_TYPE(S) (H5S_get_simple_extent_type(S))
@ -167,7 +170,6 @@ typedef struct H5S_sel_iter_op_t {
#define H5S_GET_EXTENT_NPOINTS(S) (H5S_get_simple_extent_npoints(S)) #define H5S_GET_EXTENT_NPOINTS(S) (H5S_get_simple_extent_npoints(S))
#define H5S_GET_SELECT_NPOINTS(S) (H5S_get_select_npoints(S)) #define H5S_GET_SELECT_NPOINTS(S) (H5S_get_select_npoints(S))
#define H5S_GET_SELECT_TYPE(S) (H5S_get_select_type(S)) #define H5S_GET_SELECT_TYPE(S) (H5S_get_select_type(S))
#define H5S_SELECT_GET_SEQ_LIST(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) (H5S_select_get_seq_list(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN))
#define H5S_SELECT_VALID(S) (H5S_select_valid(S)) #define H5S_SELECT_VALID(S) (H5S_select_valid(S))
#define H5S_SELECT_SERIAL_SIZE(S) (H5S_select_serial_size(S)) #define H5S_SELECT_SERIAL_SIZE(S) (H5S_select_serial_size(S))
#define H5S_SELECT_SERIALIZE(S,BUF) (H5S_select_serialize(S,BUF)) #define H5S_SELECT_SERIALIZE(S,BUF) (H5S_select_serialize(S,BUF))
@ -185,6 +187,7 @@ typedef struct H5S_sel_iter_op_t {
#define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) (H5S_select_iter_has_next_block(ITER)) #define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) (H5S_select_iter_has_next_block(ITER))
#define H5S_SELECT_ITER_NEXT(ITER,NELEM)(H5S_select_iter_next(ITER,NELEM)) #define H5S_SELECT_ITER_NEXT(ITER,NELEM)(H5S_select_iter_next(ITER,NELEM))
#define H5S_SELECT_ITER_NEXT_BLOCK(ITER) (H5S_select_iter_next_block(ITER)) #define H5S_SELECT_ITER_NEXT_BLOCK(ITER) (H5S_select_iter_next_block(ITER))
#define H5S_SELECT_ITER_GET_SEQ_LIST(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) (H5S_select_iter_get_seq_list(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN))
#define H5S_SELECT_ITER_RELEASE(ITER) (H5S_select_iter_release(ITER)) #define H5S_SELECT_ITER_RELEASE(ITER) (H5S_select_iter_release(ITER))
#endif /* H5S_MODULE */ #endif /* H5S_MODULE */
/* Handle these callbacks in a special way, since they have prologs that need to be executed */ /* Handle these callbacks in a special way, since they have prologs that need to be executed */
@ -253,9 +256,6 @@ H5_DLL herr_t H5S_select_construct_projection(const H5S_t *base_space,
H5S_t **new_space_ptr, unsigned new_space_rank, const void *buf, H5S_t **new_space_ptr, unsigned new_space_rank, const void *buf,
void const **adj_buf_ptr, hsize_t element_size); void const **adj_buf_ptr, hsize_t element_size);
H5_DLL herr_t H5S_select_release(H5S_t *ds); H5_DLL herr_t H5S_select_release(H5S_t *ds);
H5_DLL herr_t H5S_select_get_seq_list(const H5S_t *space, unsigned flags,
H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes,
size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
H5_DLL hssize_t H5S_select_serial_size(const H5S_t *space); H5_DLL hssize_t H5S_select_serial_size(const H5S_t *space);
H5_DLL herr_t H5S_select_serialize(const H5S_t *space, uint8_t **p); H5_DLL herr_t H5S_select_serialize(const H5S_t *space, uint8_t **p);
H5_DLL htri_t H5S_select_is_contiguous(const H5S_t *space); H5_DLL htri_t H5S_select_is_contiguous(const H5S_t *space);
@ -282,10 +282,11 @@ H5_DLL herr_t H5S_select_elements(H5S_t *space, H5S_seloper_t op,
/* Operations on hyperslab selections */ /* Operations on hyperslab selections */
H5_DLL herr_t H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], H5_DLL herr_t H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
const hsize_t *stride, const hsize_t count[], const hsize_t *block); const hsize_t *stride, const hsize_t count[], const hsize_t *block);
H5_DLL herr_t H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op,
const hsize_t start[], const hsize_t *stride, const hsize_t count[],
const hsize_t *block, H5S_t **new_space);
H5_DLL herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank, H5_DLL herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank,
const hsize_t *coords); const hsize_t *coords);
H5_DLL herr_t H5S_hyper_reset_scratch(H5S_t *space);
H5_DLL herr_t H5S_hyper_convert(H5S_t *space);
H5_DLL htri_t H5S_hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end); H5_DLL htri_t H5S_hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end);
H5_DLL herr_t H5S_hyper_adjust_s(H5S_t *space, const hssize_t *offset); H5_DLL herr_t H5S_hyper_adjust_s(H5S_t *space, const hssize_t *offset);
H5_DLL htri_t H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset); H5_DLL htri_t H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset);
@ -302,11 +303,14 @@ H5_DLL hsize_t H5S_hyper_get_first_inc_block(const H5S_t *space,
/* Operations on selection iterators */ /* Operations on selection iterators */
H5_DLL herr_t H5S_select_iter_init(H5S_sel_iter_t *iter, const H5S_t *space, H5_DLL herr_t H5S_select_iter_init(H5S_sel_iter_t *iter, const H5S_t *space,
size_t elmt_size); size_t elmt_size, unsigned flags);
H5_DLL herr_t H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords); H5_DLL herr_t H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords);
H5_DLL hsize_t H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter); H5_DLL hsize_t H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter);
H5_DLL herr_t H5S_select_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); H5_DLL herr_t H5S_select_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
H5_DLL herr_t H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq,
size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
H5_DLL herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter); H5_DLL herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter);
H5_DLL herr_t H5S_sel_iter_close(H5S_sel_iter_t *sel_iter);
#ifdef H5_HAVE_PARALLEL #ifdef H5_HAVE_PARALLEL
H5_DLL hsize_t H5S_mpio_set_bigio_count(hsize_t new_count); H5_DLL hsize_t H5S_mpio_set_bigio_count(hsize_t new_count);

View File

@ -28,6 +28,23 @@
/* Define user-level maximum number of dimensions */ /* Define user-level maximum number of dimensions */
#define H5S_MAX_RANK 32 #define H5S_MAX_RANK 32
/* Flags for selection iterators */
#define H5S_SEL_ITER_GET_SEQ_LIST_SORTED 0x0001 /* Retrieve elements from iterator
* in increasing offset order, for
* each call to retrieve sequences.
* Currently, this only applies to
* point selections, as hyperslab
* selections are always returned
* in increasing offset order.
*
* Note that the order is only
* increasing for each call to
* get_seq_list, the next set of
* sequences could start with an
* earlier offset than the previous
* one.
*/
/* Different types of dataspaces */ /* Different types of dataspaces */
typedef enum H5S_class_t { typedef enum H5S_class_t {
H5S_NO_CLASS = -1, /*error */ H5S_NO_CLASS = -1, /*error */

View File

@ -32,7 +32,6 @@
#include "H5Eprivate.h" /* Error handling */ #include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */ #include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */ #include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Spkg.h" /* Dataspaces */ #include "H5Spkg.h" /* Dataspaces */
#include "H5VMprivate.h" /* Vector and array functions */ #include "H5VMprivate.h" /* Vector and array functions */
@ -998,7 +997,9 @@ H5S_select_is_regular(const H5S_t *space)
herr_t herr_t
H5S_select_adjust_u(H5S_t *space, const hsize_t *offset) H5S_select_adjust_u(H5S_t *space, const hsize_t *offset)
{ {
herr_t ret_value = FAIL; /* Return value */ hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_ENTER_NOAPI_NOINIT_NOERR
@ -1006,7 +1007,16 @@ H5S_select_adjust_u(H5S_t *space, const hsize_t *offset)
HDassert(space); HDassert(space);
HDassert(offset); HDassert(offset);
ret_value = (*space->select.type->adjust_u)(space, offset); /* Check for an all-zero offset vector */
for(u = 0; u < space->extent.rank; u++)
if(0 != offset[u]) {
non_zero_offset = TRUE;
break;
} /* end if */
/* Only perform operation if the offset is non-zero */
if(non_zero_offset)
ret_value = (*space->select.type->adjust_u)(space, offset);
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_select_adjust_u() */ } /* end H5S_select_adjust_u() */
@ -1098,11 +1108,12 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset)
PURPOSE PURPOSE
Initializes iteration information for a selection. Initializes iteration information for a selection.
USAGE USAGE
herr_t H5S_select_iter_init(sel_iter, space, elmt_size) herr_t H5S_select_iter_init(sel_iter, space, elmt_size, flags)
H5S_sel_iter_t *sel_iter; OUT: Selection iterator to initialize. H5S_sel_iter_t *sel_iter; OUT: Selection iterator to initialize.
H5S_t *space; IN: Dataspace object containing selection to H5S_t *space; IN: Dataspace object containing selection to
iterate over iterate over
size_t elmt_size; IN: Size of elements in the selection size_t elmt_size; IN: Size of elements in the selection
unsigned flags; IN: Flags to control iteration behavior
RETURNS RETURNS
Non-negative on success, negative on failure. Non-negative on success, negative on failure.
DESCRIPTION DESCRIPTION
@ -1110,7 +1121,8 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset)
in the dataspace's selection. in the dataspace's selection.
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
herr_t herr_t
H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_size) H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space,
size_t elmt_size, unsigned flags)
{ {
herr_t ret_value = FAIL; /* Return value */ herr_t ret_value = FAIL; /* Return value */
@ -1125,17 +1137,23 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_s
/* Save the dataspace's rank */ /* Save the dataspace's rank */
sel_iter->rank = space->extent.rank; sel_iter->rank = space->extent.rank;
/* Point to the dataspace dimensions, if there are any */ /* If dims > 0, copy the dataspace dimensions & selection offset */
if(sel_iter->rank > 0) if(sel_iter->rank > 0) {
sel_iter->dims = space->extent.size; HDmemcpy(sel_iter->dims, space->extent.size, sizeof(hsize_t) * space->extent.rank);
else HDmemcpy(sel_iter->sel_off, space->select.offset, sizeof(hsize_t) * space->extent.rank);
sel_iter->dims = NULL; } /* end if */
/* Save the element size */ /* Save the element size */
sel_iter->elmt_size = elmt_size; sel_iter->elmt_size = elmt_size;
/* Initialize the number of elements to iterate over */
sel_iter->elmt_left = space->select.num_elem;
/* Set the flags for the iterator */
sel_iter->flags = flags;
/* Call initialization routine for selection type */ /* Call initialization routine for selection type */
ret_value = (*space->select.type->iter_init)(sel_iter, space); ret_value = (*space->select.type->iter_init)(space, sel_iter);
HDassert(sel_iter->type); HDassert(sel_iter->type);
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
@ -1389,7 +1407,7 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter)
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function: H5S_select_get_seq_list * Function: H5S_select_iter_get_seq_list
* *
* Purpose: Retrieves the next sequence of offset/length pairs for an * Purpose: Retrieves the next sequence of offset/length pairs for an
* iterator on a dataspace * iterator on a dataspace
@ -1406,24 +1424,23 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter)
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
herr_t herr_t
H5S_select_get_seq_list(const H5S_t *space, unsigned flags, H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelmts,
H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nelmts, hsize_t *off, size_t *len)
size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len)
{ {
herr_t ret_value = FAIL; /* Return value */ herr_t ret_value = FAIL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT FUNC_ENTER_NOAPI_NOINIT
/* Sanity check */ /* Sanity check */
HDassert(space); HDassert(iter);
/* Call the selection type's get_seq_list function */ /* Call the selection type's get_seq_list function */
if((ret_value = (*space->select.type->get_seq_list)(space, flags, iter, maxseq, maxbytes, nseq, nbytes, off, len)) < 0) if((ret_value = (*iter->type->iter_get_seq_list)(iter, maxseq, maxelmts, nseq, nelmts, off, len)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get selection sequence list") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get selection sequence list")
done: done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_select_get_seq_list() */ } /* end H5S_select_iter_get_seq_list() */
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
@ -1524,7 +1541,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
/* Initialize iterator */ /* Initialize iterator */
if(H5S_select_iter_init(iter, space, elmt_size) < 0) if(H5S_select_iter_init(iter, space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
iter_init = TRUE; /* Selection iteration info has been initialized */ iter_init = TRUE; /* Selection iteration info has been initialized */
@ -1558,7 +1575,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
size_t curr_seq; /* Current sequence being worked on */ size_t curr_seq; /* Current sequence being worked on */
/* Get the sequences of bytes */ /* Get the sequences of bytes */
if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0) if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Loop, while sequences left to process */ /* Loop, while sequences left to process */
@ -1729,7 +1746,6 @@ H5S_get_select_type(const H5S_t *space)
This is primarily used for reading the entire selection in one swoop. This is primarily used for reading the entire selection in one swoop.
GLOBAL VARIABLES GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS COMMENTS, BUGS, ASSUMPTIONS
Assumes that there is only a single "block" for hyperslab selections.
EXAMPLES EXAMPLES
REVISION LOG REVISION LOG
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
@ -1759,6 +1775,10 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
const H5S_t *space_b; /* Dataspace with smaller rank */ const H5S_t *space_b; /* Dataspace with smaller rank */
unsigned space_a_rank; /* Number of dimensions of dataspace A */ unsigned space_a_rank; /* Number of dimensions of dataspace A */
unsigned space_b_rank; /* Number of dimensions of dataspace B */ unsigned space_b_rank; /* Number of dimensions of dataspace B */
int space_a_dim; /* Current dimension in dataspace A */
int space_b_dim; /* Current dimension in dataspace B */
H5S_sel_type sel_a_type; /* Selection type for dataspace A */
H5S_sel_type sel_b_type; /* Selection type for dataspace B */
/* Need to be able to handle spaces of different rank: /* Need to be able to handle spaces of different rank:
* *
@ -1776,106 +1796,77 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
*/ */
if(space1->extent.rank >= space2->extent.rank) { if(space1->extent.rank >= space2->extent.rank) {
space_a = space1; space_a = space1;
space_a_rank = space_a->extent.rank;
space_b = space2; space_b = space2;
space_b_rank = space_b->extent.rank;
} /* end if */ } /* end if */
else { else {
space_a = space2; space_a = space2;
space_a_rank = space_a->extent.rank;
space_b = space1; space_b = space1;
space_b_rank = space_b->extent.rank;
} /* end else */ } /* end else */
space_a_rank = space_a->extent.rank;
space_b_rank = space_b->extent.rank;
HDassert(space_a_rank >= space_b_rank); HDassert(space_a_rank >= space_b_rank);
HDassert(space_b_rank > 0); HDassert(space_b_rank > 0);
/* Check for "easy" cases before getting into generalized block iteration code */ /* Get selection type for both dataspaces */
if((H5S_GET_SELECT_TYPE(space_a) == H5S_SEL_ALL) && (H5S_GET_SELECT_TYPE(space_b) == H5S_SEL_ALL)) { sel_a_type = H5S_GET_SELECT_TYPE(space_a);
hsize_t dims1[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #1 */ sel_b_type = H5S_GET_SELECT_TYPE(space_b);
hsize_t dims2[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #2 */
int space_a_dim; /* Current dimension in dataspace A */
int space_b_dim; /* Current dimension in dataspace B */
if(H5S_get_simple_extent_dims(space_a, dims1, NULL) < 0) /* If selections aren't "none", compare their bounds */
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality") if(sel_a_type != H5S_SEL_NONE && sel_b_type != H5S_SEL_NONE) {
if(H5S_get_simple_extent_dims(space_b, dims2, NULL) < 0) hsize_t low_a[H5S_MAX_RANK]; /* Low bound of selection in dataspace a */
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality") hsize_t low_b[H5S_MAX_RANK]; /* Low bound of selection in dataspace b */
hsize_t high_a[H5S_MAX_RANK]; /* High bound of selection in dataspace a */
hsize_t high_b[H5S_MAX_RANK]; /* High bound of selection in dataspace b */
/* Get low & high bounds for both dataspaces */
if(H5S_SELECT_BOUNDS(space_a, low_a, high_a) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for first dataspace")
if(H5S_SELECT_BOUNDS(space_b, low_b, high_b) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for second dataspace")
/* Check that the range between the low & high bounds are the same */
space_a_dim = (int)space_a_rank - 1; space_a_dim = (int)space_a_rank - 1;
space_b_dim = (int)space_b_rank - 1; space_b_dim = (int)space_b_rank - 1;
/* recall that space_a_rank >= space_b_rank.
*
* In the following while loop, we test to see if space_a and space_b
* have identical size in all dimensions they have in common.
*/
while(space_b_dim >= 0) { while(space_b_dim >= 0) {
if(dims1[space_a_dim] != dims2[space_b_dim]) /* Sanity check */
HDassert(low_a[space_a_dim] <= high_a[space_a_dim]);
HDassert(low_a[space_b_dim] <= high_a[space_b_dim]);
/* Verify that the ranges are the same */
if((high_a[space_a_dim] - low_a[space_a_dim])
!= (high_b[space_b_dim] - low_b[space_b_dim]))
HGOTO_DONE(FALSE) HGOTO_DONE(FALSE)
/* Go to next dimension */
space_a_dim--; space_a_dim--;
space_b_dim--; space_b_dim--;
} /* end while */ } /* end while */
/* Since we are selecting the entire space, we must also verify that space_a /* Check that the rest of the ranges in space a are "flat" */
* has size 1 in all dimensions that it does not share with space_b.
*/
while(space_a_dim >= 0) { while(space_a_dim >= 0) {
if(dims1[space_a_dim] != 1) /* Sanity check */
HDassert(low_a[space_a_dim] <= high_a[space_a_dim]);
/* This range should be flat to be the same in a lower dimension */
if(low_a[space_a_dim] != high_a[space_a_dim])
HGOTO_DONE(FALSE) HGOTO_DONE(FALSE)
space_a_dim--; space_a_dim--;
} /* end while */ } /* end while */
} /* end if */ } /* end if */
else if((H5S_GET_SELECT_TYPE(space1) == H5S_SEL_NONE) || (H5S_GET_SELECT_TYPE(space2) == H5S_SEL_NONE)) {
/* (Both must be, at this point, if one is) */
HGOTO_DONE(TRUE)
} /* end if */
else if((H5S_GET_SELECT_TYPE(space_a) == H5S_SEL_HYPERSLABS && space_a->select.sel_info.hslab->diminfo_valid)
&& (H5S_GET_SELECT_TYPE(space_b) == H5S_SEL_HYPERSLABS && space_b->select.sel_info.hslab->diminfo_valid)) {
int space_a_dim; /* Current dimension in dataspace A */
int space_b_dim; /* Current dimension in dataspace B */
space_a_dim = (int)space_a_rank - 1; /* If the dataspaces have the same selection type, use the selection's
space_b_dim = (int)space_b_rank - 1; * shape_same operator.
*/
/* check that the shapes are the same in the common dimensions, and that if(sel_a_type == sel_b_type)
* block == 1 in all dimensions that appear only in space_a. ret_value = (*space_a->select.type->shape_same)(space_a, space_b);
*/ /* Otherwise, iterate through all the blocks in the selection */
while(space_b_dim >= 0) {
if(space_a->select.sel_info.hslab->opt_diminfo[space_a_dim].stride !=
space_b->select.sel_info.hslab->opt_diminfo[space_b_dim].stride)
HGOTO_DONE(FALSE)
if(space_a->select.sel_info.hslab->opt_diminfo[space_a_dim].count !=
space_b->select.sel_info.hslab->opt_diminfo[space_b_dim].count)
HGOTO_DONE(FALSE)
if(space_a->select.sel_info.hslab->opt_diminfo[space_a_dim].block !=
space_b->select.sel_info.hslab->opt_diminfo[space_b_dim].block)
HGOTO_DONE(FALSE)
space_a_dim--;
space_b_dim--;
} /* end while */
while(space_a_dim >= 0) {
if(space_a->select.sel_info.hslab->opt_diminfo[space_a_dim].block != 1)
HGOTO_DONE(FALSE)
space_a_dim--;
} /* end while */
} /* end if */
/* Iterate through all the blocks in the selection */
else { else {
hsize_t start_a[H5S_MAX_RANK]; /* Start point of selection block in dataspace a */ hsize_t start_a[H5S_MAX_RANK]; /* Start point of selection block in dataspace a */
hsize_t start_b[H5S_MAX_RANK]; /* Start point of selection block in dataspace b */ hsize_t start_b[H5S_MAX_RANK]; /* Start point of selection block in dataspace b */
hsize_t end_a[H5S_MAX_RANK]; /* End point of selection block in dataspace a */ hsize_t end_a[H5S_MAX_RANK]; /* End point of selection block in dataspace a */
hsize_t end_b[H5S_MAX_RANK]; /* End point of selection block in dataspace b */ hsize_t end_b[H5S_MAX_RANK]; /* End point of selection block in dataspace b */
hsize_t off_a[H5S_MAX_RANK]; /* Offset of selection a blocks */ hssize_t offset[H5S_MAX_RANK]; /* Offset of selection b blocks relative to selection a blocks */
hsize_t off_b[H5S_MAX_RANK]; /* Offset of selection b blocks */
hbool_t first_block = TRUE; /* Flag to indicate the first block */ hbool_t first_block = TRUE; /* Flag to indicate the first block */
/* Allocate the selection iterators */ /* Allocate the selection iterators */
@ -1889,17 +1880,15 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
* that the selection iterator shouldn't be "flattened", since we * that the selection iterator shouldn't be "flattened", since we
* aren't actually going to be doing I/O with the iterators. * aren't actually going to be doing I/O with the iterators.
*/ */
if(H5S_select_iter_init(iter_a, space_a, (size_t)0) < 0) if(H5S_select_iter_init(iter_a, space_a, (size_t)0, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator a") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator a")
iter_a_init = TRUE; iter_a_init = TRUE;
if(H5S_select_iter_init(iter_b, space_b, (size_t)0) < 0) if(H5S_select_iter_init(iter_b, space_b, (size_t)0, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator b") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator b")
iter_b_init = TRUE; iter_b_init = TRUE;
/* Iterate over all the blocks in each selection */ /* Iterate over all the blocks in each selection */
while(1) { while(1) {
int space_a_dim; /* Current dimension in dataspace A */
int space_b_dim; /* Current dimension in dataspace B */
htri_t status_a, status_b; /* Status from next block checks */ htri_t status_a, status_b; /* Status from next block checks */
/* Get the current block for each selection iterator */ /* Get the current block for each selection iterator */
@ -1924,8 +1913,7 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
HGOTO_DONE(FALSE) HGOTO_DONE(FALSE)
/* Set the relative locations of the selections */ /* Set the relative locations of the selections */
off_a[space_a_dim] = start_a[space_a_dim]; offset[space_a_dim] = (hssize_t)start_b[space_b_dim] - (hssize_t)start_a[space_a_dim];
off_b[space_b_dim] = start_b[space_b_dim];
space_a_dim--; space_a_dim--;
space_b_dim--; space_b_dim--;
@ -1935,12 +1923,9 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
* in space_a is not equal to 1, get out. * in space_a is not equal to 1, get out.
*/ */
while(space_a_dim >= 0) { while(space_a_dim >= 0) {
if((end_a[space_a_dim] - start_a[space_a_dim]) != 0) if(start_a[space_a_dim] != end_a[space_a_dim])
HGOTO_DONE(FALSE) HGOTO_DONE(FALSE)
/* Set the relative locations of the selections */
off_a[space_a_dim] = start_a[space_a_dim];
space_a_dim--; space_a_dim--;
} /* end while */ } /* end while */
@ -1952,8 +1937,7 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
/* For dimensions that space_a and space_b have in common: */ /* For dimensions that space_a and space_b have in common: */
while(space_b_dim >= 0) { while(space_b_dim >= 0) {
/* Check if the blocks are in the same relative location */ /* Check if the blocks are in the same relative location */
if((start_a[space_a_dim] - off_a[space_a_dim]) != if((hsize_t)((hssize_t)start_a[space_a_dim] + offset[space_a_dim]) != start_b[space_b_dim])
(start_b[space_b_dim] - off_b[space_b_dim]))
HGOTO_DONE(FALSE) HGOTO_DONE(FALSE)
/* If the block sizes from each selection doesn't match, get out */ /* If the block sizes from each selection doesn't match, get out */
@ -1968,7 +1952,7 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
/* For dimensions that appear only in space_a: */ /* For dimensions that appear only in space_a: */
while(space_a_dim >= 0) { while(space_a_dim >= 0) {
/* If the block size isn't 1, get out */ /* If the block size isn't 1, get out */
if((end_a[space_a_dim] - start_a[space_a_dim]) != 0) if(start_a[space_a_dim] != end_a[space_a_dim])
HGOTO_DONE(FALSE) HGOTO_DONE(FALSE)
space_a_dim--; space_a_dim--;
@ -2329,7 +2313,7 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
/* Initialize iterator */ /* Initialize iterator */
if(H5S_select_iter_init(iter, space, fill_size) < 0) if(H5S_select_iter_init(iter, space, fill_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
iter_init = TRUE; /* Selection iteration info has been initialized */ iter_init = TRUE; /* Selection iteration info has been initialized */
@ -2353,7 +2337,7 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b
size_t nelem; /* Number of elements used in sequences */ size_t nelem; /* Number of elements used in sequences */
/* Get the sequences of bytes */ /* Get the sequences of bytes */
if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0) if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Loop over sequences */ /* Loop over sequences */
@ -2528,12 +2512,13 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space)
if(H5S_select_none(space) < 0) if(H5S_select_none(space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
} /* end if */ } /* end if */
/* If either selection is a point selection, fail currently */
else if((subtract_space->select.type->type == H5S_SEL_POINTS) ||
(space->select.type->type == H5S_SEL_POINTS)) {
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported")
} /* end if */
else { else {
/* Check for point selection in subtract_space, convert to hyperslab */ /* Check for all selection in space, convert to hyperslab */
if(subtract_space->select.type->type == H5S_SEL_POINTS)
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported")
/* Check for point or all selection in space, convert to hyperslab */
if(space->select.type->type == H5S_SEL_ALL) { if(space->select.type->type == H5S_SEL_ALL) {
/* Convert current "all" selection to "real" hyperslab selection */ /* Convert current "all" selection to "real" hyperslab selection */
/* Then allow operation to proceed */ /* Then allow operation to proceed */
@ -2555,14 +2540,12 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space)
if(H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) if(H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection")
} /* end if */ } /* end if */
else if(space->select.type->type == H5S_SEL_POINTS)
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported")
HDassert(space->select.type->type == H5S_SEL_HYPERSLABS); HDassert(space->select.type->type == H5S_SEL_HYPERSLABS);
HDassert(subtract_space->select.type->type == H5S_SEL_HYPERSLABS); HDassert(subtract_space->select.type->type == H5S_SEL_HYPERSLABS);
/* Both spaces are now hyperslabs, perform the operation */ /* Both spaces are now hyperslabs, perform the operation */
if(H5S__hyper_subtract(space, subtract_space) < 0) if(H5S__modify_select(space, H5S_SELECT_NOTB, subtract_space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't subtract hyperslab") HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't subtract hyperslab")
} /* end else */ } /* end else */
} /* end if */ } /* end if */

View File

@ -112,12 +112,18 @@ done:
NAME NAME
H5S__get_rebuild_status_test H5S__get_rebuild_status_test
PURPOSE PURPOSE
Determine the status of hyperslab rebuild Determine the status of the diminfo_valid field (whether we know the
selection information for an equivalent single hyperslab selection)
before and after calling H5S__hyper_rebuild.
USAGE USAGE
htri_t H5S__get_rebuild_status_test(hid_t space_id) herr_t H5S__get_rebuild_status_test(space_id, status1, status2)
hid_t space_id; IN: dataspace id hid_t space_id; IN: dataspace id
H5S_diminfo_valid_t *status1; OUT: status before calling
H5S__hyper_rebuild
H5S_diminfo_valid_t *status2; OUT: status after calling
H5S__hyper_rebuild
RETURNS RETURNS
Non-negative TRUE/FALSE on success, negative on failure Non-negative on success, negative on failure
DESCRIPTION DESCRIPTION
Query the status of rebuilding the hyperslab Query the status of rebuilding the hyperslab
GLOBAL VARIABLES GLOBAL VARIABLES
@ -126,11 +132,271 @@ done:
EXAMPLES EXAMPLES
REVISION LOG REVISION LOG
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
htri_t herr_t
H5S__get_rebuild_status_test(hid_t space_id) H5S__get_rebuild_status_test(hid_t space_id, H5S_diminfo_valid_t *status1,
H5S_diminfo_valid_t *status2)
{ {
H5S_t *space; /* Pointer to 1st dataspace */ H5S_t *space; /* Pointer to 1st dataspace */
htri_t ret_value = FAIL; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
HDassert(status1);
HDassert(status2);
/* Get dataspace structures */
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
*status1 = space->select.sel_info.hslab->diminfo_valid;
/* Fully rebuild diminfo, if necessary */
if(*status1 == H5S_DIMINFO_VALID_NO)
H5S__hyper_rebuild(space);
*status2 = space->select.sel_info.hslab->diminfo_valid;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5S__get_rebuild_status_test() */
/*--------------------------------------------------------------------------
NAME
H5S__get_diminfo_status_test
PURPOSE
Determine the status of the diminfo_valid field (whether we know the
selection information for an equivalent single hyperslab selection)
USAGE
herr_t H5S__get_diminfo_status_test(space_id, status)
hid_t space_id; IN: dataspace id
H5S_diminfo_valid_t *status; OUT: status of diminfo_valid
RETURNS
Non-negative on success, negative on failure
DESCRIPTION
Query the status of rebuilding the hyperslab
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5S__get_diminfo_status_test(hid_t space_id, H5S_diminfo_valid_t *status)
{
H5S_t *space; /* Pointer to 1st dataspace */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
HDassert(status);
/* Get dataspace structures */
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
*status = space->select.sel_info.hslab->diminfo_valid;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5S__get_diminfo_status_test() */
/*--------------------------------------------------------------------------
NAME
H5S__check_spans_tail_ptr
PURPOSE
Determine if the tail pointer of the spans are correctly set
USAGE
herr_t H5S__check_spans_tail_ptr(span_lst)
const H5S_hyper_span_info_t *span_lst; IN: the spans to check for taill pointers
RETURNS
SUCCEED/FAIL
DESCRIPTION
Checks to see if the current selection in the dataspaces has tail pointers of each
dimension correctly set.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Only check the hyperslab selection
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
H5S__check_spans_tail_ptr(const H5S_hyper_span_info_t *span_lst)
{
H5S_hyper_span_t *cur_elem;
H5S_hyper_span_t *actual_tail = NULL;
htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_STATIC
HDassert(span_lst);
cur_elem = span_lst->head;
while(cur_elem) {
actual_tail = cur_elem;
/* check the next dimension of lower order */
if(NULL != cur_elem->down)
if((ret_value = H5S__check_spans_tail_ptr(cur_elem->down)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers")
cur_elem = cur_elem->next;
} /* end while */
if(actual_tail != span_lst->tail)
HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5S__check_spans_tail_ptr */
/*--------------------------------------------------------------------------
NAME
H5S__check_points_tail_ptr
PURPOSE
Determine if the tail pointer of the points list are correctly set
USAGE
herr_t H5S__check_points_tail_ptr(pnt_lst)
const H5S_pnt_list_t *pnt_lst; IN: the points list to check for taill pointers
RETURNS
SUCCEED/FAIL
DESCRIPTION
Checks to see if the current selection in the dataspaces has tail pointers correctly set.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Only check the points selection
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
H5S__check_points_tail_ptr(const H5S_pnt_list_t *pnt_lst)
{
H5S_pnt_node_t *cur_elem;
H5S_pnt_node_t *actual_tail = NULL;
htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_STATIC
HDassert(pnt_lst);
cur_elem = pnt_lst->head;
while(cur_elem) {
actual_tail = cur_elem;
cur_elem = cur_elem->next;
} /* end while */
if(actual_tail != pnt_lst->tail)
HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5S__check_points_tail_ptr */
/*--------------------------------------------------------------------------
NAME
H5S__check_internal_consistency
PURPOSE
Determine if internal data structures are consistent
USAGE
herr_t H5S__check_internal_consistency(space)
const H5S_t *space; IN: 1st Dataspace pointer to compare
RETURNS
SUCCEED/FAIL
DESCRIPTION
Checks to see if the current selection in the dataspaces has consistent
state of internal data structure.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Currently only check the hyperslab selection
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
H5S__check_internal_consistency(const H5S_t *space)
{
hsize_t low_bounds[H5S_MAX_RANK];
hsize_t high_bounds[H5S_MAX_RANK];
unsigned u;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Check args */
HDassert(space);
if(space->select.type->type == H5S_SEL_NONE)
HGOTO_DONE(ret_value);
/* Initialize the inputs */
for(u = 0; u < space->extent.rank; u++) {
low_bounds[u] = HSIZET_MAX;
high_bounds[u] = 0;
} /* end for */
/* Check the bound box */
if(H5S_get_select_bounds(space, low_bounds, high_bounds) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the bound box could not be retrieved")
if(space->select.type->type == H5S_SEL_HYPERSLABS) {
H5S_hyper_sel_t *hslab = space->select.sel_info.hslab;
if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
for(u = 0; u < space->extent.rank; u++) {
if((hsize_t)((hssize_t)hslab->diminfo.low_bounds[u] + space->select.offset[u]) != low_bounds[u])
HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the lower bound box of the selection is inconsistent")
if((hsize_t)((hssize_t)hslab->diminfo.high_bounds[u] + space->select.offset[u]) != high_bounds[u])
HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the higher bound box of the selection is inconsistent")
} /* end for */
} /* end if */
else {
for(u = 0; u < space->extent.rank; u++) {
if((hsize_t)((hssize_t)hslab->span_lst->low_bounds[u] + space->select.offset[u]) != low_bounds[u])
HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the lower bound box of the selection is inconsistent")
if((hsize_t)((hssize_t)hslab->span_lst->high_bounds[u] + space->select.offset[u]) != high_bounds[u])
HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the higher bound box of the selection is inconsistent")
} /* end for */
} /* end else */
/* check the tail pointer */
if((NULL != hslab) && (NULL != hslab->span_lst))
if(H5S__check_spans_tail_ptr(hslab->span_lst) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers")
} /* end if */
else if(space->select.type->type == H5S_SEL_POINTS) {
H5S_pnt_list_t *pnt_lst = space->select.sel_info.pnt_lst;
if(NULL != pnt_lst)
if(H5S__check_points_tail_ptr(pnt_lst) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers")
} /* end else-if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5S__check_internal_consistency */
/*--------------------------------------------------------------------------
NAME
H5S__internal_consistency_test
PURPOSE
Determine if states of internal data structures are consistent
USAGE
htri_t H5S__internal_consistency_test(hid_t space_id)
hid_t space_id; IN: dataspace id
RETURNS
Non-negative TRUE/FALSE on success, negative on failure
DESCRIPTION
Check the states of internal data structures of the hyperslab, and see
whether they are consistent or not
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
htri_t
H5S__internal_consistency_test(hid_t space_id)
{
H5S_t *space; /* Pointer to 1st dataspace */
htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_PACKAGE FUNC_ENTER_PACKAGE
@ -138,9 +404,11 @@ H5S__get_rebuild_status_test(hid_t space_id)
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
ret_value = (htri_t)space->select.sel_info.hslab->diminfo_valid; /* Check if the dataspace selections are the same shape */
if(FAIL == H5S__check_internal_consistency(space))
HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "The dataspace has inconsistent internal state")
done: done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* H5S__get_rebuild_status_test() */ } /* H5S__internal_consistency_test() */

View File

@ -35,6 +35,7 @@ H5TS_once_t H5TS_first_init_g = PTHREAD_ONCE_INIT;
H5TS_key_t H5TS_errstk_key_g; H5TS_key_t H5TS_errstk_key_g;
H5TS_key_t H5TS_funcstk_key_g; H5TS_key_t H5TS_funcstk_key_g;
H5TS_key_t H5TS_apictx_key_g; H5TS_key_t H5TS_apictx_key_g;
H5TS_key_t H5TS_hyper_op_gen_key_g;
H5TS_key_t H5TS_cancel_key_g; H5TS_key_t H5TS_cancel_key_g;
@ -113,6 +114,9 @@ H5TS_pthread_first_thread_init(void)
/* initialize key for thread-specific API contexts */ /* initialize key for thread-specific API contexts */
pthread_key_create(&H5TS_apictx_key_g, H5TS_key_destructor); pthread_key_create(&H5TS_apictx_key_g, H5TS_key_destructor);
/* initialize key for thread-specific hyperslab operation generation */
pthread_key_create(&H5TS_hyper_op_gen_key_g, H5TS_key_destructor);
/* initialize key for thread cancellability mechanism */ /* initialize key for thread cancellability mechanism */
pthread_key_create(&H5TS_cancel_key_g, H5TS_key_destructor); pthread_key_create(&H5TS_cancel_key_g, H5TS_key_destructor);
} }
@ -362,6 +366,9 @@ H5TS_win32_process_enter(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex)
if(TLS_OUT_OF_INDEXES == (H5TS_apictx_key_g = TlsAlloc())) if(TLS_OUT_OF_INDEXES == (H5TS_apictx_key_g = TlsAlloc()))
ret_value = FALSE; ret_value = FALSE;
if(TLS_OUT_OF_INDEXES == (H5TS_hyper_op_gen_key_g = TlsAlloc()))
ret_value = FALSE;
return ret_value; return ret_value;
} /* H5TS_win32_process_enter() */ } /* H5TS_win32_process_enter() */
#endif /* H5_HAVE_WIN_THREADS */ #endif /* H5_HAVE_WIN_THREADS */
@ -431,6 +438,7 @@ H5TS_win32_process_exit(void)
TlsFree(H5TS_funcstk_key_g); TlsFree(H5TS_funcstk_key_g);
#endif /* H5_HAVE_CODESTACK */ #endif /* H5_HAVE_CODESTACK */
TlsFree(H5TS_apictx_key_g); TlsFree(H5TS_apictx_key_g);
TlsFree(H5TS_hyper_op_gen_key_g);
return; return;
} /* H5TS_win32_process_exit() */ } /* H5TS_win32_process_exit() */
@ -479,6 +487,10 @@ H5TS_win32_thread_exit(void)
if(lpvData) if(lpvData)
LocalFree((HLOCAL)lpvData); LocalFree((HLOCAL)lpvData);
lpvData = TlsGetValue(H5TS_hyper_op_gen_key_g);
if(lpvData)
LocalFree((HLOCAL)lpvData);
return ret_value; return ret_value;
} /* H5TS_win32_thread_exit() */ } /* H5TS_win32_thread_exit() */
#endif /* H5_HAVE_WIN_THREADS */ #endif /* H5_HAVE_WIN_THREADS */

View File

@ -110,6 +110,7 @@ extern H5TS_once_t H5TS_first_init_g;
extern H5TS_key_t H5TS_errstk_key_g; extern H5TS_key_t H5TS_errstk_key_g;
extern H5TS_key_t H5TS_funcstk_key_g; extern H5TS_key_t H5TS_funcstk_key_g;
extern H5TS_key_t H5TS_apictx_key_g; extern H5TS_key_t H5TS_apictx_key_g;
extern H5TS_key_t H5TS_hyper_op_gen_key_g;
#if defined c_plusplus || defined __cplusplus #if defined c_plusplus || defined __cplusplus
extern "C" extern "C"

View File

@ -226,6 +226,7 @@ MINOR, DSPACE, H5E_CANTSELECT, Can't select hyperslab
MINOR, DSPACE, H5E_CANTNEXT, Can't move to next iterator location MINOR, DSPACE, H5E_CANTNEXT, Can't move to next iterator location
MINOR, DSPACE, H5E_BADSELECT, Invalid selection MINOR, DSPACE, H5E_BADSELECT, Invalid selection
MINOR, DSPACE, H5E_CANTCOMPARE, Can't compare objects MINOR, DSPACE, H5E_CANTCOMPARE, Can't compare objects
MINOR, DSPACE, H5E_INCONSISTENTSTATE, Internal states are inconsistent
MINOR, DSPACE, H5E_CANTAPPEND, Can't append object MINOR, DSPACE, H5E_CANTAPPEND, Can't append object
# Property list errors # Property list errors

File diff suppressed because it is too large Load Diff