summaryrefslogtreecommitdiffstats
path: root/src/H5Dcontig.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Dcontig.c')
-rw-r--r--src/H5Dcontig.c813
1 files changed, 392 insertions, 421 deletions
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index 662be69..9417c40 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -25,115 +25,97 @@
/* Module Setup */
/****************/
-#include "H5Dmodule.h" /* This source code file is part of the H5D module */
-
+#include "H5Dmodule.h" /* This source code file is part of the H5D module */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5CXprivate.h" /* API Contexts */
-#include "H5Dpkg.h" /* Dataset functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* Files */
-#include "H5FDprivate.h" /* File drivers */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MFprivate.h" /* File memory management */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5FOprivate.h" /* File objects */
-#include "H5Oprivate.h" /* Object headers */
-#include "H5Pprivate.h" /* Property lists */
-#include "H5VMprivate.h" /* Vector and array functions */
-
+#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Dpkg.h" /* Dataset functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* Files */
+#include "H5FDprivate.h" /* File drivers */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5FOprivate.h" /* File objects */
+#include "H5Oprivate.h" /* Object headers */
+#include "H5Pprivate.h" /* Property lists */
+#include "H5VMprivate.h" /* Vector and array functions */
/****************/
/* Local Macros */
/****************/
-
/******************/
/* Local Typedefs */
/******************/
/* Callback info for sieve buffer readvv operation */
typedef struct H5D_contig_readvv_sieve_ud_t {
- H5F_shared_t *f_sh; /* Shared file for dataset */
- H5D_rdcdc_t *dset_contig; /* Cached information about contiguous data */
- const H5D_contig_storage_t *store_contig; /* Contiguous storage info for this I/O operation */
- unsigned char *rbuf; /* Pointer to buffer to fill */
+ H5F_shared_t * f_sh; /* Shared file for dataset */
+ H5D_rdcdc_t * dset_contig; /* Cached information about contiguous data */
+ const H5D_contig_storage_t *store_contig; /* Contiguous storage info for this I/O operation */
+ unsigned char * rbuf; /* Pointer to buffer to fill */
} H5D_contig_readvv_sieve_ud_t;
/* Callback info for [plain] readvv operation */
typedef struct H5D_contig_readvv_ud_t {
- H5F_shared_t *f_sh; /* Shared file for dataset */
- haddr_t dset_addr; /* Address of dataset */
- unsigned char *rbuf; /* Pointer to buffer to fill */
+ H5F_shared_t * f_sh; /* Shared file for dataset */
+ haddr_t dset_addr; /* Address of dataset */
+ unsigned char *rbuf; /* Pointer to buffer to fill */
} H5D_contig_readvv_ud_t;
/* Callback info for sieve buffer writevv operation */
typedef struct H5D_contig_writevv_sieve_ud_t {
- H5F_shared_t *f_sh; /* Shared file for dataset */
- H5D_rdcdc_t *dset_contig; /* Cached information about contiguous data */
- const H5D_contig_storage_t *store_contig; /* Contiguous storage info for this I/O operation */
- const unsigned char *wbuf; /* Pointer to buffer to write */
+ H5F_shared_t * f_sh; /* Shared file for dataset */
+ H5D_rdcdc_t * dset_contig; /* Cached information about contiguous data */
+ const H5D_contig_storage_t *store_contig; /* Contiguous storage info for this I/O operation */
+ const unsigned char * wbuf; /* Pointer to buffer to write */
} H5D_contig_writevv_sieve_ud_t;
/* Callback info for [plain] writevv operation */
typedef struct H5D_contig_writevv_ud_t {
- H5F_shared_t *f_sh; /* Shared file for dataset */
- haddr_t dset_addr; /* Address of dataset */
- const unsigned char *wbuf; /* Pointer to buffer to write */
+ H5F_shared_t * f_sh; /* Shared file for dataset */
+ haddr_t dset_addr; /* Address of dataset */
+ const unsigned char *wbuf; /* Pointer to buffer to write */
} H5D_contig_writevv_ud_t;
-
/********************/
/* Local Prototypes */
/********************/
/* Layout operation callbacks */
-static herr_t H5D__contig_construct(H5F_t *f, H5D_t *dset);
-static herr_t H5D__contig_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id);
-static herr_t H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
- hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space,
- H5D_chunk_map_t *cm);
-static ssize_t H5D__contig_readvv(const H5D_io_info_t *io_info,
- size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[],
- size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]);
-static ssize_t H5D__contig_writevv(const H5D_io_info_t *io_info,
- size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[],
- size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]);
-static herr_t H5D__contig_flush(H5D_t *dset);
+static herr_t H5D__contig_construct(H5F_t *f, H5D_t *dset);
+static herr_t H5D__contig_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id);
+static herr_t H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
+ hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space,
+ H5D_chunk_map_t *cm);
+static ssize_t H5D__contig_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq,
+ size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq,
+ size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]);
+static ssize_t H5D__contig_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq,
+ size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq,
+ size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]);
+static herr_t H5D__contig_flush(H5D_t *dset);
/* Helper routines */
-static herr_t H5D__contig_write_one(H5D_io_info_t *io_info, hsize_t offset,
- size_t size);
-
+static herr_t H5D__contig_write_one(H5D_io_info_t *io_info, hsize_t offset, size_t size);
/*********************/
/* Package Variables */
/*********************/
/* Contiguous storage layout I/O ops */
-const H5D_layout_ops_t H5D_LOPS_CONTIG[1] = {{
- H5D__contig_construct,
- H5D__contig_init,
- H5D__contig_is_space_alloc,
- H5D__contig_is_data_cached,
- H5D__contig_io_init,
- H5D__contig_read,
- H5D__contig_write,
+const H5D_layout_ops_t H5D_LOPS_CONTIG[1] = {
+ {H5D__contig_construct, H5D__contig_init, H5D__contig_is_space_alloc, H5D__contig_is_data_cached,
+ H5D__contig_io_init, H5D__contig_read, H5D__contig_write,
#ifdef H5_HAVE_PARALLEL
- H5D__contig_collective_read,
- H5D__contig_collective_write,
+ H5D__contig_collective_read, H5D__contig_collective_write,
#endif /* H5_HAVE_PARALLEL */
- H5D__contig_readvv,
- H5D__contig_writevv,
- H5D__contig_flush,
- NULL,
- NULL
-}};
-
+ H5D__contig_readvv, H5D__contig_writevv, H5D__contig_flush, NULL, NULL}};
/*******************/
/* Local Variables */
@@ -145,8 +127,6 @@ H5FL_BLK_DEFINE(sieve_buf);
/* Declare extern the free list to manage blocks of type conversion data */
H5FL_BLK_EXTERN(type_conv);
-
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_alloc
*
@@ -160,9 +140,9 @@ H5FL_BLK_EXTERN(type_conv);
*-------------------------------------------------------------------------
*/
herr_t
-H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage /*out */ )
+H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage /*out */)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -171,14 +151,13 @@ H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage /*out */ )
HDassert(storage);
/* Allocate space for the contiguous data */
- if(HADDR_UNDEF == (storage->addr = H5MF_alloc(f, H5FD_MEM_DRAW, storage->size)))
+ if (HADDR_UNDEF == (storage->addr = H5MF_alloc(f, H5FD_MEM_DRAW, storage->size)))
HGOTO_ERROR(H5E_IO, H5E_NOSPACE, FAIL, "unable to reserve file space")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__contig_alloc */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_fill
*
@@ -194,23 +173,24 @@ done:
herr_t
H5D__contig_fill(const H5D_io_info_t *io_info)
{
- const H5D_t *dset = io_info->dset; /* the dataset pointer */
- H5D_io_info_t ioinfo; /* Dataset I/O info */
- H5D_storage_t store; /* Union of storage info for dataset */
- hssize_t snpoints; /* Number of points in space (for error checking) */
- size_t npoints; /* Number of points in space */
- hsize_t offset; /* Offset of dataset */
- size_t max_temp_buf; /* Maximum size of temporary buffer */
+ const H5D_t * dset = io_info->dset; /* the dataset pointer */
+ H5D_io_info_t ioinfo; /* Dataset I/O info */
+ H5D_storage_t store; /* Union of storage info for dataset */
+ hssize_t snpoints; /* Number of points in space (for error checking) */
+ size_t npoints; /* Number of points in space */
+ hsize_t offset; /* Offset of dataset */
+ size_t max_temp_buf; /* Maximum size of temporary buffer */
#ifdef H5_HAVE_PARALLEL
- MPI_Comm mpi_comm = MPI_COMM_NULL; /* MPI communicator for file */
- int mpi_rank = (-1); /* This process's rank */
- int mpi_code; /* MPI return code */
- hbool_t blocks_written = FALSE; /* Flag to indicate that chunk was actually written */
- hbool_t using_mpi = FALSE; /* Flag to indicate that the file is being accessed with an MPI-capable file driver */
-#endif /* H5_HAVE_PARALLEL */
- H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */
- hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */
- herr_t ret_value = SUCCEED; /* Return value */
+ MPI_Comm mpi_comm = MPI_COMM_NULL; /* MPI communicator for file */
+ int mpi_rank = (-1); /* This process's rank */
+ int mpi_code; /* MPI return code */
+ hbool_t blocks_written = FALSE; /* Flag to indicate that chunk was actually written */
+ hbool_t using_mpi =
+ FALSE; /* Flag to indicate that the file is being accessed with an MPI-capable file driver */
+#endif /* H5_HAVE_PARALLEL */
+ H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */
+ hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -223,37 +203,36 @@ H5D__contig_fill(const H5D_io_info_t *io_info)
#ifdef H5_HAVE_PARALLEL
/* Retrieve MPI parameters */
- if(H5F_HAS_FEATURE(dset->oloc.file, H5FD_FEAT_HAS_MPI)) {
+ if (H5F_HAS_FEATURE(dset->oloc.file, H5FD_FEAT_HAS_MPI)) {
/* Get the MPI communicator */
- if(MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(dset->oloc.file)))
+ if (MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(dset->oloc.file)))
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI communicator")
/* Get the MPI rank */
- if((mpi_rank = H5F_mpi_get_rank(dset->oloc.file)) < 0)
+ if ((mpi_rank = H5F_mpi_get_rank(dset->oloc.file)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank")
/* Set the MPI-capable file driver flag */
using_mpi = TRUE;
- } /* end if */
-#endif /* H5_HAVE_PARALLEL */
+ } /* end if */
+#endif /* H5_HAVE_PARALLEL */
/* Initialize storage info for this dataset */
store.contig.dset_addr = dset->shared->layout.storage.u.contig.addr;
store.contig.dset_size = dset->shared->layout.storage.u.contig.size;
/* Get the number of elements in the dataset's dataspace */
- if((snpoints = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0)
+ if ((snpoints = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "dataset has negative number of elements")
H5_CHECKED_ASSIGN(npoints, size_t, snpoints, hssize_t);
/* Get the maximum size of temporary buffers */
- if(H5CX_get_max_temp_buf(&max_temp_buf) < 0)
+ if (H5CX_get_max_temp_buf(&max_temp_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve max. temp. buf size")
/* Initialize the fill value buffer */
- if(H5D__fill_init(&fb_info, NULL, NULL, NULL, NULL, NULL,
- &dset->shared->dcpl_cache.fill,
- dset->shared->type, dset->shared->type_id, npoints, max_temp_buf) < 0)
+ if (H5D__fill_init(&fb_info, NULL, NULL, NULL, NULL, NULL, &dset->shared->dcpl_cache.fill,
+ dset->shared->type, dset->shared->type_id, npoints, max_temp_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info")
fb_info_init = TRUE;
@@ -270,67 +249,66 @@ H5D__contig_fill(const H5D_io_info_t *io_info)
*/
/* Loop through writing the fill value to the dataset */
- while(npoints > 0) {
- size_t curr_points; /* Number of elements to write on this iteration of the loop */
- size_t size; /* Size of buffer to write */
+ while (npoints > 0) {
+ size_t curr_points; /* Number of elements to write on this iteration of the loop */
+ size_t size; /* Size of buffer to write */
/* Compute # of elements and buffer size to write for this iteration */
curr_points = MIN(fb_info.elmts_per_buf, npoints);
- size = curr_points * fb_info.file_elmt_size;
+ size = curr_points * fb_info.file_elmt_size;
/* Check for VL datatype & non-default fill value */
- if(fb_info.has_vlen_fill_type)
+ if (fb_info.has_vlen_fill_type)
/* Re-fill the buffer to use for this I/O operation */
- if(H5D__fill_refill_vl(&fb_info, curr_points) < 0)
+ if (H5D__fill_refill_vl(&fb_info, curr_points) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "can't refill fill value buffer")
#ifdef H5_HAVE_PARALLEL
- /* Check if this file is accessed with an MPI-capable file driver */
- if(using_mpi) {
- /* Write the chunks out from only one process */
- /* !! Use the internal "independent" DXPL!! -QAK */
- if(H5_PAR_META_WRITE == mpi_rank)
- if(H5D__contig_write_one(&ioinfo, offset, size) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset")
-
- /* Indicate that blocks are being written */
- blocks_written = TRUE;
- } /* end if */
- else {
-#endif /* H5_HAVE_PARALLEL */
- H5_CHECK_OVERFLOW(size, size_t, hsize_t);
- if(H5D__contig_write_one(&ioinfo, offset, size) < 0)
+ /* Check if this file is accessed with an MPI-capable file driver */
+ if (using_mpi) {
+ /* Write the chunks out from only one process */
+ /* !! Use the internal "independent" DXPL!! -QAK */
+ if (H5_PAR_META_WRITE == mpi_rank)
+ if (H5D__contig_write_one(&ioinfo, offset, size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset")
-#ifdef H5_HAVE_PARALLEL
- } /* end else */
+
+ /* Indicate that blocks are being written */
+ blocks_written = TRUE;
+ } /* end if */
+ else {
#endif /* H5_HAVE_PARALLEL */
+ H5_CHECK_OVERFLOW(size, size_t, hsize_t);
+ if (H5D__contig_write_one(&ioinfo, offset, size) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset")
+#ifdef H5_HAVE_PARALLEL
+ } /* end else */
+#endif /* H5_HAVE_PARALLEL */
- npoints -= curr_points;
- offset += size;
- } /* end while */
+ npoints -= curr_points;
+ offset += size;
+ } /* end while */
#ifdef H5_HAVE_PARALLEL
/* Only need to block at the barrier if we actually wrote fill values */
/* And if we are using an MPI-capable file driver */
- if(using_mpi && blocks_written) {
+ if (using_mpi && blocks_written) {
/* Wait at barrier to avoid race conditions where some processes are
* still writing out fill values and other processes race ahead to data
* in, getting bogus data.
*/
- if(MPI_SUCCESS != (mpi_code = MPI_Barrier(mpi_comm)))
+ if (MPI_SUCCESS != (mpi_code = MPI_Barrier(mpi_comm)))
HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code)
- } /* end if */
+ } /* end if */
#endif /* H5_HAVE_PARALLEL */
done:
/* Release the fill buffer info, if it's been initialized */
- if(fb_info_init && H5D__fill_term(&fb_info) < 0)
+ if (fb_info_init && H5D__fill_term(&fb_info) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__contig_fill() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_delete
*
@@ -346,7 +324,7 @@ done:
herr_t
H5D__contig_delete(H5F_t *f, const H5O_storage_t *storage)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -355,14 +333,13 @@ H5D__contig_delete(H5F_t *f, const H5O_storage_t *storage)
HDassert(storage);
/* Free the file space for the chunk */
- if(H5MF_xfree(f, H5FD_MEM_DRAW, storage->u.contig.addr, storage->u.contig.size) < 0)
+ if (H5MF_xfree(f, H5FD_MEM_DRAW, storage->u.contig.addr, storage->u.contig.size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free contiguous storage space")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__contig_delete */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_construct
*
@@ -378,13 +355,13 @@ done:
static herr_t
H5D__contig_construct(H5F_t *f, H5D_t *dset)
{
- hssize_t snelmts; /* Temporary holder for number of elements in dataspace */
- hsize_t nelmts; /* Number of elements in dataspace */
- size_t dt_size; /* Size of datatype */
- hsize_t tmp_size; /* Temporary holder for raw data size */
- size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */
- unsigned u; /* Local index variable */
- herr_t ret_value = SUCCEED; /* Return value */
+ hssize_t snelmts; /* Temporary holder for number of elements in dataspace */
+ hsize_t nelmts; /* Number of elements in dataspace */
+ size_t dt_size; /* Size of datatype */
+ hsize_t tmp_size; /* Temporary holder for raw data size */
+ size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -399,24 +376,25 @@ H5D__contig_construct(H5F_t *f, H5D_t *dset)
*/
/* Check for invalid dataset dimensions */
- for(u = 0; u < dset->shared->ndims; u++)
- if(dset->shared->max_dims[u] > dset->shared->curr_dims[u])
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "extendible contiguous non-external dataset not allowed")
+ for (u = 0; u < dset->shared->ndims; u++)
+ if (dset->shared->max_dims[u] > dset->shared->curr_dims[u])
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "extendible contiguous non-external dataset not allowed")
/* Retrieve the number of elements in the dataspace */
- if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0)
+ if ((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace")
nelmts = (hsize_t)snelmts;
/* Get the datatype's size */
- if(0 == (dt_size = H5T_GET_SIZE(dset->shared->type)))
+ if (0 == (dt_size = H5T_GET_SIZE(dset->shared->type)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype")
/* Compute the size of the dataset's contiguous storage */
tmp_size = nelmts * dt_size;
/* Check for overflow during multiplication */
- if(nelmts != (tmp_size / dt_size))
+ if (nelmts != (tmp_size / dt_size))
HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed")
/* Assign the dataset's contiguous storage size */
@@ -427,7 +405,7 @@ H5D__contig_construct(H5F_t *f, H5D_t *dset)
/* Adjust the sieve buffer size to the smaller one between the dataset size and the buffer size
* from the file access property. (SLU - 2012/3/30) */
- if(tmp_size < tmp_sieve_buf_size)
+ if (tmp_size < tmp_sieve_buf_size)
dset->shared->cache.contig.sieve_buf_size = tmp_size;
else
dset->shared->cache.contig.sieve_buf_size = tmp_sieve_buf_size;
@@ -436,7 +414,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__contig_construct() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_init
*
@@ -451,12 +428,11 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset,
- hid_t H5_ATTR_UNUSED dapl_id)
+H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset, hid_t H5_ATTR_UNUSED dapl_id)
{
- hsize_t tmp_size; /* Temporary holder for raw data size */
- size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */
- herr_t ret_value = SUCCEED; /* Return value */
+ hsize_t tmp_size; /* Temporary holder for raw data size */
+ size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -468,25 +444,25 @@ H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset,
* layout message less than version 3 because versions 1 & 2 would
* truncate the dimension sizes to 32-bits of information. - QAK 5/26/04
*/
- if(dset->shared->layout.version < 3) {
- hssize_t snelmts; /* Temporary holder for number of elements in dataspace */
- hsize_t nelmts; /* Number of elements in dataspace */
- size_t dt_size; /* Size of datatype */
+ if (dset->shared->layout.version < 3) {
+ hssize_t snelmts; /* Temporary holder for number of elements in dataspace */
+ hsize_t nelmts; /* Number of elements in dataspace */
+ size_t dt_size; /* Size of datatype */
/* Retrieve the number of elements in the dataspace */
- if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0)
+ if ((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace")
nelmts = (hsize_t)snelmts;
/* Get the datatype's size */
- if(0 == (dt_size = H5T_GET_SIZE(dset->shared->type)))
+ if (0 == (dt_size = H5T_GET_SIZE(dset->shared->type)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype")
/* Compute the size of the dataset's contiguous storage */
tmp_size = nelmts * dt_size;
/* Check for overflow during multiplication */
- if(nelmts != (tmp_size / dt_size))
+ if (nelmts != (tmp_size / dt_size))
HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed")
/* Assign the dataset's contiguous storage size */
@@ -500,7 +476,7 @@ H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset,
/* Adjust the sieve buffer size to the smaller one between the dataset size and the buffer size
* from the file access property. (SLU - 2012/3/30) */
- if(tmp_size < tmp_sieve_buf_size)
+ if (tmp_size < tmp_sieve_buf_size)
dset->shared->cache.contig.sieve_buf_size = tmp_size;
else
dset->shared->cache.contig.sieve_buf_size = tmp_sieve_buf_size;
@@ -509,7 +485,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__contig_init() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_is_space_alloc
*
@@ -525,7 +500,7 @@ done:
hbool_t
H5D__contig_is_space_alloc(const H5O_storage_t *storage)
{
- hbool_t ret_value = FALSE; /* Return value */
+ hbool_t ret_value = FALSE; /* Return value */
FUNC_ENTER_PACKAGE_NOERR
@@ -538,7 +513,6 @@ H5D__contig_is_space_alloc(const H5O_storage_t *storage)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__contig_is_space_alloc() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_is_data_cached
*
@@ -562,7 +536,6 @@ H5D__contig_is_data_cached(const H5D_shared_t *shared_dset)
FUNC_LEAVE_NOAPI(shared_dset->cache.contig.sieve_size > 0)
} /* end H5D__contig_is_data_cached() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_io_init
*
@@ -577,8 +550,8 @@ H5D__contig_is_data_cached(const H5D_shared_t *shared_dset)
*/
static herr_t
H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNUSED *type_info,
- hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space,
- H5D_chunk_map_t H5_ATTR_UNUSED *cm)
+ hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space,
+ const H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *cm)
{
FUNC_ENTER_STATIC_NOERR
@@ -588,7 +561,6 @@ H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D__contig_io_init() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_read
*
@@ -602,11 +574,10 @@ H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_
*-------------------------------------------------------------------------
*/
herr_t
-H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
- hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space,
- H5D_chunk_map_t H5_ATTR_UNUSED *fm)
+H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts,
+ const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm)
{
- herr_t ret_value = SUCCEED; /*return value */
+ herr_t ret_value = SUCCEED; /*return value */
FUNC_ENTER_PACKAGE
@@ -618,14 +589,13 @@ H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
HDassert(file_space);
/* Read data */
- if((io_info->io_ops.single_read)(io_info, type_info, nelmts, file_space, mem_space) < 0)
+ if ((io_info->io_ops.single_read)(io_info, type_info, nelmts, file_space, mem_space) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "contiguous read failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__contig_read() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_write
*
@@ -639,11 +609,10 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
- hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space,
- H5D_chunk_map_t H5_ATTR_UNUSED *fm)
+H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts,
+ const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm)
{
- herr_t ret_value = SUCCEED; /*return value */
+ herr_t ret_value = SUCCEED; /*return value */
FUNC_ENTER_PACKAGE
@@ -655,14 +624,13 @@ H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
HDassert(file_space);
/* Write data */
- if((io_info->io_ops.single_write)(io_info, type_info, nelmts, file_space, mem_space) < 0)
+ if ((io_info->io_ops.single_write)(io_info, type_info, nelmts, file_space, mem_space) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "contiguous write failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__contig_write() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_write_one
*
@@ -680,27 +648,26 @@ done:
static herr_t
H5D__contig_write_one(H5D_io_info_t *io_info, hsize_t offset, size_t size)
{
- hsize_t dset_off = offset; /* Offset in dataset */
- size_t dset_len = size; /* Length in dataset */
- size_t dset_curr_seq = 0; /* "Current sequence" in dataset */
- hsize_t mem_off = 0; /* Offset in memory */
- size_t mem_len = size; /* Length in memory */
- size_t mem_curr_seq = 0; /* "Current sequence" in memory */
- herr_t ret_value = SUCCEED; /* Return value */
+ hsize_t dset_off = offset; /* Offset in dataset */
+ size_t dset_len = size; /* Length in dataset */
+ size_t dset_curr_seq = 0; /* "Current sequence" in dataset */
+ hsize_t mem_off = 0; /* Offset in memory */
+ size_t mem_len = size; /* Length in memory */
+ size_t mem_curr_seq = 0; /* "Current sequence" in memory */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
HDassert(io_info);
- if(H5D__contig_writevv(io_info, (size_t)1, &dset_curr_seq, &dset_len, &dset_off,
- (size_t)1, &mem_curr_seq, &mem_len, &mem_off) < 0)
+ if (H5D__contig_writevv(io_info, (size_t)1, &dset_curr_seq, &dset_len, &dset_off, (size_t)1,
+ &mem_curr_seq, &mem_len, &mem_off) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D__contig_write_one() */
+} /* end H5D__contig_write_one() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_readvv_sieve_cb
*
@@ -714,30 +681,31 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
- void *_udata)
+H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata)
{
- H5D_contig_readvv_sieve_ud_t *udata = (H5D_contig_readvv_sieve_ud_t *)_udata; /* User data for H5VM_opvv() operator */
- H5F_shared_t *f_sh = udata->f_sh; /* Shared file for dataset */
- H5D_rdcdc_t *dset_contig = udata->dset_contig; /* Cached information about contiguous data */
- const H5D_contig_storage_t *store_contig = udata->store_contig; /* Contiguous storage info for this I/O operation */
- unsigned char *buf; /* Pointer to buffer to fill */
- haddr_t addr; /* Actual address to read */
- haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */
- haddr_t contig_end; /* End locations of block to write */
- size_t sieve_size = (size_t)-1; /* Size of sieve buffer */
- haddr_t rel_eoa; /* Relative end of file address */
- hsize_t max_data; /* Actual maximum size of data to cache */
- hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5D_contig_readvv_sieve_ud_t *udata =
+ (H5D_contig_readvv_sieve_ud_t *)_udata; /* User data for H5VM_opvv() operator */
+ H5F_shared_t *f_sh = udata->f_sh; /* Shared file for dataset */
+ H5D_rdcdc_t * dset_contig = udata->dset_contig; /* Cached information about contiguous data */
+ const H5D_contig_storage_t *store_contig =
+ udata->store_contig; /* Contiguous storage info for this I/O operation */
+ unsigned char *buf; /* Pointer to buffer to fill */
+ haddr_t addr; /* Actual address to read */
+ haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */
+ haddr_t contig_end; /* End locations of block to write */
+ size_t sieve_size = (size_t)-1; /* Size of sieve buffer */
+ haddr_t rel_eoa; /* Relative end of file address */
+ hsize_t max_data; /* Actual maximum size of data to cache */
+ hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Stash local copies of these value */
- if(dset_contig->sieve_buf != NULL) {
+ if (dset_contig->sieve_buf != NULL) {
sieve_start = dset_contig->sieve_loc;
- sieve_size = dset_contig->sieve_size;
- sieve_end = sieve_start + sieve_size;
+ sieve_size = dset_contig->sieve_size;
+ sieve_end = sieve_start + sieve_size;
} /* end if */
/* Compute offset on disk */
@@ -747,22 +715,22 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
buf = udata->rbuf + src_off;
/* Check if the sieve buffer is allocated yet */
- if(NULL == dset_contig->sieve_buf) {
+ if (NULL == dset_contig->sieve_buf) {
/* Check if we can actually hold the I/O request in the sieve buffer */
- if(len > dset_contig->sieve_buf_size) {
- if(H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0)
+ if (len > dset_contig->sieve_buf_size) {
+ if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed")
} /* end if */
else {
/* Allocate room for the data sieve buffer */
- if(NULL == (dset_contig->sieve_buf = H5FL_BLK_CALLOC(sieve_buf, dset_contig->sieve_buf_size)))
+ if (NULL == (dset_contig->sieve_buf = H5FL_BLK_CALLOC(sieve_buf, dset_contig->sieve_buf_size)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed")
/* Determine the new sieve buffer size & location */
dset_contig->sieve_loc = addr;
/* Make certain we don't read off the end of the file */
- if(HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW)))
+ if (HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine file size")
/* Set up the buffer parameters */
@@ -773,7 +741,8 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t);
/* Read the new sieve buffer */
- if(H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0)
+ if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size,
+ dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed")
/* Grab the data out of the buffer (must be first piece of data in buffer ) */
@@ -782,13 +751,13 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
/* Reset sieve buffer dirty flag */
dset_contig->sieve_dirty = FALSE;
} /* end else */
- } /* end if */
+ } /* end if */
else {
/* Compute end of sequence to retrieve */
contig_end = addr + len - 1;
/* If entire read is within the sieve buffer, read it from the buffer */
- if(addr >= sieve_start && contig_end < sieve_end) {
+ if (addr >= sieve_start && contig_end < sieve_end) {
unsigned char *base_sieve_buf = dset_contig->sieve_buf + (addr - sieve_start);
/* Grab the data out of the buffer */
@@ -797,31 +766,33 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
/* Entire request is not within this data sieve buffer */
else {
/* Check if we can actually hold the I/O request in the sieve buffer */
- if(len > dset_contig->sieve_buf_size) {
+ if (len > dset_contig->sieve_buf_size) {
/* Check for any overlap with the current sieve buffer */
- if((sieve_start >= addr && sieve_start < (contig_end + 1))
- || ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) {
+ if ((sieve_start >= addr && sieve_start < (contig_end + 1)) ||
+ ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) {
/* Flush the sieve buffer, if it's dirty */
- if(dset_contig->sieve_dirty) {
+ if (dset_contig->sieve_dirty) {
/* Write to file */
- if(H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, dset_contig->sieve_buf) < 0)
+ if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size,
+ dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed")
/* Reset sieve buffer dirty flag */
dset_contig->sieve_dirty = FALSE;
} /* end if */
- } /* end if */
+ } /* end if */
/* Read directly into the user's buffer */
- if(H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0)
+ if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed")
} /* end if */
/* Element size fits within the buffer size */
else {
/* Flush the sieve buffer if it's dirty */
- if(dset_contig->sieve_dirty) {
+ if (dset_contig->sieve_dirty) {
/* Write to file */
- if(H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, dset_contig->sieve_buf) < 0)
+ if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size,
+ dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed")
/* Reset sieve buffer dirty flag */
@@ -832,7 +803,7 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
dset_contig->sieve_loc = addr;
/* Make certain we don't read off the end of the file */
- if(HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW)))
+ if (HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine file size")
/* Only need this when resizing sieve buffer */
@@ -847,7 +818,8 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t);
/* Read the new sieve buffer */
- if(H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0)
+ if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc,
+ dset_contig->sieve_size, dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed")
/* Grab the data out of the buffer (must be first piece of data in buffer ) */
@@ -856,14 +828,13 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
/* Reset sieve buffer dirty flag */
dset_contig->sieve_dirty = FALSE;
} /* end else */
- } /* end else */
- } /* end else */
+ } /* end else */
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D__contig_readvv_sieve_cb() */
+} /* end H5D__contig_readvv_sieve_cb() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_readvv_cb
*
@@ -880,20 +851,19 @@ static herr_t
H5D__contig_readvv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata)
{
H5D_contig_readvv_ud_t *udata = (H5D_contig_readvv_ud_t *)_udata; /* User data for H5VM_opvv() operator */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Write data */
- if(H5F_shared_block_read(udata->f_sh, H5FD_MEM_DRAW, (udata->dset_addr + dst_off),
- len, (udata->rbuf + src_off)) < 0)
+ if (H5F_shared_block_read(udata->f_sh, H5FD_MEM_DRAW, (udata->dset_addr + dst_off), len,
+ (udata->rbuf + src_off)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D__contig_readvv_cb() */
+} /* end H5D__contig_readvv_cb() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_readvv
*
@@ -913,11 +883,11 @@ done:
*-------------------------------------------------------------------------
*/
static ssize_t
-H5D__contig_readvv(const H5D_io_info_t *io_info,
- size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_off_arr[],
- size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[])
+H5D__contig_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq,
+ size_t dset_len_arr[], hsize_t dset_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq,
+ size_t mem_len_arr[], hsize_t mem_off_arr[])
{
- ssize_t ret_value = -1; /* Return value */
+ ssize_t ret_value = -1; /* Return value */
FUNC_ENTER_STATIC
@@ -931,41 +901,40 @@ H5D__contig_readvv(const H5D_io_info_t *io_info,
HDassert(mem_off_arr);
/* Check if data sieving is enabled */
- if(H5F_SHARED_HAS_FEATURE(io_info->f_sh, H5FD_FEAT_DATA_SIEVE)) {
- H5D_contig_readvv_sieve_ud_t udata; /* User data for H5VM_opvv() operator */
+ if (H5F_SHARED_HAS_FEATURE(io_info->f_sh, H5FD_FEAT_DATA_SIEVE)) {
+ H5D_contig_readvv_sieve_ud_t udata; /* User data for H5VM_opvv() operator */
/* Set up user data for H5VM_opvv() */
- udata.f_sh = io_info->f_sh;
- udata.dset_contig = &(io_info->dset->shared->cache.contig);
+ udata.f_sh = io_info->f_sh;
+ udata.dset_contig = &(io_info->dset->shared->cache.contig);
udata.store_contig = &(io_info->store->contig);
- udata.rbuf = (unsigned char *)io_info->u.rbuf;
+ udata.rbuf = (unsigned char *)io_info->u.rbuf;
/* Call generic sequence operation routine */
- if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr,
- mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr,
- H5D__contig_readvv_sieve_cb, &udata)) < 0)
+ if ((ret_value =
+ H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq,
+ mem_curr_seq, mem_len_arr, mem_off_arr, H5D__contig_readvv_sieve_cb, &udata)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized sieve buffer read")
} /* end if */
else {
- H5D_contig_readvv_ud_t udata; /* User data for H5VM_opvv() operator */
+ H5D_contig_readvv_ud_t udata; /* User data for H5VM_opvv() operator */
/* Set up user data for H5VM_opvv() */
- udata.f_sh = io_info->f_sh;
+ udata.f_sh = io_info->f_sh;
udata.dset_addr = io_info->store->contig.dset_addr;
- udata.rbuf = (unsigned char *)io_info->u.rbuf;
+ udata.rbuf = (unsigned char *)io_info->u.rbuf;
/* Call generic sequence operation routine */
- if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr,
- mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr,
- H5D__contig_readvv_cb, &udata)) < 0)
+ if ((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq,
+ mem_curr_seq, mem_len_arr, mem_off_arr, H5D__contig_readvv_cb, &udata)) <
+ 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized read")
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D__contig_readvv() */
+} /* end H5D__contig_readvv() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_writevv_sieve_cb
*
@@ -979,30 +948,31 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
- void *_udata)
+H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata)
{
- H5D_contig_writevv_sieve_ud_t *udata = (H5D_contig_writevv_sieve_ud_t *)_udata; /* User data for H5VM_opvv() operator */
- H5F_shared_t *f_sh = udata->f_sh; /* Shared file for dataset */
- H5D_rdcdc_t *dset_contig = udata->dset_contig; /* Cached information about contiguous data */
- const H5D_contig_storage_t *store_contig = udata->store_contig; /* Contiguous storage info for this I/O operation */
- const unsigned char *buf; /* Pointer to buffer to fill */
- haddr_t addr; /* Actual address to read */
- haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */
- haddr_t contig_end; /* End locations of block to write */
- size_t sieve_size = (size_t)-1; /* size of sieve buffer */
- haddr_t rel_eoa; /* Relative end of file address */
- hsize_t max_data; /* Actual maximum size of data to cache */
- hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5D_contig_writevv_sieve_ud_t *udata =
+ (H5D_contig_writevv_sieve_ud_t *)_udata; /* User data for H5VM_opvv() operator */
+ H5F_shared_t *f_sh = udata->f_sh; /* Shared file for dataset */
+ H5D_rdcdc_t * dset_contig = udata->dset_contig; /* Cached information about contiguous data */
+ const H5D_contig_storage_t *store_contig =
+ udata->store_contig; /* Contiguous storage info for this I/O operation */
+ const unsigned char *buf; /* Pointer to buffer to fill */
+ haddr_t addr; /* Actual address to read */
+ haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */
+ haddr_t contig_end; /* End locations of block to write */
+ size_t sieve_size = (size_t)-1; /* size of sieve buffer */
+ haddr_t rel_eoa; /* Relative end of file address */
+ hsize_t max_data; /* Actual maximum size of data to cache */
+ hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Stash local copies of these values */
- if(dset_contig->sieve_buf != NULL) {
+ if (dset_contig->sieve_buf != NULL) {
sieve_start = dset_contig->sieve_loc;
- sieve_size = dset_contig->sieve_size;
- sieve_end = sieve_start + sieve_size;
+ sieve_size = dset_contig->sieve_size;
+ sieve_end = sieve_start + sieve_size;
} /* end if */
/* Compute offset on disk */
@@ -1012,26 +982,26 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
buf = udata->wbuf + src_off;
/* No data sieve buffer yet, go allocate one */
- if(NULL == dset_contig->sieve_buf) {
+ if (NULL == dset_contig->sieve_buf) {
/* Check if we can actually hold the I/O request in the sieve buffer */
- if(len > dset_contig->sieve_buf_size) {
- if(H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0)
+ if (len > dset_contig->sieve_buf_size) {
+ if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed")
} /* end if */
else {
/* Allocate room for the data sieve buffer */
- if(NULL == (dset_contig->sieve_buf = H5FL_BLK_CALLOC(sieve_buf, dset_contig->sieve_buf_size)))
+ if (NULL == (dset_contig->sieve_buf = H5FL_BLK_CALLOC(sieve_buf, dset_contig->sieve_buf_size)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed")
/* Clear memory */
- if(dset_contig->sieve_size > len)
+ if (dset_contig->sieve_size > len)
HDmemset(dset_contig->sieve_buf + len, 0, (dset_contig->sieve_size - len));
/* Determine the new sieve buffer size & location */
dset_contig->sieve_loc = addr;
/* Make certain we don't read off the end of the file */
- if(HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW)))
+ if (HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine file size")
/* Set up the buffer parameters */
@@ -1042,9 +1012,10 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t);
/* Check if there is any point in reading the data from the file */
- if(dset_contig->sieve_size > len) {
+ if (dset_contig->sieve_size > len) {
/* Read the new sieve buffer */
- if(H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0)
+ if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc,
+ dset_contig->sieve_size, dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed")
} /* end if */
@@ -1056,16 +1027,16 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
/* Stash local copies of these values */
sieve_start = dset_contig->sieve_loc;
- sieve_size = dset_contig->sieve_size;
- sieve_end = sieve_start + sieve_size;
+ sieve_size = dset_contig->sieve_size;
+ sieve_end = sieve_start + sieve_size;
} /* end else */
- } /* end if */
+ } /* end if */
else {
/* Compute end of sequence to retrieve */
contig_end = addr + len - 1;
/* If entire write is within the sieve buffer, write it to the buffer */
- if(addr >= sieve_start && contig_end < sieve_end) {
+ if (addr >= sieve_start && contig_end < sieve_end) {
unsigned char *base_sieve_buf = dset_contig->sieve_buf + (addr - sieve_start);
/* Put the data into the sieve buffer */
@@ -1077,14 +1048,15 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
/* Entire request is not within this data sieve buffer */
else {
/* Check if we can actually hold the I/O request in the sieve buffer */
- if(len > dset_contig->sieve_buf_size) {
+ if (len > dset_contig->sieve_buf_size) {
/* Check for any overlap with the current sieve buffer */
- if((sieve_start >= addr && sieve_start < (contig_end + 1))
- || ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) {
+ if ((sieve_start >= addr && sieve_start < (contig_end + 1)) ||
+ ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) {
/* Flush the sieve buffer, if it's dirty */
- if(dset_contig->sieve_dirty) {
+ if (dset_contig->sieve_dirty) {
/* Write to file */
- if(H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, dset_contig->sieve_buf) < 0)
+ if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size,
+ dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed")
/* Reset sieve buffer dirty flag */
@@ -1092,24 +1064,24 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
} /* end if */
/* Force the sieve buffer to be re-read the next time */
- dset_contig->sieve_loc = HADDR_UNDEF;
+ dset_contig->sieve_loc = HADDR_UNDEF;
dset_contig->sieve_size = 0;
} /* end if */
/* Write directly from the user's buffer */
- if(H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0)
+ if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed")
} /* end if */
/* Element size fits within the buffer size */
else {
/* Check if it is possible to (exactly) prepend or append to existing (dirty) sieve buffer */
- if(((addr + len) == sieve_start || addr == sieve_end) &&
- (len + sieve_size) <= dset_contig->sieve_buf_size &&
- dset_contig->sieve_dirty) {
+ if (((addr + len) == sieve_start || addr == sieve_end) &&
+ (len + sieve_size) <= dset_contig->sieve_buf_size && dset_contig->sieve_dirty) {
/* Prepend to existing sieve buffer */
- if((addr + len) == sieve_start) {
+ if ((addr + len) == sieve_start) {
/* Move existing sieve information to correct location */
- HDmemmove(dset_contig->sieve_buf + len, dset_contig->sieve_buf, dset_contig->sieve_size);
+ HDmemmove(dset_contig->sieve_buf + len, dset_contig->sieve_buf,
+ dset_contig->sieve_size);
/* Copy in new information (must be first in sieve buffer) */
H5MM_memcpy(dset_contig->sieve_buf, buf, len);
@@ -1130,9 +1102,10 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
/* Can't add the new data onto the existing sieve buffer */
else {
/* Flush the sieve buffer if it's dirty */
- if(dset_contig->sieve_dirty) {
+ if (dset_contig->sieve_dirty) {
/* Write to file */
- if(H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, dset_contig->sieve_buf) < 0)
+ if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size,
+ dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed")
/* Reset sieve buffer dirty flag */
@@ -1143,7 +1116,7 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
dset_contig->sieve_loc = addr;
/* Make certain we don't read off the end of the file */
- if(HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW)))
+ if (HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine file size")
/* Only need this when resizing sieve buffer */
@@ -1158,9 +1131,10 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t);
/* Check if there is any point in reading the data from the file */
- if(dset_contig->sieve_size > len) {
+ if (dset_contig->sieve_size > len) {
/* Read the new sieve buffer */
- if(H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0)
+ if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc,
+ dset_contig->sieve_size, dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed")
} /* end if */
@@ -1170,15 +1144,14 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
/* Set sieve buffer dirty flag */
dset_contig->sieve_dirty = TRUE;
} /* end else */
- } /* end else */
- } /* end else */
- } /* end else */
+ } /* end else */
+ } /* end else */
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D__contig_writevv_sieve_cb() */
+} /* end H5D__contig_writevv_sieve_cb() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_writevv_cb
*
@@ -1194,20 +1167,21 @@ done:
static herr_t
H5D__contig_writevv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata)
{
- H5D_contig_writevv_ud_t *udata = (H5D_contig_writevv_ud_t *)_udata; /* User data for H5VM_opvv() operator */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5D_contig_writevv_ud_t *udata =
+ (H5D_contig_writevv_ud_t *)_udata; /* User data for H5VM_opvv() operator */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Write data */
- if(H5F_shared_block_write(udata->f_sh, H5FD_MEM_DRAW, (udata->dset_addr + dst_off), len, (udata->wbuf + src_off)) < 0)
+ if (H5F_shared_block_write(udata->f_sh, H5FD_MEM_DRAW, (udata->dset_addr + dst_off), len,
+ (udata->wbuf + src_off)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D__contig_writevv_cb() */
+} /* end H5D__contig_writevv_cb() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_writevv
*
@@ -1227,11 +1201,11 @@ done:
*-------------------------------------------------------------------------
*/
static ssize_t
-H5D__contig_writevv(const H5D_io_info_t *io_info,
- size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_off_arr[],
- size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[])
+H5D__contig_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq,
+ size_t dset_len_arr[], hsize_t dset_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq,
+ size_t mem_len_arr[], hsize_t mem_off_arr[])
{
- ssize_t ret_value = -1; /* Return value (Size of sequence in bytes) */
+ ssize_t ret_value = -1; /* Return value (Size of sequence in bytes) */
FUNC_ENTER_STATIC
@@ -1245,41 +1219,40 @@ H5D__contig_writevv(const H5D_io_info_t *io_info,
HDassert(mem_off_arr);
/* Check if data sieving is enabled */
- if(H5F_SHARED_HAS_FEATURE(io_info->f_sh, H5FD_FEAT_DATA_SIEVE)) {
- H5D_contig_writevv_sieve_ud_t udata; /* User data for H5VM_opvv() operator */
+ if (H5F_SHARED_HAS_FEATURE(io_info->f_sh, H5FD_FEAT_DATA_SIEVE)) {
+ H5D_contig_writevv_sieve_ud_t udata; /* User data for H5VM_opvv() operator */
/* Set up user data for H5VM_opvv() */
- udata.f_sh = io_info->f_sh;
- udata.dset_contig = &(io_info->dset->shared->cache.contig);
+ udata.f_sh = io_info->f_sh;
+ udata.dset_contig = &(io_info->dset->shared->cache.contig);
udata.store_contig = &(io_info->store->contig);
- udata.wbuf = (const unsigned char *)io_info->u.wbuf;
+ udata.wbuf = (const unsigned char *)io_info->u.wbuf;
/* Call generic sequence operation routine */
- if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr,
- mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr,
- H5D__contig_writevv_sieve_cb, &udata)) < 0)
+ if ((ret_value =
+ H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq,
+ mem_curr_seq, mem_len_arr, mem_off_arr, H5D__contig_writevv_sieve_cb, &udata)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized sieve buffer write")
} /* end if */
else {
- H5D_contig_writevv_ud_t udata; /* User data for H5VM_opvv() operator */
+ H5D_contig_writevv_ud_t udata; /* User data for H5VM_opvv() operator */
/* Set up user data for H5VM_opvv() */
- udata.f_sh = io_info->f_sh;
+ udata.f_sh = io_info->f_sh;
udata.dset_addr = io_info->store->contig.dset_addr;
- udata.wbuf = (const unsigned char *)io_info->u.wbuf;
+ udata.wbuf = (const unsigned char *)io_info->u.wbuf;
/* Call generic sequence operation routine */
- if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr,
- mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr,
- H5D__contig_writevv_cb, &udata)) < 0)
+ if ((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq,
+ mem_curr_seq, mem_len_arr, mem_off_arr, H5D__contig_writevv_cb, &udata)) <
+ 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized read")
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D__contig_writevv() */
+} /* end H5D__contig_writevv() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_flush
*
@@ -1295,7 +1268,7 @@ done:
static herr_t
H5D__contig_flush(H5D_t *dset)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -1303,14 +1276,13 @@ H5D__contig_flush(H5D_t *dset)
HDassert(dset);
/* Flush any data in sieve buffer */
- if(H5D__flush_sieve_buf(dset) < 0)
+ if (H5D__flush_sieve_buf(dset) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush sieve buffer")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__contig_flush() */
-
/*-------------------------------------------------------------------------
* Function: H5D__contig_copy
*
@@ -1324,41 +1296,41 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
- H5F_t *f_dst, H5O_storage_contig_t *storage_dst, H5T_t *dt_src,
- H5O_copy_t *cpy_info)
+H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, H5F_t *f_dst,
+ H5O_storage_contig_t *storage_dst, H5T_t *dt_src, H5O_copy_t *cpy_info)
{
- haddr_t addr_src; /* File offset in source dataset */
- haddr_t addr_dst; /* File offset in destination dataset */
- H5T_path_t *tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */
- H5T_t *dt_dst = NULL; /* Destination datatype */
- H5T_t *dt_mem = NULL; /* Memory datatype */
- hid_t tid_src = -1; /* Datatype ID for source datatype */
- hid_t tid_dst = -1; /* Datatype ID for destination datatype */
- hid_t tid_mem = -1; /* Datatype ID for memory datatype */
- size_t src_dt_size = 0; /* Source datatype size */
- size_t mem_dt_size = 0; /* Memory datatype size */
- size_t dst_dt_size = 0; /* Destination datatype size */
- size_t max_dt_size; /* Max. datatype size */
- size_t nelmts = 0; /* Number of elements in buffer */
- size_t src_nbytes; /* Number of bytes to read from source */
- size_t mem_nbytes; /* Number of bytes to convert in memory */
- size_t dst_nbytes; /* Number of bytes to write to destination */
- hsize_t total_src_nbytes; /* Total number of bytes to copy */
- size_t buf_size; /* Size of copy buffer */
- void *buf = NULL; /* Buffer for copying data */
- void *bkg = NULL; /* Temporary buffer for copying data */
- void *reclaim_buf = NULL; /* Buffer for reclaiming data */
- H5S_t *buf_space = NULL; /* Dataspace describing buffer */
- hid_t buf_sid = -1; /* ID for buffer dataspace */
- hsize_t buf_dim[1] = {0}; /* Dimension for buffer */
- hbool_t is_vlen = FALSE; /* Flag to indicate that VL type conversion should occur */
- hbool_t fix_ref = FALSE; /* Flag to indicate that ref values should be fixed */
- H5D_shared_t *shared_fo = (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */
- hbool_t try_sieve = FALSE; /* Try to get data from the sieve buffer */
- haddr_t sieve_start = HADDR_UNDEF; /* Start location of sieve buffer */
- haddr_t sieve_end = HADDR_UNDEF; /* End locations of sieve buffer */
- herr_t ret_value = SUCCEED; /* Return value */
+ haddr_t addr_src; /* File offset in source dataset */
+ haddr_t addr_dst; /* File offset in destination dataset */
+ H5T_path_t * tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */
+ H5T_t * dt_dst = NULL; /* Destination datatype */
+ H5T_t * dt_mem = NULL; /* Memory datatype */
+ hid_t tid_src = -1; /* Datatype ID for source datatype */
+ hid_t tid_dst = -1; /* Datatype ID for destination datatype */
+ hid_t tid_mem = -1; /* Datatype ID for memory datatype */
+ size_t src_dt_size = 0; /* Source datatype size */
+ size_t mem_dt_size = 0; /* Memory datatype size */
+ size_t dst_dt_size = 0; /* Destination datatype size */
+ size_t max_dt_size; /* Max. datatype size */
+ size_t nelmts = 0; /* Number of elements in buffer */
+ size_t src_nbytes; /* Number of bytes to read from source */
+ size_t mem_nbytes; /* Number of bytes to convert in memory */
+ size_t dst_nbytes; /* Number of bytes to write to destination */
+ hsize_t total_src_nbytes; /* Total number of bytes to copy */
+ size_t buf_size; /* Size of copy buffer */
+ void * buf = NULL; /* Buffer for copying data */
+ void * bkg = NULL; /* Temporary buffer for copying data */
+ void * reclaim_buf = NULL; /* Buffer for reclaiming data */
+ H5S_t * buf_space = NULL; /* Dataspace describing buffer */
+ hid_t buf_sid = -1; /* ID for buffer dataspace */
+ hsize_t buf_dim[1] = {0}; /* Dimension for buffer */
+ hbool_t is_vlen = FALSE; /* Flag to indicate that VL type conversion should occur */
+ hbool_t fix_ref = FALSE; /* Flag to indicate that ref values should be fixed */
+ H5D_shared_t *shared_fo =
+ (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */
+ hbool_t try_sieve = FALSE; /* Try to get data from the sieve buffer */
+ haddr_t sieve_start = HADDR_UNDEF; /* Start location of sieve buffer */
+ haddr_t sieve_end = HADDR_UNDEF; /* End locations of sieve buffer */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -1370,7 +1342,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
HDassert(dt_src);
/* Allocate space for destination raw data */
- if(H5D__contig_alloc(f_dst, storage_dst) < 0)
+ if (H5D__contig_alloc(f_dst, storage_dst) < 0)
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to allocate contiguous storage")
/* Set up number of bytes to copy, and initial buffer size */
@@ -1382,49 +1354,49 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
/* Create datatype ID for src datatype. We may or may not use this ID,
* but this ensures that the src datatype will be freed.
*/
- if((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0)
+ if ((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
/* If there's a VLEN source datatype, set up type conversion information */
- if(H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) {
+ if (H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) {
/* create a memory copy of the variable-length datatype */
- if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
+ if (NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
- if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) {
+ if ((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) {
(void)H5T_close_real(dt_mem);
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register memory datatype")
} /* end if */
/* create variable-length datatype at the destinaton file */
- if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
+ if (NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy")
- if(H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) {
+ if (H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) {
(void)H5T_close_real(dt_dst);
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "cannot mark datatype on disk")
} /* end if */
- if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) {
+ if ((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) {
(void)H5T_close_real(dt_dst);
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype")
} /* end if */
/* Set up the conversion functions */
- if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem)))
+ if (NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes")
- if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst)))
+ if (NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes")
/* Determine largest datatype size */
- if(0 == (src_dt_size = H5T_get_size(dt_src)))
+ if (0 == (src_dt_size = H5T_get_size(dt_src)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to determine datatype size")
- if(0 == (mem_dt_size = H5T_get_size(dt_mem)))
+ if (0 == (mem_dt_size = H5T_get_size(dt_mem)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to determine datatype size")
max_dt_size = MAX(src_dt_size, mem_dt_size);
- if(0 == (dst_dt_size = H5T_get_size(dt_dst)))
+ if (0 == (dst_dt_size = H5T_get_size(dt_dst)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to determine datatype size")
max_dt_size = MAX(max_dt_size, dst_dt_size);
/* Set maximum number of whole elements that fit in buffer */
- if(0 == (nelmts = buf_size / max_dt_size))
+ if (0 == (nelmts = buf_size / max_dt_size))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "element size too large")
/* Set the number of bytes to transfer */
@@ -1439,11 +1411,11 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
buf_dim[0] = nelmts;
/* Create the space and set the initial extent */
- if(NULL == (buf_space = H5S_create_simple((unsigned)1, buf_dim, NULL)))
+ if (NULL == (buf_space = H5S_create_simple((unsigned)1, buf_dim, NULL)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
/* Atomize */
- if((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) {
+ if ((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) {
H5S_close(buf_space);
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID")
} /* end if */
@@ -1453,9 +1425,9 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
} /* end if */
else {
/* Check for reference datatype */
- if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) {
+ if (H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) {
/* Need to fix values of references when copying across files */
- if(f_src != f_dst)
+ if (f_src != f_dst)
fix_ref = TRUE;
} /* end if */
@@ -1465,16 +1437,16 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
/* Allocate space for copy buffer */
HDassert(buf_size);
- if(NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size)))
+ if (NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer")
/* Need extra buffer for datatype conversions, to prevent stranding/leaking memory */
- if(is_vlen || fix_ref) {
- if(NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, buf_size)))
+ if (is_vlen || fix_ref) {
+ if (NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer")
/* allocate temporary bkg buff for data conversion */
- if(NULL == (bkg = H5FL_BLK_MALLOC(type_conv, buf_size)))
+ if (NULL == (bkg = H5FL_BLK_MALLOC(type_conv, buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer")
} /* end if */
@@ -1484,23 +1456,22 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
/* If data sieving is enabled and the dataset is open in the file,
set up to copy data out of the sieve buffer if deemed possible later */
- if(H5F_HAS_FEATURE(f_src, H5FD_FEAT_DATA_SIEVE) &&
- shared_fo && shared_fo->cache.contig.sieve_buf) {
- try_sieve = TRUE;
+ if (H5F_HAS_FEATURE(f_src, H5FD_FEAT_DATA_SIEVE) && shared_fo && shared_fo->cache.contig.sieve_buf) {
+ try_sieve = TRUE;
sieve_start = shared_fo->cache.contig.sieve_loc;
- sieve_end = sieve_start + shared_fo->cache.contig.sieve_size;
+ sieve_end = sieve_start + shared_fo->cache.contig.sieve_size;
}
- while(total_src_nbytes > 0) {
+ while (total_src_nbytes > 0) {
/* Check if we should reduce the number of bytes to transfer */
- if(total_src_nbytes < src_nbytes) {
+ if (total_src_nbytes < src_nbytes) {
/* Adjust bytes to transfer */
src_nbytes = (size_t)total_src_nbytes;
/* Adjust dataspace describing buffer */
- if(is_vlen) {
+ if (is_vlen) {
/* Adjust destination & memory bytes to transfer */
- nelmts = src_nbytes / src_dt_size;
+ nelmts = src_nbytes / src_dt_size;
dst_nbytes = nelmts * dst_dt_size;
mem_nbytes = nelmts * mem_dt_size;
@@ -1508,7 +1479,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
buf_dim[0] = nelmts;
/* Adjust size of buffer's dataspace */
- if(H5S_set_extent_real(buf_space, buf_dim) < 0)
+ if (H5S_set_extent_real(buf_space, buf_dim) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to change buffer dataspace size")
} /* end if */
else
@@ -1517,19 +1488,20 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
} /* end if */
/* If the entire copy is within the sieve buffer, copy data from the sieve buffer */
- if(try_sieve && (addr_src >= sieve_start) && ((addr_src + src_nbytes -1) < sieve_end)) {
+ if (try_sieve && (addr_src >= sieve_start) && ((addr_src + src_nbytes - 1) < sieve_end)) {
unsigned char *base_sieve_buf = shared_fo->cache.contig.sieve_buf + (addr_src - sieve_start);
H5MM_memcpy(buf, base_sieve_buf, src_nbytes);
- } else
+ }
+ else
/* Read raw data from source file */
- if(H5F_block_read(f_src, H5FD_MEM_DRAW, addr_src, src_nbytes, buf) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read raw data")
+ if (H5F_block_read(f_src, H5FD_MEM_DRAW, addr_src, src_nbytes, buf) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read raw data")
/* Perform datatype conversion, if necessary */
- if(is_vlen) {
+ if (is_vlen) {
/* Convert from source file to memory */
- if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0)
+ if (H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
/* Copy into another buffer, to reclaim memory later */
@@ -1539,22 +1511,22 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
HDmemset(bkg, 0, buf_size);
/* Convert from memory to destination file */
- if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0)
+ if (H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
/* Reclaim space from variable length data */
- if(H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
+ if (H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length data")
} /* end if */
- else if(fix_ref) {
+ else if (fix_ref) {
/* Check for expanding references */
- if(cpy_info->expand_ref) {
+ if (cpy_info->expand_ref) {
/* Copy the reference elements */
- if(H5O_copy_expand_ref(f_src, tid_src, dt_src, buf, buf_size, f_dst, bkg, cpy_info) < 0)
+ if (H5O_copy_expand_ref(f_src, tid_src, dt_src, buf, buf_size, f_dst, bkg, cpy_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute")
/* After fix ref, copy the new reference elements to the buffer to write out */
- H5MM_memcpy(buf, bkg, buf_size);
+ H5MM_memcpy(buf, bkg, buf_size);
} /* end if */
else
/* Reset value to zero */
@@ -1562,7 +1534,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
} /* end if */
/* Write raw data to destination file */
- if(H5F_block_write(f_dst, H5FD_MEM_DRAW, addr_dst, dst_nbytes, buf) < 0)
+ if (H5F_block_write(f_dst, H5FD_MEM_DRAW, addr_dst, dst_nbytes, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write raw data")
/* Adjust loop variables */
@@ -1572,21 +1544,20 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
} /* end while */
done:
- if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0)
+ if (buf_sid > 0 && H5I_dec_ref(buf_sid) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID")
- if(tid_src > 0 && H5I_dec_ref(tid_src) < 0)
+ if (tid_src > 0 && H5I_dec_ref(tid_src) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
- if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0)
+ if (tid_dst > 0 && H5I_dec_ref(tid_dst) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
- if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0)
+ if (tid_mem > 0 && H5I_dec_ref(tid_mem) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
- if(buf)
+ if (buf)
buf = H5FL_BLK_FREE(type_conv, buf);
- if(reclaim_buf)
+ if (reclaim_buf)
reclaim_buf = H5FL_BLK_FREE(type_conv, reclaim_buf);
- if(bkg)
+ if (bkg)
bkg = H5FL_BLK_FREE(type_conv, bkg);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__contig_copy() */
-