summaryrefslogtreecommitdiffstats
path: root/test/dtypes.c
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2020-02-06 17:00:10 (GMT)
committerDavid Young <dyoung@hdfgroup.org>2020-05-20 14:31:54 (GMT)
commitb00d843c2d0e3b0303ccd69a6ca03a33f03ae2f9 (patch)
treeaf4d637043d0651423d51568ae63d807039c220d /test/dtypes.c
parent17f8b2913b81f0ba504d6cde0c6733b160bb11db (diff)
downloadhdf5-b00d843c2d0e3b0303ccd69a6ca03a33f03ae2f9.zip
hdf5-b00d843c2d0e3b0303ccd69a6ca03a33f03ae2f9.tar.gz
hdf5-b00d843c2d0e3b0303ccd69a6ca03a33f03ae2f9.tar.bz2
Make calls through a function pointer. Use the same number of arguments,
always.
Diffstat (limited to 'test/dtypes.c')
-rw-r--r--test/dtypes.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/test/dtypes.c b/test/dtypes.c
index 6e3c070..060d227 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();