This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH v2] Add math-inline benchmark
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Wilco Dijkstra <wdijkstr at arm dot com>, "'GNU C Library'" <libc-alpha at sourceware dot org>, Siddhesh Poyarekar <siddhesh at redhat dot com>
- Date: Fri, 17 Jul 2015 09:49:42 -0400
- Subject: Re: [PATCH v2] Add math-inline benchmark
- Authentication-results: sourceware.org; auth=none
- References: <002001d0bfb8$b36fa330$1a4ee990$ at com>
On 07/16/2015 07:15 AM, Wilco Dijkstra wrote:
> Add a benchmark for isinf/isnan/isnormal/isfinite/fpclassify. This new version adds explicit tests
> for the GCC built-ins and uses json format as suggested and no longer includes any string headers.
> The test uses 2 arrays with 1024 doubles, one with 99% finite FP numbers (10% zeroes, 10% negative)
> and 1% inf/NaN, the other with 50% inf, and 50% Nan.
> Results shows that using the GCC built-ins in math.h gives huge speedups due to avoiding explict
> calls, PLT indirection to execute a function with 3-4 instructions - around 7x on AArch64 and 2.8x
> on x64. The GCC builtins have better performance than the existing math_private inlines for __isnan,
> __finite and __isinf_ns, so these should be removed.
> 2015-07-16 Wilco Dijkstra <email@example.com>
> * benchtests/Makefile: Add bench-math-inlines, link with libm.
> * benchtests/bench-math-inlines.c: New benchmark.
Looks good to me. One nit below.
> +startup (void)
> + /* This loop should cause CPU to switch to maximal freqency.
> + This makes subsequent measurement more accurate. We need a side effect
> + to prevent the loop being deleted by compiler.
> + This should be enough to cause CPU to speed up and it is simpler than
> + running loop for constant time. This is used when user does not have root
> + access to set a constant freqency. */
> + for (int k = 0; k < 100000000; k++)
> + dontoptimize += 23 * dontoptimize + 2;
This is copied from bench-skeleton.c. Please refactor and avoid duplicating code.
Maybe we can place this in another C file e.g. bench-util.c and #include that
and then call those functions?