Commit Graph

124 Commits

Author SHA1 Message Date
Joseph Myers 8540f6d2a7 Don't require test wrappers to preserve environment variables, use more consistent environment.
One wart in the original support for test wrappers for cross testing,
as noted in
<https://sourceware.org/ml/libc-alpha/2012-10/msg00722.html>, is the
requirement for test wrappers to pass a poorly-defined set of
environment variables from the build system to the system running the
glibc under test.  Although some variables are passed explicitly via
$(test-wrapper-env), including LD_* variables that simply can't be
passed implicitly because of the side effects they'd have on the build
system's dynamic linker, others are passed implicitly, including
variables such as GCONV_PATH and LOCPATH that could potentially affect
the build system's libc (so effectively relying on any such effects
not breaking the wrappers).  In addition, the code in
cross-test-ssh.sh for preserving environment variables is fragile (it
depends on how bash formats a list of exported variables, and could
well break for multi-line variable definitions where the contents
contain things looking like other variable definitions).

This patch moves to explicitly passing environment variables via
$(test-wrapper-env).  Makefile variables that previously used
$(test-wrapper) are split up into -before-env and -after-env parts
that can be passed separately to the various .sh files used in
testing, so those files can then insert environment settings between
the two parts.

The common default environment settings in make-test-out are made into
a separate makefile variable that can also be passed to scripts,
rather than many scripts duplicating those settings (for testing an
installed glibc, it is desirable to have the GCONV_PATH setting on
just one place, so just that one place needs to support it pointing to
an installed sysroot instead of the build tree).  The default settings
are included in the variables such as $(test-program-prefix), so that
if tests do not need any non-default settings they can continue to use
single variables rather than the split-up variables.

Although this patch cleans up LC_ALL=C settings (that being part of
the common defaults), various LANG=C and LANGUAGE=C settings remain.
Those are generally unnecessary and I propose a subsequent cleanup to
remove them.  LC_ALL takes precedence over LANG, and while LANGUAGE
takes precedence over LC_ALL, it only does so for settings other than
LC_ALL=C.  So LC_ALL=C on its own is sufficient to ensure the C
locale, and anything that gets LC_ALL=C does not need the other
settings.

While preparing this patch I noticed some tests with .sh files that
appeared to do nothing beyond what the generic makefile support for
tests can do (localedata/tst-wctype.sh - the makefiles support -ENV
variables and .input files - and localedata/tst-mbswcs.sh - just runs
five tests that could be run individually from the makefile).  So I
propose another subsequent cleanup to move those to using the generic
support instead of special .sh files.

Tested x86_64 (native) and powerpc32 (cross).

	* Makeconfig (run-program-env): New variable.
	(run-program-prefix-before-env): Likewise.
	(run-program-prefix-after-env): Likewise.
	(run-program-prefix): Define in terms of new variables.
	(built-program-cmd-before-env): New variable.
	(built-program-cmd-after-env): Likewise.
	(built-program-cmd): Define in terms of new variables.
	(test-program-prefix-before-env): New variable.
	(test-program-prefix-after-env): Likewise.
	(test-program-prefix): Define in terms of new variables.
	(test-program-cmd-before-env): New variable.
	(test-program-cmd-after-env): Likewise.
	(test-program-cmd): Define in terms of new variables.
	* Rules (make-test-out): Use $(run-program-env).
	* scripts/cross-test-ssh.sh (env_blacklist): Remove variable.
	(help): Do not mention environment variables.  Mention
	--timeoutfactor option.
	(timeoutfactor): New variable.
	(blacklist_exports): Remove function.
	(exports): Remove variable.
	(command): Do not include ${exports}.
	* manual/install.texi (Configuring and compiling): Do not mention
	test wrappers preserving environment variables.  Mention that last
	assignment to a variable must take precedence.
	* INSTALL: Regenerated.
	* benchtests/Makefile (run-bench): Use $(run-program-env).
	* catgets/Makefile ($(objpfx)test1.cat): Use
	$(built-program-cmd-before-env), $(run-program-env) and
	$(built-program-cmd-after-env).
	($(objpfx)test2.cat): Do not specify environment variables
	explicitly.
	($(objpfx)de/libc.cat): Use $(built-program-cmd-before-env),
	$(run-program-env) and $(built-program-cmd-after-env).
	($(objpfx)test-gencat.out): Use $(test-program-cmd-before-env),
	$(run-program-env) and $(test-program-cmd-after-env).
	($(objpfx)sample.SJIS.cat): Do not specify environment variables
	explicitly.
	* catgets/test-gencat.sh: Use test_program_cmd_before_env,
	run_program_env and test_program_cmd_after_env arguments.
	* elf/Makefile ($(objpfx)tst-pathopt.out): Use $(run-program-env).
	* elf/tst-pathopt.sh: Use run_program_env argument.
	* iconvdata/Makefile ($(objpfx)iconv-test.out): Use
	$(test-wrapper-env) and $(run-program-env).
	* iconvdata/run-iconv-test.sh: Use test_wrapper_env and
	run_program_env arguments.
	* iconvdata/tst-table.sh: Do not set GCONV_PATH explicitly.
	* intl/Makefile ($(objpfx)tst-gettext.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	($(objpfx)tst-gettext2.out): Likewise.
	* intl/tst-gettext.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* intl/tst-gettext2.sh: Likewise.
	* intl/tst-gettext4.sh: Do not set environment variables
	explicitly.
	* intl/tst-gettext6.sh: Likewise.
	* intl/tst-translit.sh: Likewise.
	* malloc/Makefile ($(objpfx)tst-mtrace.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	* malloc/tst-mtrace.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* math/Makefile (run-regen-ulps): Use $(run-program-env).
	* nptl/Makefile ($(objpfx)tst-tls6.out): Use $(run-program-env).
	* nptl/tst-tls6.sh: Use run_program_env argument.  Set LANG=C
	explicitly with each use of ${test_wrapper_env}.
	* posix/Makefile ($(objpfx)wordexp-tst.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	* posix/tst-getconf.sh: Do not set environment variables
	explicitly.
	* posix/wordexp-tst.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* stdio-common/tst-printf.sh: Do not set environment variables
	explicitly.
	* stdlib/Makefile ($(objpfx)tst-fmtmsg.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	* stdlib/tst-fmtmsg.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	Split $test calls into $test_pre and $test.
	* timezone/Makefile (build-testdata): Use
	$(built-program-cmd-before-env), $(run-program-env) and
	$(built-program-cmd-after-env).

localedata/ChangeLog:
	* Makefile ($(addprefix $(objpfx),$(CTYPE_FILES))): Use
	$(built-program-cmd-before-env), $(run-program-env) and
	$(built-program-cmd-after-env).
	($(objpfx)sort-test.out): Use $(test-program-prefix-before-env),
	$(run-program-env) and $(test-program-prefix-after-env).
	($(objpfx)tst-fmon.out): Use $(run-program-prefix-before-env),
	$(run-program-env) and $(run-program-prefix-after-env).
	($(objpfx)tst-locale.out): Use $(built-program-cmd-before-env),
	$(run-program-env) and $(built-program-cmd-after-env).
	($(objpfx)tst-trans.out): Use $(run-program-prefix-before-env),
	$(run-program-env), $(run-program-prefix-after-env),
	$(test-program-prefix-before-env) and
	$(test-program-prefix-after-env).
	($(objpfx)tst-ctype.out): Use $(test-program-cmd-before-env),
	$(run-program-env) and $(test-program-cmd-after-env).
	($(objpfx)tst-wctype.out): Likewise.
	($(objpfx)tst-langinfo.out): Likewise.
	($(objpfx)tst-langinfo-static.out): Likewise.
	* gen-locale.sh: Use localedef_before_env, run_program_env and
	localedef_after_env arguments.
	* sort-test.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* tst-ctype.sh: Use tst_ctype_before_env, run_program_env and
	tst_ctype_after_env arguments.
	* tst-fmon.sh: Use run_program_prefix_before_env, run_program_env
	and run_program_prefix_after_env arguments.
	* tst-langinfo.sh: Use tst_langinfo_before_env, run_program_env
	and tst_langinfo_after_env arguments.
	* tst-locale.sh: Use localedef_before_env, run_program_env and
	localedef_after_env arguments.
	* tst-mbswcs.sh: Do not set environment variables explicitly.
	* tst-numeric.sh: Likewise.
	* tst-rpmatch.sh: Likewise.
	* tst-trans.sh: Use run_program_prefix_before_env,
	run_program_env, run_program_prefix_after_env,
	test_program_prefix_before_env and test_program_prefix_after_env
	arguments.
	* tst-wctype.sh: Use tst_wctype_before_env, run_program_env and
	tst_wctype_after_env arguments.
2014-06-06 22:19:27 +00:00
Siddhesh Poyarekar 15eaf6ffe3 benchtests: Add new directive for benchmark initialization hook
Add a new 'init' directive that specifies the name of the function to
call to do function-specific initialization.  This is useful for
benchmarks that need to do a one-time initialization before the
functions are executed.
2014-05-26 12:37:29 +05:30
Joseph Myers 79520f4bd6 Use existing makefile variables for dependencies on glibc libraries.
glibc's Makeconfig defines some variables such as $(libm) and $(libdl)
for linking with libraries built by glibc, and nptl/Makeconfig
(included by the toplevel Makeconfig) defines others such as
$(shared-thread-library).

In some places glibc's Makefiles use those variables when linking
against the relevant libraries, but in other places they hardcode the
location of the libraries in the build tree.  This patch cleans up
various places to use the variables that already exist (in the case of
libm, replacing several duplicate definitions of a $(link-libm)
variable in subdirectory Makefiles).  (It's not necessarily exactly
equivalent to what the existing code does - in particular,
$(shared-thread-library) includes libpthread_nonshared, but is
replacing places that just referred to libpthread.so.  But I think
that change is desirable on the general principle of linking things as
close as possible to the way in which they would be linked with an
installed library, unless there is a clear reason not to do so.)

To support running tests with an installed copy of glibc without
needing the full build tree from when that copy was built, I think it
will be useful to use such variables more generally and systematically
- every time the rules for building a test refer to some file from the
build tree that's also installed by glibc, use a makefile variable so
that the installed-testing case can point those variables to installed
copies of the files.  This patch just deals with straightforward cases
where such variables already exist.

It's quite possible some uses of $(shared-thread-library) should
actually be a new $(thread-library) variable that's set appropriately
in the --disable-shared case, if those uses would in fact work without
shared libraries.  I didn't change the status quo that those cases
hardcode use of a shared library whether or not it's actually needed
(but other uses such as $(libm) and $(libdl) would now get the static
library if the shared library isn't built, when some previously
hardcoded use of the shared library - if they actually need shared
libraries, the test itself needs an enable-shared conditional anyway).

Tested x86_64.

	* benchtests/Makefile
	($(addprefix $(objpfx)bench-,$(bench-math))): Depend on $(libm),
	not $(common-objpfx)math/libm.so.
	($(addprefix $(objpfx)bench-,$(bench-pthread))): Depend on
	$(shared-thread-library), not $(common-objpfx)nptl/libpthread.so.
	* elf/Makefile ($(objpfx)noload): Depend on $(libdl), not
	$(common-objpfx)dlfcn/libdl.so.
	($(objpfx)tst-audit8): Depend on $(libm), not
	$(common-objpfx)math/libm.so.
	* malloc/Makefile ($(objpfx)libmemusage.so): Depend on $(libdl),
	not $(common-objpfx)dlfcn/libdl.so.
	* math/Makefile
	($(addprefix $(objpfx),$(filter-out $(tests-static),$(tests)))):
	Depend on $(libm), not $(objpfx)libm.so.  Do not condition on
	[$(build-shared) = yes].
	($(objpfx)test-fenv-tls): Depend on $(shared-thread-library), not
	$(common-objpfx)nptl/libpthread.so.
	* misc/Makefile ($(objpfx)tst-tsearch): Depend on $(libm), not
	$(common-objpfx)math/libm.so$(libm.so-version) or
	$(common-objpfx)math/libm.a depending on [$(build-shared) = yes].
	* nptl/Makefile ($(objpfx)tst-unload): Depend on $(libdl), not
	$(common-objpfx)dlfcn/libdl.so.
	* setjmp/Makefile (link-libm): Remove variable.
	($(objpfx)tst-setjmp-fp): Depend on $(libm), not $(link-libm).
	* stdio-common/Makefile (link-libm): Remove variable.
	($(objpfx)tst-printf-round): Depend on $(libm), not $(link-libm).
	* stdlib/Makefile (link-libm): Remove variable.
	($(objpfx)bug-getcontext): Depend on $(libm), not $(link-libm).
	($(objpfx)tst-strtod-round): Likewise.
	($(objpfx)tst-tininess): Likewise.
	($(objpfx)tst-strtod-underflow): Likewise.
	($(objpfx)tst-strtod6): Likewise.
	($(objpfx)tst-tls-atexit): Depend on $(shared-thread-library) and
	$(libdl), not $(common-objpfx)nptl/libpthread.so and
	$(common-objpfx)dlfcn/libdl.so.
2014-05-16 21:38:08 +00:00
Siddhesh Poyarekar bb9c256fb0 benchtests: Link against objects in build directory
Using -lm and -lpthread results in the shared objects in the system
being used to link against.  This happened to work for libm because
there haven't been any changes to the libm ABI recently that could
break the existing benchmarks.  This doesn't always work for the
pthread benchmarks.  The correct way to build against libraries in the
build directory is to have the binaries explicitly depend on them so
that $(+link) can pick them up.
2014-04-15 14:33:06 +05:30
Will Newton 970c602aa6 benchtests: Improve readability of JSON output
Add a small library to print JSON values and use it to improve the
readability of the benchmark output and the readability of the
benchmark code.

ChangeLog:

2014-04-11  Will Newton  <will.newton@linaro.org>

	* benchtests/Makefile (extra-objs): Add json-lib.o.
	(bench-func): Tidy up JSON output.
	* benchtests/bench-skeleton.c: Include json-lib.h.
	(main): Use JSON library functions to do output of
	benchmark results.
	* benchtests/bench-timing-type.c (main): Output the
	timing type simply, leaving formatting to the user.
	* benchtests/json-lib.c: New file.
	* benchtests/json-lib.h: Likewise.
2014-04-11 16:05:03 +01:00
Torvald Riegel 6a5d6ea128 benchtests: Add pthread_once common-case test.
We have a single thread that runs a no-op initialization once and then
repeatedly runs checks of the initialization (i.e., an acquire load and
conditional jump) in a tight loop.  This gives us, on average, the
best-case latency of pthread_once (the initialization is the
exactly-once slow path, and we're not looking at initialization-related
synchronization overheads in this case).
2014-04-10 21:22:28 +02:00
Will Newton f6c557968c benchtests: Build ffs and ffsl benchtests with -fno-builtin
Without this flag it is possible that the compiler will optimize
away the calls to ffs/ffsll.

ChangeLog:

2014-04-01  Will Newton  <will.newton@linaro.org>

	* benchtests/Makefile (CFLAGS-bench-ffs.c): Add
	-fno-builtin.  (CFLAGS-bench-ffsll.c): Likewise.
2014-04-01 12:50:41 +01:00
Will Newton c760f5c210 benchtests: Add benchtests for ffs and ffsll
Add benchtests for ffs and ffsll. There is no benchtest for ffsl as
it is identical to one of the other functions.

2014-03-31  Will Newton  <will.newton@linaro.org>

	* benchtests/Makefile (bench): Add ffs and ffsll to list
	of tests.
	* benchtests/ffs-inputs: New file.
	* benchtests/ffsll-inputs: Likewise.
2014-03-31 12:50:41 +01:00
Siddhesh Poyarekar 5673750800 Detailed benchmark outputs for functions
This patch adds an option to get detailed benchmark output for
functions.  Invoking the benchmark with 'make DETAILED=1 bench' causes
each benchmark program to store a mean execution time for each input
it works on.  This is useful to give a more comprehensive picture of
performance of functions compared to just the single mean figure.
2014-03-29 09:40:19 +05:30
Siddhesh Poyarekar cb5e4aada7 Make bench.out in json format
This patch changes the output format of the main benchmark output file
(bench.out) to an extensible format.  I chose JSON over XML because in
addition to being extensible, it is also not too verbose.
Additionally it has good support in python.

The significant change I have made in terms of functionality is to put
timing information as an attribute in JSON instead of a string and to
do that, there is a separate program that prints out a JSON snippet
mentioning the type of timing (hp_timing or clock_gettime).  The mean
timing has now changed from iterations per unit to actual timing per
iteration.
2014-03-29 09:37:44 +05:30
Siddhesh Poyarekar cf806aff60 [benchtests] Use inputs file for modf
The modf benchmark can now use the framework since the introduction of
output arguments.
2014-03-29 09:35:50 +05:30
Will Newton 60a2f3c166 benchtests/bench-strtod.c: Increase timeout value
This benchmark can take longer than the default 2 seconds on slower
platforms, so increase it to 10 seconds.

ChangeLog:

2014-03-26  Will Newton <will.newton@linaro.org>

	* benchtests/bench-strtod.c (TIMEOUT): Define to 10.
2014-03-26 09:43:28 +00:00
Siddhesh Poyarekar 27c673b8de benchtests: Move bench.py to benchtests/scripts/
It makes much more sense to have all benchmarking-related scripts in a
single place away from everything else.
2014-03-24 21:16:36 +05:30
Siddhesh Poyarekar df26ea5359 Implement benchmarking script in python
Implemented the benchmark script in python since it is much cleaner
and simpler to maintain.
2014-03-21 17:32:50 +05:30
Ondřej Bílka 7b3551e3a8 Make strtok benchmark competive.
We include a generic version of strtok to result which could be faster
when underlying primitives are better optimized than current version.
2014-02-28 22:45:33 +01:00
Joseph Myers a5f891ac8d Consistently include Makeconfig after defining subdir.
In <https://sourceware.org/ml/libc-alpha/2014-01/msg00196.html> I
noted it was necessary to add includes of Makeconfig early in various
subdirectory makefiles for the tests-special variable settings added
by that patch to be conditional on configuration information.  No-one
commented on the general question there of whether Makeconfig should
always be included immediately after the definition of subdir.

This patch implements that early inclusion of Makeconfig in each
directory (which is a lot easier than consistent placement of includes
of Rules).  Includes are added if needed, or moved up if already
present.  Subdirectory "all:" targets are removed, since Makeconfig
provides one.

There is potential for further cleanups I haven't done.  Rules and
Makerules have code such as

ifneq   "$(findstring env,$(origin headers))" ""
headers :=
endif

to override to empty any value of various variables that came from the
environment.  I think there is a case for Makeconfig setting all the
subdirectory variables (other than subdir) to empty to ensure no
outside value is going to take effect if a subdirectory fails to
define a variable.  (A list of such variables, possibly out of date
and incomplete, is in manual/maint.texi.)  Rules and Makerules would
give errors if Makeconfig hadn't already been included, instead of
including it themselves.  The special code to override values coming
from the environment would then be obsolete and could be removed.

Tested x86_64, including that installed binaries are identical before
and after the patch.

	* argp/Makefile: Include Makeconfig immediately after defining
	subdir.
	* assert/Makefile: Likewise.
	* benchtests/Makefile: Likewise.
	* catgets/Makefile: Likewise.
	* conform/Makefile: Likewise.
	* crypt/Makefile: Likewise.
	* csu/Makefile: Likewise.
	(all): Remove target.
	* ctype/Makefile: Include Makeconfig immediately after defining
	subdir.
	* debug/Makefile: Likewise.
	* dirent/Makefile: Likewise.
	* dlfcn/Makefile: Likewise.
	* gmon/Makefile: Likewise.
	* gnulib/Makefile: Likewise.
	* grp/Makefile: Likewise.
	* gshadow/Makefile: Likewise.
	* hesiod/Makefile: Likewise.
	* hurd/Makefile: Likewise.
	(all): Remove target.
	* iconvdata/Makefile: Include Makeconfig immediately after
	defining subdir.
	* inet/Makefile: Likewise.
	* intl/Makefile: Likewise.
	* io/Makefile: Likewise.
	* libio/Makefile: Likewise.
	(all): Remove target.
	* locale/Makefile: Include Makeconfig immediately after defining
	subdir.
	* login/Makefile: Likewise.
	* mach/Makefile: Likewise.
	(all): Remove target.
	* malloc/Makefile: Include Makeconfig immediately after defining
	subdir.
	(all): Remove target.
	* manual/Makefile: Include Makeconfig immediately after defining
	subdir.
	* math/Makefile: Likewise.
	* misc/Makefile: Likewise.
	* nis/Makefile: Likewise.
	* nss/Makefile: Likewise.
	* po/Makefile: Likewise.
	(all): Remove target.
	* posix/Makefile: Include Makeconfig immediately after defining
	subdir.
	* pwd/Makefile: Likewise.
	* resolv/Makefile: Likewise.
	* resource/Makefile: Likewise.
	* rt/Makefile: Likewise.
	* setjmp/Makefile: Likewise.
	* shadow/Makefile: Likewise.
	* signal/Makefile: Likewise.
	* socket/Makefile: Likewise.
	* soft-fp/Makefile: Likewise.
	* stdio-common/Makefile: Likewise.
	* stdlib/Makefile: Likewise.
	* streams/Makefile: Likewise.
	* string/Makefile: Likewise.
	* sunrpc/Makefile: Likewise.
	(all): Remove target.
	* sysvipc/Makefile: Include Makeconfig immediately after defining
	subdir.
	* termios/Makefile: Likewise.
	* time/Makefile: Likewise.
	* timezone/Makefile: Likewise.
	(all): Remove target.
	* wcsmbs/Makefile: Include Makeconfig immediately after defining
	subdir.
	* wctype/Makefile: Likewise.

libidn/ChangeLog:
	* Makefile: Include Makeconfig immediately after defining subdir.

localedata/ChangeLog:
	* Makefile: Include Makeconfig immediately after defining subdir.
	(all): Remove target.

nptl/ChangeLog:
	* Makefile: Include Makeconfig immediately after defining subdir.

nptl_db/ChangeLog:
	* Makefile: Include Makeconfig immediately after defining subdir.
2014-02-26 23:12:03 +00:00
Siddhesh Poyarekar b8cd1c4ea5 Minor formatting fix 2014-02-21 11:31:41 +05:30
Rajalakshmi Srinivasaraghavan bd939d2322 print length in strrchr benchtest
The return criteria of strrchr() is to read till NULL even if the
search character is hit.  So its better to print len instead of pos.
2014-02-21 11:30:03 +05:30
Ondřej Bílka a1ffb40e32 Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
Mike Frysinger c5bb8e2399 tests: unify fortification handler logic
We have multiple tests that copy & paste the same logic for disabling the
fortification output.  Let's unify this in the test-skeleton instead.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2014-02-08 06:58:43 -05:00
Siddhesh Poyarekar 649ecea212 Correct inputs for sin and cos
The inputs for the slowest path in asin and acos were incorrect and
had some fast path inputs there too.
2014-01-10 09:57:51 +05:30
Allan McRae d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Siddhesh Poyarekar dd1d85e5dd Benchmark inputs for cos and sin
Add a comprehensive number of inputs for all branches in sin and cos
computation, excluding the fast paths.  This also adds a number of
inputs for the multiple precision slow paths.
2013-12-31 12:12:46 +05:30
Siddhesh Poyarekar 1acbb90f7a benchmark inputs for atan
Add a more comprehensive set of inputs for the atan function.  I have
also fixed the name on the multiple precision fallback inputs (I
couldn't find any new inputs there) to reflect the fact that the
fallback is only 144bits and not 768bits as I had earlier mentioned.
2013-12-31 12:11:13 +05:30
Siddhesh Poyarekar 4c012ed391 benchmark inputs for tanh and atanh 2013-12-31 12:06:30 +05:30
Siddhesh Poyarekar eff9832405 benchmark inputs for asinh and acosh
Like sinh and cosh, this patch has benchmark inputs for asinh and
acosh, generated using a random number generator and spread over
significant branches, ignoring the fast return paths.
2013-12-31 12:05:16 +05:30
Siddhesh Poyarekar ce641152c4 benchmark inputs for sinh and cosh
Add a full set of inputs for sinh and cosh functions generated using a
random number generator and spreading it over all branches in the
function, ignoring the fast paths (i.e. immediate return for special
values).
2013-12-31 12:03:44 +05:30
Siddhesh Poyarekar b19221b9a5 benchmark inputs for asin and acos
Add a comprehensive set of inputs for asin and acos functions,
including the multiple precision fallback path.
2013-12-31 12:01:40 +05:30
Rajalakshmi Srinivasaraghavan 9f6e964c3a benchtests: Add strtok benchmark 2013-12-19 06:45:54 -05:00
Siddhesh Poyarekar 19b5525e52 benchmark inputs for exp2, log2, log and tan 2013-12-12 09:31:53 +05:30
Siddhesh Poyarekar 9298ecba15 Accept output arguments to benchmark functions
This patch adds the ability to accept output arguments to functions
being benchmarked, by nesting the argument type in <> in the args
directive.  It includes the sincos implementation as an example, where
the function would have the following args directive:

  ## args: double:<double *>:<double *>

This simply adds a definition for a static variable whose pointer gets
passed into the function, so it's not yet possible to pass something
more complicated like a pre-allocated string or array.  That would be
a good feature to add if a function needs it.

The values in the input file will map only to the input arguments.  So
if I had a directive like this for a function foo:

  ## args: int:<int *>:int:<int *>

and I have a value list like this:

1, 2
3, 4
5, 6

then the function calls generated would be:

foo (1, &out1, 2, &out2);
foo (3, &out1, 4, &out2);
foo (5, &out1, 6, &out2);
2013-12-05 10:12:59 +05:30
Steve Ellcey fe7da22091 Benchmark test for sqrt function. 2013-12-02 09:37:18 -08:00
Ondřej Bílka a950349667 Also remove benchtests/bench-strsep-ifunc.c 2013-11-26 17:34:34 +01:00
Ondřej Bílka 826fa85580 Remove duplicate ifunc benchtests. 2013-11-26 12:48:33 +01:00
Rajalakshmi Srinivasaraghavan 250c23bdd9 benchtests: Add strsep benchmark 2013-11-18 06:49:44 -06:00
Steve Ellcey e8470ea216 2013-11-13 Steve Ellcey <sellcey@mips.com>
* benchtests/bench-timing.h: Include time.h.
2013-11-13 08:48:25 -08:00
Adhemerval Zanella 450a2e2d19 benchtests: Add strtod benchmark 2013-11-11 11:24:07 -02:00
Siddhesh Poyarekar dfa1b402a0 Benchmark inputs for pow
These inputs cover all normal processing paths for pow including all
its slow paths.
2013-10-28 16:36:46 +05:30
Siddhesh Poyarekar 54f73d9c08 New inputs for exp
A more comprehensive set of inputs for exp, including all slow paths.
The inputs have been shuffled so that they don't give a false-positive
due to a hot cache.
2013-10-28 16:35:08 +05:30
Torvald Riegel 40fefba1b5 benchtests: Add include-sources directive.
This adds the "include-sources" directive to scripts/bench.pl.  This
allows for including source code (vs including headers, which might get
a different search path) after the inclusion of any headers.
2013-10-10 14:45:30 +03:00
Siddhesh Poyarekar a357259bf8 Add more directives to benchmark input files
This patch adds some more directives to the benchmark inputs file,
moving functionality from the Makefile and making the code generation
script a bit cleaner.  The function argument and return types that
were earlier added as variables in the makefile and passed to the
script via command line arguments are now the 'args' and 'ret'
directive respectively.  'args' should be a colon separated list of
argument types (skipped if the function doesn't accept any arguments)
and 'ret' should be the return type.

Additionally, an 'includes' directive may have a comma separated list
of headers to include in the source.  For example, the pow input file
now looks like this:

42.0, 42.0
1.0000000000000020, 1.5

I did this to unclutter the benchtests Makefile a bit and eventually
eliminate dependency of the tests on the Makefile and have tests
depend on their respective include files only.
2013-10-07 11:51:25 +05:30
Siddhesh Poyarekar 7849ff938c Add benchmark inputs for sincos 2013-09-19 16:55:27 +05:30
Will Newton b987c77672 benchtests: Rename argument to TIMING_INIT macro.
The TIMING_INIT macro currently sets the number of loop iterations
to 1000, which limits usefulness. Make the argument a clock
resolution value and multiply by 1000 in bench-skeleton.c instead
to allow easier reuse.

ChangeLog:

2013-09-11  Will Newton  <will.newton@linaro.org>

	* benchtests/bench-timing.h (TIMING_INIT): Rename ITERS
	parameter to RES. Remove hardcoded 1000 value.
	* benchtests/bench-skeleton.c (main): Pass RES parameter
	to TIMING_INIT and multiply result by 1000.
2013-09-11 15:18:20 +01:00
Adhemerval Zanella e029e2e5c5 benchtests: Add memrchr benchmark 2013-09-06 09:24:52 -03:00
Will Newton bbf6e8e4f4 benchtests/Makefile: Run benchmark for memcpy.
The benchmark for memcpy got disabled accidentally. Re-enable it.

ChangeLog:

2013-09-06   Will Newton  <will.newton@linaro.org>

	* benchtests/Makefile (string-bench): Add memcpy.
2013-09-06 11:59:00 +01:00
Will Newton 44558701ff benchtests: Switch string benchmarks to use bench-timing.h.
Switch the string benchmarks to using bench-timing.h instead
of hp-timing.h directly. This allows the string benchmarks to
be run usefully on architectures such as ARM that do not have
support for hp-timing.h.

In order to do this the tests have been changed from timing each
individual call and picking the lowest execution time recorded to
timing a number of calls and taking the mean execution time.

ChangeLog:

2013-09-04   Will Newton  <will.newton@linaro.org>

	* benchtests/bench-timing.h (TIMING_PRINT_MEAN): New macro.
	* benchtests/bench-string.h: Include bench-timing.h instead
	of including hp-timing.h directly. (INNER_LOOP_ITERS): New
	define. (HP_TIMING_BEST): Delete macro. (test_init): Remove
	call to HP_TIMING_DIFF_INIT.
	* benchtests/bench-memccpy.c: Use bench-timing.h macros
	instead of hp-timing.h macros.
	* benchtests/bench-memchr.c: Likewise.
	* benchtests/bench-memcmp.c: Likewise.
	* benchtests/bench-memcpy.c: Likewise.
	* benchtests/bench-memmem.c: Likewise.
	* benchtests/bench-memmove.c: Likewise.
	* benchtests/bench-memset.c: Likewise.
	* benchtests/bench-rawmemchr.c: Likewise.
	* benchtests/bench-strcasecmp.c: Likewise.
	* benchtests/bench-strcasestr.c: Likewise.
	* benchtests/bench-strcat.c: Likewise.
	* benchtests/bench-strchr.c: Likewise.
	* benchtests/bench-strcmp.c: Likewise.
	* benchtests/bench-strcpy.c: Likewise.
	* benchtests/bench-strcpy_chk.c: Likewise.
	* benchtests/bench-strlen.c: Likewise.
	* benchtests/bench-strncasecmp.c: Likewise.
	* benchtests/bench-strncat.c: Likewise.
	* benchtests/bench-strncmp.c: Likewise.
	* benchtests/bench-strncpy.c: Likewise.
	* benchtests/bench-strnlen.c: Likewise.
	* benchtests/bench-strpbrk.c: Likewise.
	* benchtests/bench-strrchr.c: Likewise.
	* benchtests/bench-strspn.c: Likewise.
	* benchtests/bench-strstr.c: Likewise.
2013-09-04 15:40:12 +01:00
Will Newton cae16d6675 benchtests/Makefile: Use LDLIBS instead of LDFLAGS.
LDFLAGS puts the library too early in the command line if --as-needed
is being used. Use LDLIBS instead.

ChangeLog:

2013-09-04  Will Newton  <will.newton@linaro.org>

	* benchtests/Makefile: Use LDLIBS instead of LDFLAGS.
2013-09-04 15:38:41 +01:00
Adhemerval Zanella 85c2e6110c Fix loop construction to functions calls
Check wheter the compiler has the option -fno-tree-loop-distribute-patterns
to inhibit loop transformation to library calls and uses it on memset
and memmove default implementation to avoid recursive calls.
2013-06-20 19:42:05 -05:00
Siddhesh Poyarekar 94aca5e740 Port remaining string benchmarks
There were a few more string benchmarks (strcpy_chk and stpcpy_check)
in the debug directory that needed to be ported over.
2013-06-11 20:51:55 +05:30
Siddhesh Poyarekar 9702047480 Copy over string performance tests into benchtests
Copy over already existing string performance tests into benchtests.
Bits not related to performance measurements have been omitted.
2013-06-11 15:08:13 +05:30
Siddhesh Poyarekar c1f75dc386 Begin porting string performance tests to benchtests
This is the initial support for string function performance tests,
along with copying tests for memcpy and memcpy-ifunc as proof of
concept.  The string function benchmarks perform operations at
different alignments and for different sizes and compare performance
between plain operations and the optimized string operations.  Due to
this their output is incompatible with the function benchmarks where
we're interested in fastest time, throughput, etc.

In future, the correctness checks in the benchmark tests can be
removed.  Same goes for the performance measurements in the
string/test-*.
2013-06-11 15:08:13 +05:30
Siddhesh Poyarekar 50b818bf96 Avoid overwriting earlier flags in CPPFLAGS-nonlib in benchtests
When setting BENCH_DURATION in CPPFLAGS-nonlib, append to the variable
instead of assigning to it, to avoid overwriting earlier set flags,
notably the -DNOT_IN_libc=1 flag.
2013-06-10 10:08:46 +05:30
Siddhesh Poyarekar 3ce9e01097 Sort benchmark functions 2013-05-22 11:07:39 +05:30
Siddhesh Poyarekar 051063c88b Add benchmark inputs for math functions
Add benchmark inputs for inverse and hyperbolic trigonometric
functions and log.
2013-05-22 11:07:33 +05:30
Siddhesh Poyarekar fef94eab0b Add a README for benchtests
Move instructions from the Makefile here and expand on them.
2013-05-21 14:59:50 +05:30
Siddhesh Poyarekar 48a18de1e1 Prevent optimizing out of benchmark function call
Resolves: #15424

The compiler would optimize the benchmark function call out of the
loop and call it only once, resulting in blazingly fast times for some
benchmarks (notably atan, sin and cos).  Mark the inputs as volatile
so that the code is forced to read again from the input for each
iteration.
2013-05-17 19:10:33 +05:30
Siddhesh Poyarekar 43fe811b73 Use HP_TIMING for benchmarks if available
HP_TIMING uses native timestamping instructions if available, thus
greatly reducing the overhead of recording start and end times for
function calls.  For architectures that don't have HP_TIMING
available, we fall back to the clock_gettime bits.  One may also
override this by invoking the benchmark as follows:

  make USE_CLOCK_GETTIME=1 bench

and get the benchmark results using clock_gettime.  One has to do
`make bench-clean` to ensure that the benchmark programs are rebuilt.
2013-05-13 13:44:32 +05:30
Siddhesh Poyarekar 5c637fe5ee Fix coding style 2013-05-10 17:44:27 +05:30
Ondrej Bilka bb7cf681e9 Preheat CPU in benchtests.
A benchmark could be skewed by CPU initialy working on minimal
frequency and speeding up later. We first run code in loop
to partialy fix this issue.
2013-05-08 08:25:08 +02:00
Siddhesh Poyarekar f0ee064b7d Allow multiple input domains to be run in the same benchmark program
Some math functions have distinct performance characteristics in
specific domains of inputs, where some inputs return via a fast path
while other inputs require multiple precision calculations, that too
at different precision levels.  The way to implement different domains
was to have a separate source file and benchmark definition, resulting
in separate programs.

This clutters up the benchmark, so this change allows these domains to
be consolidated into the same input file.  To do this, the input file
format is now enhanced to allow comments with a preceding # and
directives with two # at the begining of a line.  A directive that
looks like:

tells the benchmark generation script that what follows is a different
domain of inputs.  The value of the 'name' directive (in this case,
foo) is used in the output.  The two input domains are then executed
sequentially and their results collated separately.  with the above
directive, there would be two lines in the result that look like:

func(): ....
func(foo): ...
2013-04-30 14:17:57 +05:30
Siddhesh Poyarekar d569c6eeb4 Maintain runtime of each benchmark at ~10 seconds
The idea to run benchmarks for a constant number of iterations is
problematic.  While the benchmarks may run for 10 seconds on x86_64,
they could run for about 30 seconds on powerpc and worse, over 3
minutes on arm.  Besides that, adding a new benchmark is cumbersome
since one needs to find out the number of iterations needed for a
sufficient runtime.

A better idea would be to run each benchmark for a specific amount of
time.  This patch does just that.  The run time defaults to 10 seconds
and it is configurable at command line:

  make BENCH_DURATION=5 bench
2013-04-30 14:10:20 +05:30
Siddhesh Poyarekar 45d69176e8 Mention files in which fast/slow paths of math functions are implemented 2013-04-24 14:07:40 +05:30
Adhemerval Zanella 3c0265394d PowerPC: modf optimization
This patch implements modf/modff optimization for POWER by focus
on FP operations instead of relying in integer ones.
2013-04-23 13:38:52 -05:00
Siddhesh Poyarekar 037714dd49 Add benchmark inputs for cos and tan 2013-04-17 17:45:55 +05:30
Siddhesh Poyarekar 4856bcd2df Define NOT_IN_libc when compiling benchmark programs 2013-04-16 18:34:03 +05:30
Siddhesh Poyarekar a296407432 Add target bench-clean 2013-04-16 14:07:21 +05:30
Siddhesh Poyarekar 206a669911 Write to bench.out-tmp only once
Appending benchmark program output on every run could result in a case
where the benchmark run was cancelled, resulting in a partially
written file.  This file gets used again on the next run, resulting in
results being appended to old results.

It could have been possible to remove the file before every benchmark
run, but it is easier to just write the output to bench.out-tmp only
once.
2013-04-15 13:53:35 +05:30
Siddhesh Poyarekar acb4325fc7 Rebuild benchmark sources when Makefile is updated
Benchmark programs are generated using parameters from the Makefile,
so it is necessary to rebuild them whenever the parameters in the
Makefile are updated.  Hence, added a dependency for the generated C
source on the Makefile so that it gets regenerated when the Makefile
is updated.
2013-04-15 11:17:01 +05:30
Siddhesh Poyarekar 8fc1bee546 Move bench target to benchtests
The bench target will only be used within the benchtests directory.
2013-04-12 15:01:44 +05:30
Siddhesh Poyarekar 64aabd4b80 Add benchmark inputs for atan
Add separate inputs for slow and fast paths of atan
2013-04-03 15:50:15 +05:30
Siddhesh Poyarekar 92e3664bb5 Add benchmark inputs for sin 2013-04-02 17:48:47 +05:30
Siddhesh Poyarekar 81f311c2ee Add benchmark tests for slowpow and slowexp
Separate benchmarks for the fast and slow implementations of pow and
exp since measuring both together doesn't make sense.  Adjust the
iterations for pow and exp accordingly so that they run long enough
for the measurements to be meaningful.
2013-04-02 17:45:45 +05:30
Adhemerval Zanella 60c414c346 PowerPC: remove branch prediction from rint implementation
The branch prediction hints is actually hurts performance in this case.
The assembly implementation make two assumptions: 1. 'fabs (x) < 2^52'
is unlikely and 2. 'x > 0.0' is unlike (if 1. is true). Since it a
general floating point function, expected input is not bounded and then
it is better to let the hardware handle the branches.
2013-04-01 06:36:51 -05:00
Siddhesh Poyarekar 8cfdb7e056 Framework for performance benchmarking of functions
See benchtests/Makefile to know how to use it.
2013-03-15 12:30:03 +05:30