[svn-r8301] Purpose:

Code optimization

Description:
    Move handling for free list arrays that have no maximum size to separate
set of routines and optimize computations for free list arrays with maximum
size to avoid re-computing sizes all the time.

Platforms tested:
    h5committest
    Solaris 2.7 (arabica)
This commit is contained in:
Quincey Koziol 2004-04-06 08:11:45 -05:00
parent 4c8f0b2463
commit 43d3a9bfe8
10 changed files with 457 additions and 318 deletions

View File

@ -130,15 +130,15 @@ static H5AC_t *current_cache_g = NULL; /*for sorting */
/* Declare a free list to manage the H5AC_t struct */
H5FL_DEFINE_STATIC(H5AC_t);
/* Declare a PQ free list to manage the cache mapping array information */
H5FL_ARR_DEFINE_STATIC(unsigned,-1);
/* Declare a free list to manage the cache mapping sequence information */
H5FL_SEQ_DEFINE_STATIC(unsigned);
/* Declare a PQ free list to manage the cache slot array information */
H5FL_ARR_DEFINE_STATIC(H5AC_info_ptr_t,-1);
/* Declare a free list to manage the cache slot sequence information */
H5FL_SEQ_DEFINE_STATIC(H5AC_info_ptr_t);
#ifdef H5AC_DEBUG
/* Declare a PQ free list to manage the protected slot array information */
H5FL_ARR_DEFINE_STATIC(H5AC_prot_t,-1);
/* Declare a free list to manage the protected slot sequence information */
H5FL_SEQ_DEFINE_STATIC(H5AC_prot_t);
#endif /* H5AC_DEBUG */
@ -374,12 +374,12 @@ H5AC_create(const H5F_t *f, int size_hint)
if (NULL==(f->shared->cache = cache = H5FL_CALLOC(H5AC_t)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
cache->nslots = (unsigned)size_hint;
if (NULL==( cache->slot = H5FL_ARR_CALLOC(H5AC_info_ptr_t,cache->nslots)))
if (NULL==( cache->slot = H5FL_SEQ_CALLOC(H5AC_info_ptr_t,cache->nslots)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
if (NULL==( cache->dslot = H5FL_ARR_CALLOC(H5AC_info_ptr_t,cache->nslots)))
if (NULL==( cache->dslot = H5FL_SEQ_CALLOC(H5AC_info_ptr_t,cache->nslots)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
#ifdef H5AC_DEBUG
if ((cache->prot = H5FL_ARR_CALLOC(H5AC_prot_t,cache->nslots))==NULL)
if ((cache->prot = H5FL_SEQ_CALLOC(H5AC_prot_t,cache->nslots))==NULL)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
#endif /* H5AC_DEBUG */
@ -390,12 +390,12 @@ done:
if(ret_value<0) {
if(cache!=NULL) {
if(cache->dslot !=NULL)
cache->dslot = H5FL_ARR_FREE (H5AC_info_ptr_t,cache->dslot);
cache->dslot = H5FL_SEQ_FREE (H5AC_info_ptr_t,cache->dslot);
if(cache->slot !=NULL)
cache->slot = H5FL_ARR_FREE (H5AC_info_ptr_t,cache->slot);
cache->slot = H5FL_SEQ_FREE (H5AC_info_ptr_t,cache->slot);
#ifdef H5AC_DEBUG
if(cache->prot !=NULL)
cache->prot = H5FL_ARR_FREE (H5AC_prot_t,cache->prot);
cache->prot = H5FL_SEQ_FREE (H5AC_prot_t,cache->prot);
#endif /* H5AC_DEBUG */
f->shared->cache = H5FL_FREE (H5AC_t,f->shared->cache);
} /* end if */
@ -445,12 +445,12 @@ H5AC_dest(H5F_t *f, hid_t dxpl_id)
cache->prot[i].aprots = 0;
cache->prot[i].nprots = 0;
}
cache->prot = H5FL_ARR_FREE(H5AC_prot_t,cache->prot);
cache->prot = H5FL_SEQ_FREE(H5AC_prot_t,cache->prot);
}
#endif
cache->dslot = H5FL_ARR_FREE(H5AC_info_ptr_t,cache->dslot);
cache->slot = H5FL_ARR_FREE(H5AC_info_ptr_t,cache->slot);
cache->dslot = H5FL_SEQ_FREE(H5AC_info_ptr_t,cache->dslot);
cache->slot = H5FL_SEQ_FREE(H5AC_info_ptr_t,cache->slot);
cache->nslots = 0;
f->shared->cache = cache = H5FL_FREE(H5AC_t,cache);
@ -565,7 +565,7 @@ H5AC_flush(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, unsi
* Sort the cache entries by address since flushing them in
* ascending order by address is much more efficient.
*/
if (NULL==(map=H5FL_ARR_MALLOC(unsigned,cache->nslots)))
if (NULL==(map=H5FL_SEQ_MALLOC(unsigned,cache->nslots)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
#ifdef H5_HAVE_PARALLEL
/* If MPI based VFD is used, do special parallel I/O actions */
@ -782,7 +782,7 @@ H5AC_flush(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, unsi
done:
if(map!=NULL)
map = H5FL_ARR_FREE(unsigned,map);
map = H5FL_SEQ_FREE(unsigned,map);
FUNC_LEAVE_NOAPI(ret_value)
}

View File

@ -177,11 +177,11 @@ 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 */
H5FL_ARR_DEFINE_STATIC(H5B_key_t,-1);
/* 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 */
H5FL_ARR_DEFINE_STATIC(haddr_t,-1);
/* 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 */
H5FL_DEFINE_STATIC(H5B_t);
@ -251,8 +251,8 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata,
bt->nchildren = 0;
if (NULL==(bt->page=H5FL_BLK_CALLOC(page,size)) ||
NULL==(bt->native=H5FL_BLK_MALLOC(native_block,total_native_keysize)) ||
NULL==(bt->child=H5FL_ARR_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) ||
NULL==(bt->key=H5FL_ARR_MALLOC(H5B_key_t,(size_t)(2*H5F_KVALUE(f,type)+1))))
NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) ||
NULL==(bt->key=H5FL_SEQ_MALLOC(H5B_key_t,(size_t)(2*H5F_KVALUE(f,type)+1))))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node")
/*
@ -350,8 +350,8 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
bt->ndirty = 0;
if (NULL==(bt->page=H5FL_BLK_MALLOC(page,size)) ||
NULL==(bt->native=H5FL_BLK_MALLOC(native_block,total_nkey_size)) ||
NULL==(bt->key=H5FL_ARR_MALLOC(H5B_key_t,(size_t)(2*H5F_KVALUE(f,type)+1))) ||
NULL==(bt->child=H5FL_ARR_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))))
NULL==(bt->key=H5FL_SEQ_MALLOC(H5B_key_t,(size_t)(2*H5F_KVALUE(f,type)+1))) ||
NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
if (H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, bt->page)<0)
HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree node")
@ -578,8 +578,8 @@ H5B_dest(H5F_t UNUSED *f, H5B_t *bt)
/* Verify that node is clean */
assert(bt->cache_info.dirty==0);
H5FL_ARR_FREE(haddr_t,bt->child);
H5FL_ARR_FREE(H5B_key_t,bt->key);
H5FL_SEQ_FREE(haddr_t,bt->child);
H5FL_SEQ_FREE(H5B_key_t,bt->key);
H5FL_BLK_FREE(page,bt->page);
H5FL_BLK_FREE(native_block,bt->native);
H5FL_FREE(H5B_t,bt);
@ -1706,7 +1706,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
* We've reached the left-most leaf. Now follow the right-sibling
* pointer from leaf to leaf until we've processed all leaves.
*/
if (NULL==(child=H5FL_ARR_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) ||
if (NULL==(child=H5FL_SEQ_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) ||
NULL==(key=H5MM_malloc((2*H5F_KVALUE(f, type)+1)*type->sizeof_nkey)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
@ -1759,7 +1759,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
done:
if(child!=NULL)
H5FL_ARR_FREE(haddr_t,child);
H5FL_SEQ_FREE(haddr_t,child);
if(key!=NULL)
H5MM_xfree(key);
FUNC_LEAVE_NOAPI(ret_value)
@ -2357,8 +2357,8 @@ H5B_copy(const H5F_t *f, const H5B_t *old_bt)
if (NULL==(new_node->page=H5FL_BLK_MALLOC(page,size)) ||
NULL==(new_node->native=H5FL_BLK_MALLOC(native_block,total_native_keysize)) ||
NULL==(new_node->child=H5FL_ARR_MALLOC(haddr_t,nkeys)) ||
NULL==(new_node->key=H5FL_ARR_MALLOC(H5B_key_t,(nkeys+1))))
NULL==(new_node->child=H5FL_SEQ_MALLOC(haddr_t,nkeys)) ||
NULL==(new_node->key=H5FL_SEQ_MALLOC(H5B_key_t,(nkeys+1))))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node")
/* Copy the other structures */
@ -2382,8 +2382,8 @@ done:
if(new_node) {
H5FL_BLK_FREE (page,new_node->page);
H5FL_BLK_FREE (native_block,new_node->native);
H5FL_ARR_FREE (haddr_t,new_node->child);
H5FL_ARR_FREE (H5B_key_t,new_node->key);
H5FL_SEQ_FREE (haddr_t,new_node->child);
H5FL_SEQ_FREE (H5B_key_t,new_node->key);
H5FL_FREE (H5B_t,new_node);
} /* end if */
} /* end if */

View File

@ -936,8 +936,6 @@ done:
void *
H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size)
{
size_t blk_size; /* Temporary block size */
H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */
void *ret_value=NULL; /* Return value */
FUNC_ENTER_NOAPI(H5FL_blk_realloc, NULL)
@ -948,11 +946,15 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size)
/* Check if we are actually re-allocating a block */
if(block!=NULL) {
H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */
/* Get the pointer to the chunk info header in front of the chunk to free */
temp=(H5FL_blk_list_t *)((unsigned char *)block-sizeof(H5FL_blk_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */
/* check if we are actually changing the size of the buffer */
if(new_size!=temp->size) {
size_t blk_size; /* Temporary block size */
if((ret_value=H5FL_blk_malloc(head,new_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block")
blk_size=MIN(new_size,temp->size);
@ -1158,6 +1160,7 @@ static herr_t
H5FL_arr_init(H5FL_arr_head_t *head)
{
H5FL_gc_arr_node_t *new_node; /* Pointer to the node for the new list to garbage collect */
size_t u; /* Local index variable */
herr_t ret_value=SUCCEED; /* return value*/
FUNC_ENTER_NOAPI_NOINIT(H5FL_arr_init)
@ -1173,21 +1176,13 @@ H5FL_arr_init(H5FL_arr_head_t *head)
new_node->next=H5FL_arr_gc_head.first;
H5FL_arr_gc_head.first=new_node;
/* Allocate room for the free lists, if the arrays have a maximum size */
if(head->maxelem>0) {
if (NULL==(head->u.list_arr = H5MM_calloc((size_t)head->maxelem*sizeof(H5FL_arr_node_t *))))
/* Allocate room for the free lists */
if (NULL==(head->list_arr = H5MM_calloc((size_t)head->maxelem*sizeof(H5FL_arr_node_t))))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
if (NULL==(head->onlist = H5MM_calloc((size_t)head->maxelem*sizeof(unsigned))))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
} /* end if */
else {
head->u.queue.init=0;
head->u.queue.allocated=0;
head->u.queue.onlist=0;
head->u.queue.list_mem=0;
head->u.queue.name=head->name;
head->u.queue.head=NULL;
} /* end else */
/* Initialize the size of each array */
for(u=1; u<(size_t)head->maxelem; u++)
head->list_arr[u].size=head->size*u;
/* Indicate that the free list is initialized */
head->init=1;
@ -1215,7 +1210,7 @@ done:
void *
H5FL_arr_free(H5FL_arr_head_t *head, void *obj)
{
H5FL_arr_node_t *temp; /* Temp. ptr to the new free list node allocated */
H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */
size_t mem_size; /* Size of memory being freed */
size_t free_nelem; /* Number of elements in node being free'd */
void *ret_value=NULL; /* Return value */
@ -1232,28 +1227,26 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj)
/* Make certain that the free list is initialized */
assert(head->init);
/* Check if there are a maximum number of elements in list */
if(head->maxelem>0) {
/* Get the pointer to the info header in front of the block to free */
temp=(H5FL_arr_node_t *)((unsigned char *)obj-sizeof(H5FL_arr_node_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */
temp=(H5FL_arr_list_t *)((unsigned char *)obj-sizeof(H5FL_arr_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */
/* Save the number of elements for later */
/* Get the number of elements */
free_nelem=temp->nelem;
/* Double-check that there is enough room for arrays of this size */
assert((int)free_nelem<=head->maxelem);
/* Link into the free list */
temp->next=head->u.list_arr[free_nelem];
temp->next=head->list_arr[free_nelem].list;
/* Point free list at the node freed */
head->u.list_arr[free_nelem]=temp;
head->list_arr[free_nelem].list=temp;
/* Set the amount of memory being freed */
mem_size=free_nelem*head->size;
/* Get the size of arrays with this many elements */
mem_size=head->list_arr[free_nelem].size;
/* Increment the number of blocks & memory used on free list */
head->onlist[free_nelem]++;
head->list_arr[free_nelem].onlist++;
head->list_mem+=mem_size;
/* Increment the amount of "array" freed memory globally */
@ -1270,11 +1263,6 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj)
if(H5FL_arr_gc()<0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free")
} /* end if */
/* No maximum number of elements, use block routine */
else
H5FL_blk_free(&(head->u.queue),obj);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_arr_free() */
@ -1298,7 +1286,7 @@ done:
void *
H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem)
{
H5FL_arr_node_t *new_obj; /* Pointer to the new free list node allocated */
H5FL_arr_list_t *new_obj; /* Pointer to the new free list node allocated */
void *ret_value; /* Pointer to object to return */
size_t mem_size; /* Size of memory block being recycled */
@ -1313,54 +1301,42 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem)
if(H5FL_arr_init(head)<0)
HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'array' blocks")
/* Set the set of the memory block */
mem_size=head->size*elem;
/* Get the set of the memory block */
mem_size=head->list_arr[elem].size;
/* Check if there is a maximum number of elements in array */
if(head->maxelem>0) {
/* Sanity check that the number of elements is supported */
assert((int)elem<=head->maxelem);
/* Check for nodes available on the free list first */
if(head->u.list_arr[elem]!=NULL) {
if(head->list_arr[elem].list!=NULL) {
/* Get a pointer to the block on the free list */
new_obj=head->u.list_arr[elem];
new_obj=head->list_arr[elem].list;
/* Remove node from free list */
head->u.list_arr[elem]=head->u.list_arr[elem]->next;
head->list_arr[elem].list=head->list_arr[elem].list->next;
/* Decrement the number of blocks & memory used on free list */
head->onlist[elem]--;
head->list_arr[elem].onlist--;
head->list_mem-=mem_size;
/* Decrement the amount of global "array" free list memory in use */
H5FL_arr_gc_head.mem_freed-=mem_size;
/* Restore number of elements */
new_obj->nelem=elem;
/* Get the pointer to the data block */
ret_value=((char *)new_obj)+sizeof(H5FL_arr_node_t);
} /* end if */
/* Otherwise allocate a node */
else {
if (NULL==(new_obj = H5FL_malloc(sizeof(H5FL_arr_node_t)+mem_size)))
if (NULL==(new_obj = H5FL_malloc(sizeof(H5FL_arr_list_t)+mem_size)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Increment the number of blocks allocated in list */
head->allocated++;
} /* end else */
/* Initialize the new object */
new_obj->nelem=elem;
/* Get a pointer to the new block */
ret_value=((char *)new_obj)+sizeof(H5FL_arr_node_t);
} /* end else */
} /* end if */
/* No fixed number of elements, use PQ routine */
else
ret_value=H5FL_blk_malloc(&(head->u.queue),mem_size);
ret_value=((char *)new_obj)+sizeof(H5FL_arr_list_t);
done:
FUNC_LEAVE_NOAPI(ret_value)
@ -1398,7 +1374,7 @@ H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Clear to zeros */
HDmemset(ret_value,0,head->size*elem);
HDmemset(ret_value,0,head->list_arr[elem].size);
done:
FUNC_LEAVE_NOAPI(ret_value)
@ -1423,8 +1399,6 @@ done:
void *
H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem)
{
size_t blk_size; /* Size of block */
H5FL_arr_node_t *temp; /* Temp. ptr to the new free list node allocated */
void *ret_value; /* Pointer to object to return */
FUNC_ENTER_NOAPI(H5FL_arr_realloc, NULL)
@ -1434,20 +1408,21 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem)
assert(new_elem);
/* Check if we are really allocating the object */
if(obj==NULL) {
if(obj==NULL)
ret_value=H5FL_arr_malloc(head,new_elem);
} /* end if */
else {
/* Check if there is a maximum number of elements in array */
if(head->maxelem>0) {
H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */
/* Sanity check that the number of elements is supported */
assert((int)new_elem<=head->maxelem);
/* Get the pointer to the info header in front of the block to free */
temp=(H5FL_arr_node_t *)((unsigned char *)obj-sizeof(H5FL_arr_node_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */
temp=(H5FL_arr_list_t *)((unsigned char *)obj-sizeof(H5FL_arr_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */
/* Check if the size is really changing */
if(temp->nelem!=new_elem) {
size_t blk_size; /* Size of block */
/* Get the new array of objects */
ret_value=H5FL_arr_malloc(head,new_elem);
@ -1460,10 +1435,6 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem)
} /* end if */
else
ret_value=obj;
} /* end if */
/* No fixed number of elements, use block routine */
else
ret_value=H5FL_blk_realloc(&(head->u.queue),obj,head->size*new_elem);
} /* end else */
done:
@ -1489,24 +1460,21 @@ done:
static herr_t
H5FL_arr_gc_list(H5FL_arr_head_t *head)
{
H5FL_arr_node_t *arr_free_list; /* Pointer to nodes in free list being garbage collected */
H5FL_arr_list_t *arr_free_list; /* Pointer to nodes in free list being garbage collected */
void *tmp; /* Temporary node pointer */
unsigned u; /* Counter for array of free lists */
size_t total_mem; /* Total memory used on list */
herr_t ret_value=SUCCEED; /* return value*/
FUNC_ENTER_NOAPI_NOINIT(H5FL_arr_gc_list)
/* Check if the array has a fixed maximum number of elements */
if(head->maxelem>0) {
/* Walk through the array of free lists */
for(u=0; u<(unsigned)head->maxelem; u++) {
if(head->onlist[u]>0) {
if(head->list_arr[u].onlist>0) {
/* Calculate the total memory used on this list */
total_mem=head->onlist[u]*u*head->size;
total_mem=head->list_arr[u].onlist*head->list_arr[u].size;
/* For each free list being garbage collected, walk through the nodes and free them */
arr_free_list=head->u.list_arr[u];
arr_free_list=head->list_arr[u].list;
while(arr_free_list!=NULL) {
tmp=arr_free_list->next;
@ -1518,8 +1486,8 @@ H5FL_arr_gc_list(H5FL_arr_head_t *head)
} /* end while */
/* Indicate no free nodes on the free list */
head->u.list_arr[u]=NULL;
head->onlist[u]=0;
head->list_arr[u].list=NULL;
head->list_arr[u].onlist=0;
/* Decrement count of free memory on this "array" list */
head->list_mem-=total_mem;
@ -1527,20 +1495,13 @@ H5FL_arr_gc_list(H5FL_arr_head_t *head)
/* Decrement global count of free memory on "array" lists */
H5FL_arr_gc_head.mem_freed-=total_mem;
} /* end if */
} /* end for */
/* Double check that all the memory on this list is recycled */
assert(head->list_mem==0);
} /* end if */
/* No maximum number of elements, use the block call to garbage collect */
else
if(H5FL_blk_gc_list(&(head->u.queue))<0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FL_arr_gc_list() */
@ -1618,8 +1579,6 @@ H5FL_arr_term(void)
while(H5FL_arr_gc_head.first!=NULL) {
tmp=H5FL_arr_gc_head.first->next;
/* Check if the array has a fixed maximum number of elements */
if(H5FL_arr_gc_head.first->list->maxelem>0) {
/* Check if the list has allocations outstanding */
#ifdef H5FL_DEBUG
printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.first->list->name,(int)H5FL_arr_gc_head.first->list->allocated);
@ -1632,10 +1591,7 @@ printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.fi
/* No allocations left open for list, get rid of it */
else {
/* Free the array of free lists */
H5MM_xfree(H5FL_arr_gc_head.first->list->u.list_arr);
/* Free the array of "onlist" counts */
H5MM_xfree(H5FL_arr_gc_head.first->list->onlist);
H5MM_xfree(H5FL_arr_gc_head.first->list->list_arr);
/* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */
H5FL_arr_gc_head.first->list->init=0;
@ -1643,27 +1599,6 @@ printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.fi
/* Free the node from the garbage collection list */
H5MM_xfree(H5FL_arr_gc_head.first);
} /* end else */
} /* end if */
/* No maximum number of elements, use the PQ information */
else {
#ifdef H5FL_DEBUG
printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.first->list->name,(int)H5FL_arr_gc_head.first->list->u.queue.allocated);
#endif /* H5FL_DEBUG */
/* Check if the list has allocations outstanding */
if(H5FL_arr_gc_head.first->list->u.queue.allocated>0) {
/* Add free list to the list of nodes with allocations open still */
H5FL_arr_gc_head.first->next=left;
left=H5FL_arr_gc_head.first;
} /* end if */
/* No allocations left open for list, get rid of it */
else {
/* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */
H5FL_arr_gc_head.first->list->init=0;
/* Free the node from the garbage collection list */
H5MM_xfree(H5FL_arr_gc_head.first);
} /* end else */
} /* end else */
H5FL_arr_gc_head.first=tmp;
} /* end while */
@ -1674,6 +1609,148 @@ printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.fi
FUNC_LEAVE_NOAPI(H5FL_arr_gc_head.first!=NULL ? 1 : 0)
} /* end H5FL_arr_term() */
/*-------------------------------------------------------------------------
* Function: H5FL_seq_free
*
* Purpose: Release a sequence of objects & put on free list
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Saturday, April 3, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void *
H5FL_seq_free(H5FL_seq_head_t *head, void *obj)
{
void *ret_value=NULL; /* Return value */
FUNC_ENTER_NOAPI(H5FL_seq_free, NULL)
/* The H5MM_xfree code allows obj to null */
if (!obj)
HGOTO_DONE (NULL)
/* Double check parameters */
assert(head);
/* Make certain that the free list is initialized */
assert(head->queue.init);
/* Use block routine */
H5FL_blk_free(&(head->queue),obj);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_seq_free() */
/*-------------------------------------------------------------------------
* Function: H5FL_seq_malloc
*
* Purpose: Allocate a sequence of objects
*
* Return: Success: Pointer to a valid sequence object
* Failure: NULL
*
* Programmer: Quincey Koziol
* Saturday, April 3, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void *
H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem)
{
void *ret_value; /* Pointer to object to return */
FUNC_ENTER_NOAPI(H5FL_seq_malloc, NULL)
/* Double check parameters */
assert(head);
assert(elem);
/* Use block routine */
ret_value=H5FL_blk_malloc(&(head->queue),head->size*elem);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_seq_malloc() */
/*-------------------------------------------------------------------------
* Function: H5FL_seq_calloc
*
* Purpose: Allocate a sequence of objects and clear it to zeros
*
* Return: Success: Pointer to a valid array object
* Failure: NULL
*
* Programmer: Quincey Koziol
* Saturday, April 3, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void *
H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem)
{
void *ret_value; /* Pointer to object to return */
FUNC_ENTER_NOAPI(H5FL_seq_calloc, NULL)
/* Double check parameters */
assert(head);
assert(elem);
/* Use block routine */
ret_value=H5FL_blk_calloc(&(head->queue),head->size*elem);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_seq_calloc() */
/*-------------------------------------------------------------------------
* Function: H5FL_seq_realloc
*
* Purpose: Reallocate a sequence of objects
*
* Return: Success: Pointer to a valid sequence object
* Failure: NULL
*
* Programmer: Quincey Koziol
* Saturday, April 3, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void *
H5FL_seq_realloc(H5FL_seq_head_t *head, void * obj, size_t new_elem)
{
void *ret_value; /* Pointer to object to return */
FUNC_ENTER_NOAPI(H5FL_seq_realloc, NULL)
/* Double check parameters */
assert(head);
assert(new_elem);
/* Use block routine */
ret_value=H5FL_blk_realloc(&(head->queue),obj,head->size*new_elem);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_seq_realloc() */
/*-------------------------------------------------------------------------
* Function: H5FL_garbage_coll

View File

@ -39,6 +39,7 @@
#ifdef H5_NO_FREE_LISTS
#define H5_NO_REG_FREE_LISTS
#define H5_NO_ARR_FREE_LISTS
#define H5_NO_SEQ_FREE_LISTS
#define H5_NO_BLK_FREE_LISTS
#endif /* H5_NO_FREE_LISTS */
@ -137,7 +138,7 @@ typedef struct H5FL_blk_head_t {
#define H5FL_BLK_NAME(t) H5_##t##_blk_free_list
#ifndef H5_NO_BLK_FREE_LISTS
/* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */
#define H5FL_BLK_DEFINE_COMMON(t) H5FL_blk_head_t H5FL_BLK_NAME(t)={0,0,0,0,#t,NULL}
#define H5FL_BLK_DEFINE_COMMON(t) H5FL_blk_head_t H5FL_BLK_NAME(t)={0,0,0,0,#t"_blk",NULL}
/* Declare a free list to manage objects of type 't' */
#define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t)
@ -178,26 +179,29 @@ typedef struct H5FL_blk_head_t {
#endif /* H5_NO_BLK_FREE_LISTS */
/* Data structure to store each array in free list */
typedef union H5FL_arr_node_t {
union H5FL_arr_node_t *next; /* Pointer to next block in free list */
typedef union H5FL_arr_list_t {
union H5FL_arr_list_t *next; /* Pointer to next block in free list */
size_t nelem; /* Number of elements in this array */
double unused1; /* Unused normally, just here for aligment */
haddr_t unused2; /* Unused normally, just here for aligment */
} H5FL_arr_list_t;
/* Data structure for each size of array element */
typedef struct H5FL_arr_node_t {
size_t size; /* Size of the blocks in the list */
unsigned onlist; /* Number of blocks on free list */
H5FL_arr_list_t *list; /* List of free blocks */
} H5FL_arr_node_t;
/* Data structure for free list of array blocks */
typedef struct H5FL_arr_head_t {
unsigned init; /* Whether the free list has been initialized */
unsigned allocated; /* Number of blocks allocated */
unsigned *onlist; /* Number of blocks on free list */
size_t list_mem; /* Amount of memory in block on free list */
const char *name; /* Name of the type */
int maxelem; /* Maximum number of elements in an array */
size_t size; /* Size of the array elements in the list */
union {
H5FL_arr_node_t **list_arr; /* Array of lists of free blocks */
H5FL_blk_head_t queue; /* Priority queue of array blocks */
}u;
H5FL_arr_node_t *list_arr; /* Array of lists of free blocks */
} H5FL_arr_head_t;
/*
@ -206,7 +210,7 @@ typedef struct H5FL_arr_head_t {
#define H5FL_ARR_NAME(t) H5_##t##_arr_free_list
#ifndef H5_NO_ARR_FREE_LISTS
/* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */
#define H5FL_ARR_DEFINE_COMMON(t,m) H5FL_arr_head_t H5FL_ARR_NAME(t)={0,0,NULL,0,#t"_arr",m+1,sizeof(t),{NULL}}
#define H5FL_ARR_DEFINE_COMMON(t,m) H5FL_arr_head_t H5FL_ARR_NAME(t)={0,0,0,#t"_arr",m+1,sizeof(t),NULL}
/* Declare a free list to manage arrays of type 't' */
#define H5FL_ARR_DEFINE(t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(t,m)
@ -230,7 +234,7 @@ typedef struct H5FL_arr_head_t {
#define H5FL_ARR_REALLOC(t,obj,new_elem) H5FL_arr_realloc(&(H5FL_ARR_NAME(t)),obj,new_elem)
#else /* H5_NO_ARR_FREE_LISTS */
/* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */
/* Common macro for H5FL_ARR_DEFINE & H5FL_ARR_DEFINE_STATIC */
#define H5FL_ARR_DEFINE_COMMON(t,m) int H5FL_ARR_NAME(t)
#define H5FL_ARR_DEFINE(t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(t,m)
@ -242,6 +246,57 @@ typedef struct H5FL_arr_head_t {
#define H5FL_ARR_REALLOC(t,obj,new_elem) H5MM_realloc(obj,(new_elem)*sizeof(t))
#endif /* H5_NO_ARR_FREE_LISTS */
/* Data structure for free list of sequence blocks */
typedef struct H5FL_seq_head_t {
H5FL_blk_head_t queue; /* Priority queue of sequence blocks */
size_t size; /* Size of the sequence elements in the list */
} H5FL_seq_head_t;
/*
* Macros for defining & using free lists for a sequence of a type
*
* Sequences are like arrays, except they have no upper limit.
*
*/
#define H5FL_SEQ_NAME(t) H5_##t##_seq_free_list
#ifndef H5_NO_SEQ_FREE_LISTS
/* Common macro for H5FL_SEQ_DEFINE & H5FL_SEQ_DEFINE_STATIC */
#define H5FL_SEQ_DEFINE_COMMON(t) H5FL_seq_head_t H5FL_SEQ_NAME(t)={{0,0,0,0,#t"_seq",NULL},sizeof(t)}
/* Declare a free list to manage sequences of type 't' */
#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t)
/* Reference a free list for sequences of type 't' defined in another file */
#define H5FL_SEQ_EXTERN(t) extern H5_DLL H5FL_seq_head_t H5FL_SEQ_NAME(t)
/* Declare a static free list to manage sequences of type 't' */
#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t)
/* Allocate a sequence of type 't' */
#define H5FL_SEQ_MALLOC(t,elem) H5FL_seq_malloc(&(H5FL_SEQ_NAME(t)),elem)
/* Allocate a sequence of type 't' and clear it to all zeros */
#define H5FL_SEQ_CALLOC(t,elem) H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)),elem)
/* Free a sequence of type 't' */
#define H5FL_SEQ_FREE(t,obj) H5FL_seq_free(&(H5FL_SEQ_NAME(t)),obj)
/* Re-allocate a sequence of type 't' */
#define H5FL_SEQ_REALLOC(t,obj,new_elem) H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)),obj,new_elem)
#else /* H5_NO_SEQ_FREE_LISTS */
/* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */
#define H5FL_SEQ_DEFINE_COMMON(t) int H5FL_SEQ_NAME(t)
#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t)
#define H5FL_SEQ_EXTERN(t) extern H5_DLL int H5FL_SEQ_NAME(t)
#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t)
#define H5FL_SEQ_MALLOC(t,elem) H5MM_malloc((elem)*sizeof(t))
#define H5FL_SEQ_CALLOC(t,elem) H5MM_calloc((elem)*sizeof(t))
#define H5FL_SEQ_FREE(t,obj) H5MM_xfree(obj)
#define H5FL_SEQ_REALLOC(t,obj,new_elem) H5MM_realloc(obj,(new_elem)*sizeof(t))
#endif /* H5_NO_SEQ_FREE_LISTS */
/*
* Library prototypes.
*/
@ -257,6 +312,10 @@ H5_DLL void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem);
H5_DLL void * H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem);
H5_DLL void * H5FL_arr_free(H5FL_arr_head_t *head, void *obj);
H5_DLL void * H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem);
H5_DLL void * H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem);
H5_DLL void * H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem);
H5_DLL void * H5FL_seq_free(H5FL_seq_head_t *head, void *obj);
H5_DLL void * H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem);
H5_DLL herr_t H5FL_garbage_coll(void);
H5_DLL herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim,
int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim);

View File

@ -134,8 +134,8 @@ static int interface_initialize_g = 0;
/* Declare a free list to manage the H5G_node_t struct */
H5FL_DEFINE_STATIC(H5G_node_t);
/* Declare a free list to manage arrays of H5G_entry_t's */
H5FL_ARR_DEFINE_STATIC(H5G_entry_t,-1);
/* Declare a free list to manage sequences of H5G_entry_t's */
H5FL_SEQ_DEFINE_STATIC(H5G_entry_t);
/* Declare a free list to manage blocks of symbol node data */
H5FL_BLK_DEFINE_STATIC(symbol_node);
@ -360,7 +360,7 @@ H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_udata1
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for symbol table node");
p=buf;
if (NULL==(sym = H5FL_CALLOC(H5G_node_t)) ||
NULL==(sym->entry=H5FL_ARR_CALLOC(H5G_entry_t,(2*H5F_SYM_LEAF_K(f)))))
NULL==(sym->entry=H5FL_SEQ_CALLOC(H5G_entry_t,(2*H5F_SYM_LEAF_K(f)))))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
if (H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, buf) < 0)
HGOTO_ERROR(H5E_SYM, H5E_READERROR, NULL, "unable to read symbol table node");
@ -572,7 +572,7 @@ H5G_node_dest(H5F_t UNUSED *f, H5G_node_t *sym)
assert (sym->cache_info.dirty==0);
if(sym->entry)
sym->entry = H5FL_ARR_FREE(H5G_entry_t,sym->entry);
sym->entry = H5FL_SEQ_FREE(H5G_entry_t,sym->entry);
H5FL_FREE(H5G_node_t,sym);
FUNC_LEAVE_NOAPI(SUCCEED);
@ -671,7 +671,7 @@ H5G_node_create(H5F_t *f, hid_t dxpl_id, H5B_ins_t UNUSED op, void *_lt_key,
if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, size)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to allocate file space");
sym->cache_info.dirty = TRUE;
sym->entry = H5FL_ARR_CALLOC(H5G_entry_t,(2*H5F_SYM_LEAF_K(f)));
sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t,(2*H5F_SYM_LEAF_K(f)));
if (NULL==sym->entry)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
if (H5AC_set(f, dxpl_id, H5AC_SNODE, *addr_p, sym) < 0)
@ -691,7 +691,7 @@ done:
if(ret_value<0) {
if(sym!=NULL) {
if(sym->entry!=NULL)
H5FL_ARR_FREE(H5G_entry_t,sym->entry);
H5FL_SEQ_FREE(H5G_entry_t,sym->entry);
H5FL_FREE(H5G_node_t,sym);
} /* end if */
} /* end if */

View File

@ -139,8 +139,8 @@ static int interface_initialize_g = 0;
/* Declare a free list to manage the H5HG_t struct */
H5FL_DEFINE_STATIC(H5HG_heap_t);
/* Declare a free list to manage arrays of H5HG_obj_t's */
H5FL_ARR_DEFINE_STATIC(H5HG_obj_t,-1);
/* Declare a free list to manage sequences of H5HG_obj_t's */
H5FL_SEQ_DEFINE_STATIC(H5HG_obj_t);
/* Declare a PQ free list to manage heap chunks */
H5FL_BLK_DEFINE_STATIC(heap_chunk);
@ -196,7 +196,7 @@ H5HG_create (H5F_t *f, hid_t dxpl_id, size_t size)
if (NULL==(heap->chunk = H5FL_BLK_MALLOC (heap_chunk,size)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
heap->nalloc = H5HG_NOBJS (f, size);
if (NULL==(heap->obj = H5FL_ARR_CALLOC (H5HG_obj_t,heap->nalloc)))
if (NULL==(heap->obj = H5FL_SEQ_CALLOC (H5HG_obj_t,heap->nalloc)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Initialize the header */
@ -334,7 +334,7 @@ H5HG_load (H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1,
/* Decode each object */
p = heap->chunk + H5HG_SIZEOF_HDR (f);
nalloc = H5HG_NOBJS (f, heap->size);
if (NULL==(heap->obj = H5FL_ARR_CALLOC (H5HG_obj_t,nalloc)))
if (NULL==(heap->obj = H5FL_SEQ_CALLOC (H5HG_obj_t,nalloc)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
heap->nalloc = nalloc;
while (p<heap->chunk+heap->size) {
@ -497,7 +497,7 @@ H5HG_dest (H5F_t *f, H5HG_heap_t *heap)
}
}
heap->chunk = H5FL_BLK_FREE(heap_chunk,heap->chunk);
heap->obj = H5FL_ARR_FREE(H5HG_obj_t,heap->obj);
heap->obj = H5FL_SEQ_FREE(H5HG_obj_t,heap->obj);
H5FL_FREE (H5HG_heap_t,heap);
FUNC_LEAVE_NOAPI(SUCCEED);

View File

@ -61,8 +61,8 @@ static herr_t H5HP_sink_min(H5HP_t *heap, size_t loc);
/* Declare a free list to manage the H5HP_t struct */
H5FL_DEFINE_STATIC(H5HP_t);
/* Declare a free list to manage arrays of H5HP_ent_t */
H5FL_ARR_DEFINE_STATIC(H5HP_ent_t,-1);
/* Declare a free list to manage sequences of H5HP_ent_t */
H5FL_SEQ_DEFINE_STATIC(H5HP_ent_t);
/*--------------------------------------------------------------------------
@ -354,7 +354,7 @@ H5HP_create(H5HP_type_t heap_type)
HGOTO_ERROR(H5E_HEAP,H5E_NOSPACE,NULL,"memory allocation failed");
/* Allocate the array to store the heap entries */
if((new_heap->heap=H5FL_ARR_MALLOC(H5HP_ent_t, H5HP_START_SIZE+1))==NULL)
if((new_heap->heap=H5FL_SEQ_MALLOC(H5HP_ent_t, H5HP_START_SIZE+1))==NULL)
HGOTO_ERROR(H5E_HEAP,H5E_NOSPACE,NULL,"memory allocation failed");
/* Set the internal fields */
@ -386,7 +386,7 @@ done:
if(ret_value==NULL) {
if(new_heap!=NULL) {
if(new_heap->heap!=NULL)
H5FL_ARR_FREE(H5HP_ent_t,new_heap->heap);
H5FL_SEQ_FREE(H5HP_ent_t,new_heap->heap);
H5FL_FREE(H5HP_t,new_heap);
} /* end if */
} /* end if */
@ -487,7 +487,7 @@ H5HP_insert(H5HP_t *heap, int val, void *obj)
/* Check if we need to allocate more room for heap array */
if(heap->nobjs>=heap->nalloc) {
size_t n = MAX(H5HP_START_SIZE, 2*(heap->nalloc-1)) + 1;
H5HP_ent_t *new_heap = H5FL_ARR_REALLOC(H5HP_ent_t,heap->heap, n);
H5HP_ent_t *new_heap = H5FL_SEQ_REALLOC(H5HP_ent_t,heap->heap, n);
if (!new_heap)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend heap array");
@ -924,7 +924,7 @@ H5HP_close(H5HP_t *heap)
assert(heap->heap[0].obj==NULL);
/* Free internal structures for heap */
H5FL_ARR_FREE(H5HP_ent_t,heap->heap);
H5FL_SEQ_FREE(H5HP_ent_t,heap->heap);
/* Free actual heap object */
H5FL_FREE(H5HP_t,heap);

View File

@ -140,13 +140,13 @@ static void *(*H5O_fast_g[H5G_NCACHED]) (const H5G_cache_t *,
/* Declare a free list to manage the H5O_t struct */
H5FL_DEFINE_STATIC(H5O_t);
/* Declare a PQ free list to manage the H5O_mesg_t array information */
H5FL_ARR_DEFINE_STATIC(H5O_mesg_t,-1);
/* Declare a free list to manage the H5O_mesg_t sequence information */
H5FL_SEQ_DEFINE_STATIC(H5O_mesg_t);
/* Declare a PQ free list to manage the H5O_chunk_t array information */
H5FL_ARR_DEFINE_STATIC(H5O_chunk_t,-1);
/* Declare a free list to manage the H5O_chunk_t sequence information */
H5FL_SEQ_DEFINE_STATIC(H5O_chunk_t);
/* Declare a PQ free list to manage the chunk image information */
/* Declare a free list to manage the chunk image information */
H5FL_BLK_DEFINE_STATIC(chunk_image);
/* Declare external the free list for time_t's */
@ -287,7 +287,7 @@ H5O_init(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/, had
oh->nchunks = 1;
oh->alloc_nchunks = H5O_NCHUNKS;
if (NULL == (oh->chunk = H5FL_ARR_MALLOC(H5O_chunk_t, oh->alloc_nchunks)))
if (NULL == (oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, oh->alloc_nchunks)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
tmp_addr = ent->header + (hsize_t)H5O_SIZEOF_HDR(f);
@ -302,7 +302,7 @@ H5O_init(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/, had
oh->nmesgs = 1;
oh->alloc_nmesgs = H5O_NMESGS;
if (NULL == (oh->mesg = H5FL_ARR_CALLOC(H5O_mesg_t, oh->alloc_nmesgs)))
if (NULL == (oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
oh->mesg[0].type = H5O_NULL;
@ -515,7 +515,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
/* build the message array */
oh->alloc_nmesgs = MAX(H5O_NMESGS, nmesgs);
if (NULL==(oh->mesg=H5FL_ARR_CALLOC(H5O_mesg_t,oh->alloc_nmesgs)))
if (NULL==(oh->mesg=H5FL_SEQ_CALLOC(H5O_mesg_t,oh->alloc_nmesgs)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* read each chunk from disk */
@ -523,7 +523,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
/* increase chunk array size */
if (oh->nchunks >= oh->alloc_nchunks) {
unsigned na = oh->alloc_nchunks + H5O_NCHUNKS;
H5O_chunk_t *x = H5FL_ARR_REALLOC (H5O_chunk_t, oh->chunk, na);
H5O_chunk_t *x = H5FL_SEQ_REALLOC (H5O_chunk_t, oh->chunk, na);
if (!x)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
@ -825,7 +825,7 @@ H5O_dest(H5F_t UNUSED *f, H5O_t *oh)
oh->chunk[i].image = H5FL_BLK_FREE(chunk_image,oh->chunk[i].image);
}
oh->chunk = H5FL_ARR_FREE(H5O_chunk_t,oh->chunk);
oh->chunk = H5FL_SEQ_FREE(H5O_chunk_t,oh->chunk);
/* destroy messages */
for (i = 0; i < oh->nmesgs; i++) {
@ -837,7 +837,7 @@ H5O_dest(H5F_t UNUSED *f, H5O_t *oh)
else
H5O_free_real(oh->mesg[i].type, oh->mesg[i].native);
}
oh->mesg = H5FL_ARR_FREE(H5O_mesg_t,oh->mesg);
oh->mesg = H5FL_SEQ_FREE(H5O_mesg_t,oh->mesg);
/* destroy object header */
H5FL_FREE(H5O_t,oh);
@ -2608,7 +2608,7 @@ H5O_alloc_extend_chunk(H5O_t *oh, unsigned chunkno, size_t size)
/* create a new null message */
if (oh->nmesgs >= oh->alloc_nmesgs) {
unsigned na = oh->alloc_nmesgs + H5O_NMESGS;
H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na);
H5O_mesg_t *x = H5FL_SEQ_REALLOC (H5O_mesg_t, oh->mesg, na);
if (NULL==x)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
@ -2750,7 +2750,7 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
*/
if (oh->nchunks >= oh->alloc_nchunks) {
unsigned na = oh->alloc_nchunks + H5O_NCHUNKS;
H5O_chunk_t *x = H5FL_ARR_REALLOC (H5O_chunk_t, oh->chunk, na);
H5O_chunk_t *x = H5FL_SEQ_REALLOC (H5O_chunk_t, oh->chunk, na);
if (!x)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
@ -2771,7 +2771,7 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
if (oh->nmesgs + 3 > oh->alloc_nmesgs) {
int old_alloc=oh->alloc_nmesgs;
unsigned na = oh->alloc_nmesgs + MAX (H5O_NMESGS, 3);
H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na);
H5O_mesg_t *x = H5FL_SEQ_REALLOC (H5O_mesg_t, oh->mesg, na);
if (!x)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
@ -2937,7 +2937,7 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
if (oh->nmesgs >= oh->alloc_nmesgs) {
int old_alloc=oh->alloc_nmesgs;
unsigned na = oh->alloc_nmesgs + H5O_NMESGS;
H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na);
H5O_mesg_t *x = H5FL_SEQ_REALLOC (H5O_mesg_t, oh->mesg, na);
if (!x)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");

View File

@ -60,7 +60,7 @@ H5FL_DEFINE(H5S_simple_t);
H5FL_DEFINE(H5S_t);
/* Declare a free list to manage the array's of hsize_t's */
H5FL_ARR_DEFINE(hsize_t,-1);
H5FL_ARR_DEFINE(hsize_t,H5S_MAX_RANK);
/* Declare a free list to manage the array's of hssize_t's */
H5FL_ARR_DEFINE(hssize_t,H5S_MAX_RANK);

View File

@ -44,12 +44,15 @@ static herr_t H5S_select_iter_next_block(H5S_sel_iter_t *iter);
/* Declare external the free list for hssize_t arrays */
H5FL_ARR_EXTERN(hssize_t);
/* Declare a free list to manage arrays of size_t */
H5FL_ARR_DEFINE_STATIC(size_t,-1);
/* Declare a free list to manage arrays of hsize_t */
/* Declare external the free list for hsize_t arrays */
H5FL_ARR_EXTERN(hsize_t);
/* Declare a free list to manage sequences of size_t */
H5FL_SEQ_DEFINE_STATIC(size_t);
/* Declare a free list to manage sequences of hsize_t */
H5FL_SEQ_DEFINE_STATIC(hsize_t);
/* Declare a free list to manage blocks of single datatype element data */
H5FL_BLK_EXTERN(type_elem);
@ -912,9 +915,9 @@ H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t
vector_size=H5D_XFER_HYPER_VECTOR_SIZE_DEF;
/* Allocate the vector I/O arrays */
if((len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL)
if((len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array");
if((off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL)
if((off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array");
/* Get the datatype size */
@ -998,9 +1001,9 @@ done:
/* Release length & offset vectors */
if(len!=NULL)
H5FL_ARR_FREE(size_t,len);
H5FL_SEQ_FREE(size_t,len);
if(off!=NULL)
H5FL_ARR_FREE(hsize_t,off);
H5FL_SEQ_FREE(hsize_t,off);
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5S_select_iterate() */
@ -1353,9 +1356,9 @@ H5S_select_fill(void *_fill, size_t fill_size, const H5S_t *space, void *_buf)
vector_size=H5D_XFER_HYPER_VECTOR_SIZE_DEF;
/* Allocate the vector I/O arrays */
if((len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL)
if((len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array");
if((off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL)
if((off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array");
/* Initialize iterator */
@ -1400,9 +1403,9 @@ done:
/* Release length & offset vectors */
if(len!=NULL)
H5FL_ARR_FREE(size_t,len);
H5FL_SEQ_FREE(size_t,len);
if(off!=NULL)
H5FL_ARR_FREE(hsize_t,off);
H5FL_SEQ_FREE(hsize_t,off);
/* Release fill value, if allocated */
if(_fill==NULL && fill)
@ -1467,9 +1470,9 @@ H5S_select_fscat (H5F_t *f, struct H5O_layout_t *layout,
vector_size=dxpl_cache->vec_size;
/* Allocate the vector I/O arrays */
if((len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL)
if((len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array");
if((off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL)
if((off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array");
/* Compute the number of bytes available in buffer */
@ -1500,9 +1503,9 @@ H5S_select_fscat (H5F_t *f, struct H5O_layout_t *layout,
done:
if(len!=NULL)
H5FL_ARR_FREE(size_t,len);
H5FL_SEQ_FREE(size_t,len);
if(off!=NULL)
H5FL_ARR_FREE(hsize_t,off);
H5FL_SEQ_FREE(hsize_t,off);
FUNC_LEAVE_NOAPI(ret_value);
} /* H5S_select_fscat() */
@ -1566,9 +1569,9 @@ H5S_select_fgath (H5F_t *f, const struct H5O_layout_t *layout,
vector_size=dxpl_cache->vec_size;
/* Allocate the vector I/O arrays */
if((len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL)
if((len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O length vector array");
if((off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL)
if((off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O offset vector array");
/* Compute the number of bytes available in buffer */
@ -1599,9 +1602,9 @@ H5S_select_fgath (H5F_t *f, const struct H5O_layout_t *layout,
done:
if(len!=NULL)
H5FL_ARR_FREE(size_t,len);
H5FL_SEQ_FREE(size_t,len);
if(off!=NULL)
H5FL_ARR_FREE(hsize_t,off);
H5FL_SEQ_FREE(hsize_t,off);
FUNC_LEAVE_NOAPI(ret_value);
} /* H5S_select_fgath() */
@ -1654,9 +1657,9 @@ H5S_select_mscat (const void *_tscat_buf, size_t elmt_size, const H5S_t *space,
vector_size=dxpl_cache->vec_size;
/* Allocate the vector I/O arrays */
if((len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL)
if((len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array");
if((off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL)
if((off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array");
/* Compute the number of bytes available in buffer */
@ -1686,9 +1689,9 @@ H5S_select_mscat (const void *_tscat_buf, size_t elmt_size, const H5S_t *space,
done:
if(len!=NULL)
H5FL_ARR_FREE(size_t,len);
H5FL_SEQ_FREE(size_t,len);
if(off!=NULL)
H5FL_ARR_FREE(hsize_t,off);
H5FL_SEQ_FREE(hsize_t,off);
FUNC_LEAVE_NOAPI(ret_value);
} /* H5S_select_mscat() */
@ -1743,9 +1746,9 @@ H5S_select_mgath (const void *_buf, size_t elmt_size, const H5S_t *space,
vector_size=dxpl_cache->vec_size;
/* Allocate the vector I/O arrays */
if((len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL)
if((len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O length vector array");
if((off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL)
if((off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O offset vector array");
/* Compute the number of bytes available in buffer */
@ -1775,9 +1778,9 @@ H5S_select_mgath (const void *_buf, size_t elmt_size, const H5S_t *space,
done:
if(len!=NULL)
H5FL_ARR_FREE(size_t,len);
H5FL_SEQ_FREE(size_t,len);
if(off!=NULL)
H5FL_ARR_FREE(hsize_t,off);
H5FL_SEQ_FREE(hsize_t,off);
FUNC_LEAVE_NOAPI(ret_value);
} /* H5S_select_mgath() */
@ -1843,13 +1846,13 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, const H5D_dcpl_cache_t *dc
vector_size=dxpl_cache->vec_size;
/* Allocate the vector I/O arrays */
if((mem_len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL)
if((mem_len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array");
if((mem_off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL)
if((mem_off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array");
if((file_len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL)
if((file_len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array");
if((file_off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL)
if((file_off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array");
/* Get number of bytes in selection */
@ -1920,13 +1923,13 @@ done:
/* Free vector arrays */
if(file_len!=NULL)
H5FL_ARR_FREE(size_t,file_len);
H5FL_SEQ_FREE(size_t,file_len);
if(file_off!=NULL)
H5FL_ARR_FREE(hsize_t,file_off);
H5FL_SEQ_FREE(hsize_t,file_off);
if(mem_len!=NULL)
H5FL_ARR_FREE(size_t,mem_len);
H5FL_SEQ_FREE(size_t,mem_len);
if(mem_off!=NULL)
H5FL_ARR_FREE(hsize_t,mem_off);
H5FL_SEQ_FREE(hsize_t,mem_off);
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5S_select_read() */
@ -1991,13 +1994,13 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_ca
vector_size=dxpl_cache->vec_size;
/* Allocate the vector I/O arrays */
if((mem_len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL)
if((mem_len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array");
if((mem_off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL)
if((mem_off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array");
if((file_len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL)
if((file_len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array");
if((file_off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL)
if((file_off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array");
/* Initialize file iterator */
@ -2111,13 +2114,13 @@ done:
/* Free vector arrays */
if(file_len!=NULL)
H5FL_ARR_FREE(size_t,file_len);
H5FL_SEQ_FREE(size_t,file_len);
if(file_off!=NULL)
H5FL_ARR_FREE(hsize_t,file_off);
H5FL_SEQ_FREE(hsize_t,file_off);
if(mem_len!=NULL)
H5FL_ARR_FREE(size_t,mem_len);
H5FL_SEQ_FREE(size_t,mem_len);
if(mem_off!=NULL)
H5FL_ARR_FREE(hsize_t,mem_off);
H5FL_SEQ_FREE(hsize_t,mem_off);
#ifdef QAK
{
int mpi_rank;