[svn-r8807] Purpose:

Code optimization

Description:
    Don't copy layout information, just point to existing information.


Platforms tested:
    Solaris 2.7 (arabica)
    FreeBSD 4.10 (sleipnir) w/parallel
    Too minor to require h5committest
This commit is contained in:
Quincey Koziol 2004-07-05 14:19:13 -05:00
parent fc512bc771
commit 06d8d7e98a

View File

@ -133,7 +133,7 @@ typedef struct H5D_istore_key_t {
typedef struct H5D_istore_ud1_t {
H5D_istore_key_t key; /*key values */
haddr_t addr; /*file address of chunk */
H5O_layout_t mesg; /*layout message */
const H5O_layout_t *mesg; /*layout message */
hsize_t total_storage; /*output from iterator */
FILE *stream; /*debug output stream */
hsize_t *dims; /*dataset dimensions */
@ -238,11 +238,11 @@ H5D_istore_sizeof_rkey(H5F_t UNUSED *f, const void *_udata)
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_sizeof_rkey);
assert(udata);
assert(udata->mesg.u.chunk.ndims > 0 && udata->mesg.u.chunk.ndims <= H5O_LAYOUT_NDIMS);
assert(udata->mesg->u.chunk.ndims > 0 && udata->mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS);
nbytes = 4 + /*storage size */
4 + /*filter mask */
udata->mesg.u.chunk.ndims*8; /*dimension indices */
udata->mesg->u.chunk.ndims*8; /*dimension indices */
FUNC_LEAVE_NOAPI(nbytes);
} /* end H5D_istore_sizeof_rkey() */
@ -360,7 +360,7 @@ H5D_istore_debug_key (FILE *stream, H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int i
"Filter mask:", key->filter_mask);
HDfprintf(stream, "%*s%-*s {", indent, "", fwidth,
"Logical offset:");
for (u=0; u<udata->mesg.u.chunk.ndims; u++)
for (u=0; u<udata->mesg->u.chunk.ndims; u++)
HDfprintf (stream, "%s%Hd", u?", ":"", key->offset[u]);
HDfputs ("}\n", stream);
@ -403,10 +403,10 @@ H5D_istore_cmp2(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_uda
assert(lt_key);
assert(rt_key);
assert(udata);
assert(udata->mesg.u.chunk.ndims > 0 && udata->mesg.u.chunk.ndims <= H5O_LAYOUT_NDIMS);
assert(udata->mesg->u.chunk.ndims > 0 && udata->mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS);
/* Compare the offsets but ignore the other fields */
ret_value = H5V_vector_cmp_s(udata->mesg.u.chunk.ndims, lt_key->offset, rt_key->offset);
ret_value = H5V_vector_cmp_s(udata->mesg->u.chunk.ndims, lt_key->offset, rt_key->offset);
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5D_istore_cmp2() */
@ -455,12 +455,12 @@ H5D_istore_cmp3(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_uda
assert(lt_key);
assert(rt_key);
assert(udata);
assert(udata->mesg.u.chunk.ndims > 0 && udata->mesg.u.chunk.ndims <= H5O_LAYOUT_NDIMS);
assert(udata->mesg->u.chunk.ndims > 0 && udata->mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS);
if (H5V_vector_lt_s(udata->mesg.u.chunk.ndims, udata->key.offset,
if (H5V_vector_lt_s(udata->mesg->u.chunk.ndims, udata->key.offset,
lt_key->offset)) {
ret_value = -1;
} else if (H5V_vector_ge_s(udata->mesg.u.chunk.ndims, udata->key.offset,
} else if (H5V_vector_ge_s(udata->mesg->u.chunk.ndims, udata->key.offset,
rt_key->offset)) {
ret_value = 1;
}
@ -507,7 +507,7 @@ H5D_istore_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t op,
assert(lt_key);
assert(rt_key);
assert(udata);
assert(udata->mesg.u.chunk.ndims > 0 && udata->mesg.u.chunk.ndims < H5O_LAYOUT_NDIMS);
assert(udata->mesg->u.chunk.ndims > 0 && udata->mesg->u.chunk.ndims < H5O_LAYOUT_NDIMS);
assert(addr_p);
/* Allocate new storage */
@ -523,7 +523,7 @@ H5D_istore_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t op,
*/
lt_key->nbytes = udata->key.nbytes;
lt_key->filter_mask = udata->key.filter_mask;
for (u=0; u<udata->mesg.u.chunk.ndims; u++)
for (u=0; u<udata->mesg->u.chunk.ndims; u++)
lt_key->offset[u] = udata->key.offset[u];
/*
@ -533,11 +533,11 @@ H5D_istore_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t op,
if (H5B_INS_LEFT != op) {
rt_key->nbytes = 0;
rt_key->filter_mask = 0;
for (u=0; u<udata->mesg.u.chunk.ndims; u++) {
assert (udata->key.offset[u]+(hssize_t)(udata->mesg.u.chunk.dim[u]) >
for (u=0; u<udata->mesg->u.chunk.ndims; u++) {
assert (udata->key.offset[u]+(hssize_t)(udata->mesg->u.chunk.dim[u]) >
udata->key.offset[u]);
rt_key->offset[u] = udata->key.offset[u] +
(hssize_t)(udata->mesg.u.chunk.dim[u]);
(hssize_t)(udata->mesg->u.chunk.dim[u]);
}
}
@ -591,8 +591,8 @@ H5D_istore_found(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, haddr_t addr, const void
assert(lt_key);
/* Is this *really* the requested chunk? */
for (u=0; u<udata->mesg.u.chunk.ndims; u++) {
if (udata->key.offset[u] >= lt_key->offset[u]+(hssize_t)(udata->mesg.u.chunk.dim[u]))
for (u=0; u<udata->mesg->u.chunk.ndims; u++) {
if (udata->key.offset[u] >= lt_key->offset[u]+(hssize_t)(udata->mesg->u.chunk.dim[u]))
HGOTO_DONE(FAIL);
}
@ -601,7 +601,7 @@ H5D_istore_found(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, haddr_t addr, const void
udata->key.nbytes = lt_key->nbytes;
udata->key.filter_mask = lt_key->filter_mask;
assert (lt_key->nbytes>0);
for (u = 0; u < udata->mesg.u.chunk.ndims; u++)
for (u = 0; u < udata->mesg->u.chunk.ndims; u++)
udata->key.offset[u] = lt_key->offset[u];
done:
@ -677,7 +677,7 @@ H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key,
assert("HDF5 INTERNAL ERROR -- see rpm" && 0);
HGOTO_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error");
} else if (H5V_vector_eq_s (udata->mesg.u.chunk.ndims,
} else if (H5V_vector_eq_s (udata->mesg->u.chunk.ndims,
udata->key.offset, lt_key->offset) &&
lt_key->nbytes>0) {
/*
@ -716,20 +716,20 @@ H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key,
ret_value = H5B_INS_NOOP;
}
} else if (H5V_hyper_disjointp(udata->mesg.u.chunk.ndims,
lt_key->offset, udata->mesg.u.chunk.dim,
udata->key.offset, udata->mesg.u.chunk.dim)) {
assert(H5V_hyper_disjointp(udata->mesg.u.chunk.ndims,
rt_key->offset, udata->mesg.u.chunk.dim,
udata->key.offset, udata->mesg.u.chunk.dim));
} else if (H5V_hyper_disjointp(udata->mesg->u.chunk.ndims,
lt_key->offset, udata->mesg->u.chunk.dim,
udata->key.offset, udata->mesg->u.chunk.dim)) {
assert(H5V_hyper_disjointp(udata->mesg->u.chunk.ndims,
rt_key->offset, udata->mesg->u.chunk.dim,
udata->key.offset, udata->mesg->u.chunk.dim));
/*
* Split this node, inserting the new new node to the right of the
* current node. The MD_KEY is where the split occurs.
*/
md_key->nbytes = udata->key.nbytes;
md_key->filter_mask = udata->key.filter_mask;
for (u=0; u<udata->mesg.u.chunk.ndims; u++) {
assert(0 == udata->key.offset[u] % udata->mesg.u.chunk.dim[u]);
for (u=0; u<udata->mesg->u.chunk.ndims; u++) {
assert(0 == udata->key.offset[u] % udata->mesg->u.chunk.dim[u]);
md_key->offset[u] = udata->key.offset[u];
}
@ -828,7 +828,7 @@ H5D_istore_iter_dump (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, hadd
}
HDfprintf(bt_udata->stream, " 0x%08x %8Zu %10a [",
lt_key->filter_mask, lt_key->nbytes, addr);
for (u=0; u<bt_udata->mesg.u.chunk.ndims; u++)
for (u=0; u<bt_udata->mesg->u.chunk.ndims; u++)
HDfprintf(bt_udata->stream, "%s%Hd", u?", ":"", lt_key->offset[u]);
HDfputs("]\n", bt_udata->stream);
@ -914,7 +914,7 @@ H5D_istore_flush_entry(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache,
if (ent->dirty) {
H5D_istore_ud1_t udata; /*pass through B-tree */
udata.mesg = dset->layout;
udata.mesg = &dset->layout;
udata.key.filter_mask = 0;
udata.addr = HADDR_UNDEF;
udata.key.nbytes = ent->chunk_size;
@ -1919,7 +1919,7 @@ H5D_istore_create(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout /*out */ )
assert(layout->u.chunk.dim[u] > 0);
#endif
udata.mesg.u.chunk.ndims = layout->u.chunk.ndims;
udata.mesg = layout;
if (H5B_create(f, dxpl_id, H5B_ISTORE, &udata, &(layout->u.chunk.addr)/*out*/) < 0)
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree");
@ -1971,7 +1971,7 @@ H5D_istore_allocated(H5F_t *f, hid_t dxpl_id, H5D_t *dset)
} /* end for */
HDmemset(&udata, 0, sizeof udata);
udata.mesg.u.chunk.ndims = dset->layout.u.chunk.ndims;
udata.mesg = &dset->layout;
if (H5B_iterate(f, dxpl_id, H5B_ISTORE, H5D_istore_iter_allocated, dset->layout.u.chunk.addr, &udata)<0)
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree");
@ -2022,7 +2022,7 @@ H5D_istore_get_addr(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
/* Initialize the information about the chunk we are looking for */
for (u=0; u<layout->u.chunk.ndims; u++)
udata->key.offset[u] = offset[u];
udata->mesg = *layout;
udata->mesg = layout;
udata->addr = HADDR_UNDEF;
/* Go get the chunk information */
@ -2323,7 +2323,7 @@ H5D_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5D_t *dset,
if(!chunk_exists) {
/* Initialize the chunk information */
udata.mesg = dset->layout;
udata.mesg = &dset->layout;
udata.key.filter_mask = 0;
udata.addr = HADDR_UNDEF;
H5_CHECK_OVERFLOW(chunk_size,hsize_t,size_t);
@ -2556,10 +2556,7 @@ H5D_istore_prune_by_extent(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache,
HDmemset(&udata, 0, sizeof udata);
udata.stream = stdout;
udata.mesg.u.chunk.addr = dset->layout.u.chunk.addr;
udata.mesg.u.chunk.ndims = dset->layout.u.chunk.ndims;
for(u = 0; u < dset->layout.u.chunk.ndims; u++)
udata.mesg.u.chunk.dim[u] = dset->layout.u.chunk.dim[u];
udata.mesg = &dset->layout;
udata.dims = curr_dims;
if(H5B_iterate(f, dxpl_id, H5B_ISTORE, H5D_istore_prune_extent, dset->layout.u.chunk.addr, &udata) < 0)
@ -2604,11 +2601,11 @@ H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t UNUSED a
FUNC_ENTER_NOAPI_NOINIT(H5D_istore_prune_extent);
/* Figure out what chunks are no longer in use for the specified extent and release them */
for(u = 0; u < bt_udata->mesg.u.chunk.ndims - 1; u++)
for(u = 0; u < bt_udata->mesg->u.chunk.ndims - 1; u++)
if((hsize_t)lt_key->offset[u] > bt_udata->dims[u]) {
#ifdef H5D_ISTORE_DEBUG
HDfputs("b-tree:remove:[", bt_udata->stream);
for(u = 0; u < bt_udata->mesg.u.chunk.ndims - 1; u++)
for(u = 0; u < bt_udata->mesg->u.chunk.ndims - 1; u++)
HDfprintf(bt_udata->stream, "%s%Hd", u ? ", " : "", lt_key->offset[u]);
HDfputs("]\n", bt_udata->stream);
#endif
@ -2618,7 +2615,7 @@ H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t UNUSED a
udata.mesg = bt_udata->mesg;
/* Remove */
if(H5B_remove(f, dxpl_id, H5B_ISTORE, bt_udata->mesg.u.chunk.addr, &udata) < 0)
if(H5B_remove(f, dxpl_id, H5B_ISTORE, bt_udata->mesg->u.chunk.addr, &udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_ITER_ERROR, "unable to remove entry");
break;
} /* end if */
@ -2895,7 +2892,7 @@ H5D_istore_delete(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout)
if(H5F_addr_defined(layout->u.chunk.addr)) {
/* Set up user data for B-tree deletion */
HDmemset(&udata, 0, sizeof udata);
udata.mesg = *layout;
udata.mesg = layout;
/* Delete entire B-tree */
if(H5B_delete(f, dxpl_id, H5B_ISTORE, layout->u.chunk.addr, &udata)<0)
@ -3026,13 +3023,15 @@ done:
herr_t
H5D_istore_dump_btree(H5F_t *f, hid_t dxpl_id, FILE *stream, unsigned ndims, haddr_t addr)
{
H5O_layout_t layout;
H5D_istore_ud1_t udata;
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5D_istore_dump_btree, FAIL);
HDmemset(&udata, 0, sizeof udata);
udata.mesg.u.chunk.ndims = ndims;
layout.u.chunk.ndims = ndims;
udata.mesg = &layout;
udata.stream = stream;
if(stream)
HDfprintf(stream, " Address: %a\n",addr);
@ -3129,12 +3128,14 @@ herr_t
H5D_istore_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent,
int fwidth, int ndims)
{
H5O_layout_t layout;
H5D_istore_ud1_t udata;
FUNC_ENTER_NOAPI_NOFUNC(H5D_istore_debug);
HDmemset (&udata, 0, sizeof udata);
udata.mesg.u.chunk.ndims = ndims;
layout.u.chunk.ndims = ndims;
udata.mesg = &layout;
H5B_debug (f, dxpl_id, addr, stream, indent, fwidth, H5B_ISTORE, &udata);