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]

[PATCH 1/3] New make target gen-libm-inputs


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(-)

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
    <http://www.gnu.org/licenses/>.  */
 
-/* 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 <input> <output>");
-  const char *input_filename = argv[1];
-  const char *output_filename = argv[2];
+  if (argc < 3)
+    error (EXIT_FAILURE, 0, "usage: gen-auto-libm-tests <input> [<input> <input> ...] <output>");
+
   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);
 }
-- 
2.5.0


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