]> git.ipfire.org Git - thirdparty/glibc.git/blob - benchtests/Makefile
Mention files in which fast/slow paths of math functions are implemented
[thirdparty/glibc.git] / benchtests / Makefile
1 # Copyright (C) 2013 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
3
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
13
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <http://www.gnu.org/licenses/>.
17
18
19 # Makefile for benchmark tests. The only useful target here is `bench`.
20
21 # Adding a new function `foo`:
22 # ---------------------------
23
24 # - Append the function name to the bench variable
25
26 # - Define foo-ITER with the number of iterations you want to run. Keep it
27 # high enough that the overhead of clock_gettime is only a small fraction of
28 # the total run time of the test. A good idea would be to keep the run time
29 # of each test at around 10 seconds for x86_64. That is just a guideline,
30 # since some scenarios may require higher run times.
31
32 # - Define foo-ARGLIST as a colon separated list of types of the input
33 # arguments. Use `void` if function does not take any inputs. Put in quotes
34 # if the input argument is a pointer, e.g.:
35
36 # malloc-ARGLIST: "void *"
37
38 # - Define foo-RET as the type the function returns. Skip if the function
39 # returns void. One could even skip foo-ARGLIST if the function does not
40 # take any inputs AND the function returns void.
41
42
43 # - Make a file called `foo-inputs` with one input value per line, an input
44 # being a comma separated list of arguments to be passed into the function.
45 # See pow-inputs for an example.
46
47 subdir := benchtests
48 bench := exp pow rint sin cos tan atan modf \
49 slowexp slowpow slowsin slowcos slowtan slowatan
50
51 # exp function fast path: sysdeps/ieee754/dbl-64/e_exp.c
52 exp-ITER = 5e8
53 exp-ARGLIST = double
54 exp-RET = double
55 LDFLAGS-bench-exp = -lm
56
57 # pow function fast path: sysdeps/ieee754/dbl-64/e_pow.c
58 pow-ITER = 2e8
59 pow-ARGLIST = double:double
60 pow-RET = double
61 LDFLAGS-bench-pow = -lm
62
63 rint-ITER = 250000000
64 rint-ARGLIST = double
65 rint-RET = double
66 LDFLAGS-bench-rint = -lm
67
68 # exp function slowest path: sysdeps/ieee754/dbl-64/mpexp.c
69 slowexp-ITER = 3e5
70 slowexp-ARGLIST = double
71 slowexp-RET = double
72 slowexp-INCLUDE = slowexp.c
73 LDFLAGS-bench-slowexp = -lm
74
75 # sin function fast path: sysdeps/ieee754/dbl-64/s_sin.c
76 sin-ITER = 3e9
77 sin-ARGLIST = double
78 sin-RET = double
79 LDFLAGS-bench-sin = -lm
80
81 # cos function fast path: sysdeps/ieee754/dbl-64/s_sin.c
82 cos-ITER = 3e9
83 cos-ARGLIST = double
84 cos-RET = double
85 LDFLAGS-bench-cos = -lm
86
87 # tan function fast path: sysdeps/ieee754/dbl-64/s_tan.c
88 tan-ITER = 3e9
89 tan-ARGLIST = double
90 tan-RET = double
91 LDFLAGS-bench-tan = -lm
92
93 # atan function fast path: sysdeps/ieee754/dbl-64/s_atan.c
94 atan-ITER = 6e9
95 atan-ARGLIST = double
96 atan-RET = double
97 LDFLAGS-bench-atan = -lm
98
99 # pow function slowest path: sysdeps/ieee754/dbl-64/slowpow.c
100 slowpow-ITER = 1e5
101 slowpow-ARGLIST = double:double
102 slowpow-RET = double
103 slowpow-INCLUDE = slowpow.c
104 LDFLAGS-bench-slowpow = -lm
105
106 # sin function slowest path: sysdeps/ieee754/dbl-64/sincos32.c
107 slowsin-ITER = 3e7
108 slowsin-ARGLIST = double
109 slowsin-RET = double
110 slowsin-INCLUDE = slowsin.c
111 LDFLAGS-bench-slowsin = -lm
112
113 # cos function slowest path: sysdeps/ieee754/dbl-64/sincos32.c
114 slowcos-ITER = 3e7
115 slowcos-ARGLIST = double
116 slowcos-RET = double
117 slowcos-INCLUDE = slowcos.c
118 LDFLAGS-bench-slowcos = -lm
119
120 # tan function slowest path: sysdeps/ieee754/dbl-64/mptan.c
121 slowtan-ITER = 3e7
122 slowtan-ARGLIST = double
123 slowtan-RET = double
124 slowtan-INCLUDE = slowtan.c
125 LDFLAGS-bench-slowtan = -lm
126
127 # atan function slowest path: sysdeps/ieee754/dbl-64/mpatan.c
128 slowatan-ITER = 3e8
129 slowatan-ARGLIST = double
130 slowatan-RET = double
131 slowatan-INCLUDE = slowatan.c
132 LDFLAGS-bench-slowatan = -lm
133
134 \f
135
136 # Rules to build and execute the benchmarks. Do not put any benchmark
137 # parameters beyond this point.
138
139 include ../Makeconfig
140 include ../Rules
141
142 binaries-bench := $(addprefix $(objpfx)bench-,$(bench))
143
144 # This makes sure CPPFLAGS-nonlib and CFLAGS-nonlib are passed
145 # for all these modules.
146 cpp-srcs-left := $(binaries-bench:=.c)
147 lib := nonlib
148 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
149
150 bench-deps := bench-skeleton.c Makefile
151
152 run-bench = $(test-wrapper-env) \
153 GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
154 $($*-ENV) $(rtld-prefix) $${run}
155
156 bench-clean:
157 rm -f $(binaries-bench) $(addsuffix .o,$(binaries-bench))
158
159 bench: $(binaries-bench)
160 { for run in $^; do \
161 echo "Running $${run}" >&2; \
162 $(run-bench); \
163 done; } > $(objpfx)bench.out-tmp; \
164 if [ -f $(objpfx)bench.out ]; then \
165 mv -f $(objpfx)bench.out $(objpfx)bench.out.old; \
166 fi; \
167 mv -f $(objpfx)bench.out-tmp $(objpfx)bench.out
168
169 $(binaries-bench): %: %.o \
170 $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
171 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
172 $(+link)
173
174 $(objpfx)bench-%.c: %-inputs $(bench-deps)
175 { if [ -n "$($*-INCLUDE)" ]; then \
176 cat $($*-INCLUDE); \
177 fi; \
178 $(..)scripts/bench.pl $(patsubst %-inputs,%,$<) \
179 $($*-ITER) $($*-ARGLIST) $($*-RET); } > $@-tmp
180 mv -f $@-tmp $@