summaryrefslogtreecommitdiffstats
path: root/src/H5Dio.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-04-08 18:19:02 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-04-08 18:19:02 (GMT)
commitaa5e1dc4d24d8a80001d3c727523b3df47eb2d15 (patch)
tree75874216fe09f58193a2d1f0f441e90c58e05409 /src/H5Dio.c
parentb356572029fea96927d79adde60e88ce6a65bdf5 (diff)
downloadhdf5-aa5e1dc4d24d8a80001d3c727523b3df47eb2d15.zip
hdf5-aa5e1dc4d24d8a80001d3c727523b3df47eb2d15.tar.gz
hdf5-aa5e1dc4d24d8a80001d3c727523b3df47eb2d15.tar.bz2
[svn-r8328] Purpose:
Code optimization Description: Check for only performing I/O on a single chunk and re-use memory dataspace, instead of re-creating the same dataspace & selection the hard way. Platforms tested: Solaris 2.7 (arabica) FreeBSD 4.9 (sleipnir) w/parallel too minor to require h5committest
Diffstat (limited to 'src/H5Dio.c')
-rw-r--r--src/H5Dio.c176
1 files changed, 96 insertions, 80 deletions
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 2dbecdf..1008215 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -377,7 +377,6 @@ done:
herr_t
H5D_get_dxpl_cache(hid_t dxpl_id, H5D_dxpl_cache_t *cache)
{
- H5P_genplist_t *dx_plist; /* Data transfer property list */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5D_get_dxpl_cache,FAIL)
@@ -2878,109 +2877,126 @@ H5D_create_chunk_mem_map_hyper(const fm_map *fm)
/* Sanity check */
assert(fm->f_ndims>0);
- /* Get bounding box for selection */
- if(H5S_get_select_bounds(fm->file_space, file_sel_start, file_sel_end)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info")
+ /* Check for all I/O going to a single chunk */
+ if(H5TB_count(fm->fsel)==1) {
+ H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */
- /* Get bounding box for selection */
- if(H5S_get_select_bounds(fm->mem_space, mem_sel_start, mem_sel_end)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info")
+ /* Get the node */
+ curr_node=H5TB_first(fm->fsel->root);
- /* Calculate the adjustment for memory selection from file selection */
- assert(fm->m_ndims==fm->f_ndims);
- for(u=0; u<fm->f_ndims; u++)
- adjust[u]=file_sel_start[u]-mem_sel_start[u];
-#ifdef QAK
-{
- int mpi_rank;
- MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
- if(mpi_rank==1) {
- HDfprintf(stderr,"%s: rank=%d - adjust={",FUNC,mpi_rank);
- for(u=0; u<fm->f_ndims; u++)
- HDfprintf(stderr,"%Hd%s",adjust[u],(u<(fm->f_ndims-1) ? ", " : "}\n"));
+ /* Get pointer to chunk's information */
+ chunk_info=curr_node->data;
+ assert(chunk_info);
+
+ /* Copy the memory dataspace & selection to be the chunk's dataspace & selection */
+ if((chunk_info->mspace = H5S_copy(fm->mem_space))==NULL)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space")
} /* end if */
-}
+ else {
+ /* Get bounding box for file selection */
+ if(H5S_get_select_bounds(fm->file_space, file_sel_start, file_sel_end)<0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info")
+
+ /* Get bounding box for memory selection */
+ if(H5S_get_select_bounds(fm->mem_space, mem_sel_start, mem_sel_end)<0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info")
+
+ /* Calculate the adjustment for memory selection from file selection */
+ assert(fm->m_ndims==fm->f_ndims);
+ for(u=0; u<fm->f_ndims; u++)
+ adjust[u]=file_sel_start[u]-mem_sel_start[u];
+#ifdef QAK
+ {
+ int mpi_rank;
+ MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
+ if(mpi_rank==1) {
+ HDfprintf(stderr,"%s: rank=%d - adjust={",FUNC,mpi_rank);
+ for(u=0; u<fm->f_ndims; u++)
+ HDfprintf(stderr,"%Hd%s",adjust[u],(u<(fm->f_ndims-1) ? ", " : "}\n"));
+ } /* end if */
+ }
#endif /* QAK */
#ifdef QAK
-HDfprintf(stderr,"%s: adjust={",FUNC);
-for(u=0; u<fm->f_ndims; u++)
- HDfprintf(stderr,"%Hd%s",adjust[u],(u<(fm->f_ndims-1) ? ", " : "}\n"));
+ HDfprintf(stderr,"%s: adjust={",FUNC);
+ for(u=0; u<fm->f_ndims; u++)
+ HDfprintf(stderr,"%Hd%s",adjust[u],(u<(fm->f_ndims-1) ? ", " : "}\n"));
#endif /* QAK */
- /* Iterate over each chunk in the chunk list */
- curr_node=H5TB_first(fm->fsel->root);
- while(curr_node) {
- H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */
+ /* Iterate over each chunk in the chunk list */
+ curr_node=H5TB_first(fm->fsel->root);
+ while(curr_node) {
+ H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */
- /* Get pointer to chunk's information */
- chunk_info=curr_node->data;
- assert(chunk_info);
+ /* Get pointer to chunk's information */
+ chunk_info=curr_node->data;
+ assert(chunk_info);
- /* Copy the information */
+ /* Copy the information */
- /* Copy the memory dataspace */
- if((chunk_info->mspace = H5S_copy(fm->mem_space))==NULL)
- HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space")
+ /* Copy the memory dataspace */
+ if((chunk_info->mspace = H5S_copy(fm->mem_space))==NULL)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space")
- /* Release the current selection */
- if(H5S_select_release(chunk_info->mspace)<0)
- HGOTO_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection")
+ /* Release the current selection */
+ if(H5S_select_release(chunk_info->mspace)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection")
- /* Copy the file chunk's selection */
- if(H5S_select_copy(chunk_info->mspace,chunk_info->fspace)<0)
- HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy selection")
+ /* Copy the file chunk's selection */
+ if(H5S_select_copy(chunk_info->mspace,chunk_info->fspace)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy selection")
- /* Compensate for the chunk offset */
- for(u=0; u<fm->f_ndims; u++) {
- H5_CHECK_OVERFLOW(fm->layout->dim[u],hsize_t,hssize_t);
- chunk_adjust[u]=adjust[u]-(chunk_info->coords[u]*(hssize_t)fm->layout->dim[u]); /*lint !e771 The adjust array will always be initialized */
- } /* end for */
+ /* Compensate for the chunk offset */
+ for(u=0; u<fm->f_ndims; u++) {
+ H5_CHECK_OVERFLOW(fm->layout->dim[u],hsize_t,hssize_t);
+ chunk_adjust[u]=adjust[u]-(chunk_info->coords[u]*(hssize_t)fm->layout->dim[u]); /*lint !e771 The adjust array will always be initialized */
+ } /* end for */
#ifdef QAK
-{
- int mpi_rank;
- MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
- if(mpi_rank==1) {
- HDfprintf(stderr,"%s: rank=%d - Before adjusting memory selection\n",FUNC,mpi_rank);
- HDfprintf(stderr,"%s: rank=%d - chunk_adjust={",FUNC,mpi_rank);
- for(u=0; u<fm->f_ndims; u++)
- HDfprintf(stderr,"%Hd%s",chunk_adjust[u],(u<(fm->f_ndims-1) ? ", " : "}\n"));
- } /* end if */
-}
+ {
+ int mpi_rank;
+ MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
+ if(mpi_rank==1) {
+ HDfprintf(stderr,"%s: rank=%d - Before adjusting memory selection\n",FUNC,mpi_rank);
+ HDfprintf(stderr,"%s: rank=%d - chunk_adjust={",FUNC,mpi_rank);
+ for(u=0; u<fm->f_ndims; u++)
+ HDfprintf(stderr,"%Hd%s",chunk_adjust[u],(u<(fm->f_ndims-1) ? ", " : "}\n"));
+ } /* end if */
+ }
#endif /* QAK */
#ifdef QAK
-HDfprintf(stderr,"%s: Before adjusting memory selection\n",FUNC);
-HDfprintf(stderr,"%s: chunk_adjust={",FUNC);
-for(u=0; u<fm->f_ndims; u++)
- HDfprintf(stderr,"%Hd%s",chunk_adjust[u],(u<(fm->f_ndims-1) ? ", " : "}\n"));
+ HDfprintf(stderr,"%s: Before adjusting memory selection\n",FUNC);
+ HDfprintf(stderr,"%s: chunk_adjust={",FUNC);
+ for(u=0; u<fm->f_ndims; u++)
+ HDfprintf(stderr,"%Hd%s",chunk_adjust[u],(u<(fm->f_ndims-1) ? ", " : "}\n"));
#endif /* QAK */
- /* Adjust the selection */
- if(H5S_hyper_adjust(chunk_info->mspace,chunk_adjust)<0) /*lint !e772 The chunk_adjust array will always be initialized */
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection")
+ /* Adjust the selection */
+ if(H5S_hyper_adjust(chunk_info->mspace,chunk_adjust)<0) /*lint !e772 The chunk_adjust array will always be initialized */
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection")
#ifdef QAK
-{
- int mpi_rank;
- MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
- if(mpi_rank==1)
- HDfprintf(stderr,"%s: rank=%d - After adjusting memory selection\n",FUNC,mpi_rank);
-}
+ {
+ int mpi_rank;
+ MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
+ if(mpi_rank==1)
+ HDfprintf(stderr,"%s: rank=%d - After adjusting memory selection\n",FUNC,mpi_rank);
+ }
#endif /* QAK */
#ifdef QAK
-HDfprintf(stderr,"%s: After adjusting memory selection\n",FUNC);
+ HDfprintf(stderr,"%s: After adjusting memory selection\n",FUNC);
-{
- hsize_t mem_dims[H5O_LAYOUT_NDIMS]; /* Dimensions of memory space */
+ {
+ hsize_t mem_dims[H5O_LAYOUT_NDIMS]; /* Dimensions of memory space */
- if(H5S_get_simple_extent_dims(chunk_info->mspace, mem_dims, NULL)<0)
- HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality")
+ if(H5S_get_simple_extent_dims(chunk_info->mspace, mem_dims, NULL)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality")
- HDfprintf(stderr,"%s: mem_dims={",FUNC);
- for(u=0; u<fm->m_ndims; u++)
- HDfprintf(stderr,"%Hd%s",mem_dims[u],(u<(fm->m_ndims-1) ? ", " : "}\n"));
-}
+ HDfprintf(stderr,"%s: mem_dims={",FUNC);
+ for(u=0; u<fm->m_ndims; u++)
+ HDfprintf(stderr,"%Hd%s",mem_dims[u],(u<(fm->m_ndims-1) ? ", " : "}\n"));
+ }
#endif /* QAK */
- /* Get the next chunk node in the TBBT */
- curr_node=H5TB_next(curr_node);
- } /* end while */
+ /* Get the next chunk node in the TBBT */
+ curr_node=H5TB_next(curr_node);
+ } /* end while */
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)