diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2006-10-19 17:07:26 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2006-10-19 17:07:26 (GMT) |
commit | a1edc7069162a619957c7407d04b91e081044219 (patch) | |
tree | ca5e64791fcad2730a6ae92d7ba667bf9306cc41 /tools/h5repack/testh5repack_make.c | |
parent | 78a3d673e6cb491d8087b74d0e2cbdd8ca89bb47 (diff) | |
download | hdf5-a1edc7069162a619957c7407d04b91e081044219.zip hdf5-a1edc7069162a619957c7407d04b91e081044219.tar.gz hdf5-a1edc7069162a619957c7407d04b91e081044219.tar.bz2 |
[svn-r12784]
Fixes for bugs 676, 228
676: both h5repack and h5diff use H5Dread. In the case of a "big"
dataset, use read/write by hyperslabs the same way h5dump uses. An
arbitrary value of 1GB was defined for "big", i.e, if the dataset is
greater than 1GB, then read/write by hyperslabs
228: use the file type in read/write by default. A new switch -n was
introduced if the user wants to use a native type, which was the
previous use by default.
Added a new test for h5repack that repacks a 1GB dataset
Tested: heping (serial, parallel), sol, copper
Diffstat (limited to 'tools/h5repack/testh5repack_make.c')
-rw-r--r-- | tools/h5repack/testh5repack_make.c | 170 |
1 files changed, 147 insertions, 23 deletions
diff --git a/tools/h5repack/testh5repack_make.c b/tools/h5repack/testh5repack_make.c index cc4b47d..319af3d 100644 --- a/tools/h5repack/testh5repack_make.c +++ b/tools/h5repack/testh5repack_make.c @@ -17,11 +17,14 @@ #include "h5repack.h" #include "testh5repack.h" -#define DIM1 40 -#define DIM2 20 -#define CDIM1 DIM1/2 -#define CDIM2 DIM2/2 -#define RANK 2 +#define DIM1 40 +#define DIM2 20 +#define CDIM1 DIM1/2 +#define CDIM2 DIM2/2 +#define RANK 2 +#define GBLL ((unsigned long_long) 1024*1024*1024) + + int make_all_objects(hid_t loc_id); int make_attributes(hid_t loc_id); @@ -38,6 +41,8 @@ int make_nbit(hid_t loc_id); int make_scaleoffset(hid_t loc_id); int make_all(hid_t loc_id); int make_fill(hid_t loc_id); +int make_big(hid_t loc_id); + /*------------------------------------------------------------------------- @@ -161,6 +166,17 @@ int make_testfiles(void) return -1; /*------------------------------------------------------------------------- + * create a file with all the filters + *------------------------------------------------------------------------- + */ + if((loc_id = H5Fcreate(FNAME11,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) + return -1; + if (make_all(loc_id)<0) + goto out; + if(H5Fclose(loc_id)<0) + return -1; + +/*------------------------------------------------------------------------- * create a file with the nbit filter *------------------------------------------------------------------------- */ @@ -183,18 +199,17 @@ int make_testfiles(void) return -1; /*------------------------------------------------------------------------- - * create a file with all the filters + * create a big file *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME11,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) + if((loc_id = H5Fcreate(FNAME14,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) return -1; - if (make_all(loc_id)<0) + if (make_big(loc_id)<0) goto out; if(H5Fclose(loc_id)<0) return -1; - - PASSED(); + return 0; out: @@ -737,13 +752,15 @@ int make_nbit(hid_t loc_id) #endif /*------------------------------------------------------------------------- - * close space and dcpl + * close *------------------------------------------------------------------------- */ if(H5Sclose(sid)<0) goto out; if(H5Pclose(dcpl)<0) goto out; + if (H5Tclose(dtid)<0) + goto out; return 0; @@ -1226,10 +1243,6 @@ out: return -1; } - - - - /*------------------------------------------------------------------------- * Function: make a file with an integer dataset with a fill value * @@ -1250,17 +1263,128 @@ int make_fill(hid_t loc_id) * H5T_INTEGER, write a fill value *------------------------------------------------------------------------- */ + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) + goto out; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue)<0) + goto out; + if ((sid = H5Screate_simple(2,dims,NULL))<0) + goto out; + if ((did = H5Dcreate(loc_id,"dset_fill",H5T_NATIVE_INT,sid,dcpl))<0) + goto out; + if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + goto out; - dcpl = H5Pcreate(H5P_DATASET_CREATE); - H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue); - sid = H5Screate_simple(2,dims,NULL); - did = H5Dcreate(loc_id,"dset_fill",H5T_NATIVE_INT,sid,dcpl); - H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf); - H5Pclose(dcpl); - H5Dclose(did); - H5Sclose(sid); + /* close */ + if(H5Sclose(sid)<0) + goto out; + if(H5Pclose(dcpl)<0) + goto out; + if(H5Dclose(did)<0) + goto out; return 0; +out: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Sclose(sid); + H5Dclose(did); + } H5E_END_TRY; + return -1; + +} + +/*------------------------------------------------------------------------- + * Function: make a big file + * + * Purpose: used in test read by hyperslabs. writes a 1GB file by iterating + * trough 1MB hyperslabs + * + *------------------------------------------------------------------------- + */ +int make_big(hid_t loc_id) +{ + hid_t did; + hid_t f_sid; + hid_t m_sid; + hid_t tid; + hid_t dcpl; + hsize_t dims[1]={GBLL}; /* dataset dimensions */ + hsize_t hs_size[1]={GBLL/1024}; /* hyperslab dimensions */ + hsize_t chunk_dims[1]={hs_size[0]}; /* chunk dimensions */ + hsize_t hs_start[1]; + size_t size; + size_t nelmts=(size_t)hs_size[0]; + char fillvalue=-1; + char *buf=NULL; + int i, j, s; + char c; + + /* create */ + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) + goto out; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_CHAR, &fillvalue)<0) + goto out; + if(H5Pset_chunk(dcpl, 1, chunk_dims)<0) + goto out; + if ((f_sid = H5Screate_simple(1,dims,NULL))<0) + goto out; + if ((did = H5Dcreate(loc_id,"big",H5T_NATIVE_CHAR,f_sid,dcpl))<0) + goto out; + if ((m_sid = H5Screate_simple(1, hs_size, hs_size))<0) + goto out; + if ((tid = H5Dget_type(did))<0) + goto out; + if ((size = H5Tget_size(tid))<=0) + goto out; + + /* create a evenly divided buffer from 0 to 127 */ + buf=(char *) HDmalloc((unsigned)(nelmts*size)); + s = 1024 / 127; + for (i=0, j=0, c=0; i<1024; j++, i++) + { + if ( j==s) + { + c++; + j=0; + }; + + HDmemset(buf, c, nelmts); + + hs_start[0] = i * GBLL/1024; + if (H5Sselect_hyperslab (f_sid,H5S_SELECT_SET,hs_start,NULL,hs_size, NULL)<0) + goto out; + if (H5Dwrite (did,H5T_NATIVE_CHAR,m_sid,f_sid,H5P_DEFAULT,buf)<0) + goto out; + + /* write only one hyperslab, for space considerations */ + if (i==0) + break; + + } + free(buf); + buf=NULL; + + /* close */ + if(H5Sclose(f_sid)<0) + goto out; + if(H5Sclose(m_sid)<0) + goto out; + if(H5Pclose(dcpl)<0) + goto out; + if(H5Dclose(did)<0) + goto out; + + return 0; + +out: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Sclose(f_sid); + H5Sclose(m_sid); + H5Dclose(did); + } H5E_END_TRY; + return -1; + } |