about summary refs log tree commit diff
path: root/math/gen-auto-libm-tests.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2017-02-06 18:41:20 +0000
committerJoseph Myers <joseph@codesourcery.com>2017-02-06 18:41:20 +0000
commit4f1bc131db81042e8e8d1f829ed18e28d9c56b58 (patch)
tree74c14e29f2928fade2d9f27a664915ee4897ebc2 /math/gen-auto-libm-tests.c
parent5cd81881e221d2943ca41b2da7bb87c0ede3386b (diff)
downloadglibc-4f1bc131db81042e8e8d1f829ed18e28d9c56b58.tar.gz
glibc-4f1bc131db81042e8e8d1f829ed18e28d9c56b58.tar.xz
glibc-4f1bc131db81042e8e8d1f829ed18e28d9c56b58.zip
Split auto-libm-test-out by function.
math/auto-libm-test-out is, at over 30 MB, by far the largest file in
the glibc source tree.  This patch splits it by function, so reducing
it to auto-libm-test-out-<func> files that are all under 5 MB in size.

This is preliminary to splitting up libm-test.inc as well so that each
function's tests can also be processed separately by
gen-libm-test.pl.  As a preliminary patch it doesn't actually
implement that step; rather, all the separate files get concatenated
by the Makefile to produce the monolithic auto-libm-test-out file
again as an input to gen-libm-test.pl.  (The concatentation is
identical to the file in the source tree before this patch.)

Even this preliminary step, however, is of use independent of
splitting up libm-test.inc: some tests for csin and csinh have not
been moved to auto-libm-test-in because they result in
auto-libm-test-out generation taking several minutes rather than a few
seconds (all released MPC versions are very slow for certain sin /
sinh inputs; there are some old improvements in MPC mainline which
should eventually become MPC 1.1, but the complex inverse trig and
hyperbolic functions are slow even in MPC mainline and have yet to be
moved to auto-libm-test-in at all), and it seems much more reasonable
to add such inputs to auto-libm-test-in when it will only slow down
regeneration for particular functions than when it will slow down
regeneration globally.

gen-auto-libm-tests still parses the whole input file, but only
generates output for the requested function.  This ensures bad syntax
in the file is always detected, and parsing the whole file is quick;
it's output generation that is comparatively slow for some functions.

Tested for x86_64.

	* math/gen-auto-libm-tests.c: Update comment about use of program.
	(generate_output): Add argument FUNCTION.
	(main): Require extra argument.  Pass function name to
	generate_output.
	* math/Makefile (generated): Add auto-libm-test-out.
	(libm-test-funcs-auto): New variable.
	(auto-libm-test-out-files): New variable.
	($(objpfx)libm-test.c): Depend on $(auto-libm-test-out-files).
	Concatenate those files to form $(objpfx)auto-libm-test-out and
	use it as input to gen-libm-test.pl.
	* math/README.libm-test: Update.
	* math/auto-libm-test-out: Remove.
	* math/auto-libm-test-out-acos: New generated file.
	* math/auto-libm-test-out-acosh: Likewise.
	* math/auto-libm-test-out-asin: Likewise.
	* math/auto-libm-test-out-asinh: Likewise.
	* math/auto-libm-test-out-atan: Likewise.
	* math/auto-libm-test-out-atan2: Likewise.
	* math/auto-libm-test-out-atanh: Likewise.
	* math/auto-libm-test-out-cabs: Likewise.
	* math/auto-libm-test-out-carg: Likewise.
	* math/auto-libm-test-out-cbrt: Likewise.
	* math/auto-libm-test-out-ccos: Likewise.
	* math/auto-libm-test-out-ccosh: Likewise.
	* math/auto-libm-test-out-cexp: Likewise.
	* math/auto-libm-test-out-clog: Likewise.
	* math/auto-libm-test-out-clog10: Likewise.
	* math/auto-libm-test-out-cos: Likewise.
	* math/auto-libm-test-out-cosh: Likewise.
	* math/auto-libm-test-out-cpow: Likewise.
	* math/auto-libm-test-out-csin: Likewise.
	* math/auto-libm-test-out-csinh: Likewise.
	* math/auto-libm-test-out-csqrt: Likewise.
	* math/auto-libm-test-out-ctan: Likewise.
	* math/auto-libm-test-out-ctanh: Likewise.
	* math/auto-libm-test-out-erf: Likewise.
	* math/auto-libm-test-out-erfc: Likewise.
	* math/auto-libm-test-out-exp: Likewise.
	* math/auto-libm-test-out-exp10: Likewise.
	* math/auto-libm-test-out-exp2: Likewise.
	* math/auto-libm-test-out-expm1: Likewise.
	* math/auto-libm-test-out-fma: Likewise.
	* math/auto-libm-test-out-hypot: Likewise.
	* math/auto-libm-test-out-j0: Likewise.
	* math/auto-libm-test-out-j1: Likewise.
	* math/auto-libm-test-out-jn: Likewise.
	* math/auto-libm-test-out-lgamma: Likewise.
	* math/auto-libm-test-out-log: Likewise.
	* math/auto-libm-test-out-log10: Likewise.
	* math/auto-libm-test-out-log1p: Likewise.
	* math/auto-libm-test-out-log2: Likewise.
	* math/auto-libm-test-out-pow: Likewise.
	* math/auto-libm-test-out-sin: Likewise.
	* math/auto-libm-test-out-sincos: Likewise.
	* math/auto-libm-test-out-sinh: Likewise.
	* math/auto-libm-test-out-sqrt: Likewise.
	* math/auto-libm-test-out-tan: Likewise.
	* math/auto-libm-test-out-tanh: Likewise.
	* math/auto-libm-test-out-tgamma: Likewise.
	* math/auto-libm-test-out-y0: Likewise.
	* math/auto-libm-test-out-y1: Likewise.
	* math/auto-libm-test-out-yn: Likewise.
Diffstat (limited to 'math/gen-auto-libm-tests.c')
-rw-r--r--math/gen-auto-libm-tests.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/math/gen-auto-libm-tests.c b/math/gen-auto-libm-tests.c
index 9f497e019f..cae2f72cb8 100644
--- a/math/gen-auto-libm-tests.c
+++ b/math/gen-auto-libm-tests.c
@@ -23,7 +23,7 @@
 
    (use of current MPC and MPFR versions recommended) and run it as:
 
-   gen-auto-libm-tests auto-libm-test-in auto-libm-test-out
+   gen-auto-libm-tests auto-libm-test-in <func> auto-libm-test-out-<func>
 
    The input file auto-libm-test-in contains three kinds of lines:
 
@@ -98,7 +98,7 @@
    accompanied by a comment referring to an open bug in glibc
    Bugzilla.
 
-   The output file auto-libm-test-out contains the test lines from
+   The output file auto-libm-test-out-<func> contains the test lines from
    auto-libm-test-in, 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
@@ -2158,10 +2158,10 @@ output_for_one_input_case (FILE *fp, const char *filename, test_function *tf,
     generic_value_free (&generic_outputs[i]);
 }
 
-/* Generate test output data to FILENAME.  */
+/* Generate test output data for FUNCTION to FILENAME.  */
 
 static void
-generate_output (const char *filename)
+generate_output (const char *function, const char *filename)
 {
   FILE *fp = fopen (filename, "w");
   if (fp == NULL)
@@ -2169,6 +2169,8 @@ generate_output (const char *filename)
   for (size_t i = 0; i < ARRAY_SIZE (test_functions); i++)
     {
       test_function *tf = &test_functions[i];
+      if (strcmp (tf->name, function) != 0)
+	continue;
       for (size_t j = 0; j < tf->num_tests; j++)
 	{
 	  input_test *it = &tf->tests[j];
@@ -2185,12 +2187,14 @@ 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>");
+  if (argc != 4)
+    error (EXIT_FAILURE, 0,
+	   "usage: gen-auto-libm-tests <input> <func> <output>");
   const char *input_filename = argv[1];
-  const char *output_filename = argv[2];
+  const char *function = argv[2];
+  const char *output_filename = argv[3];
   init_fp_formats ();
   read_input (input_filename);
-  generate_output (output_filename);
+  generate_output (function, output_filename);
   exit (EXIT_SUCCESS);
 }