This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][benchtests] Use benchmark framework for strtod
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>, libc-alpha at sourceware dot org
- Date: Wed, 04 Dec 2013 09:54:57 -0200
- Subject: Re: [PATCH][benchtests] Use benchmark framework for strtod
- Authentication-results: sourceware.org; auth=none
- References: <20131204074418 dot GP14845 at spoyarek dot pnq dot redhat dot com>
Hi Siddhesh,
With this patch, I'm seeing some compilations errors when issuing 'make bench':
error: expected identifier or â(â before â<â token
struct args { volatile const char * arg0; volatile <char **> arg1;};
^
/home/azanella/glibc/build/glibc64_power7/benchtests/bench-strtod.c:3:67: warning: no semicolon at end of struct or union [enabled by default]
struct args { volatile const char * arg0; volatile <char **> arg1;};
^
./bench-skeleton.c: In function âmainâ:
/home/azanella/glibc/build/glibc64_power7/benchtests/bench-strtod.c:2:81: error: âstruct argsâ has no member named âarg1â
#define CALL_BENCH_FUNC(v, i) strtod ( variants[v].in[i].arg0, variants[v].in[i].arg1);
^
/home/azanella/glibc/build/glibc64_power7/benchtests/bench-strtod.c:75:35: note: in expansion of macro âCALL_BENCH_FUNCâ
#define BENCH_FUNC(i, j) ({ret = CALL_BENCH_FUNC (i, j);})
^
./bench-skeleton.c:77:3: note: in expansion of macro âBENCH_FUNCâ
BENCH_FUNC (v, i);
^
In file included from /home/azanella/glibc/build/glibc64_power7/benchtests/bench-strtod.c:77:0:
./bench-skeleton.c:77:3: warning: passing argument 1 of âstrtodâ discards âvolatileâ qualifier from pointer target type [enabled by default]
In file included from ../include/stdlib.h:10:0,
from /home/azanella/glibc/build/glibc64_power7/benchtests/bench-strtod.c:1:
../stdlib/stdlib.h:164:15: note: expected âconst char * restrictâ but argument is of type âconst volatile char *â
extern double strtod (const char *__restrict __nptr,
^
make[1]: *** [/home/azanella/glibc/build/glibc64_power7/benchtests/bench-strtod.o] Error 1
On 04-12-2013 05:44, Siddhesh Poyarekar wrote:
> Hi,
>
> Currently the strtod benchtest uses the test skeleton. With the
> ability to provide output arguments in place, this can be trivially
> replaced with an input file that has the list of inputs. It currently
> generates a build warning:
>
> In file included from /home/siddhesh/src/upstream/glibc/build/64/benchtests/bench-strtod.c:79:0:
> ./bench-skeleton.c: In function âmainâ:
> ./bench-skeleton.c:77:3: warning: passing argument 1 of âstrtodâ discards âvolatileâ qualifier from pointer target type [enabled by default]
> BENCH_FUNC (v, i);
> ^
> In file included from ../include/stdlib.h:10:0,
> from /home/siddhesh/src/upstream/glibc/build/64/benchtests/bench-strtod.c:1:
> ../stdlib/stdlib.h:164:15: note: expected âconst char * restrictâ but argument is of type âconst volatile char *â
> extern double strtod (const char *__restrict __nptr,
> ^
>
> which I am unable to currently avoid because I need the volatile in
> place to prevent gcc from inlining the math functions. I'll figure
> out a way to fix this warning later if that is OK.
>
> OK to commit?
>
> Siddhesh
>
> * benchtests/bench-strtod.c: Remove file.
> * benchtests/strtod-inputs: New file.
>
> diff --git a/benchtests/bench-strtod.c b/benchtests/bench-strtod.c
> deleted file mode 100644
> index 3a8a65f..0000000
> --- a/benchtests/bench-strtod.c
> +++ /dev/null
> @@ -1,117 +0,0 @@
> -/* Measure strtod implementation.
> - Copyright (C) 2013 Free Software Foundation, Inc.
> - 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
> - <http://www.gnu.org/licenses/>. */
> -
> -#define TEST_MAIN
> -#define TEST_NAME "strtod"
> -
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include "bench-timing.h"
> -
> -#undef INNER_LOOP_ITERS
> -#define INNER_LOOP_ITERS 65536
> -
> -static const char *inputs[] =
> -{
> - "1e308",
> - "100000000e300",
> - "0x1p1023",
> - "0x1000p1011",
> - "0x1p1020",
> - "0x0.00001p1040" "1e-307",
> - "0.000001e-301",
> - "0.0000001e-300",
> - "0.00000001e-299",
> - "1000000e-313",
> - "10000000e-314",
> - "100000000e-315",
> - "0x1p-1021",
> - "0x1000p-1033",
> - "0x10000p-1037",
> - "0x0.001p-1009",
> - "0x0.0001p-1005",
> - "12.345",
> - "12.345e19",
> - "-.1e+9",
> - ".125",
> - "1e20",
> - "0e-19",
> - "4\00012",
> - "5.9e-76",
> - "0x1.4p+3",
> - "0xAp0",
> - "0x0Ap0",
> - "0x0A",
> - "0xA0",
> - "0x0.A0p8",
> - "0x0.50p9",
> - "0x0.28p10",
> - "0x0.14p11",
> - "0x0.0A0p12",
> - "0x0.050p13",
> - "0x0.028p14",
> - "0x0.014p15",
> - "0x00.00A0p16",
> - "0x00.0050p17",
> - "0x00.0028p18",
> - "0x00.0014p19",
> - "0x1p-1023",
> - "0x0.8p-1022",
> - "Inf",
> - "-Inf",
> - "+InFiNiTy",
> - "0x80000Ap-23",
> - "1e-324",
> - "0x100000000000008p0",
> - "0x100000000000008.p0",
> - "0x100000000000008.00p0",
> - "0x10000000000000800p0",
> - "0x10000000000000801p0",
> - NULL
> -};
> -
> -int
> -do_bench (void)
> -{
> - const size_t iters = INNER_LOOP_ITERS;
> - timing_t res __attribute__ ((unused));
> -
> - TIMING_INIT (res);
> -
> - for (size_t i = 0; inputs[i] != NULL; ++i)
> - {
> - char *ep;
> - timing_t start, stop, cur;
> -
> - printf ("Input %-24s:", inputs[i]);
> - TIMING_NOW (start);
> - for (size_t j = 0; j < iters; ++j)
> - strtod (inputs[i], &ep);
> - TIMING_NOW (stop);
> -
> - TIMING_DIFF (cur, start, stop);
> - TIMING_PRINT_MEAN ((double) cur, (double) iters);
> - putchar ('\n');
> - }
> -
> - return 0;
> -}
> -
> -#define TEST_FUNCTION do_bench ()
> -
> -#include "../test-skeleton.c"
> diff --git a/benchtests/strtod-inputs b/benchtests/strtod-inputs
> new file mode 100644
> index 0000000..102b5dd
> --- /dev/null
> +++ b/benchtests/strtod-inputs
> @@ -0,0 +1,57 @@
> +## includes: stdlib.h
> +## args: const char *:<char **>
> +## ret: double
> +"1e308"
> +"100000000e300"
> +"0x1p1023"
> +"0x1000p1011"
> +"0x1p1020"
> +"0x0.00001p1040" "1e-307"
> +"0.000001e-301"
> +"0.0000001e-300"
> +"0.00000001e-299"
> +"1000000e-313"
> +"10000000e-314"
> +"100000000e-315"
> +"0x1p-1021"
> +"0x1000p-1033"
> +"0x10000p-1037"
> +"0x0.001p-1009"
> +"0x0.0001p-1005"
> +"12.345"
> +"12.345e19"
> +"-.1e+9"
> +".125"
> +"1e20"
> +"0e-19"
> +"4\00012"
> +"5.9e-76"
> +"0x1.4p+3"
> +"0xAp0"
> +"0x0Ap0"
> +"0x0A"
> +"0xA0"
> +"0x0.A0p8"
> +"0x0.50p9"
> +"0x0.28p10"
> +"0x0.14p11"
> +"0x0.0A0p12"
> +"0x0.050p13"
> +"0x0.028p14"
> +"0x0.014p15"
> +"0x00.00A0p16"
> +"0x00.0050p17"
> +"0x00.0028p18"
> +"0x00.0014p19"
> +"0x1p-1023"
> +"0x0.8p-1022"
> +"Inf"
> +"-Inf"
> +"+InFiNiTy"
> +"0x80000Ap-23"
> +"1e-324"
> +"0x100000000000008p0"
> +"0x100000000000008.p0"
> +"0x100000000000008.00p0"
> +"0x10000000000000800p0"
> +"0x10000000000000801p0"
>