From f29e2a01e35e466fdcc292a0c443265efdf4b025 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Mon, 23 Feb 2004 11:52:45 -0500 Subject: [svn-r8218] Purpose: bug fix in H5Zshuffle.c add more tests to h5repack that exposed the bug Description: when creating a dataset with the shuffle filter and duplicating it in a new dataset (file) the call to H5Z_set_local_shuffle failed. this is because the value of cd_nelmts of the filter structure is set to 1 (H5Z_SHUFFLE_TOTAL_NPARMS) when the original dataset is created, but when the new dataset is created there is a checking instruction that fails if the value of cd_nelmts is not 0 (its original value, H5Z_SHUFFLE_USER_NPARMS) Solution: just remove that check condition, since the value of cd_nelmts is not used anyway. if we decide that the value of cd_nelmts is necessary, then the H5O_pline_copy function must be changed to update this value (a different update for each filter) Platforms tested: linux solaris AIX Misc. update: --- src/H5Zshuffle.c | 4 - tools/h5repack/h5repack.h | 4 +- tools/h5repack/h5repack_filters.c | 22 ---- tools/h5repack/testh5repack_filters.c | 213 ++++++++++++++++------------------ tools/h5repack/testh5repack_main.c | 64 +++++++--- tools/h5repack/testh5repack_make.c | 38 +++--- 6 files changed, 165 insertions(+), 180 deletions(-) diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c index eb95f98..196f037 100644 --- a/src/H5Zshuffle.c +++ b/src/H5Zshuffle.c @@ -82,10 +82,6 @@ H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id) if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,0,NULL)<0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get shuffle parameters") - /* Check that no parameters are currently set */ - if(cd_nelmts!=H5Z_SHUFFLE_USER_NPARMS) - HGOTO_ERROR(H5E_PLINE, H5E_BADVALUE, FAIL, "incorrect # of shuffle parameters") - /* Set "local" parameter for this dataset */ if((cd_values[H5Z_SHUFFLE_PARM_SIZE]=(unsigned)H5Tget_size(type_id))==0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index 5bda25c..fa1c4b4 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -294,9 +294,7 @@ void write_dset_in(hid_t loc_id, hid_t file_id, int make_diffs /* flag to modify data buffers */); -int make_deflate(hid_t loc_id); -int make_szip(hid_t loc_id); -int make_nofilters(hid_t loc_id); +int make_filters(hid_t loc_id); diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index 9a91679..ab592a0 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -149,44 +149,23 @@ int apply_filters(const char* name, /* object name from traverse list */ name,options->threshold); return 0; } - /* get information about input filters */ if ((nfilters = H5Pget_nfilters(dcpl_id))<0) return -1; - -/*------------------------------------------------------------------------- - * check if we have the H5Z_FILTER_NONE filter - * if so, just delete all filters from the DCPL and exit - *------------------------------------------------------------------------- - */ - - for ( i=0; infilters; i++) - { - if (obj->filter[i].filtn==H5Z_FILTER_NONE) - { - if (nfilters && H5Premove_filter(dcpl_id,H5Z_FILTER_NONE)<0) - return -1; - return 0; - } - } - /*------------------------------------------------------------------------- * check if we have filters in the pipeline * we want to replace them with the input filters *------------------------------------------------------------------------- */ - if (nfilters) { if (H5Premove_filter(dcpl_id,H5Z_FILTER_ALL)<0) return -1; } - /*------------------------------------------------------------------------- * filters require CHUNK layout; if we do not have one define a default *------------------------------------------------------------------------- */ - if (obj->chunk.rank<=0) { obj->chunk.rank=rank; @@ -204,7 +183,6 @@ int apply_filters(const char* name, /* object name from traverse list */ * H5Z_FILTER_SZIP 4 , szip compression *------------------------------------------------------------------------- */ - for ( i=0; infilters; i++) { switch (obj->filter[i].filtn) diff --git a/tools/h5repack/testh5repack_filters.c b/tools/h5repack/testh5repack_filters.c index 7b7837b..5a26f5d 100644 --- a/tools/h5repack/testh5repack_filters.c +++ b/tools/h5repack/testh5repack_filters.c @@ -22,144 +22,162 @@ #define CDIM2 DIM2/2 #define RANK 2 +/*------------------------------------------------------------------------- + * Function: make_dset + * + * Purpose: utility function to create and write a dataset in LOC_ID + *------------------------------------------------------------------------- + */ +static +int make_dset(hid_t loc_id,const char *name,hid_t sid, hid_t dcpl,void *buf) +{ + hid_t dsid; + /* create the dataset */ + if((dsid = H5Dcreate (loc_id,name,H5T_NATIVE_INT,sid,dcpl))<0) + return -1; + /* write */ + if(H5Dwrite(dsid,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + goto out; + /* close */ + if(H5Dclose(dsid)<0) + return -1; + return 0; + out: + H5E_BEGIN_TRY { + H5Dclose(dsid); + } H5E_END_TRY; + return -1; + +} /*------------------------------------------------------------------------- - * Function: make_deflate + * Function: make_filters * - * Purpose: make a dataset using DEFLATE (GZIP) compression in LOC_ID + * Purpose: make several datasets with filters in location LOC_ID * *------------------------------------------------------------------------- */ -int make_deflate(hid_t loc_id) +int make_filters(hid_t loc_id) { hid_t dcpl; /* dataset creation property list */ - hid_t dsid; /* dataset ID */ hid_t sid; /* dataspace ID */ + unsigned szip_options_mask=H5_SZIP_ALLOW_K13_OPTION_MASK|H5_SZIP_NN_OPTION_MASK; + unsigned szip_pixels_per_block=8; hsize_t dims[RANK]={DIM1,DIM2}; hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; int buf[DIM1][DIM2]; - int i, j, n=0; + char name[5]; + int i, j, n; - for (i=0; i