glibc/benchtests/Makefile

503 lines
12 KiB
Makefile
Raw Normal View History

# Copyright (C) 2013-2022 Free Software Foundation, Inc.
# Copyright The GNU Toolchain Authors.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
Prefer https to http for gnu.org and fsf.org URLs Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
# <https://www.gnu.org/licenses/>.
# Makefile for benchmark tests. The only useful target here is `bench`.
2013-05-22 05:35:04 +00:00
# Add benchmark functions in alphabetical order.
subdir := benchtests
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
include ../Makeconfig
bench-math := \
acos \
acosh \
asin \
asinh \
atan \
atan2 \
atanh \
cbrt \
cos \
cosf \
cosh \
erf \
erfc \
exp \
exp10 \
exp10f \
exp2 \
exp2f \
expf \
expm1 \
fmax \
fmaxf \
fmin \
fminf \
hypot \
hypotf \
ilogb \
ilogbf \
isfinite \
isinf \
isnan \
j0 \
j1 \
lgamma \
log \
log10 \
log1p \
log2 \
log2f \
logb \
logbf \
logf \
modf \
pow \
powf \
rint \
roundeven \
roundevenf \
sin \
sincos \
sincosf \
sinf \
sinh \
sqrt \
tan \
tanh \
tgamma \
trunc \
truncf \
y0 \
y1 \
ifneq (,$(filter yes,$(float96-fcts)))
bench-math += \
cbrtl \
# bench-math
endif
ifneq (,$(filter yes,$(float128-fcts) $(float128-alias-fcts)))
bench-math += \
expf128 \
ilogbf128 \
powf128 \
sinf128 \
# bench-math
endif
bench-pthread := \
pthread-locks \
pthread-mutex-lock \
pthread-mutex-trylock \
pthread-spin-lock \
pthread-spin-trylock \
pthread_once \
thread_create \
# bench-pthread
LDLIBS-bench-pthread-mutex-lock += -lm
LDLIBS-bench-pthread-mutex-trylock += -lm
LDLIBS-bench-pthread-spin-lock += -lm
LDLIBS-bench-pthread-spin-trylock += -lm
bench-string := \
ffs \
ffsll \
# bench-string
# String function benchmarks.
string-benchset := \
bzero \
bzero-large \
bzero-walk \
memccpy \
memchr \
memcmp \
memcmpeq \
memcpy \
memcpy-large \
memcpy-random \
memcpy-walk \
memmem \
memmove \
memmove-large \
memmove-walk \
mempcpy \
memrchr \
memset \
memset-large \
memset-walk \
memset-zero \
memset-zero-large \
memset-zero-walk \
rawmemchr \
stpcpy \
stpcpy_chk \
stpncpy \
strcasecmp \
strcasestr \
strcat \
strchr \
strchrnul \
strcmp \
strcoll \
strcpy \
strcpy_chk \
strcspn \
strlen \
strncasecmp \
strncat \
strncmp \
strncpy \
strnlen \
strpbrk \
strrchr \
strsep \
strspn \
strstr \
strtok \
# string-benchset
# Build and run locale-dependent benchmarks only if we're building natively.
ifeq (no,$(cross-compiling))
wcsmbs-benchset := \
wcpcpy \
wcpncpy \
wcrtomb \
wcscat \
wcschr \
wcschrnul \
wcscmp \
wcscpy \
wcscspn \
wcslen \
wcsncat \
wcsncmp \
wcsncpy \
wcsnlen \
wcspbrk \
wcsrchr \
wcsspn \
wmemchr \
wmemcmp \
wmemset \
# wcsmbs-benchset
else
wcsmbs-benchset :=
endif
string-benchset-all := $(string-benchset) ${wcsmbs-benchset}
ifeq (no,$(cross-compiling))
2015-05-12 17:22:14 +00:00
# We have to generate locales
LOCALES := \
ar_SA.UTF-8 \
cs_CZ.UTF-8 \
da_DK.UTF-8 \
el_GR.UTF-8 \
en_GB.UTF-8 \
en_US.UTF-8 \
es_ES.UTF-8 \
fa_IR.UTF-8 \
fr_FR.UTF-8 \
he_IL.UTF-8 \
hi_IN.UTF-8 \
hu_HU.UTF-8 \
is_IS.UTF-8 \
it_IT.UTF-8 \
ja_JP.UTF-8 \
pl_PL.UTF-8 \
pt_PT.UTF-8 \
ru_RU.UTF-8 \
si_LK.UTF-8 \
sr_RS.UTF-8 \
sv_SE.UTF-8 \
tr_TR.UTF-8 \
vi_VN.UTF-8 \
zh_CN.UTF-8 \
# LOCALES
2015-05-12 17:22:14 +00:00
include ../gen-locales.mk
endif
2015-05-12 17:22:14 +00:00
hash-benchset := \
dl-elf-hash \
dl-new-hash \
nss-hash \
# hash-benchset
stdlib-benchset := \
arc4random \
strtod \
# stdlib-benchset
2013-11-11 13:23:02 +00:00
stdio-common-benchset := sprintf
math-benchset := math-inlines
ifeq (${BENCHSET},)
benchset := $(string-benchset-all) $(stdlib-benchset) $(stdio-common-benchset) \
$(math-benchset) $(hash-benchset)
else
benchset := $(foreach B,$(filter %-benchset,${BENCHSET}), ${${B}})
endif
CFLAGS-bench-ffs.c += -fno-builtin
CFLAGS-bench-ffsll.c += -fno-builtin
CFLAGS-bench-sqrt.c += -fno-builtin
CFLAGS-bench-fmin.c += -fno-builtin
CFLAGS-bench-fminf.c += -fno-builtin
CFLAGS-bench-fmax.c += -fno-builtin
CFLAGS-bench-fmaxf.c += -fno-builtin
CFLAGS-bench-trunc.c += -fno-builtin
CFLAGS-bench-truncf.c += -fno-builtin
CFLAGS-bench-roundeven.c += -fno-builtin
CFLAGS-bench-roundevenf.c += -fno-builtin
CFLAGS-bench-isnan.c += $(config-cflags-signaling-nans)
CFLAGS-bench-isinf.c += $(config-cflags-signaling-nans)
CFLAGS-bench-isfinite.c += $(config-cflags-signaling-nans)
ifeq (${BENCHSET},)
bench-malloc := malloc-thread malloc-simple
else
bench-malloc := $(filter malloc-%,${BENCHSET})
endif
ifeq (${STATIC-BENCHTESTS},yes)
+link-benchtests = $(+link-static-tests)
link-libc-benchtests = $(link-libc-static)
libm-benchtests = $(common-objpfx)math/libm.a
thread-library-benchtests = $(static-thread-library)
else
link-libc-benchtests = $(link-libc)
+link-benchtests = $(+link-tests)
thread-library-benchtests = $(shared-thread-library)
libm-benchtests = $(libm)
endif
$(addprefix $(objpfx)bench-,$(bench-math)): $(libm-benchtests)
$(addprefix $(objpfx)bench-,$(math-benchset)): $(libm-benchtests)
$(addprefix $(objpfx)bench-,$(bench-pthread)): $(thread-library-benchtests)
$(addprefix $(objpfx)bench-,$(bench-malloc)): $(thread-library-benchtests)
$(addprefix $(objpfx)bench-,pthread-locks): $(libm-benchtests)
$(addprefix $(objpfx)bench-,pthread-mutex-locks): $(libm-benchtests)
2013-09-19 11:25:27 +00:00
# Rules to build and execute the benchmarks. Do not put any benchmark
# parameters beyond this point.
# We don't want the benchmark programs to run in parallel since that could
# affect their performance.
.NOTPARALLEL:
bench-extra-objs = json-lib.o
extra-objs += $(bench-extra-objs)
others-extras = $(bench-extra-objs)
# The default duration: 1 seconds.
ifndef BENCH_DURATION
BENCH_DURATION := 1
endif
CPPFLAGS-nonlib += -DDURATION=$(BENCH_DURATION) -D_ISOMAC
# Use clock_gettime to measure performance of functions. The default is
# to use the architecture-specific high precision timing instructions.
ifdef USE_CLOCK_GETTIME
CPPFLAGS-nonlib += -DUSE_CLOCK_GETTIME
else
# On x86 processors, use RDTSCP, instead of RDTSC, to measure performance
# of functions. All x86 processors since 2010 support RDTSCP instruction.
ifdef USE_RDTSCP
CPPFLAGS-nonlib += -DUSE_RDTSCP
endif
endif
DETAILED_OPT :=
ifdef DETAILED
DETAILED_OPT := -d
endif
bench-deps := bench-skeleton.c bench-timing.h Makefile
run-bench = $(test-wrapper-env) \
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
$(run-program-env) \
$($*-ENV) $(test-via-rtld-prefix) $${run}
timing-type := $(objpfx)bench-timing-type
extra-objs += bench-timing-type.o
include ../Rules
bench-math += $(bench-libmvec)
ifeq (${BENCHSET},)
bench := $(bench-math) $(bench-pthread) $(bench-string)
else
bench := $(foreach B,$(filter bench-%,${BENCHSET}), ${${B}})
endif
# NB: Use "=" instead of ":=" since sysdeps Makefiles may add more
# benches.
binaries-bench = $(addprefix $(objpfx)bench-,$(bench))
extra-objs += $(addsuffix .o,$(addprefix bench-,$(bench)))
binaries-benchset = $(addprefix $(objpfx)bench-,$(benchset))
extra-objs += $(addsuffix .o,$(addprefix bench-,$(benchset)))
binaries-bench-malloc := $(addprefix $(objpfx)bench-,$(bench-malloc))
extra-objs += $(addsuffix .o,$(addprefix bench-,$(bench-malloc)))
# This makes sure CPPFLAGS-nonlib and CFLAGS-nonlib are passed
# for all these modules.
cpp-srcs-left := $(binaries-benchset:=.c) $(binaries-bench:=.c) \
$(binaries-bench-malloc:=.c) $(timing-type:=.c)
lib := nonlib
include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
2013-04-16 08:37:21 +00:00
bench-clean:
rm -f $(binaries-bench) $(addsuffix .o,$(binaries-bench))
rm -f $(binaries-benchset) $(addsuffix .o,$(binaries-benchset))
rm -f $(binaries-bench-malloc) $(addsuffix .o,$(binaries-bench-malloc))
rm -f $(timing-type) $(addsuffix .o,$(timing-type))
rm -f $(addprefix $(objpfx),$(bench-extra-objs))
# Validate the passed in BENCHSET
ifneq ($(strip ${BENCHSET}),)
VALIDBENCHSETNAMES := \
bench-math \
bench-pthread \
bench-string \
hash-benchset \
malloc-simple \
malloc-thread \
math-benchset \
stdio-common-benchset \
stdlib-benchset \
string-benchset \
wcsmbs-benchset \
# VALIDBENCHSETNAMES
INVALIDBENCHSETNAMES := $(filter-out ${VALIDBENCHSETNAMES},${BENCHSET})
ifneq (${INVALIDBENCHSETNAMES},)
$(info The following values in BENCHSET are invalid: ${INVALIDBENCHSETNAMES})
$(info The valid ones are: ${VALIDBENCHSETNAMES})
$(error Invalid BENCHSET value)
endif
endif
bench: bench-build bench-set bench-func bench-malloc
# Target to only build the benchmark without running it. We generate locales
# only if we're building natively.
ifeq (no,$(cross-compiling))
bench-build: $(gen-locales) $(timing-type) $(binaries-bench) \
$(binaries-benchset) $(binaries-bench-malloc)
else
bench-build: $(timing-type) $(binaries-bench) $(binaries-benchset) \
$(binaries-bench-malloc)
endif
bench-set: $(binaries-benchset)
for run in $^; do \
echo "Running $${run}"; \
$(run-bench) > $${run}.out; \
done
2013-04-16 08:37:21 +00:00
bench-malloc: $(binaries-bench-malloc)
for run in $^; do \
echo "$${run}"; \
if [ `basename $${run}` = "bench-malloc-thread" ]; then \
for thr in 1 8 16 32; do \
echo "Running $${run} $${thr}"; \
$(run-bench) $${thr} > $${run}-$${thr}.out; \
done;\
else \
for thr in 8 16 32 64 128 256 512 1024 2048 4096; do \
echo "Running $${run} $${thr}"; \
$(run-bench) $${thr} > $${run}-$${thr}.out; \
done;\
fi;\
done
# Build and execute the benchmark functions. This target generates JSON
# formatted bench.out. Each of the programs produce independent JSON output,
# so one could even execute them individually and process it using any JSON
# capable language or tool.
bench-func: $(binaries-bench)
if [ -n '$^' ] ; then \
{ timing_type=$$($(test-wrapper-env) \
$(run-program-env) \
$(test-via-rtld-prefix) \
$(timing-type)); \
echo "{\"timing_type\": \"$${timing_type}\","; \
echo " \"functions\": {"; \
for run in $^; do \
op=$$($(run-bench) $(DETAILED_OPT)); \
ret=$$?; \
case "$${ret}" in \
77) \
echo "UNSUPPORTED $${run}: $${op}" >&2; \
;; \
0) \
echo "Running $${run}" >&2; \
if [ "$${run}" != "$<" ]; then \
echo ","; \
fi; \
echo "$${op}"; \
;; \
*) \
echo "FAILED $${run}" >&2; \
;; \
esac; \
done; \
echo; \
echo " }"; \
echo "}"; \
} > $(objpfx)bench.out-tmp; \
if [ -f $(objpfx)bench.out ]; then \
mv -f $(objpfx)bench.out $(objpfx)bench.out.old; \
fi; \
mv -f $(objpfx)bench.out-tmp $(objpfx)bench.out; \
$(PYTHON) scripts/validate_benchout.py $(objpfx)bench.out \
scripts/benchout.schema.json; \
fi
ifeq ($(bind-now),yes)
link-bench-bind-now = -Wl,-z,now
endif
bench-link-targets = $(timing-type) $(binaries-bench) $(binaries-benchset) \
$(binaries-bench-malloc)
$(bench-link-targets): %: %.o $(objpfx)json-lib.o \
$(link-extra-libs-tests) \
$(sort $(filter $(common-objpfx)lib%,$(link-libc-benchtests))) \
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
$(+link-benchtests)
$(bench-link-targets): LDFLAGS += $(link-bench-bind-now)
$(objpfx)bench-%.c: %-inputs $(bench-deps)
{ if [ -n "$($*-INCLUDE)" ]; then \
cat $($*-INCLUDE); \
fi; \
$(PYTHON) scripts/bench.py $(patsubst %-inputs,%,$<); } > $@-tmp
mv -f $@-tmp $@