summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2020-02-06 17:00:10 (GMT)
committerDavid Young <dyoung@hdfgroup.org>2020-02-06 17:00:10 (GMT)
commita5a9e75f6a0ebf6f67509a740d9235366b7de046 (patch)
tree5dbd08b5978bab5d409ab42426dab61a2cba7417
parent69a064eef8aeeba0090ccbe0914348daced513ff (diff)
downloadhdf5-a5a9e75f6a0ebf6f67509a740d9235366b7de046.zip
hdf5-a5a9e75f6a0ebf6f67509a740d9235366b7de046.tar.gz
hdf5-a5a9e75f6a0ebf6f67509a740d9235366b7de046.tar.bz2
Make calls through a function pointer. Use the same number of arguments,
always.
-rw-r--r--test/dtypes.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/test/dtypes.c b/test/dtypes.c
index a12d204..a58edf1 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -7816,17 +7816,17 @@ error:
} /* end test_versionbounds() */
herr_t no_operation(H5T_t *t, int mode);
-herr_t H5T__forward_args_with_func_overhead(H5T_t *t);
-herr_t H5T__forward_args_without_func_overhead(H5T_t *t);
+herr_t H5T__forward_args_with_func_overhead(H5T_t *t, int);
+herr_t H5T__forward_args_without_func_overhead(H5T_t *t, int);
herr_t __attribute__((noinline))
-H5T__forward_args_with_func_overhead(H5T_t *t)
+H5T__forward_args_with_func_overhead(H5T_t *t, int mode)
{
herr_t ret_value = FAIL;
FUNC_ENTER_STATIC
- if ((ret_value = no_operation(t, 10)) == FAIL)
+ if ((ret_value = no_operation(t, mode)) == FAIL)
HGOTO_ERROR(17, 31, FAIL, "that didn't work");
done:
@@ -7834,9 +7834,9 @@ done:
}
herr_t __attribute__((noinline))
-H5T__forward_args_without_func_overhead(H5T_t *t)
+H5T__forward_args_without_func_overhead(H5T_t *t, int mode)
{
- return no_operation(t, 10);
+ return no_operation(t, mode);
}
/*-------------------------------------------------------------------------
@@ -7863,6 +7863,8 @@ main(void)
H5T_t *t;
int i, ntimes = 100 * 1000 * 1000;
uint64_t start, stop;
+ typedef herr_t (*fn_t)(H5T_t *, int);
+ volatile fn_t fn = no_operation;
/* Set the random # seed */
HDsrandom((unsigned)HDtime(NULL));
@@ -7876,26 +7878,32 @@ main(void)
t = (H5T_t *)H5I_object(H5T_NATIVE_SHORT);
if (t == NULL) abort();
+ fn = no_operation;
start = __builtin_ia32_rdtsc();
- for (i = 0; i < ntimes; i++)
- no_operation(t, 10);
+ for (i = 0; i < ntimes; i++) {
+ (*fn)(t, 10);
+ }
stop = __builtin_ia32_rdtsc();
- printf("%d calls to no-op routine, %" PRIu64 " cycles\n",
- ntimes, stop - start);
+ printf("%d calls to %11s routine, %" PRIu64 " cycles\n",
+ ntimes, "no-op", stop - start);
+ fn = H5T__forward_args_without_func_overhead;
start = __builtin_ia32_rdtsc();
- for (i = 0; i < ntimes; i++)
- H5T__forward_args_without_func_overhead(t);
+ for (i = 0; i < ntimes; i++) {
+ (*fn)(t, 10);
+ }
stop = __builtin_ia32_rdtsc();
- printf("%d calls to no-overhead version, %" PRIu64 " cycles\n",
- ntimes, stop - start);
+ printf("%d calls to %11s version, %" PRIu64 " cycles\n",
+ ntimes, "no-overhead", stop - start);
+ fn = H5T__forward_args_with_func_overhead;
start = __builtin_ia32_rdtsc();
- for (i = 0; i < ntimes; i++)
- H5T__forward_args_with_func_overhead(t);
+ for (i = 0; i < ntimes; i++) {
+ (*fn)(t, 10);
+ }
stop = __builtin_ia32_rdtsc();
- printf("%d calls to overhead version, %" PRIu64 " cycles\n",
- ntimes, stop - start);
+ printf("%d calls to %11s version, %" PRIu64 " cycles\n",
+ ntimes, "overhead", stop - start);
/* Do the tests */
nerrors += test_classes();