diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-05-03 18:53:45 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-05-03 18:53:45 (GMT) |
commit | 3231afc0de3ade97aabfc2003aa47875e1a54921 (patch) | |
tree | 1fab3ec9f4550ce13bbb1ed51674ae9ceb8b6d94 | |
parent | 5fc9dec1df918156589b96ce21a10b7a7d41b354 (diff) | |
download | hdf5-3231afc0de3ade97aabfc2003aa47875e1a54921.zip hdf5-3231afc0de3ade97aabfc2003aa47875e1a54921.tar.gz hdf5-3231afc0de3ade97aabfc2003aa47875e1a54921.tar.bz2 |
[svn-r8471] Purpose:
Code optimization
Description:
Eliminate the B-tree "split_ratios" as a parameter and pull it from the
DXPL instead.
Platforms tested:
Solaris 2.7 (arabica)
FreeBSD 4.9 (sleipnir) w/parallel
too minor to require h5committest
-rw-r--r-- | src/H5B.c | 56 | ||||
-rw-r--r-- | src/H5Bprivate.h | 2 | ||||
-rw-r--r-- | src/H5Distore.c | 12 | ||||
-rw-r--r-- | src/H5Dprivate.h | 5 | ||||
-rw-r--r-- | src/H5Fistore.c | 12 | ||||
-rw-r--r-- | src/H5Gstab.c | 4 |
6 files changed, 44 insertions, 47 deletions
@@ -100,19 +100,22 @@ #define H5B_PACKAGE /*suppress error about including H5Bpkg */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ +/* Pablo information */ +/* (Put before include files to avoid problems with inline functions) */ +#define PABLO_MASK H5B_mask + /* private headers */ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Bpkg.h" /* B-link trees */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MFprivate.h" /* File memory management */ #include "H5MMprivate.h" /* Memory management */ - -/* Pablo information */ -#define PABLO_MASK H5B_mask +#include "H5Pprivate.h" /* Property lists */ /* Local macros */ @@ -128,7 +131,6 @@ /* PRIVATE PROTOTYPES */ static H5B_ins_t H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, - const double split_ratios[], uint8_t *lt_key, hbool_t *lt_key_changed, uint8_t *md_key, void *udata, @@ -144,8 +146,7 @@ static size_t H5B_nodesize(H5F_t *f, const H5B_class_t *type, size_t *total_nkey_size, size_t sizeof_rkey); static herr_t H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, haddr_t old_addr, int idx, - const double split_ratios[], void *udata, - haddr_t *new_addr/*out*/); + void *udata, haddr_t *new_addr/*out*/); static H5B_t * H5B_copy(H5F_t *f, const H5B_t *old_bt); #ifdef H5B_DEBUG static herr_t H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, @@ -177,10 +178,10 @@ H5FL_BLK_DEFINE_STATIC(page); /* Declare a PQ free list to manage the native block information */ H5FL_BLK_DEFINE_STATIC(native_block); -/* Declare a free list to manage the H5B_key_t array information */ +/* Declare a free list to manage the H5B_key_t sequence information */ H5FL_SEQ_DEFINE_STATIC(H5B_key_t); -/* Declare a free list to manage the haddr_t array information */ +/* Declare a free list to manage the haddr_t sequence information */ H5FL_SEQ_DEFINE_STATIC(haddr_t); /* Declare a free list to manage the H5B_t struct */ @@ -414,11 +415,11 @@ done: * Jun 23 1997 * * Modifications: - * rky 980828 - * Only p0 writes metadata to disk. + * rky 980828 + * Only p0 writes metadata to disk. * - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. + * Robb Matzke, 1999-07-28 + * The ADDR argument is passed by value. * * Quincey Koziol, 2002-7-180 * Added dxpl parameter to allow more control over I/O from metadata @@ -696,12 +697,13 @@ done: */ static herr_t H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, haddr_t old_addr, - int idx, const double split_ratios[], void *udata, - haddr_t *new_addr_p/*out*/) + int idx, void *udata, haddr_t *new_addr_p/*out*/) { + H5P_genplist_t *dx_plist; /* Data transfer property list */ H5B_t *new_bt = NULL, *tmp_bt = NULL; herr_t ret_value = SUCCEED; int i, k, nleft, nright; + double split_ratios[3]; /* B-tree split ratios */ size_t recsize = 0; FUNC_ENTER_NOAPI_NOINIT(H5B_split); @@ -720,6 +722,15 @@ H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, haddr recsize = old_bt->sizeof_rkey + H5F_SIZEOF_ADDR(f); k = H5F_KVALUE(f, type); + + /* Get the dataset transfer property list */ + if (NULL == (dx_plist = H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") + + /* Get B-tree split ratios */ + if(H5P_get(dx_plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &split_ratios)<0) + HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve B-tree split ratios") + #ifdef H5B_DEBUG if (H5DEBUG(B)) { const char *side; @@ -925,7 +936,7 @@ done: */ herr_t H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, - const double split_ratios[], void *udata) + void *udata) { /* * These are defined this way to satisfy alignment constraints. @@ -953,7 +964,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, assert(type->sizeof_nkey <= sizeof _lt_key); assert(H5F_addr_defined(addr)); - if ((my_ins = H5B_insert_helper(f, dxpl_id, addr, type, split_ratios, lt_key, + if ((my_ins = H5B_insert_helper(f, dxpl_id, addr, type, lt_key, <_key_changed, md_key, udata, rt_key, &rt_key_changed, &child/*out*/))<0 || my_ins<0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to insert key"); @@ -1199,8 +1210,8 @@ H5B_insert_child(H5F_t *f, const H5B_class_t *type, H5B_t *bt, */ static H5B_ins_t H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, - const double split_ratios[], uint8_t *lt_key, - hbool_t *lt_key_changed, uint8_t *md_key, void *udata, + uint8_t *lt_key, hbool_t *lt_key_changed, + uint8_t *md_key, void *udata, uint8_t *rt_key, hbool_t *rt_key_changed, haddr_t *new_node_p/*out*/) { @@ -1288,7 +1299,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type idx = 0; if (H5B_decode_keys(f, bt, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key"); - if ((my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, split_ratios, + if ((my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, bt->key[idx].nkey, lt_key_changed, md_key, udata, bt->key[idx+1].nkey, rt_key_changed, &child_addr/*out*/))<0) @@ -1330,7 +1341,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type idx = bt->nchildren - 1; if (H5B_decode_keys(f, bt, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key"); - if ((my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, split_ratios, + if ((my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, bt->key[idx].nkey, lt_key_changed, md_key, udata, bt->key[idx+1].nkey, rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum subtree"); @@ -1376,7 +1387,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type * Follow a branch out of this node to another subtree. */ assert(idx >= 0 && idx < bt->nchildren); - if ((my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, split_ratios, + if ((my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, bt->key[idx].nkey, lt_key_changed, md_key, udata, bt->key[idx+1].nkey, rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert subtree"); @@ -1427,8 +1438,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type * If this node is full then split it before inserting the new child. */ if (bt->nchildren == 2 * H5F_KVALUE(f, type)) { - if (H5B_split(f, dxpl_id, type, bt, addr, idx, split_ratios, udata, - new_node_p/*out*/)<0) + if (H5B_split(f, dxpl_id, type, bt, addr, idx, udata, new_node_p/*out*/)<0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node"); if (NULL == (twin = H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, type, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node"); diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index c3ebf85..1f7a8eb 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -116,7 +116,7 @@ H5_DLL herr_t H5B_create (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void H5_DLL herr_t H5B_find (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata); H5_DLL herr_t H5B_insert (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, - const double split_ratios[], void *udata); + void *udata); H5_DLL herr_t H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op, haddr_t addr, void *udata); H5_DLL herr_t H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, diff --git a/src/H5Distore.c b/src/H5Distore.c index 85bb007..6d2a84d 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -107,7 +107,6 @@ typedef struct H5F_rdcc_ent_t { hbool_t locked; /*entry is locked in cache */ hbool_t dirty; /*needs to be written to disk? */ H5O_layout_t *layout; /*the layout message */ - double split_ratios[3];/*B-tree node splitting ratios */ H5O_pline_t *pline; /*filter pipeline message */ hssize_t offset[H5O_LAYOUT_NDIMS]; /*chunk name */ size_t rd_count; /*bytes remaining to be read */ @@ -980,7 +979,7 @@ H5F_istore_flush_entry(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, * Create the chunk it if it doesn't exist, or reallocate the chunk if * its size changed. Then write the data into the file. */ - if (H5B_insert(f, dxpl_id, H5B_ISTORE, ent->layout->addr, ent->split_ratios, &udata)<0) + if (H5B_insert(f, dxpl_id, H5B_ISTORE, ent->layout->addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk"); if (H5F_block_write(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, dxpl_id, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file"); @@ -1518,8 +1517,6 @@ H5F_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, con ent->wr_count = chunk_size; ent->chunk = chunk; - HDmemcpy(&(ent->split_ratios),&dxpl_cache->btree_split_ratio,H5D_XFER_BTREE_SPLIT_RATIO_SIZE); - /* Add it to the cache */ assert(NULL==rdcc->slot[idx]); rdcc->slot[idx] = ent; @@ -1658,8 +1655,6 @@ H5F_istore_unlock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, x.alloc_size = x.chunk_size; x.chunk = chunk; - HDmemcpy(&(x.split_ratios),&dxpl_cache->btree_split_ratio,H5D_XFER_BTREE_SPLIT_RATIO_SIZE); - H5F_istore_flush_entry (f, dxpl_cache, dxpl_id, &x, TRUE); } else { if(chunk) @@ -2178,7 +2173,6 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, H5F_istore_ud1_t udata; /* B-tree pass-through for creating chunk */ void *chunk=NULL; /* Chunk buffer for writing fill values */ H5P_genplist_t *dx_plist; /* Data xfer property list */ - double split_ratios[3];/* B-tree node splitting ratios */ #ifdef H5_HAVE_PARALLEL MPI_Comm mpi_comm=MPI_COMM_NULL; /* MPI communicator for file */ int mpi_rank=(-1); /* This process's rank */ @@ -2216,8 +2210,6 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, /* Get necessary properties from dataset transfer property list */ if (NULL == (dx_plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); - if(H5P_get(dx_plist,H5D_XFER_BTREE_SPLIT_RATIO_NAME,split_ratios)<0) - HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "can't get B-tree split ratios"); if(H5P_get(dx_plist,H5D_XFER_EDC_NAME,&edc)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get edc information"); if(H5P_get(dx_plist,H5D_XFER_FILTER_CB_NAME,&cb_struct)<0) @@ -2360,7 +2352,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, udata.key.offset[u] = chunk_offset[u]; /* Allocate the chunk with all processes */ - if (H5B_insert(f, dxpl_id, H5B_ISTORE, layout->addr, split_ratios, &udata)<0) + if (H5B_insert(f, dxpl_id, H5B_ISTORE, layout->addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk"); /* Check if fill values should be written to blocks */ diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index eff4345..7f90465 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -93,6 +93,9 @@ #define H5D_XFER_BKGR_BUF_TYPE_SIZE sizeof(H5T_bkg_t) #define H5D_XFER_BKGR_BUF_TYPE_DEF H5T_BKG_NO /* Definitions for B-tree node splitting ratio property */ +/* (These default B-tree node splitting ratios are also used for splitting + * group's B-trees as well as chunked dataset's B-trees - QAK) + */ #define H5D_XFER_BTREE_SPLIT_RATIO_NAME "btree_split_ratio" #define H5D_XFER_BTREE_SPLIT_RATIO_SIZE sizeof(double[3]) #define H5D_XFER_BTREE_SPLIT_RATIO_DEF {0.1, 0.5, 0.9} @@ -146,7 +149,7 @@ #define H5D_XFER_IO_XFER_MODE_SIZE sizeof(H5FD_mpio_xfer_t) #define H5D_XFER_IO_XFER_MODE_DEF H5FD_MPIO_INDEPENDENT /* Definitions for EDC property */ -#define H5D_XFER_EDC_NAME "error-detecting" +#define H5D_XFER_EDC_NAME "err_detect" #define H5D_XFER_EDC_SIZE sizeof(H5Z_EDC_t) #define H5D_XFER_EDC_DEF H5Z_ENABLE_EDC /* Definitions for filter callback function property */ diff --git a/src/H5Fistore.c b/src/H5Fistore.c index 85bb007..6d2a84d 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -107,7 +107,6 @@ typedef struct H5F_rdcc_ent_t { hbool_t locked; /*entry is locked in cache */ hbool_t dirty; /*needs to be written to disk? */ H5O_layout_t *layout; /*the layout message */ - double split_ratios[3];/*B-tree node splitting ratios */ H5O_pline_t *pline; /*filter pipeline message */ hssize_t offset[H5O_LAYOUT_NDIMS]; /*chunk name */ size_t rd_count; /*bytes remaining to be read */ @@ -980,7 +979,7 @@ H5F_istore_flush_entry(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, * Create the chunk it if it doesn't exist, or reallocate the chunk if * its size changed. Then write the data into the file. */ - if (H5B_insert(f, dxpl_id, H5B_ISTORE, ent->layout->addr, ent->split_ratios, &udata)<0) + if (H5B_insert(f, dxpl_id, H5B_ISTORE, ent->layout->addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk"); if (H5F_block_write(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, dxpl_id, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file"); @@ -1518,8 +1517,6 @@ H5F_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, con ent->wr_count = chunk_size; ent->chunk = chunk; - HDmemcpy(&(ent->split_ratios),&dxpl_cache->btree_split_ratio,H5D_XFER_BTREE_SPLIT_RATIO_SIZE); - /* Add it to the cache */ assert(NULL==rdcc->slot[idx]); rdcc->slot[idx] = ent; @@ -1658,8 +1655,6 @@ H5F_istore_unlock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, x.alloc_size = x.chunk_size; x.chunk = chunk; - HDmemcpy(&(x.split_ratios),&dxpl_cache->btree_split_ratio,H5D_XFER_BTREE_SPLIT_RATIO_SIZE); - H5F_istore_flush_entry (f, dxpl_cache, dxpl_id, &x, TRUE); } else { if(chunk) @@ -2178,7 +2173,6 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, H5F_istore_ud1_t udata; /* B-tree pass-through for creating chunk */ void *chunk=NULL; /* Chunk buffer for writing fill values */ H5P_genplist_t *dx_plist; /* Data xfer property list */ - double split_ratios[3];/* B-tree node splitting ratios */ #ifdef H5_HAVE_PARALLEL MPI_Comm mpi_comm=MPI_COMM_NULL; /* MPI communicator for file */ int mpi_rank=(-1); /* This process's rank */ @@ -2216,8 +2210,6 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, /* Get necessary properties from dataset transfer property list */ if (NULL == (dx_plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); - if(H5P_get(dx_plist,H5D_XFER_BTREE_SPLIT_RATIO_NAME,split_ratios)<0) - HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "can't get B-tree split ratios"); if(H5P_get(dx_plist,H5D_XFER_EDC_NAME,&edc)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get edc information"); if(H5P_get(dx_plist,H5D_XFER_FILTER_CB_NAME,&cb_struct)<0) @@ -2360,7 +2352,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, udata.key.offset[u] = chunk_offset[u]; /* Allocate the chunk with all processes */ - if (H5B_insert(f, dxpl_id, H5B_ISTORE, layout->addr, split_ratios, &udata)<0) + if (H5B_insert(f, dxpl_id, H5B_ISTORE, layout->addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk"); /* Check if fill values should be written to blocks */ diff --git a/src/H5Gstab.c b/src/H5Gstab.c index b5591b8..4804cff 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -216,7 +216,6 @@ H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent, hi { H5O_stab_t stab; /*symbol table message */ H5G_bt_ud1_t udata; /*data to pass through B-tree */ - static double split_ratios[3] = {0.1, 0.5, 0.9}; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_stab_insert, FAIL); @@ -235,13 +234,14 @@ H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent, hi /* initialize data to pass through B-tree */ if (NULL == H5O_read(grp_ent, H5O_STAB_ID, 0, &stab, dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table"); + udata.operation = H5G_OPER_INSERT; udata.name = name; udata.heap_addr = stab.heap_addr; H5G_ent_copy(&(udata.ent),obj_ent,H5G_COPY_NULL); /* NULL copy here, no copies happens in H5G_node_insert() callback() */ /* insert */ - if (H5B_insert(grp_ent->file, dxpl_id, H5B_SNODE, stab.btree_addr, split_ratios, &udata) < 0) + if (H5B_insert(grp_ent->file, dxpl_id, H5B_SNODE, stab.btree_addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert entry"); /* update the name offset in the entry */ |