From 9d23b171a5e54c8e1c2d254e2e4b24003d3caf61 Mon Sep 17 00:00:00 2001 From: Peter Cao Date: Wed, 30 Jan 2013 17:06:40 -0500 Subject: [svn-r23208] adding a large compound dataset to the test file --- tools/misc/h5perf_gentest.c | 97 ++++++++++++++++++++++++++++++++------------- 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/tools/misc/h5perf_gentest.c b/tools/misc/h5perf_gentest.c index b5b8059..6442a10 100755 --- a/tools/misc/h5perf_gentest.c +++ b/tools/misc/h5perf_gentest.c @@ -14,7 +14,8 @@ #define NGROUPS 20 #define NDSETS 20 #define NATTRS 20 -#define NROWS 40 +#define DIM0 40 +#define NROWS 100 #define NTYPES 9 #define MAXVLEN 10 #define FIXED_LEN 8 @@ -40,12 +41,15 @@ typedef struct { int add_attrs(hid_t oid, int idx); int add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf) ; +herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, + int nattrs, hsize_t nrows, hsize_t dim0, hsize_t chunk, int vlen, + int compressed, int latest); int main (int argc, char *argv[]) { char fname[32]; - int i, ngrps=NGROUPS, ndsets=NDSETS, nattrs=NATTRS, nrows=NROWS, - chunk=NROWS/10+1, vlen=MAXVLEN, l=0, z=0; + int i, ngrps=NGROUPS, ndsets=NDSETS, nattrs=NATTRS, dim0=DIM0, + chunk=DIM0/10+1, nrows=NROWS, vlen=MAXVLEN, l=0, z=0; memset(fname, 0, 32); for (i=1; inrows) chunk=nrows/4; + if (dim0dim0) chunk=dim0/4; if (chunk<1) chunk = 1; if (vlen<1) vlen = MAXVLEN; if (strlen(fname)<=0) sprintf(fname, FNAME); - create_perf_test_file(fname, ngrps, ndsets, nattrs, nrows, (hsize_t)chunk, vlen, z, l); + create_perf_test_file(fname, ngrps, ndsets, nattrs, (hsize_t)nrows, + (hsize_t)dim0, (hsize_t)chunk, vlen, z, l); return 0; } @@ -119,18 +127,19 @@ int main (int argc, char *argv[]) Programmer: Peter Cao , Jan. 2013 ****************************************************************************/ -herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, int nattrs, - int nrows, hsize_t chunk, int vlen, int compressed, int latest) +herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, + int nattrs, hsize_t nrows, hsize_t dim0, hsize_t chunk, int vlen, + int compressed, int latest) { int i, j, k; - hid_t fid, sid_null, sid_1d, sid_2d, did, aid, sid_2, fapl=H5P_DEFAULT, dcpl=H5P_DEFAULT, - gid1, gid2, cmp_tid, tid_str, tid_enum, tid_array_f, tid_vlen_i, - tid_vlen_s; + hid_t fid, sid_null, sid_1d, sid_2d, did, aid, sid_2, sid_large, + fapl=H5P_DEFAULT, dcpl=H5P_DEFAULT, gid1, gid2, cmp_tid, tid_str, + tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s; char name[32]; - hsize_t dims[1]={nrows}, dims2d[2]={nrows, (nrows/4+1)}, dims_array[1]={FIXED_LEN}, + hsize_t dims[1]={dim0}, dims2d[2]={dim0, (dim0/4+1)}, dims_array[1]={FIXED_LEN}, dim1[1]={2}; char *enum_names[4] = {"SOLID", "LIQUID", "GAS", "PLASMA"}; - test_comp_t *buf_comp=NULL; + test_comp_t *buf_comp=NULL, *buf_comp_large=NULL; int *buf_int=NULL; float (*buf_float_a)[FIXED_LEN]=NULL; double **buf_double2d=NULL; @@ -146,6 +155,9 @@ herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, int nattr hid_t types[NTYPES] = { H5T_NATIVE_INT, H5T_NATIVE_UINT64, H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE, tid_str, tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s}; hsize_t coords[4][2] = { {0, 1}, {3, 5}, {1, 0}, {2, 4}}, start=0, stride=1, count=1; + + /* the large compound dataset will be at least as large as regular datasets. */ + if (nrows < dim0) nrows = dim0; /* create fixed string datatype */ types[4] = tid_str = H5Tcopy (H5T_C_S1); @@ -184,6 +196,7 @@ herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, int nattr sid_1d = H5Screate_simple (1, dims, NULL); sid_2d = H5Screate_simple (2, dims2d, NULL); sid_2 = H5Screate_simple (1, dim1, NULL); + sid_large = H5Screate_simple (1, &nrows, NULL); sid_null = H5Screate (H5S_NULL); /* create fid access property */ @@ -201,7 +214,7 @@ herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, int nattr /* set dataset compression */ if (compressed) { if (chunk<=0) { - chunk = nrows/10+1;; + chunk = dim0/10+1;; H5Pset_chunk (dcpl, 1, &chunk); } H5Pset_shuffle (dcpl); @@ -209,12 +222,13 @@ herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, int nattr } /* allocate buffers */ - buf_comp = (test_comp_t *)calloc(nrows, sizeof(test_comp_t)); - buf_int = (int *)calloc(nrows, sizeof(int)); - buf_float_a = malloc(nrows*sizeof(*buf_float_a)); - buf_vlen_i = (hvl_t *)calloc(nrows, sizeof (hvl_t)); - buf_vlen_s = (char **)calloc(nrows, sizeof(char *)); - buf_str = malloc(nrows*sizeof (*buf_str)); + buf_comp = (test_comp_t *)calloc(dim0, sizeof(test_comp_t)); + buf_comp_large = (test_comp_t *)calloc(nrows, sizeof(test_comp_t)); + buf_int = (int *)calloc(dim0, sizeof(int)); + buf_float_a = malloc(dim0*sizeof(*buf_float_a)); + buf_vlen_i = (hvl_t *)calloc(dim0, sizeof (hvl_t)); + buf_vlen_s = (char **)calloc(dim0, sizeof(char *)); + buf_str = malloc(dim0*sizeof (*buf_str)); /* allocate array of doulbe pointers */ buf_double2d = (double **)calloc(dims2d[0],sizeof(double *)); @@ -253,7 +267,23 @@ herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, int nattr buf_double2d[i][j] = i+j/10000.0; } - + for (i=0; i