summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2000-11-16 17:32:46 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2000-11-16 17:32:46 (GMT)
commit4fe7973b5c7e444179fa45fc56a864d8e838f048 (patch)
tree2cd7f8459a9c8b30355dc816043cab43f257acf6
parenteddfdc1274cc129b2d8b65eeecd8c7c3273244b6 (diff)
downloadhdf5-4fe7973b5c7e444179fa45fc56a864d8e838f048.zip
hdf5-4fe7973b5c7e444179fa45fc56a864d8e838f048.tar.gz
hdf5-4fe7973b5c7e444179fa45fc56a864d8e838f048.tar.bz2
[svn-r2947] Purpose:
Code optimization Description: Re-vamped FUNC_ENTER macro to remove as many of the if's as possible and also to only check once if any given function is an API function. This improves the performance of the hyperslab I/O benchmark (h5hypers) that I've been testing with by another 5%. All library functions should be 5-15% faster, depending on how many times they are called and what percentage of the function's time was spent in the FUNC_ENTER macro vs. the percentage of time in the main body of the function. Platforms tested: Solaris 2.6 (baldric)
-rw-r--r--src/H5private.h56
1 files changed, 32 insertions, 24 deletions
diff --git a/src/H5private.h b/src/H5private.h
index 399391d..3a30680 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -944,36 +944,44 @@ extern hbool_t H5_libinit_g; /*good thing C's lazy about extern! */
#define FUNC_ENTER_INIT(func_name,interface_init_func,err) { \
CONSTR (FUNC, #func_name); \
PABLO_SAVE (ID_ ## func_name) \
+ static unsigned know_api=0, is_api=0; \
H5TRACE_DECL; \
\
PABLO_TRACE_ON (PABLO_MASK, pablo_func_id); \
\
- /* Initialize the library */ \
- H5_FIRST_THREAD_INIT \
- H5_API_UNSET_CANCEL \
- H5_API_LOCK_BEGIN \
- if (!(H5_INIT_GLOBAL)) { \
- H5_INIT_GLOBAL = TRUE; \
- if (H5_init_library()<0) { \
- HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
- "library initialization failed"); \
- } \
- } \
- H5_API_LOCK_END \
- \
- /* Initialize this interface or bust */ \
- if (!interface_initialize_g) { \
- interface_initialize_g = 1; \
- if (interface_init_func && \
- ((herr_t(*)(void))interface_init_func)()<0) { \
- interface_initialize_g = 0; \
- HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
- "interface initialization failed"); \
- } \
- } \
+ /* Check if we know this is an API function or not */ \
+ /* (Also useful for wrapping the global and library checks) */ \
+ if(!know_api) { \
+ know_api=1; \
+ is_api=H5_IS_API(FUNC); \
\
+ /* Initialize the library */ \
+ H5_FIRST_THREAD_INIT \
+ H5_API_UNSET_CANCEL \
+ H5_API_LOCK_BEGIN \
+ if (!(H5_INIT_GLOBAL)) { \
+ H5_INIT_GLOBAL = TRUE; \
+ if (H5_init_library()<0) { \
+ HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
+ "library initialization failed"); \
+ } \
+ } \
+ H5_API_LOCK_END \
+ \
+ /* Initialize this interface or bust */ \
+ if (!interface_initialize_g) { \
+ interface_initialize_g = 1; \
+ if (interface_init_func && \
+ ((herr_t(*)(void))interface_init_func)()<0) { \
+ interface_initialize_g = 0; \
+ HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
+ "interface initialization failed"); \
+ } \
+ } \
+ } \
+ \
/* Clear thread error stack entering public functions */ \
- if (H5E_clearable_g && H5_IS_API (FUNC)) { \
+ if (is_api && H5E_clearable_g) { \
H5E_clear (); \
} \
{