diff options
-rwxr-xr-x | bin/trace | 1 | ||||
-rw-r--r-- | src/H5.c | 20 | ||||
-rw-r--r-- | src/H5MM.c | 53 | ||||
-rw-r--r-- | src/H5MMprivate.h | 4 | ||||
-rw-r--r-- | src/H5public.h | 17 | ||||
-rw-r--r-- | test/tmisc.c | 68 |
6 files changed, 64 insertions, 99 deletions
@@ -132,6 +132,7 @@ $Source = ""; "H5VL_blob_optional_t" => "VA", "void" => "x", "FILE" => "x", + "H5_alloc_stats_t" => "x", "H5A_operator_t" => "x", "H5A_operator1_t" => "x", "H5A_operator2_t" => "x", @@ -611,13 +611,7 @@ done: * filters or non-native VOL connectors. * * Parameters: - * unsigned long long *total_alloc_bytes; OUT: Running count of total # of bytes allocated - * size_t *curr_alloc_bytes; OUT: Current # of bytes allocated - * size_t *peak_alloc_bytes; OUT: Peak # of bytes allocated - * size_t *max_block_size; OUT: Largest block allocated - * size_t *total_alloc_blocks_count; OUT: Running count of total # of blocks allocated - * size_t *curr_alloc_blocks_count; OUT: Current # of blocks allocated - * size_t *peak_alloc_blocks_count; OUT: Peak # of blocks allocated + * H5_alloc_stats_t *stats; OUT: Memory allocation statistics * * Return: Success: non-negative * Failure: negative @@ -628,21 +622,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5get_alloc_stats(unsigned long long *total_alloc_bytes, size_t *curr_alloc_bytes, - size_t *peak_alloc_bytes, size_t *max_block_size, size_t *total_alloc_blocks_count, - size_t *curr_alloc_blocks_count, size_t *peak_alloc_blocks_count) +H5get_alloc_stats(H5_alloc_stats_t *stats) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "*UL*z*z*z*z*z*z", total_alloc_bytes, curr_alloc_bytes, - peak_alloc_bytes, max_block_size, total_alloc_blocks_count, - curr_alloc_blocks_count, peak_alloc_blocks_count); + H5TRACE1("e", "*x", stats); /* Call the internal allocation stat routine to get the values */ - if(H5MM_get_alloc_stats(total_alloc_bytes, curr_alloc_bytes, peak_alloc_bytes, - max_block_size, total_alloc_blocks_count, curr_alloc_blocks_count, - peak_alloc_blocks_count) < 0) + if(H5MM_get_alloc_stats(stats) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get allocation stats") done: @@ -635,13 +635,7 @@ H5MM_memcpy(void *dest, const void *src, size_t n) * entire library. * * Parameters: - * unsigned long long *total_alloc_bytes; OUT: Running count of total # of bytes allocated - * size_t *curr_alloc_bytes; OUT: Current # of bytes allocated - * size_t *peak_alloc_bytes; OUT: Peak # of bytes allocated - * size_t *max_block_size; OUT: Largest block allocated - * size_t *total_alloc_blocks_count; OUT: Running count of total # of blocks allocated - * size_t *curr_alloc_blocks_count; OUT: Current # of blocks allocated - * size_t *peak_alloc_blocks_count; OUT: Peak # of blocks allocated + * H5_alloc_stats_t *stats; OUT: Memory allocation statistics * * Return: Success: non-negative * Failure: negative @@ -652,44 +646,25 @@ H5MM_memcpy(void *dest, const void *src, size_t n) *------------------------------------------------------------------------- */ herr_t -H5MM_get_alloc_stats(unsigned long long *total_alloc_bytes, size_t *curr_alloc_bytes, - size_t *peak_alloc_bytes, size_t *max_block_size, size_t *total_alloc_blocks_count, - size_t *curr_alloc_blocks_count, size_t *peak_alloc_blocks_count) +H5MM_get_alloc_stats(H5_alloc_stats_t *stats) { FUNC_ENTER_NOAPI_NOERR #if defined H5_MEMORY_ALLOC_SANITY_CHECK - if(total_alloc_bytes) - *total_alloc_bytes = H5MM_total_alloc_bytes_s; - if(curr_alloc_bytes) - *curr_alloc_bytes = H5MM_curr_alloc_bytes_s; - if(peak_alloc_bytes) - *peak_alloc_bytes = H5MM_peak_alloc_bytes_s; - if(max_block_size) - *max_block_size = H5MM_max_block_size_s; - if(total_alloc_blocks_count) - *total_alloc_blocks_count = H5MM_total_alloc_blocks_count_s; - if(curr_alloc_blocks_count) - *curr_alloc_blocks_count = H5MM_curr_alloc_blocks_count_s; - if(peak_alloc_blocks_count) - *peak_alloc_blocks_count = H5MM_peak_alloc_blocks_count_s; + if(stats) { + stats->total_alloc_bytes = H5MM_total_alloc_bytes_s; + stats->curr_alloc_bytes = H5MM_curr_alloc_bytes_s; + stats->peak_alloc_bytes = H5MM_peak_alloc_bytes_s; + stats->max_block_size = H5MM_max_block_size_s; + stats->total_alloc_blocks_count = H5MM_total_alloc_blocks_count_s; + stats->curr_alloc_blocks_count = H5MM_curr_alloc_blocks_count_s; + stats->peak_alloc_blocks_count = H5MM_peak_alloc_blocks_count_s; + } /* end if */ #else /* H5_MEMORY_ALLOC_SANITY_CHECK */ - if(total_alloc_bytes) - *total_alloc_bytes = 0; - if(curr_alloc_bytes) - *curr_alloc_bytes = 0; - if(peak_alloc_bytes) - *peak_alloc_bytes = 0; - if(max_block_size) - *max_block_size = 0; - if(total_alloc_blocks_count) - *total_alloc_blocks_count = 0; - if(curr_alloc_blocks_count) - *curr_alloc_blocks_count = 0; - if(peak_alloc_blocks_count) - *peak_alloc_blocks_count = 0; + if(stats) + HDmemset(stats, 0, sizeof(H5_alloc_stats_t)); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5get_alloc_stats() */ +} /* end H5MM_get_alloc_stats() */ diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index 3bf8c49..0787eb2 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -47,9 +47,7 @@ H5_DLL char *H5MM_strdup(const char *s); H5_DLL void *H5MM_xfree(void *mem); H5_DLL void *H5MM_xfree_const(const void *mem); H5_DLL void *H5MM_memcpy(void *dest, const void *src, size_t n); -H5_DLL herr_t H5MM_get_alloc_stats(unsigned long long *total_alloc_bytes, size_t *curr_alloc_bytes, - size_t *peak_alloc_bytes, size_t *max_block_size, size_t *total_alloc_blocks_count, - size_t *curr_alloc_blocks_count, size_t *peak_alloc_blocks_count); +H5_DLL herr_t H5MM_get_alloc_stats(H5_alloc_stats_t *stats); #if defined H5_MEMORY_ALLOC_SANITY_CHECK H5_DLL void H5MM_sanity_check_all(void); H5_DLL void H5MM_final_sanity_check(void); diff --git a/src/H5public.h b/src/H5public.h index 60bad93..f592ab9 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -378,6 +378,19 @@ typedef struct H5O_token_t { uint8_t __data[H5O_MAX_TOKEN_SIZE]; } H5O_token_t; +/* + * Allocation statistics info struct + */ +typedef struct H5_alloc_stats_t { + unsigned long long total_alloc_bytes; /* Running count of total # of bytes allocated */ + size_t curr_alloc_bytes; /* Current # of bytes allocated */ + size_t peak_alloc_bytes; /* Peak # of bytes allocated */ + size_t max_block_size; /* Largest block allocated */ + size_t total_alloc_blocks_count; /* Running count of total # of blocks allocated */ + size_t curr_alloc_blocks_count; /* Current # of blocks allocated */ + size_t peak_alloc_blocks_count; /* Peak # of blocks allocated */ +} H5_alloc_stats_t; + /* Functions in H5.c */ H5_DLL herr_t H5open(void); H5_DLL herr_t H5close(void); @@ -388,9 +401,7 @@ H5_DLL herr_t H5set_free_list_limits (int reg_global_lim, int reg_list_lim, int blk_list_lim); H5_DLL herr_t H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, size_t *fac_size); -H5_DLL herr_t H5get_alloc_stats(unsigned long long *total_alloc_bytes, size_t *curr_alloc_bytes, - size_t *peak_alloc_bytes, size_t *max_block_size, size_t *total_alloc_blocks_count, - size_t *curr_alloc_blocks_count, size_t *peak_alloc_blocks_count); +H5_DLL herr_t H5get_alloc_stats(H5_alloc_stats_t *stats); H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum); H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum, diff --git a/test/tmisc.c b/test/tmisc.c index a555b3e..bd9ae53 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -5709,13 +5709,7 @@ test_misc35(void) size_t arr_size_final; /* Final amount of array memory allocated */ size_t blk_size_final; /* Final amount of block memory allocated */ size_t fac_size_final; /* Final amount of factory memory allocated */ - unsigned long long total_alloc_bytes; /* Running count of total # of bytes allocated */ - size_t curr_alloc_bytes; /* Current # of bytes allocated */ - size_t peak_alloc_bytes; /* Peak # of bytes allocated */ - size_t max_block_size; /* Largest block allocated */ - size_t total_alloc_blocks_count; /* Running count of total # of blocks allocated */ - size_t curr_alloc_blocks_count; /* Current # of blocks allocated */ - size_t peak_alloc_blocks_count; /* Peak # of blocks allocated */ + H5_alloc_stats_t alloc_stats; /* Memory stats */ herr_t ret; /* Return value */ /* Output message about test being performed */ @@ -5778,43 +5772,41 @@ test_misc35(void) ERROR("fac_size_final > fac_size_start"); /* Retrieve memory allocation statistics */ - ret = H5get_alloc_stats(&total_alloc_bytes, &curr_alloc_bytes, - &peak_alloc_bytes, &max_block_size, &total_alloc_blocks_count, - &curr_alloc_blocks_count, &peak_alloc_blocks_count); + ret = H5get_alloc_stats(&alloc_stats); CHECK(ret, FAIL, "H5get_alloc_stats"); #if defined H5_MEMORY_ALLOC_SANITY_CHECK /* All the values should be >0 */ - if(0 == total_alloc_bytes) - ERROR("total_alloc_bytes == 0"); - if(0 == curr_alloc_bytes) - ERROR("curr_alloc_bytes == 0"); - if(0 == peak_alloc_bytes) - ERROR("peak_alloc_bytes == 0"); - if(0 == max_block_size) - ERROR("max_block_size == 0"); - if(0 == total_alloc_blocks_count) - ERROR("total_alloc_blocks_count == 0"); - if(0 == curr_alloc_blocks_count) - ERROR("curr_alloc_blocks_count == 0"); - if(0 == peak_alloc_blocks_count) - ERROR("peak_alloc_blocks_count == 0"); + if(0 == alloc_stats.total_alloc_bytes) + ERROR("alloc_stats.total_alloc_bytes == 0"); + if(0 == alloc_stats.curr_alloc_bytes) + ERROR("alloc_stats.curr_alloc_bytes == 0"); + if(0 == alloc_stats.peak_alloc_bytes) + ERROR("alloc_stats.peak_alloc_bytes == 0"); + if(0 == alloc_stats.max_block_size) + ERROR("alloc_stats.max_block_size == 0"); + if(0 == alloc_stats.total_alloc_blocks_count) + ERROR("alloc_stats.total_alloc_blocks_count == 0"); + if(0 == alloc_stats.curr_alloc_blocks_count) + ERROR("alloc_stats.curr_alloc_blocks_count == 0"); + if(0 == alloc_stats.peak_alloc_blocks_count) + ERROR("alloc_stats.peak_alloc_blocks_count == 0"); #else /* H5_MEMORY_ALLOC_SANITY_CHECK */ /* All the values should be == 0 */ - if(0 != total_alloc_bytes) - ERROR("total_alloc_bytes != 0"); - if(0 != curr_alloc_bytes) - ERROR("curr_alloc_bytes != 0"); - if(0 != peak_alloc_bytes) - ERROR("peak_alloc_bytes != 0"); - if(0 != max_block_size) - ERROR("max_block_size != 0"); - if(0 != total_alloc_blocks_count) - ERROR("total_alloc_blocks_count != 0"); - if(0 != curr_alloc_blocks_count) - ERROR("curr_alloc_blocks_count != 0"); - if(0 != peak_alloc_blocks_count) - ERROR("peak_alloc_blocks_count != 0"); + if(0 != alloc_stats.total_alloc_bytes) + ERROR("alloc_stats.total_alloc_bytes != 0"); + if(0 != alloc_stats.curr_alloc_bytes) + ERROR("alloc_stats.curr_alloc_bytes != 0"); + if(0 != alloc_stats.peak_alloc_bytes) + ERROR("alloc_stats.peak_alloc_bytes != 0"); + if(0 != alloc_stats.max_block_size) + ERROR("alloc_stats.max_block_size != 0"); + if(0 != alloc_stats.total_alloc_blocks_count) + ERROR("alloc_stats.total_alloc_blocks_count != 0"); + if(0 != alloc_stats.curr_alloc_blocks_count) + ERROR("alloc_stats.curr_alloc_blocks_count != 0"); + if(0 != alloc_stats.peak_alloc_blocks_count) + ERROR("alloc_stats.peak_alloc_blocks_count != 0"); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ } /* end test_misc35() */ |