diff options
Diffstat (limited to 'tools/h5repack')
-rw-r--r-- | tools/h5repack/h5repack.h | 1 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 17 | ||||
-rw-r--r-- | tools/h5repack/h5repack_filters.c | 50 |
3 files changed, 55 insertions, 13 deletions
diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index 384ec2d..b63102b 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -176,6 +176,7 @@ void init_packobject(pack_info_t *obj); int apply_filters(const char* name, /* object name from traverse list */ int rank, /* rank of dataset */ hsize_t *dims, /* dimensions of dataset */ + size_t msize, /* size of type */ hid_t dcpl_id, /* dataset creation property list */ pack_opt_t *options, /* repack options */ int *has_filter); /* (OUT) object NAME has a filter */ diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 312f085..b165dc7 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -23,9 +23,6 @@ extern char *progname; -#if 0 -#define H5REPACK_DEBUG -#endif /*------------------------------------------------------------------------- * macros @@ -41,7 +38,7 @@ static void print_dataset_info(hid_t dcpl_id,char *objname,double per, int pr); static int do_copy_objects(hid_t fidin,hid_t fidout,trav_table_t *travt,pack_opt_t *options); static int copy_attr(hid_t loc_in,hid_t loc_out,pack_opt_t *options); static int copy_user_block(const char *infile, const char *outfile, hsize_t size); -#if defined (H5REPACK_DEBUG) +#if defined (H5REPACK_DEBUG_USER_BLOCK) static void print_user_block(const char *filename, hid_t fid); #endif @@ -212,7 +209,7 @@ int copy_objects(const char* fnamein, -#if defined (H5REPACK_DEBUG) +#if defined (H5REPACK_DEBUG_USER_BLOCK) print_user_block(fnamein,fidin); #endif @@ -713,7 +710,13 @@ int do_copy_objects(hid_t fidin, /* apply the filter */ if (apply_s) { - if (apply_filters(travt->objs[i].name,rank,dims,dcpl_out,options,&has_filter) < 0) + if (apply_filters(travt->objs[i].name, + rank, + dims, + msize, + dcpl_out, + options, + &has_filter) < 0) goto error; } @@ -1453,7 +1456,7 @@ done: * *------------------------------------------------------------------------- */ -#if defined (H5REPACK_DEBUG) +#if defined (H5REPACK_DEBUG_USER_BLOCK) static void print_user_block(const char *filename, hid_t fid) { diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index cd4693e..8f51e20 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -15,6 +15,7 @@ #include "h5repack.h" #include "h5test.h" +#include "h5tools.h" /*------------------------------------------------------------------------- @@ -193,6 +194,7 @@ int aux_assign_obj(const char* name, /* object name from traverse lis int apply_filters(const char* name, /* object name from traverse list */ int rank, /* rank of dataset */ hsize_t *dims, /* dimensions of dataset */ + size_t msize, /* size of type */ hid_t dcpl_id, /* dataset creation property list */ pack_opt_t *options, /* repack options */ int *has_filter) /* (OUT) object NAME has a filter */ @@ -250,13 +252,13 @@ int apply_filters(const char* name, /* object name from traverse list */ if ((layout = H5Pget_layout(dcpl_id))<0) return -1; - if (layout==H5D_CHUNKED) + if (layout == H5D_CHUNKED) { if ((rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize/*out*/))<0) return -1; - obj.layout=H5D_CHUNKED; - obj.chunk.rank=rank; - for ( i=0; i<rank; i++) + obj.layout = H5D_CHUNKED; + obj.chunk.rank = rank; + for ( i = 0; i < rank; i++) obj.chunk.chunk_lengths[i] = chsize[i]; } } @@ -283,9 +285,45 @@ int apply_filters(const char* name, /* object name from traverse list */ */ if (obj.layout==-1) { - obj.chunk.rank=rank; - for (i=0; i<rank; i++) + + /* stripmine info */ + hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ + hsize_t sm_nbytes; /*bytes per stripmine */ + + obj.chunk.rank = rank; + + +#if 0 + for ( i = 0; i < rank; i++) + { obj.chunk.chunk_lengths[i] = dims[i]; + } + +#else + + /* + * determine the strip mine size. The strip mine is + * a hyperslab whose size is manageable. + */ + + sm_nbytes = msize; + for ( i = rank; i > 0; --i) + { + sm_size[i - 1] = MIN(dims[i - 1], H5TOOLS_BUFSIZE / sm_nbytes); + sm_nbytes *= sm_size[i - 1]; + assert(sm_nbytes > 0); + + } + + for ( i = 0; i < rank; i++) + { + obj.chunk.chunk_lengths[i] = sm_size[i]; + } + +#endif + + + } for ( i=0; i<obj.nfilters; i++) |