summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5D.c13
-rw-r--r--src/H5Distore.c86
-rw-r--r--src/H5Fistore.c86
-rw-r--r--src/H5Fprivate.h2
-rw-r--r--test/Makefile.in4
-rw-r--r--test/tmisc.c320
6 files changed, 442 insertions, 69 deletions
diff --git a/src/H5D.c b/src/H5D.c
index d4f28db..b033e48 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -3196,10 +3196,12 @@ H5D_init_storage(H5D_t *dset, const H5S_t *space)
hsize_t addr; /* Offset in dataset */
void *buf = NULL; /* Buffer for fill value writing */
H5O_fill_t fill; /* Fill value information */
+ H5D_space_time_t space_time; /* When to allocate space */
H5P_genplist_t *plist; /* Property list */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5D_init_storage);
+
assert(dset);
assert(space);
@@ -3208,6 +3210,8 @@ H5D_init_storage(H5D_t *dset, const H5S_t *space)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list");
if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill value");
+ if(H5P_get(plist, H5D_CRT_SPACE_TIME_NAME, &space_time) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve space allocation time");
switch (dset->layout.type) {
case H5D_CONTIGUOUS:
@@ -3252,12 +3256,15 @@ H5D_init_storage(H5D_t *dset, const H5S_t *space)
break;
case H5D_CHUNKED:
-#ifdef H5_HAVE_PARALLEL
/*
* If the dataset is accessed via parallel I/O, allocate file space
* for all chunks now and initialize each chunk with the fill value.
*/
- if (IS_H5FD_MPIO(dset->ent.file) || IS_H5FD_MPIPOSIX(dset->ent.file)) {
+ if (space_time==H5D_SPACE_ALLOC_EARLY
+#ifdef H5_HAVE_PARALLEL
+ || (IS_H5FD_MPIO(dset->ent.file) || IS_H5FD_MPIPOSIX(dset->ent.file))
+#endif /*H5_HAVE_PARALLEL*/
+ ) {
/* We only handle simple data spaces so far */
int ndims;
hsize_t dim[H5O_LAYOUT_NDIMS];
@@ -3271,13 +3278,13 @@ H5D_init_storage(H5D_t *dset, const H5S_t *space)
&(dset->layout), dim, plist)<0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to allocate all chunks of dataset");
} /* end if */
-#endif /*H5_HAVE_PARALLEL*/
break;
} /* end switch */
done:
if (buf)
H5FL_BLK_FREE(type_conv,buf);
+
FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 2c6a403..c9dc766 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -2320,7 +2320,6 @@ done:
* that they should never be written.
*-------------------------------------------------------------------------
*/
-#ifdef H5_HAVE_PARALLEL
herr_t
H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
const hsize_t *space_dim, H5P_genplist_t *dc_plist)
@@ -2334,11 +2333,14 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
void *chunk=NULL; /* Chunk buffer for writing fill values */
H5P_genplist_t *dx_plist; /* Data xfer property list */
double split_ratios[3];/* B-tree node splitting ratios */
- int mpi_rank; /* This process's rank */
- int mpi_size; /* Total # of processes */
+#ifdef H5_HAVE_PARALLEL
+ int mpi_rank=(-1); /* This process's rank */
+ int mpi_size=(-1); /* Total # of processes */
int mpi_round=0; /* Current process responsible for I/O */
int mpi_code; /* MPI return code */
unsigned blocks_written=0; /* Flag to indicate that chunk was actually written */
+ unsigned using_mpi=0; /* Flag to indicate that the file is being accessed with an MPI-capable file driver */
+#endif /* H5_HAVE_PARALLEL */
int carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */
int i; /* Local index variable */
unsigned u; /* Local index variable */
@@ -2369,9 +2371,36 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
if(H5P_get(dx_plist,H5D_XFER_BTREE_SPLIT_RATIO_NAME,split_ratios)<0)
HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "can't get B-tree split ratios");
+#ifdef H5_HAVE_PARALLEL
+ /* Retrieve up MPI parameters */
+ if(IS_H5FD_MPIO(f)) {
+ if ((mpi_rank=H5FD_mpio_mpi_rank(f->shared->lf))<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank");
+ if ((mpi_size=H5FD_mpio_mpi_size(f->shared->lf))<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI size");
+
+ /* Set the MPI-capable file driver flag */
+ using_mpi=1;
+ } /* end if */
+ else {
+ if(IS_H5FD_MPIPOSIX(f)) {
+ /* Get the MPI rank & size */
+ if ((mpi_rank=H5FD_mpiposix_mpi_rank(f->shared->lf))<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank");
+ if ((mpi_size=H5FD_mpiposix_mpi_size(f->shared->lf))<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI size");
+
+ /* Set the MPI-capable file driver flag */
+ using_mpi=1;
+ } /* end if */
+ } /* end else */
+#endif /* H5_HAVE_PARALLEL */
+
+#ifdef H5_HAVE_PARALLEL
/* Can't use data I/O pipeline in parallel (yet) */
- if (pline.nfilters>0)
+ if (using_mpi && pline.nfilters>0)
HGOTO_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, FAIL, "can't use data pipeline in parallel");
+#endif /* H5_HAVE_PARALLEL */
/*
* Setup indice to go through all chunks. (Future improvement
@@ -2404,24 +2433,6 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
} /* end else */
} /* end if */
- /* Retrieve up MPI parameters */
- if(IS_H5FD_MPIO(f)) {
- if ((mpi_rank=H5FD_mpio_mpi_rank(f->shared->lf))<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank");
- if ((mpi_size=H5FD_mpio_mpi_size(f->shared->lf))<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI size");
- } /* end if */
- else {
- /* Sanity Check */
- assert(IS_H5FD_MPIPOSIX(f));
-
- /* Get the MPI rank & size */
- if ((mpi_rank=H5FD_mpiposix_mpi_rank(f->shared->lf))<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank");
- if ((mpi_size=H5FD_mpiposix_mpi_size(f->shared->lf))<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI size");
- } /* end else */
-
/* Loop over all chunks */
carry=0;
while (carry==0) {
@@ -2441,15 +2452,26 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
/* Check if fill values should be written to blocks */
if(fill_time != H5D_FILL_TIME_NEVER) {
- /* Round-robin write the chunks out from only one process */
- if(mpi_round==mpi_rank) {
+#ifdef H5_HAVE_PARALLEL
+ /* Check if this file is accessed with an MPI-capable file driver */
+ if(using_mpi) {
+ /* Round-robin write the chunks out from only one process */
+ if(mpi_round==mpi_rank) {
+ if (H5F_block_write(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, dxpl_id, chunk)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file");
+ } /* end if */
+ mpi_round=(++mpi_round)%mpi_size;
+
+ /* Indicate that blocks are being written */
+ blocks_written=1;
+ } /* end if */
+ else {
+#endif /* H5_HAVE_PARALLEL */
if (H5F_block_write(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, dxpl_id, chunk)<0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file");
- } /* end if */
- mpi_round=(++mpi_round)%mpi_size;
-
- /* Indicate that blocks are being written */
- blocks_written=1;
+#ifdef H5_HAVE_PARALLEL
+ } /* end else */
+#endif /* H5_HAVE_PARALLEL */
} /* end if */
} /* end if */
@@ -2463,8 +2485,10 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
} /* end for */
} /* end while */
+#ifdef H5_HAVE_PARALLEL
/* Only need to block at the barrier if we actually allocated a chunk */
- if(blocks_written) {
+ /* And if we are using an MPI-capable file driver */
+ if(using_mpi && blocks_written) {
/* Wait at barrier to avoid race conditions where some processes are
* still writing out chunks and other processes race ahead to read
* them in, getting bogus data.
@@ -2481,6 +2505,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code);
} /* end else */
} /* end if */
+#endif /* H5_HAVE_PARALLEL */
done:
/* Free the chunk for fill values */
@@ -2489,7 +2514,6 @@ done:
FUNC_LEAVE(ret_value);
}
-#endif /* H5_HAVE_PARALLEL */
/*-------------------------------------------------------------------------
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index 2c6a403..c9dc766 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -2320,7 +2320,6 @@ done:
* that they should never be written.
*-------------------------------------------------------------------------
*/
-#ifdef H5_HAVE_PARALLEL
herr_t
H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
const hsize_t *space_dim, H5P_genplist_t *dc_plist)
@@ -2334,11 +2333,14 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
void *chunk=NULL; /* Chunk buffer for writing fill values */
H5P_genplist_t *dx_plist; /* Data xfer property list */
double split_ratios[3];/* B-tree node splitting ratios */
- int mpi_rank; /* This process's rank */
- int mpi_size; /* Total # of processes */
+#ifdef H5_HAVE_PARALLEL
+ int mpi_rank=(-1); /* This process's rank */
+ int mpi_size=(-1); /* Total # of processes */
int mpi_round=0; /* Current process responsible for I/O */
int mpi_code; /* MPI return code */
unsigned blocks_written=0; /* Flag to indicate that chunk was actually written */
+ unsigned using_mpi=0; /* Flag to indicate that the file is being accessed with an MPI-capable file driver */
+#endif /* H5_HAVE_PARALLEL */
int carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */
int i; /* Local index variable */
unsigned u; /* Local index variable */
@@ -2369,9 +2371,36 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
if(H5P_get(dx_plist,H5D_XFER_BTREE_SPLIT_RATIO_NAME,split_ratios)<0)
HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "can't get B-tree split ratios");
+#ifdef H5_HAVE_PARALLEL
+ /* Retrieve up MPI parameters */
+ if(IS_H5FD_MPIO(f)) {
+ if ((mpi_rank=H5FD_mpio_mpi_rank(f->shared->lf))<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank");
+ if ((mpi_size=H5FD_mpio_mpi_size(f->shared->lf))<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI size");
+
+ /* Set the MPI-capable file driver flag */
+ using_mpi=1;
+ } /* end if */
+ else {
+ if(IS_H5FD_MPIPOSIX(f)) {
+ /* Get the MPI rank & size */
+ if ((mpi_rank=H5FD_mpiposix_mpi_rank(f->shared->lf))<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank");
+ if ((mpi_size=H5FD_mpiposix_mpi_size(f->shared->lf))<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI size");
+
+ /* Set the MPI-capable file driver flag */
+ using_mpi=1;
+ } /* end if */
+ } /* end else */
+#endif /* H5_HAVE_PARALLEL */
+
+#ifdef H5_HAVE_PARALLEL
/* Can't use data I/O pipeline in parallel (yet) */
- if (pline.nfilters>0)
+ if (using_mpi && pline.nfilters>0)
HGOTO_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, FAIL, "can't use data pipeline in parallel");
+#endif /* H5_HAVE_PARALLEL */
/*
* Setup indice to go through all chunks. (Future improvement
@@ -2404,24 +2433,6 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
} /* end else */
} /* end if */
- /* Retrieve up MPI parameters */
- if(IS_H5FD_MPIO(f)) {
- if ((mpi_rank=H5FD_mpio_mpi_rank(f->shared->lf))<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank");
- if ((mpi_size=H5FD_mpio_mpi_size(f->shared->lf))<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI size");
- } /* end if */
- else {
- /* Sanity Check */
- assert(IS_H5FD_MPIPOSIX(f));
-
- /* Get the MPI rank & size */
- if ((mpi_rank=H5FD_mpiposix_mpi_rank(f->shared->lf))<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank");
- if ((mpi_size=H5FD_mpiposix_mpi_size(f->shared->lf))<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI size");
- } /* end else */
-
/* Loop over all chunks */
carry=0;
while (carry==0) {
@@ -2441,15 +2452,26 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
/* Check if fill values should be written to blocks */
if(fill_time != H5D_FILL_TIME_NEVER) {
- /* Round-robin write the chunks out from only one process */
- if(mpi_round==mpi_rank) {
+#ifdef H5_HAVE_PARALLEL
+ /* Check if this file is accessed with an MPI-capable file driver */
+ if(using_mpi) {
+ /* Round-robin write the chunks out from only one process */
+ if(mpi_round==mpi_rank) {
+ if (H5F_block_write(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, dxpl_id, chunk)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file");
+ } /* end if */
+ mpi_round=(++mpi_round)%mpi_size;
+
+ /* Indicate that blocks are being written */
+ blocks_written=1;
+ } /* end if */
+ else {
+#endif /* H5_HAVE_PARALLEL */
if (H5F_block_write(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, dxpl_id, chunk)<0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file");
- } /* end if */
- mpi_round=(++mpi_round)%mpi_size;
-
- /* Indicate that blocks are being written */
- blocks_written=1;
+#ifdef H5_HAVE_PARALLEL
+ } /* end else */
+#endif /* H5_HAVE_PARALLEL */
} /* end if */
} /* end if */
@@ -2463,8 +2485,10 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
} /* end for */
} /* end while */
+#ifdef H5_HAVE_PARALLEL
/* Only need to block at the barrier if we actually allocated a chunk */
- if(blocks_written) {
+ /* And if we are using an MPI-capable file driver */
+ if(using_mpi && blocks_written) {
/* Wait at barrier to avoid race conditions where some processes are
* still writing out chunks and other processes race ahead to read
* them in, getting bogus data.
@@ -2481,6 +2505,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code);
} /* end else */
} /* end if */
+#endif /* H5_HAVE_PARALLEL */
done:
/* Free the chunk for fill values */
@@ -2489,7 +2514,6 @@ done:
FUNC_LEAVE(ret_value);
}
-#endif /* H5_HAVE_PARALLEL */
/*-------------------------------------------------------------------------
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index a4a2a3d..dd7cbd9 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -391,12 +391,10 @@ __DLL__ herr_t H5F_seq_writev(H5F_t *f, hid_t dxpl_id,
/* Functions that operate on indexed storage */
-#ifdef H5_HAVE_PARALLEL
__DLL__ herr_t H5F_istore_allocate (H5F_t *f, hid_t dxpl_id,
const struct H5O_layout_t *layout,
const hsize_t *space_dim,
struct H5P_genplist_t *dc_plist);
-#endif /* H5_HAVE_PARALLEL */
__DLL__ hsize_t H5F_istore_allocated(H5F_t *f, unsigned ndims, haddr_t addr);
__DLL__ herr_t H5F_istore_dump_btree(H5F_t *f, FILE *stream, unsigned ndims,
haddr_t addr);
diff --git a/test/Makefile.in b/test/Makefile.in
index e1e0d73..97895cd 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -48,8 +48,8 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \
mount_[0-9].h5 testmeta.h5 ttime.h5 trefer[12].h5 tvltypes.h5 \
tvlstr.h5 flush.h5 enum1.h5 titerate.h5 ttsafe.h5 tarray1.h5 \
tgenprop.h5 tmisc.h5 tmisc2a.h5 tmisc2b.h5 tmisc3.h5 tmisc4a.h5 \
- tmisc4b.h5 tmisc5.h5 tmisc6.h5 tmisc7.h5 set_extent_read.h5 \
- set_extent_create.h5
+ tmisc4b.h5 tmisc5.h5 tmisc6.h5 tmisc7.h5 tmisc8.h5 \
+ set_extent_read.h5 set_extent_create.h5
CLEAN=$(TIMINGS)
## Source and object files for programs... The TEST_SRC list contains all the
diff --git a/test/tmisc.c b/test/tmisc.c
index 0d2ffcd..e0b3d92 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -119,6 +119,20 @@ typedef struct
#define MISC7_TYPENAME1 "Datatype1"
#define MISC7_TYPENAME2 "Datatype2"
+/* Definitions for misc. test #8 */
+#define MISC8_FILE "tmisc8.h5"
+#define MISC8_DSETNAME1 "Dataset1"
+#define MISC8_DSETNAME2 "Dataset2"
+#define MISC8_DSETNAME3 "Dataset3"
+#define MISC8_DSETNAME4 "Dataset4"
+#define MISC8_DSETNAME5 "Dataset5"
+#define MISC8_DSETNAME6 "Dataset6"
+#define MISC8_RANK 2
+#define MISC8_DIM0 100
+#define MISC8_DIM1 100
+#define MISC8_CHUNK_DIM0 10
+#define MISC8_CHUNK_DIM1 10
+
/****************************************************************
**
** test_misc1(): test unlinking a dataset from a group and immediately
@@ -1012,6 +1026,310 @@ test_misc7(void)
/****************************************************************
**
+** test_misc8(): Test storage size of various types of dataset
+** storage methods.
+**
+****************************************************************/
+static void
+test_misc8(void)
+{
+ hid_t fid, did, sid;
+ hid_t fapl; /* File access property list */
+ hid_t dcpl; /* Dataset creation property list */
+ int rank=MISC8_RANK;
+ hsize_t dims[MISC8_RANK]={MISC8_DIM0,MISC8_DIM1};
+ hsize_t chunk_dims[MISC8_RANK]={MISC8_CHUNK_DIM0,MISC8_CHUNK_DIM1};
+ hsize_t storage_size; /* Number of bytes of raw data storage used */
+ int *wdata; /* Data to write */
+ int *tdata; /* Temporary pointer to data write */
+#ifdef VERIFY_DATA
+ int *rdata; /* Data to read */
+ int *tdata2; /* Temporary pointer to data to read */
+#endif /* VERIFY_DATA */
+ unsigned u,v; /* Local index variables */
+ int mdc_nelmts; /* Metadata number of elements */
+#ifdef H5_WANT_H5_V1_4_COMPAT
+ int rdcc_nelmts; /* Raw data number of elements */
+#else /* H5_WANT_H5_V1_4_COMPAT */
+ size_t rdcc_nelmts; /* Raw data number of elements */
+#endif /* H5_WANT_H5_V1_4_COMPAT */
+ size_t rdcc_nbytes; /* Raw data number of bytes */
+ double rdcc_w0; /* Raw data write percentage */
+ hssize_t start[MISC8_RANK]; /* Hyperslab start */
+ hsize_t count[MISC8_RANK]; /* Hyperslab block count */
+ herr_t ret;
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing dataset storage sizes\n"));
+
+ /* Allocate space for the data to write & read */
+ wdata=malloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1);
+ CHECK(wdata,NULL,"malloc");
+#ifdef VERIFY_DATA
+ rdata=malloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1);
+ CHECK(rdata,NULL,"malloc");
+#endif /* VERIFY_DATA */
+
+ /* Initialize values */
+ tdata=wdata;
+ for(u=0; u<MISC8_DIM0; u++)
+ for(v=0; v<MISC8_DIM1; v++)
+ *tdata++=((u*MISC8_DIM1)+v)%13;
+
+ /* Create a file acccess property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Get the default file access properties for caching */
+ ret=H5Pget_cache(fapl,&mdc_nelmts,&rdcc_nelmts,&rdcc_nbytes,&rdcc_w0);
+ CHECK(ret, FAIL, "H5Pget_cache");
+
+ /* Decrease the size of the raw data cache */
+ rdcc_nbytes=0;
+
+ /* Set the file access properties for caching */
+ ret=H5Pset_cache(fapl,mdc_nelmts,rdcc_nelmts,rdcc_nbytes,rdcc_w0);
+ CHECK(ret, FAIL, "H5Pset_cache");
+
+ /* Create the file */
+ fid=H5Fcreate(MISC8_FILE,H5F_ACC_TRUNC,H5P_DEFAULT,fapl);
+ CHECK(fid,FAIL,"H5Fcreate");
+
+ /* Close file access property list */
+ ret=H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Create a simple dataspace */
+ sid = H5Screate_simple(rank,dims,NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Select a hyperslab which coincides with chunk boundaries */
+ /* (For later use) */
+ start[0]=0; start[1]=0;
+ count[0]=MISC8_CHUNK_DIM0*2; count[1]=MISC8_CHUNK_DIM1*2;
+ ret = H5Sselect_hyperslab(sid,H5S_SELECT_SET,start,NULL,count,NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Create a dataset creation property list */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+
+ /* Set the space allocation time to early */
+ ret = H5Pset_space_time(dcpl,H5D_SPACE_ALLOC_EARLY);
+ CHECK(ret, FAIL, "H5Pset_space_time");
+
+ /* Create a contiguous dataset, with space allocation early */
+ did = H5Dcreate(fid, MISC8_DSETNAME1, H5T_NATIVE_INT, sid, dcpl);
+ CHECK(did, FAIL, "H5Dcreate");
+
+ /* Check the storage size */
+ storage_size=H5Dget_storage_size(did);
+ CHECK(storage_size, 0, "H5Dget_storage_size");
+ VERIFY(storage_size, MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT), "H5Dget_storage_size");
+
+ /* Close dataset ID */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+#ifndef H5_HAVE_PARALLEL
+ /* Set the space allocation time to late */
+ ret = H5Pset_space_time(dcpl,H5D_SPACE_ALLOC_LATE);
+ CHECK(ret, FAIL, "H5Pset_space_time");
+
+ /* Create a contiguous dataset, with space allocation late */
+ did = H5Dcreate(fid, MISC8_DSETNAME2, H5T_NATIVE_INT, sid, dcpl);
+ CHECK(did, FAIL, "H5Dcreate");
+
+ /* Check the storage size before data is written */
+ storage_size=H5Dget_storage_size(did);
+ VERIFY(storage_size, 0, "H5Dget_storage_size");
+
+ /* Write data */
+ ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Check the storage size after data is written */
+ storage_size=H5Dget_storage_size(did);
+ CHECK(storage_size, 0, "H5Dget_storage_size");
+ VERIFY(storage_size, MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT), "H5Dget_storage_size");
+
+ /* Close dataset ID */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+#endif /* H5_HAVE_PARALLEL */
+
+ /* Set the space allocation time to early */
+ ret = H5Pset_space_time(dcpl,H5D_SPACE_ALLOC_EARLY);
+ CHECK(ret, FAIL, "H5Pset_space_time");
+
+ /* Use chunked storage for this dataset */
+ ret = H5Pset_chunk(dcpl,rank,chunk_dims);
+ CHECK(ret, FAIL, "H5Pset_chunk");
+
+ /* Create a chunked dataset, with space allocation early */
+ did = H5Dcreate(fid, MISC8_DSETNAME3, H5T_NATIVE_INT, sid, dcpl);
+ CHECK(did, FAIL, "H5Dcreate");
+
+ /* Check the storage size after data is written */
+ storage_size=H5Dget_storage_size(did);
+ CHECK(storage_size, 0, "H5Dget_storage_size");
+ VERIFY(storage_size, MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT), "H5Dget_storage_size");
+
+ /* Close dataset ID */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+#ifndef H5_HAVE_PARALLEL
+ /* Set the space allocation time to late */
+ ret = H5Pset_space_time(dcpl,H5D_SPACE_ALLOC_LATE);
+ CHECK(ret, FAIL, "H5Pset_space_time");
+
+ /* Create a chunked dataset, with space allocation late */
+ did = H5Dcreate(fid, MISC8_DSETNAME4, H5T_NATIVE_INT, sid, dcpl);
+ CHECK(did, FAIL, "H5Dcreate");
+
+ /* Check the storage size before data is written */
+ storage_size=H5Dget_storage_size(did);
+ VERIFY(storage_size, 0, "H5Dget_storage_size");
+
+ /* Write part of the dataset */
+ ret = H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Check the storage size after only four chunks are written */
+ storage_size=H5Dget_storage_size(did);
+ VERIFY(storage_size, 4*MISC8_CHUNK_DIM0*MISC8_CHUNK_DIM1*H5Tget_size(H5T_NATIVE_INT), "H5Dget_storage_size");
+
+ /* Write entire dataset */
+ ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+#ifdef VERIFY_DATA
+ /* Read data */
+ ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check values written */
+ tdata=wdata;
+ tdata2=rdata;
+ for(u=0; u<MISC8_DIM0; u++)
+ for(v=0; v<MISC8_DIM1; v++,tdata++,tdata2++)
+ if(*tdata!=*tdata2) {
+ num_errs++;
+ printf("Error on line %d: u=%u, v=%d, *tdata=%d, *tdata2=%d\n",__LINE__,(unsigned)u,(unsigned)v,(int)*tdata,(int)*tdata2);
+ }
+#endif /* VERIFY_DATA */
+
+ /* Check the storage size after data is written */
+ storage_size=H5Dget_storage_size(did);
+ CHECK(storage_size, 0, "H5Dget_storage_size");
+ VERIFY(storage_size, MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT), "H5Dget_storage_size");
+
+ /* Close dataset ID */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+#endif /* H5_HAVE_PARALLEL */
+
+ /* Set the space allocation time to early */
+ ret = H5Pset_space_time(dcpl,H5D_SPACE_ALLOC_EARLY);
+ CHECK(ret, FAIL, "H5Pset_space_time");
+
+ /* Use compression as well as chunking for these datasets */
+ ret = H5Pset_deflate(dcpl,9);
+ CHECK(ret, FAIL, "H5Pset_deflate");
+
+ /* Create a chunked dataset, with space allocation early */
+ did = H5Dcreate(fid, MISC8_DSETNAME5, H5T_NATIVE_INT, sid, dcpl);
+ CHECK(did, FAIL, "H5Dcreate");
+
+ /* Check the storage size after data is written */
+ storage_size=H5Dget_storage_size(did);
+ CHECK(storage_size, 0, "H5Dget_storage_size");
+ VERIFY(storage_size, MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT), "H5Dget_storage_size");
+
+ /* Close dataset ID */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+#ifndef H5_HAVE_PARALLEL
+ /* Set the space allocation time to late */
+ ret = H5Pset_space_time(dcpl,H5D_SPACE_ALLOC_LATE);
+ CHECK(ret, FAIL, "H5Pset_space_time");
+
+ /* Create a chunked dataset, with space allocation late */
+ did = H5Dcreate(fid, MISC8_DSETNAME6, H5T_NATIVE_INT, sid, dcpl);
+ CHECK(did, FAIL, "H5Dcreate");
+
+ /* Check the storage size before data is written */
+ storage_size=H5Dget_storage_size(did);
+ VERIFY(storage_size, 0, "H5Dget_storage_size");
+
+ /* Write part of the dataset */
+ ret = H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Check the storage size after only four chunks are written */
+ storage_size=H5Dget_storage_size(did);
+ CHECK(storage_size, 0, "H5Dget_storage_size");
+ if(storage_size>=(4*MISC8_CHUNK_DIM0*MISC8_CHUNK_DIM1*H5Tget_size(H5T_NATIVE_INT))) {
+ num_errs++;
+ printf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size);
+ }
+
+ /* Write entire dataset */
+ ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+#ifdef VERIFY_DATA
+ /* Read data */
+ ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check values written */
+ tdata=wdata;
+ tdata2=rdata;
+ for(u=0; u<MISC8_DIM0; u++)
+ for(v=0; v<MISC8_DIM1; v++,tdata++,tdata2++)
+ if(*tdata!=*tdata2) {
+ num_errs++;
+ printf("Error on line %d: u=%u, v=%d, *tdata=%d, *tdata2=%d\n",__LINE__,(unsigned)u,(unsigned)v,(int)*tdata,(int)*tdata2);
+ }
+#endif /* VERIFY_DATA */
+
+ /* Check the storage size after data is written */
+ storage_size=H5Dget_storage_size(did);
+ CHECK(storage_size, 0, "H5Dget_storage_size");
+ if(storage_size>=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) {
+ num_errs++;
+ printf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size);
+ }
+
+ /* Close dataset ID */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+#endif /* H5_HAVE_PARALLEL */
+
+ /* Close dataset creation property list */
+ ret=H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Close dataspace */
+ ret=H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close file */
+ ret=H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Free the read & write buffers */
+ free(wdata);
+#ifdef VERIFY_DATA
+ free(rdata);
+#endif /* VERIFY_DATA */
+} /* end test_misc8() */
+
+/****************************************************************
+**
** test_misc(): Main misc. test routine.
**
****************************************************************/
@@ -1028,6 +1346,7 @@ test_misc(void)
test_misc5(); /* Test several level deep nested compound & VL datatypes */
test_misc6(); /* Test object header continuation code */
test_misc7(); /* Test for sensible datatypes stored on disk */
+ test_misc8(); /* Test storage sizes of various types of dataset storage */
} /* test_misc() */
@@ -1058,4 +1377,5 @@ cleanup_misc(void)
remove(MISC5_FILE);
remove(MISC6_FILE);
remove(MISC7_FILE);
+ remove(MISC8_FILE);
}