From patchwork Fri Dec 11 10:19:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 58267 Delivered-To: patch@linaro.org Received: by 10.112.157.166 with SMTP id wn6csp33174lbb; Fri, 11 Dec 2015 02:19:31 -0800 (PST) X-Received: by 10.66.190.98 with SMTP id gp2mr2488843pac.64.1449829171823; Fri, 11 Dec 2015 02:19:31 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id wh2si343790pac.170.2015.12.11.02.19.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Dec 2015 02:19:31 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-65491-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libc-alpha-return-65491-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-65491-patch=linaro.org@sourceware.org; dkim=pass header.i=@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=nMn676OiEyiJc3dLFmgvk5C3qhnE+ o2eVFGbsM8SAyieY401GQ24y8ZOORP/O8ysdR0YQRxHvP8ZSmf73jVdoYs5d21u/ OD4juIiChghhyGPTuOX1IOB6NnaFViUG0zby+FYC60+6dMJ2OjMbTWZlvM+b6QbB GeI/VHhF09jHu8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=rE/jj1Oj3VWwvMdWpC+pnMtMCNA=; b=Qe9 5A6P3cqOHvwvJI+ybIrOI8zSeCNxTIX7Kh3ViaMLbw4GO2W/kfeWS2q0FDJiLxnI aLPgDOXNTzj0lg8sITEZiH6dzClENPmjI9aDkCIhKjoBGIRQyXASfnnJnzzx0iCh LJgGGOPUM1YyVZ53PAeVGnOveAzUXJFFt43ckdJE= Received: (qmail 51270 invoked by alias); 11 Dec 2015 10:19:22 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 51219 invoked by uid 89); 11 Dec 2015 10:19:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f49.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=EMsWvueCnan6PJoa7lqvmtdU6jEDnCkjhxsypzHH4yk=; b=MA41Hvg6UMfDu6johmKpbUSCRAPcBGPgV1ytrwZDIr86377Ewx7o2FaSNoo5e0z+lL KaQThhHVEF4kKOwFRRMr2r2Q8hxrOWomCHtZG33Ix8aN+O6UqJBgTUMruKbCprgBQLX+ V6yoFQM/EHbe7453PtNEnqBRhOb+Zn1GKjaALZSCnwGKy5yjA0hDSidDQtobCxaWRj7t kmp1uMEXtmhSL+B6X/qyCmwOdtJIVnJklrJGnlm5eBwAWOYufXHmjxzNN6HHkXLhIU3f CNUHC5gxmFZmh8Ztqc85NmtBPVJN4Hp05KezNOXYyZMrrfpXUqIvHCg7yo4SRCUSfe6M YNgA== X-Gm-Message-State: ALoCoQnY1pkQyV4rejrRSB6v8upBsc6CeBOTRvTzJY0r3Fu/IDbJrvflphBNc5XpaGQnPmHeyHEK9TxhqYRO1s27RmB2IRMepA== X-Received: by 10.67.22.99 with SMTP id hr3mr23579316pad.10.1449829157529; Fri, 11 Dec 2015 02:19:17 -0800 (PST) Date: Fri, 11 Dec 2015 15:49:11 +0530 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [PATCH 1/3] New make target gen-libm-inputs Message-ID: <20151211101911.GA2372@linaro-laptop.intra.reserved-bit.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Hi, Create a new target gen-libm-inputs to generate auto-libm-test-out from auto-libm-test-in and a newly generated auto-libm-test-in-benchtests. The latter file is now generated from benchmark inputs in benchtests/*-inputs for all math functions that are included in the benchmarks. This includes a few thousand inputs for each of the functions to the test, effectively testing all paths of the major functions. I discovered the need for this when when patching sincos (patchset coming up soon) where the current test inputs did not catch a bug. Patch 2/3 and 3/3 are regenerated files, the first being regenerated auto-libm-test-out and the other being the x86_64 libm-test-ulps. The ulp update is trivial but the auto-libm-test-out update is massive (136MB), which is why I have left both out and will be pushing as obvious once this patch is approved. Siddhesh * Makefile.in (gen-libm-inputs): New target. * benchtests/Makefile (auto-libm-test-in-benchtests): New target. * math/Makefile (gen-libm-inputs): New target. * math/README.libm-test: Update to include new target. * math/gen-auto-libm-tests.c: Update instructions to run the test inputs generator. (main): Accept multiple input files. --- Makefile.in | 3 +++ benchtests/Makefile | 7 +++++++ math/Makefile | 28 ++++++++++++++++++++++++++++ math/README.libm-test | 13 ++++++++++--- math/gen-auto-libm-tests.c | 32 +++++++++++++++----------------- 5 files changed, 63 insertions(+), 20 deletions(-) -- 2.5.0 diff --git a/Makefile.in b/Makefile.in index 710ce7e..6148495 100644 --- a/Makefile.in +++ b/Makefile.in @@ -18,3 +18,6 @@ bench bench-clean: # Convenience target to rebuild ULPs for all math tests. regen-ulps: $(MAKE) -C $(srcdir)/math $(PARALLELMFLAGS) objdir=`pwd` $@ + +gen-libm-inputs: + $(MAKE) -C $(srcdir)/math $(PARALLELMFLAGS) objdir=`pwd` $@ diff --git a/benchtests/Makefile b/benchtests/Makefile index d6f0b15..2c51c4e 100644 --- a/benchtests/Makefile +++ b/benchtests/Makefile @@ -179,3 +179,10 @@ $(objpfx)bench-%.c: %-inputs $(bench-deps) fi; \ scripts/bench.py $(patsubst %-inputs,%,$<); } > $@-tmp mv -f $@-tmp $@ + +# Auto-generate inputs for libm tests. + +auto-libm-test-in-benchtests: $(..)scripts/gen-libm-test-from-benchtests.awk \ + $(bench-math:%=%-inputs) + $(AWK) -f $^ > $(..)math/$@-tmp + mv -f $(..)math/$@{-tmp,} diff --git a/math/Makefile b/math/Makefile index 0ff3baa..3afc231 100644 --- a/math/Makefile +++ b/math/Makefile @@ -305,3 +305,31 @@ $(objpfx)atest-exp: $(gmp-objs) $(objpfx)atest-sincos: $(gmp-objs) $(objpfx)atest-exp2: $(gmp-objs) $(objpfx)test-fenv-tls: $(shared-thread-library) + +# Generate libm test inputs + +# The input files; auto-libm-test-in is the default and +# auto-libm-test-in-benchtests is auto-generated from all of the input files in +# benchtests. If there are others that need to be separate from these files, +# then mention them here to have them included in generating +# auto-libm-test-out. +auto-libm-test-inputs := auto-libm-test-in auto-libm-test-in-benchtests + +gen-auto-libm-tests-modules := gen-auto-libm-tests + +# Very simple target. We don't really care for any glibc configuration to +# affect this. TODO: add configure check to determine if MPC, MPFR development +# libraries are available. +$(objpfx)gen-auto-libm-tests: $(gen-auto-libm-tests-modules:%=%.c) + $(CC) -o $@ $^ -O2 -std=gnu11 -Wall -Wextra -lmpc -lmpfr -lgmp + +# Don't introduce auto-libm-test-out in the dependency tree because we don't +# want the tests to be regenerated by default. The target system may not have +# gmp, mpfr, etc. installed. +gen-libm-inputs: $(objpfx)gen-auto-libm-tests $(auto-libm-test-inputs) + $^ auto-libm-test-out + +# Auto-generate inputs from the math benchmark inputs. +.PHONY: auto-libm-test-in-benchtests +auto-libm-test-in-benchtests: + $(MAKE) -C $(..)/benchtests $(PARALLELMFLAGS) $@ diff --git a/math/README.libm-test b/math/README.libm-test index 4fa675c..8798b88 100644 --- a/math/README.libm-test +++ b/math/README.libm-test @@ -57,9 +57,16 @@ before it's considered incorrect. The "auto-libm-test-out" file contains sets of test cases to exercise, the conditions under which to exercise each, and the expected results. -The file is generated by the "gen-auto-libm-tests" program from the -"auto-libm-test-in" file. See the comments in gen-auto-libm-tests.c -for details about the content and format of the -in and -out files. +The file is generated by calling make as follows: + + make gen-libm-inputs + +This needs a current version of MPC and MPFR. The default input file +for this is auto-libm-test-in, but there may be additional input files +that the target may read to generate the output. See the Makefile to +know which input files the make target currently reads. See also the +comments in gen-auto-libm-tests.c for details about the content and +format of the -in and -out files. How can I generate "libm-test-ulps"? ==================================== diff --git a/math/gen-auto-libm-tests.c b/math/gen-auto-libm-tests.c index 2b7bb5a..5633680 100644 --- a/math/gen-auto-libm-tests.c +++ b/math/gen-auto-libm-tests.c @@ -16,16 +16,8 @@ License along with the GNU C Library; if not, see . */ -/* Compile this program as: - - gcc -std=gnu11 -O2 -Wall -Wextra gen-auto-libm-tests.c -lmpc -lmpfr -lgmp \ - -o gen-auto-libm-tests - - (use of current MPC and MPFR versions recommended) and run it as: - - gen-auto-libm-tests auto-libm-test-in auto-libm-test-out - - The input file auto-libm-test-in contains three kinds of lines: +/* The input files (auto-libm-test-in auto-libm-test-in-benchtests and others) + contain three kinds of lines: Lines beginning with "#" are comments, and are ignored, as are empty lines. @@ -99,7 +91,7 @@ Bugzilla. The output file auto-libm-test-out contains the test lines from - auto-libm-test-in, and, after the line for a given test, some + all input files, and, after the line for a given test, some number of output test lines. An output test line is of the form "= function rounding-mode format input1 input2 ... : output1 output2 ... : flags". rounding-mode is "tonearest", "towardzero", "upward" @@ -557,7 +549,10 @@ static test_function test_functions[] = FUNC_mpfr_f_f ("log10", mpfr_log10, false), FUNC_mpfr_f_f ("log1p", mpfr_log1p, false), FUNC_mpfr_f_f ("log2", mpfr_log2, false), + FUNC ("modf", ARGS1 (type_fp), RET2 (type_fp, type_fp), false, false, + false, CALC (mpfr_f_11, mpfr_modf)), FUNC_mpfr_ff_f ("pow", mpfr_pow, false), + FUNC_mpfr_f_f ("rint", mpfr_erf, false), FUNC_mpfr_f_f ("sin", mpfr_sin, false), FUNC ("sincos", ARGS1 (type_fp), RET2 (type_fp, type_fp), false, false, false, CALC (mpfr_f_11, mpfr_sin_cos)), @@ -2174,12 +2169,15 @@ generate_output (const char *filename) int main (int argc, char **argv) { - if (argc != 3) - error (EXIT_FAILURE, 0, "usage: gen-auto-libm-tests "); - const char *input_filename = argv[1]; - const char *output_filename = argv[2]; + if (argc < 3) + error (EXIT_FAILURE, 0, "usage: gen-auto-libm-tests [ ...] "); + init_fp_formats (); - read_input (input_filename); - generate_output (output_filename); + + /* Read all input files. */ + for (int i = 1; i < argc - 1; i++) + read_input (argv[i]); + + generate_output (argv[argc - 1]); exit (EXIT_SUCCESS); }