diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2003-12-31 14:00:36 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2003-12-31 14:00:36 (GMT) |
commit | 738e808d262a79d43a4697bb731c5d2961a006a2 (patch) | |
tree | 64dbf68fe83ebfad007bd655aa0b2536173053e8 /tools/h5repack | |
parent | ee2eecf1b43916925411798297a06bffd39b76f2 (diff) | |
download | hdf5-738e808d262a79d43a4697bb731c5d2961a006a2.zip hdf5-738e808d262a79d43a4697bb731c5d2961a006a2.tar.gz hdf5-738e808d262a79d43a4697bb731c5d2961a006a2.tar.bz2 |
[svn-r7999] Purpose:
h5repack new features
Description:
added support/ tests for contiguous and compact layout processing
Solution:
Platforms tested:
linux
solaris
AIX
Misc. update:
Diffstat (limited to 'tools/h5repack')
-rw-r--r-- | tools/h5repack/h5repack.h | 7 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 2 | ||||
-rw-r--r-- | tools/h5repack/h5repack_layout.c | 87 | ||||
-rw-r--r-- | tools/h5repack/h5repack_parse.c | 2 | ||||
-rw-r--r-- | tools/h5repack/h5repack_verify.c | 20 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_main.c | 7 |
6 files changed, 97 insertions, 28 deletions
diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index cee7c1e..16e0f6a 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -205,9 +205,10 @@ int check_szip(int rank, /* chunk rank */ int has_layout(hid_t dcpl_id, pack_info_t *obj); -int layout_this(const char* name, /* object name from traverse list */ - pack_opt_t *options, /* repack options */ - pack_info_t *pack); /* info about object to apply layout */ +int layout_this(hid_t dcpl_id, /* DCPL from input object */ + const char* name, /* object name from traverse list */ + pack_opt_t *options, /* repack options */ + pack_info_t *pack /*OUT*/) /* object to apply layout */; int apply_layout(hid_t dcpl_id, pack_opt_t *options, /* repack options */ diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 569af82..cfdb6e7 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -265,7 +265,7 @@ int do_copy_file(hid_t fidin, * if the layout could not be applied, continue *------------------------------------------------------------------------- */ - if (layout_this(travt->objs[i].name,options,&pack)) + if (layout_this(dcpl_id,travt->objs[i].name,options,&pack)) { if (apply_layout(dcpl_id,options,&pack)<0) continue; diff --git a/tools/h5repack/h5repack_layout.c b/tools/h5repack/h5repack_layout.c index 0fff459..0a673d9 100644 --- a/tools/h5repack/h5repack_layout.c +++ b/tools/h5repack/h5repack_layout.c @@ -17,13 +17,23 @@ #include "h5repack.h" +static void CANNOT_LAYOUT(pack_opt_t *options) +{ + if (options->verbose) + printf("Warning: This layout cannot be applied, this object\ + requires chunked layout\n"); +} + + + /*------------------------------------------------------------------------- * Function: layout_this * - * Purpose: find the object name NAME (got from the traverse list) + * Purpose: check if the layout can be applied; + * find the object name NAME (got from the traverse list) * in the repack options list; assign the layout information OBJ * - * Return: 0 not found, 1 found + * Return: 0 cannot apply, 1 can, -1 error * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * @@ -32,35 +42,69 @@ *------------------------------------------------------------------------- */ -int layout_this(const char* name, /* object name from traverse list */ +int layout_this(hid_t dcpl_id, /* DCPL from input object */ + const char* name, /* object name from traverse list */ pack_opt_t *options, /* repack options */ pack_info_t *pack /*OUT*/) /* object to apply layout */ { - char *pdest; - int result; - int i; + int nfilters; /* number of filters in the input object */ + H5D_layout_t layout; /* layout */ + char *pdest; + int result; + int i, ret=1; - /* if we are applying to all objects just return true */ + /* check if we have filters in the input object */ + if ((nfilters = H5Pget_nfilters(dcpl_id))<0) + return -1; + + /* applying to all objects */ if (options->all_layout) { /* assign the global layout info to the OBJ info */ pack->layout=options->layout_g; - if (H5D_CHUNKED==options->layout_g) { /* set up chunk */ + + switch (options->layout_g) + { + case H5D_CHUNKED: pack->chunk.rank=options->chunk_g.rank; for ( i=0; i<pack->chunk.rank; i++) pack->chunk.chunk_lengths[i]=options->chunk_g.chunk_lengths[i]; - } - return 1; + break; + + case H5D_CONTIGUOUS: + case H5D_COMPACT: + if (nfilters) + { + CANNOT_LAYOUT(options); + ret=0; + } + break; + + default: + ret=0; + break; + }/*switch*/ + return ret; } + /* find the object */ for ( i=0; i<options->op_tbl->nelems; i++) { - if (options->op_tbl->objs[i].layout != -1 ) + layout=options->op_tbl->objs[i].layout; + if ( layout != -1 ) { if (strcmp(options->op_tbl->objs[i].path,name)==0) { - *pack=options->op_tbl->objs[i]; - return 1; + if (nfilters && layout!=H5D_CHUNKED) + { + CANNOT_LAYOUT(options); + return 0; + } + else + { + *pack=options->op_tbl->objs[i]; + return 1; + } } pdest = strstr(name,options->op_tbl->objs[i].path); @@ -69,8 +113,16 @@ int layout_this(const char* name, /* object name from traverse list */ /* found at position 1, meaning without '/' */ if( pdest != NULL && result==1 ) { - *pack=options->op_tbl->objs[i]; - return 1; + if (nfilters && layout!=H5D_CHUNKED) + { + CANNOT_LAYOUT(options); + return 0; + } + else + { + *pack=options->op_tbl->objs[i]; + return 1; + } } } } @@ -114,7 +166,10 @@ int apply_layout(hid_t dcpl_id, if(H5Pset_chunk(dcpl_id, obj->chunk.rank, obj->chunk.chunk_lengths)<0) return -1; } - + else if (H5D_COMPACT==obj->layout) { + if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY)<0) + return -1; + } return 0; } diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c index aa6ff82..0364206 100644 --- a/tools/h5repack/h5repack_parse.c +++ b/tools/h5repack/h5repack_parse.c @@ -391,7 +391,7 @@ obj_list_t* parse_layout(const char *str, } /* j */ - if ( pack->layout=H5D_CHUNKED ) + if ( pack->layout==H5D_CHUNKED ) { /*------------------------------------------------------------------------- diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c index 4486477..e2545bc 100644 --- a/tools/h5repack/h5repack_verify.c +++ b/tools/h5repack/h5repack_verify.c @@ -96,17 +96,29 @@ int has_layout(hid_t dcpl_id, { hsize_t chsize[64]; /* chunk size in elements */ H5D_layout_t layout; /* layout */ + int nfilters; /* number of filters */ int rank; /* rank */ int i; /* index */ /* if no information about the input layout is requested return exit */ if (obj==NULL) return 1; - - layout = H5Pget_layout(dcpl_id); + + /* check if we have filters in the input object */ + if ((nfilters = H5Pget_nfilters(dcpl_id))<0) + return -1; + + /* a non chunked layout was requested on a filtered object; avoid the test */ + if (nfilters && obj->layout!=H5D_CHUNKED) + return 1; + + /* get layout */ + if ((layout = H5Pget_layout(dcpl_id))<0) + return -1; + if (obj->layout != layout) return 0; - + if (layout==H5D_CHUNKED) { if ((rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize/*out*/))<0) @@ -118,8 +130,6 @@ int has_layout(hid_t dcpl_id, return 0; } - - return 1; } diff --git a/tools/h5repack/testh5repack_main.c b/tools/h5repack/testh5repack_main.c index ab5da12..f211adf 100644 --- a/tools/h5repack/testh5repack_main.c +++ b/tools/h5repack/testh5repack_main.c @@ -557,7 +557,6 @@ test_layout_contiguous(void) * test an individual object option *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; if (h5repack_addlayout("dset1:CONTI",&pack_options)<0) @@ -724,11 +723,15 @@ int main (void) #endif -#if 0 +#if 1 /* test a copy with layout CONTI options */ nerrors += test_layout_contiguous(); +#endif + +#if 1 + /* test a copy with layout COMPA options */ nerrors += test_layout_compact(); |