summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-09-11 12:19:45 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-09-11 12:19:45 (GMT)
commitf41b8ab87bfc9702f12a3df10911960731556bed (patch)
treeb5ceafd5da2e0c1ef9ac09fcd0b0929e97e7cb62 /src
parentf4d4d427b2f8bae72a12d4cdbee6acfc233b4c44 (diff)
downloadhdf5-f41b8ab87bfc9702f12a3df10911960731556bed.zip
hdf5-f41b8ab87bfc9702f12a3df10911960731556bed.tar.gz
hdf5-f41b8ab87bfc9702f12a3df10911960731556bed.tar.bz2
[svn-r17463] Description:
Add another regression test for userblock+alignment usage, and correct [another] issue with the combination. *sigh* Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.8 (amazon) in debug mode Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src')
-rw-r--r--src/H5FDspace.c7
-rw-r--r--src/H5MFaggr.c58
2 files changed, 39 insertions, 26 deletions
diff --git a/src/H5FDspace.c b/src/H5FDspace.c
index 19f9281..9895938 100644
--- a/src/H5FDspace.c
+++ b/src/H5FDspace.c
@@ -126,6 +126,7 @@ H5FD_space_init_interface(void)
static haddr_t
H5FD_extend(H5FD_t *file, H5FD_mem_t type, hbool_t new_block, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size)
{
+ hsize_t orig_size = size; /* Original allocation size */
haddr_t eoa; /* Address of end-of-allocated space */
hsize_t extra; /* Extra space to allocate, to align request */
haddr_t ret_value; /* Return value */
@@ -143,7 +144,7 @@ H5FD_extend(H5FD_t *file, H5FD_mem_t type, hbool_t new_block, hsize_t size, hadd
/* Compute extra space to allocate, if this is a new block and should be aligned */
extra = 0;
- if(new_block && file->alignment > 1 && size >= file->threshold) {
+ if(new_block && file->alignment > 1 && orig_size >= file->threshold) {
hsize_t mis_align; /* Amount EOA is misaligned */
/* Check for EOA already aligned */
@@ -171,6 +172,10 @@ H5FD_extend(H5FD_t *file, H5FD_mem_t type, hbool_t new_block, hsize_t size, hadd
if(file->cls->set_eoa(file, type, eoa) < 0)
HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed")
+ /* Post-condition sanity check */
+ if(new_block && file->alignment && orig_size >= file->threshold)
+ HDassert(!(ret_value % file->alignment));
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_extend() */
diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c
index 1435d18..aa982da 100644
--- a/src/H5MFaggr.c
+++ b/src/H5MFaggr.c
@@ -152,11 +152,9 @@ haddr_t
H5MF_aggr_alloc(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr,
H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, hsize_t size)
{
- hsize_t alignment = 0, mis_align = 0;
- haddr_t frag_addr = 0, eoa_frag_addr = 0;
- hsize_t frag_size = 0, eoa_frag_size = 0;
- haddr_t eoa = 0; /* Initial EOA for the file */
- H5FD_mem_t alloc_type, other_alloc_type;
+ haddr_t eoa_frag_addr = HADDR_UNDEF; /* Address of fragment at EOA */
+ hsize_t eoa_frag_size = 0; /* Size of fragment at EOA */
+ haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */
haddr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5MF_aggr_alloc, HADDR_UNDEF)
@@ -174,6 +172,7 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size);
HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES);
HDassert(size > 0);
+ /* Get the EOA for the file */
if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type)))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa")
@@ -183,29 +182,37 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size);
* through H5FD_alloc()
*/
if(f->shared->feature_flags & aggr->feature_flag) {
+ haddr_t aggr_frag_addr = HADDR_UNDEF; /* Address of aggregrator fragment */
+ hsize_t aggr_frag_size = 0; /* Size of aggregator fragment */
+ hsize_t alignment; /* Alignment of this section */
+ hsize_t aggr_mis_align = 0; /* Mis-alignment of aggregator */
+ H5FD_mem_t alloc_type, other_alloc_type;/* Current aggregator & 'other' aggregator types */
+
#ifdef H5MF_AGGR_DEBUG
HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_size, aggr->size);
#endif /* H5MF_AGGR_DEBUG */
+ /* Turn off alignment if allocation < threshold */
alignment = f->shared->alignment;
if(!((alignment > 1) && (size >= f->shared->threshold)))
alignment = 0; /* no alignment */
- if(alignment && aggr->addr > 0 && aggr->size > 0 && (mis_align = aggr->addr % alignment)) {
- frag_addr = aggr->addr;
- frag_size = alignment - mis_align;
+ /* Generate fragment if aggregator is mis-aligned */
+ if(alignment && aggr->addr > 0 && aggr->size > 0 && (aggr_mis_align = (aggr->addr + H5FD_get_base_addr(f->shared->lf)) % alignment)) {
+ aggr_frag_addr = aggr->addr;
+ aggr_frag_size = alignment - aggr_mis_align;
} /* end if */
alloc_type = aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW;
other_alloc_type = other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW;
/* Check if the space requested is larger than the space left in the block */
- if((size + frag_size) > aggr->size) {
+ if((size + aggr_frag_size) > aggr->size) {
htri_t extended = FALSE; /* Whether the file was extended */
/* Check if the block asked for is too large for 'normal' aggregator block */
if(size >= aggr->alloc_size) {
- hsize_t ext_size = size + frag_size;
+ hsize_t ext_size = size + aggr_frag_size;
/* Check for overlapping into file's temporary allocation space */
if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr))
@@ -215,7 +222,7 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space")
else if (extended) {
/* aggr->size is unchanged */
- ret_value = aggr->addr + frag_size;
+ ret_value = aggr->addr + aggr_frag_size;
aggr->addr += ext_size;
aggr->tot_size += ext_size;
} else {
@@ -247,8 +254,8 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz
HDfprintf(stderr, "%s: Allocating block\n", FUNC);
#endif /* H5MF_AGGR_DEBUG */
- if(frag_size > (ext_size - size))
- ext_size += (frag_size - (ext_size - size));
+ if(aggr_frag_size > (ext_size - size))
+ ext_size += (aggr_frag_size - (ext_size - size));
/* Check for overlapping into file's temporary allocation space */
if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr))
@@ -257,8 +264,8 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC);
if((aggr->addr > 0) && (extended = H5FD_try_extend(f->shared->lf, alloc_type, f, aggr->addr + aggr->size, ext_size)) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space")
else if (extended) {
- aggr->addr += frag_size;
- aggr->size += (ext_size - frag_size);
+ aggr->addr += aggr_frag_size;
+ aggr->size += (ext_size - aggr_frag_size);
aggr->tot_size += ext_size;
} else {
haddr_t new_space; /* Address of new space allocated */
@@ -304,19 +311,19 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC);
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment")
/* Freeing any possible fragment due to alignment in the block after extension */
- if(extended && frag_size)
- if(H5MF_xfree(f, type, dxpl_id, frag_addr, frag_size) < 0)
+ if(extended && aggr_frag_size)
+ if(H5MF_xfree(f, type, dxpl_id, aggr_frag_addr, aggr_frag_size) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment")
} /* end if */
else {
/* Allocate space out of the block */
- ret_value = aggr->addr + frag_size;
- aggr->size -= (size + frag_size);
- aggr->addr += (size + frag_size);
+ ret_value = aggr->addr + aggr_frag_size;
+ aggr->size -= (size + aggr_frag_size);
+ aggr->addr += (size + aggr_frag_size);
/* free any possible fragment */
- if (frag_size)
- if(H5MF_xfree(f, type, dxpl_id, frag_addr, frag_size) < 0)
+ if(aggr_frag_size)
+ if(H5MF_xfree(f, type, dxpl_id, aggr_frag_addr, aggr_frag_size) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment")
} /* end else */
} /* end if */
@@ -339,13 +346,14 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC);
/* Sanity check for overlapping into file's temporary allocation space */
HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr));
+ /* Post-condition sanity check */
+ if(f->shared->alignment && size >= f->shared->threshold)
+ HDassert(!((ret_value + H5FD_get_base_addr(f->shared->lf)) % f->shared->alignment));
+
done:
#ifdef H5MF_AGGR_DEBUG
HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value);
#endif /* H5MF_AGGR_DEBUG */
-
- if(alignment)
- HDassert(!(ret_value % alignment));
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5MF_aggr_alloc() */