This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] Add math-inline benchmark


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.
> 
> ChangeLog:
> 2015-07-16  Wilco Dijkstra  <wdijkstr@arm.com>
> 
> 	* benchtests/Makefile: Add bench-math-inlines, link with libm.
> 	* benchtests/bench-math-inlines.c: New benchmark.

Looks good to me. One nit below.

> +void
> +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?

Siddhesh?

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]