diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5FDlog.c | 19 | ||||
-rw-r--r-- | src/H5FDmulti.c | 3 | ||||
-rw-r--r-- | src/H5FDpublic.h | 2 | ||||
-rw-r--r-- | src/H5Faccum.c | 27 | ||||
-rw-r--r-- | src/H5MF.c | 20 | ||||
-rw-r--r-- | src/H5MFaggr.c | 93 |
6 files changed, 121 insertions, 43 deletions
diff --git a/src/H5FDlog.c b/src/H5FDlog.c index e3d67359..bd53658 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -1020,12 +1020,29 @@ H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) +H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) { H5FD_log_t *file = (H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR + if(file->fa.flags != 0) { + if(H5F_addr_gt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { + hsize_t size = addr - file->eoa; + + /* Retain the flavor of the space allocated by the extension */ + if(file->fa.flags & H5FD_LOG_FLAVOR) { + HDassert(addr < file->iosize); + H5_CHECK_OVERFLOW(size, hsize_t, size_t); + HDmemset(&file->flavor[file->eoa], (int)type, (size_t)size); + } /* end if */ + + /* Log the extension like an allocation */ + if(file->fa.flags & H5FD_LOG_ALLOC) + HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", file->eoa, addr, size, flavors[type]); + } /* end if */ + } /* end if */ + file->eoa = addr; FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 772384f..cdb874a 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -308,7 +308,8 @@ H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id, /* Initialize */ ALL_MEMBERS(mt) { - memb_map[mt] = (H5FD_MEM_DRAW==mt?mt:H5FD_MEM_SUPER); + /* Treat global heap as raw data, not metadata */ + memb_map[mt] = ((mt == H5FD_MEM_DRAW || mt == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : H5FD_MEM_SUPER); memb_fapl[mt] = -1; memb_name[mt] = NULL; memb_addr[mt] = HADDR_UNDEF; diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 0c5605c..b70af68 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -100,7 +100,7 @@ typedef enum H5F_mem_t H5FD_mem_t; H5FD_MEM_SUPER, /*super*/ \ H5FD_MEM_SUPER, /*btree*/ \ H5FD_MEM_DRAW, /*draw*/ \ - H5FD_MEM_SUPER, /*gheap*/ \ + H5FD_MEM_DRAW, /*gheap*/ \ H5FD_MEM_SUPER, /*lheap*/ \ H5FD_MEM_SUPER /*ohdr*/ \ } diff --git a/src/H5Faccum.c b/src/H5Faccum.c index 1c2abd9..032bd80 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -115,6 +115,7 @@ herr_t H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/) { + H5FD_mem_t map_type; /* Mapped memory type */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -123,8 +124,11 @@ H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, HDassert(f->shared); HDassert(buf); + /* Treat global heap as raw data */ + map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type; + /* Check if this information is in the metadata accumulator */ - if((f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && type != H5FD_MEM_DRAW) { + if((f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { if(size < H5F_ACCUM_MAX_SIZE) { /* Sanity check */ HDassert(!f->shared->accum.buf || (f->shared->accum.alloc_size >= f->shared->accum.size)); @@ -173,7 +177,7 @@ H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, f->shared->accum.dirty_off += amount_before; /* Dispatch to driver */ - if(H5FD_read(f->shared->lf, dxpl_id, type, addr, amount_before, f->shared->accum.buf) < 0) + if(H5FD_read(f->shared->lf, dxpl_id, map_type, addr, amount_before, f->shared->accum.buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end if */ else @@ -187,7 +191,7 @@ H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, H5_ASSIGN_OVERFLOW(amount_after, ((addr + size) - (f->shared->accum.loc + f->shared->accum.size)), hsize_t, size_t); /* Dispatch to driver */ - if(H5FD_read(f->shared->lf, dxpl_id, type, (f->shared->accum.loc + f->shared->accum.size), amount_after, (f->shared->accum.buf + f->shared->accum.size + amount_before)) < 0) + if(H5FD_read(f->shared->lf, dxpl_id, map_type, (f->shared->accum.loc + f->shared->accum.size), amount_after, (f->shared->accum.buf + f->shared->accum.size + amount_before)) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end if */ @@ -201,13 +205,13 @@ H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, /* Current read doesn't overlap with metadata accumulator, read it from file */ else { /* Dispatch to driver */ - if(H5FD_read(f->shared->lf, dxpl_id, type, addr, size, buf) < 0) + if(H5FD_read(f->shared->lf, dxpl_id, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end else */ } /* end if */ else { /* Read the data */ - if(H5FD_read(f->shared->lf, dxpl_id, type, addr, size, buf) < 0) + if(H5FD_read(f->shared->lf, dxpl_id, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") /* Check for overlap w/dirty accumulator */ @@ -250,7 +254,7 @@ H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, } /* end if */ else { /* Read the data */ - if(H5FD_read(f->shared->lf, dxpl_id, type, addr, size, buf) < 0) + if(H5FD_read(f->shared->lf, dxpl_id, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end else */ @@ -415,6 +419,7 @@ herr_t H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) { + H5FD_mem_t map_type; /* Mapped memory type */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -424,8 +429,11 @@ H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, HDassert(f->intent & H5F_ACC_RDWR); HDassert(buf); + /* Treat global heap as raw data */ + map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type; + /* Check for accumulating metadata */ - if((f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && type != H5FD_MEM_DRAW) { + if((f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { if(size < H5F_ACCUM_MAX_SIZE) { /* Sanity check */ HDassert(!f->shared->accum.buf || (f->shared->accum.alloc_size >= f->shared->accum.size)); @@ -719,7 +727,7 @@ HDmemset(f->shared->accum.buf + size, 0, (f->shared->accum.alloc_size - size)); } /* end if */ else { /* Write the data */ - if(H5FD_write(f->shared->lf, dxpl_id, type, addr, size, buf) < 0) + if(H5FD_write(f->shared->lf, dxpl_id, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Check for overlap w/accumulator */ @@ -804,7 +812,7 @@ HDmemset(f->shared->accum.buf + size, 0, (f->shared->accum.alloc_size - size)); } /* end if */ else { /* Write the data */ - if(H5FD_write(f->shared->lf, dxpl_id, type, addr, size, buf) < 0) + if(H5FD_write(f->shared->lf, dxpl_id, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end else */ @@ -846,6 +854,7 @@ H5F_accum_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t UNUSED type, haddr_t addr, /* Sanity check */ /* (The metadata accumulator should not intersect w/raw data */ HDassert(H5FD_MEM_DRAW != type); + HDassert(H5FD_MEM_GHEAP != type); /* (global heap data is being treated as raw data currently) */ /* Check for overlapping the beginning of the accumulator */ if(H5F_addr_le(addr, f->shared->accum.loc)) { @@ -153,7 +153,8 @@ H5MF_init_merge_flags(H5F_t *f) all_metadata_same = TRUE; for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) /* Skip checking raw data free list mapping */ - if(type != H5FD_MEM_DRAW) { + /* (global heap is treated as raw data) */ + if(type != H5FD_MEM_DRAW && type != H5FD_MEM_GHEAP) { /* Check for any different type mappings */ if(f->shared->fs_type_map[type] != f->shared->fs_type_map[H5FD_MEM_SUPER]) { all_metadata_same = FALSE; @@ -176,9 +177,12 @@ H5MF_init_merge_flags(H5F_t *f) HDmemset(f->shared->fs_aggr_merge, 0, sizeof(f->shared->fs_aggr_merge)); /* Check if merging raw data should be allowed */ + /* (treat global heaps as raw data) */ if(H5FD_MEM_DRAW == f->shared->fs_type_map[H5FD_MEM_DRAW] || - H5FD_MEM_DEFAULT == f->shared->fs_type_map[H5FD_MEM_DRAW]) + H5FD_MEM_DEFAULT == f->shared->fs_type_map[H5FD_MEM_DRAW]) { f->shared->fs_aggr_merge[H5FD_MEM_DRAW] = H5F_FS_MERGE_RAWDATA; + f->shared->fs_aggr_merge[H5FD_MEM_GHEAP] = H5F_FS_MERGE_RAWDATA; + } /* end if */ break; case H5MF_AGGR_MERGE_DICHOTOMY: @@ -186,7 +190,9 @@ H5MF_init_merge_flags(H5F_t *f) HDmemset(f->shared->fs_aggr_merge, H5F_FS_MERGE_METADATA, sizeof(f->shared->fs_aggr_merge)); /* Allow merging raw data allocations together */ + /* (treat global heaps as raw data) */ f->shared->fs_aggr_merge[H5FD_MEM_DRAW] = H5F_FS_MERGE_RAWDATA; + f->shared->fs_aggr_merge[H5FD_MEM_GHEAP] = H5F_FS_MERGE_RAWDATA; break; case H5MF_AGGR_MERGE_TOGETHER: @@ -717,6 +723,7 @@ H5MF_try_extend(H5F_t *f, hid_t dxpl_id, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, hsize_t extra_requested) { haddr_t end; /* End of block to extend */ + H5FD_mem_t map_type; /* Mapped type */ htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -728,18 +735,21 @@ HDfprintf(stderr, "%s: Entering: alloc_type = %u, addr = %a, size = %Hu, extra_r HDassert(f); HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); + /* Set mapped type, treating global heap as raw data */ + map_type = (alloc_type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : alloc_type; + /* Compute end of block to extend */ end = addr + size; /* Check if the block is exactly at the end of the file */ - if((ret_value = H5FD_try_extend(f->shared->lf, alloc_type, f, end, extra_requested)) < 0) + if((ret_value = H5FD_try_extend(f->shared->lf, map_type, f, end, extra_requested)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") else if(ret_value == FALSE) { H5F_blk_aggr_t *aggr; /* Aggregator to use */ /* Check for test block able to extend aggregation block */ - aggr = (alloc_type == H5FD_MEM_DRAW) ? &(f->shared->sdata_aggr) : &(f->shared->meta_aggr); - if((ret_value = H5MF_aggr_try_extend(f, aggr, alloc_type, end, extra_requested)) < 0) + aggr = (map_type == H5FD_MEM_DRAW) ? &(f->shared->sdata_aggr) : &(f->shared->meta_aggr); + if((ret_value = H5MF_aggr_try_extend(f, aggr, map_type, end, extra_requested)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending aggregation block") else if(ret_value == FALSE) { H5FD_mem_t fs_type; /* Free space type (mapped from allocation type) */ diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index 8a25c8c..ad91e45 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -46,6 +46,7 @@ /******************/ /* Local Typedefs */ /******************/ +#define EXTEND_THRESHOLD .10 /********************/ @@ -108,14 +109,14 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ HDassert(size > 0); /* Couldn't find anything from the free space manager, go allocate some */ - if(alloc_type != H5FD_MEM_DRAW) { + if(alloc_type != H5FD_MEM_DRAW && alloc_type != H5FD_MEM_GHEAP) { /* Handle metadata differently from "raw" data */ if(HADDR_UNDEF == (ret_value = H5MF_aggr_alloc(f, dxpl_id, &(f->shared->meta_aggr), &(f->shared->sdata_aggr), alloc_type, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate metadata") } /* end if */ else { - /* Allocate "raw" data */ - if(HADDR_UNDEF == (ret_value = H5MF_aggr_alloc(f, dxpl_id, &(f->shared->sdata_aggr), &(f->shared->meta_aggr), alloc_type, size))) + /* Allocate "raw" data: H5FD_MEM_DRAW and H5FD_MEM_GHEAP */ + if(HADDR_UNDEF == (ret_value = H5MF_aggr_alloc(f, dxpl_id, &(f->shared->sdata_aggr), &(f->shared->meta_aggr), H5FD_MEM_DRAW, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate raw data") } /* end else */ @@ -242,7 +243,7 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz } /* end if */ /* Allocate space from the VFD (i.e. at the end of the file) */ - if(HADDR_UNDEF == (ret_value = H5FD_alloc(f->shared->lf, dxpl_id, type, f, size, &eoa_frag_addr, &eoa_frag_size))) + if(HADDR_UNDEF == (ret_value = H5FD_alloc(f->shared->lf, dxpl_id, alloc_type, f, size, &eoa_frag_addr, &eoa_frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate aggregation block") } /* end else */ } /* end if */ @@ -307,12 +308,12 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); /* Freeing any possible fragment due to file allocation */ if(eoa_frag_size) - if(H5MF_xfree(f, type, dxpl_id, eoa_frag_addr, eoa_frag_size) < 0) + if(H5MF_xfree(f, alloc_type, dxpl_id, eoa_frag_addr, eoa_frag_size) < 0) 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 && aggr_frag_size) - if(H5MF_xfree(f, type, dxpl_id, aggr_frag_addr, aggr_frag_size) < 0) + if(H5MF_xfree(f, alloc_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 { @@ -323,7 +324,7 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); /* free any possible fragment */ if(aggr_frag_size) - if(H5MF_xfree(f, type, dxpl_id, aggr_frag_addr, aggr_frag_size) < 0) + if(H5MF_xfree(f, alloc_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 */ @@ -364,6 +365,16 @@ HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); * Purpose: Check if a block is inside an aggregator block and extend it * if possible. * + * Note: + * When the block to be extended adjoins the aggregator-- + * 1) When the aggregator is at end of file: + * A) If the request is below the threshold, extend the block into the aggregator + * B) If the request is above the threshold, + * a) extend the aggregator by aggr->alloc_size or the extended amount + * b) extend the block into the aggregator + * 2) When the aggregator is not at end of file: + * Extended the block into the aggregator if it has enough space to satisfy the request + * * Return: Success: TRUE(1) - Block was extended * FALSE(0) - Block could not be extended * Failure: FAIL @@ -388,26 +399,56 @@ H5MF_aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, H5FD_mem_t type, /* Check if this aggregator is active */ if(f->shared->feature_flags & aggr->feature_flag) { - /* If the block being tested adjoins the beginning of the aggregator + /* + * If the block being tested adjoins the beginning of the aggregator * block, check if the aggregator can accomodate the extension. */ if(H5F_addr_eq(blk_end, aggr->addr)) { - /* If the aggregator block is at the end of the file, extend the - * file and "bubble" the aggregator up - */ - if((ret_value = H5FD_try_extend(f->shared->lf, type, f, (aggr->addr + aggr->size), extra_requested)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") - else if(ret_value == TRUE) { - /* Shift the aggregator block by the extra requested */ - aggr->addr += extra_requested; - - /* Add extra requested to the aggregator block's total amount allocated */ - aggr->tot_size += extra_requested; - } /* end if */ - else { - /* Check if the aggregator block has enough internal space to satisfy - * extending the block. - */ + haddr_t eoa; /* EOA for the file */ + + /* Get the EOA for the file */ + if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") + + /* If the aggregator is at the end of file: */ + if(H5F_addr_eq(eoa, aggr->addr + aggr->size)) { + /* If extra_requested is below percentage threshold, extend block into the aggregator. */ + if(extra_requested <= (EXTEND_THRESHOLD * aggr->size)) { + aggr->size -= extra_requested; + aggr->addr += extra_requested; + + /* Indicate success */ + HGOTO_DONE(TRUE); + } + /* + * If extra_requested is above percentage threshold: + * 1) "bubble" up the aggregator by aggr->alloc_size or extra_requested + * 2) extend the block into the aggregator + */ + else { + hsize_t extra = (extra_requested < aggr->alloc_size) ? aggr->alloc_size : extra_requested; + + if((ret_value = H5FD_try_extend(f->shared->lf, type, f, (aggr->addr + aggr->size), extra)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") + else if(ret_value == TRUE) { + /* Shift the aggregator block by the extra requested */ + /* (allocates the space for the extra_requested) */ + aggr->addr += extra_requested; + + /* Add extra to the aggregator's total allocated amount */ + aggr->tot_size += extra; + + /* Account for any space added to the aggregator */ + /* (either 0 (if extra_requested > aggr->alloc_size) or + * (aggr->alloc_size - extra_requested) -QAK + */ + aggr->size += extra; + aggr->size -= extra_requested; + } /* end if */ + } /* end if */ + } /* end if */ + else { /* The aggreator is not at end of file */ + /* Check if aggregator has enough internal space to satisfy the extension. */ if(aggr->size >= extra_requested) { /* Extend block into aggregator */ aggr->size -= extra_requested; @@ -416,8 +457,8 @@ H5MF_aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, H5FD_mem_t type, /* Indicate success */ HGOTO_DONE(TRUE); } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ } /* end if */ done: |