tile: switch to using <fenv.h> fallback functions
[glibc.git] / benchtests / README
blob045b7a673d1c8136aa732fa3486b14992cab3e82
1 Using the glibc microbenchmark suite
2 ====================================
4 The glibc microbenchmark suite automatically generates code for specified
5 functions, builds and calls them repeatedly for given inputs to give some
6 basic performance properties of the function.
8 Running the benchmark:
9 =====================
11 The benchmark can be executed by invoking make as follows:
13   $ make bench
15 This runs each function for 10 seconds and appends its output to
16 benchtests/bench.out.  To ensure that the tests are rebuilt, one could run:
18   $ make bench-clean
20 The duration of each test can be configured setting the BENCH_DURATION variable
21 in the call to make.  One should run `make bench-clean' before changing
22 BENCH_DURATION.
24   $ make BENCH_DURATION=1 bench
26 The benchmark suite does function call measurements using architecture-specific
27 high precision timing instructions whenever available.  When such support is
28 not available, it uses clock_gettime (CLOCK_PROCESS_CPUTIME_ID).  One can force
29 the benchmark to use clock_gettime by invoking make as follows:
31   $ make USE_CLOCK_GETTIME=1 bench
33 Again, one must run `make bench-clean' before changing the measurement method.
35 Adding a function to benchtests:
36 ===============================
38 If the name of the function is `foo', then the following procedure should allow
39 one to add `foo' to the bench tests:
41 - Append the function name to the bench variable in the Makefile.
43 - Define foo-ARGLIST as a colon separated list of types of the input
44   arguments.  Use `void' if function does not take any inputs.  Put in quotes
45   if the input argument is a pointer, e.g.:
47      malloc-ARGLIST: "void *"
49 - Define foo-RET as the type the function returns.  Skip if the function
50   returns void.  One could even skip foo-ARGLIST if the function does not
51   take any inputs AND the function returns void.
53 - Make a file called `foo-inputs` with one input value per line, an input
54   being a comma separated list of arguments to be passed into the function.
55   See pow-inputs for an example.
57   The script that parses the -inputs file treats lines beginning with a single
58   `#' as comments.  Lines beginning with two hashes `##' are treated specially
59   as `directives'.
61 Multiple execution units per function:
62 =====================================
64 Some functions have distinct performance characteristics for different input
65 domains and it may be necessary to measure those separately.  For example, some
66 math functions perform computations at different levels of precision (64-bit vs
67 240-bit vs 768-bit) and mixing them does not give a very useful picture of the
68 performance of these functions.  One could separate inputs for these domains in
69 the same file by using the `name' directive that looks something like this:
71   ##name: 240bit
73 See the pow-inputs file for an example of what such a partitioned input file
74 would look like.
76 Benchmark Sets:
77 ==============
79 In addition to standard benchmarking of functions, one may also generate
80 custom outputs for a set of functions.  This is currently used by string
81 function benchmarks where the aim is to compare performance between
82 implementations at various alignments and for various sizes.
84 To add a benchset for `foo':
86 - Add `foo' to the benchset variable.
87 - Write your bench-foo.c that prints out the measurements to stdout.
88 - On execution, a bench-foo.out is created in $(objpfx) with the contents of
89   stdout.