[svn-r16112] #1375. Define a default chunk whose size is manageable. Defined currently as the same size of hyperslab (that compares the dimension sizes against a predefined constant size and chooses the minimum between the two)

Tested : linux, windows
This commit is contained in:
Pedro Vicente Nunes 2008-11-21 10:39:06 -05:00
parent a4487662b0
commit b067b416b2
3 changed files with 55 additions and 13 deletions

View File

@ -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 */

View File

@ -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)
{

View File

@ -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++)