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]

[COMMITTED] Add convenience target to automatically update ULPs for your machine.


On 04/05/2013 11:14 AM, Carlos O'Donell wrote:
> On 04/05/2013 05:38 AM, Andreas Schwab wrote:
>> "Carlos O'Donell" <carlos@redhat.com> writes:
>>
>>> +         eval $(make-test-out) -u -o $(objpfx); \
>>
>> eval is evil.  Why do you need that?
> 
> No. It's not required. Thanks for noticing.
> 
> I have to rewrite this anyway, I didn't notice $(make-test-out)
> relies upon $^ and that doesn't work here.
> 
> I have to do something similar to what Siddhesh did for `make bench'.

Given that Jaegar and Schwab reviewed this I'm going to commit this
to make our lives easier :-)

v2
- Remove use of evil `eval'.
- Added custom variable to run math tests.
- Rename `regenulps' to `regen-ulps'.
- Updated wiki to mention new instructions.

2013-04-04  Carlos O'Donell  <carlos@redhat.com>

        * Makefile.in (regen-ulps): New target.
        * math/Makefile [ifneq (no,$(PERL)]: Declare regen-ulps with .PHONY.
        [ifneq (no,$(PERL)] (run-regen-ulps): New variable.
        [ifneq (no,$(PERL)] (regen-ulps): New target.
        [ifeq (no,$(PERL)] (regen-ulps): New target.
        * math/libm-test.inc (ulps_file_name): Define.
        (output_dir): New variable.
        (options): Add "output-dir" option.
        (parse_opt): Handle 'o' case.
        (main): If output_dir is non-NULL use it as a prefix
        otherwise use "".

diff --git a/Makefile.in b/Makefile.in
index df75b8f..b120d5f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -14,3 +14,8 @@ install:
 
 bench:
        $(MAKE) -C $(srcdir)/benchtests $(PARALLELMFLAGS) objdir=`pwd` $@
+
+# Convenience target to rebuild ULPs for all math tests.
+regen-ulps:
+       $(MAKE) -C $(srcdir)/math $(PARALLELMFLAGS) objdir=`pwd` $@
+
diff --git a/math/Makefile b/math/Makefile
index f396ba2..ee5b582 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -150,6 +150,33 @@ extra-objs += libieee.a ieee-math.o
 
 include ../Rules
 
+ifneq (no,$(PERL))
+# Run the math programs to automatically generate ULPs files.
+.PHONY: regen-ulps
+
+run-regen-ulps = $(test-wrapper-env) \
+           GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
+           $($*-ENV) $(run-via-rtld-prefix) $${run}
+
+regen-ulps: $(addprefix $(objpfx),$(libm-tests))
+       rm -f $(objpfx)ULPs; rm -f $(objpfx)NewUlps; \
+       cp $(ulps-file) $(objpfx)libm-test-ulps; \
+       for run in $^; do \
+         echo "Regenerating ULPs for $${run}"; \
+         $(run-regen-ulps) -u -o $(objpfx); \
+         cat $(objpfx)ULPs >> $(objpfx)libm-test-ulps; \
+         rm $(objpfx)ULPs; \
+       done; \
+       $(PERL) gen-libm-test.pl -o $(objpfx) -n -u $(objpfx)libm-test-ulps; \
+       echo "Automatic regeneration of ULPs complete."; \
+       echo "Difference between the current baseline and the new baseline is:";\
+       diff -urN $(ulps-file) $(objpfx)NewUlps; \
+       echo "Copy $(objpfx)NewUlps to $(ulps-file) (relative to source)."
+else
+regen-ulps:
+       @echo "Automatic regeneration of ULPs requires perl."; \
+       exit 1;
+endif
 
 # The generated sysd-rules file defines rules like this for sources
 # coming from sysdeps/ directories.  These rules find the generic sources.
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 92fa6a2..78d2107 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -210,8 +210,10 @@
 #define M_PI_LOG10El           M_PIl * M_LOG10El
 #define M_SQRT_2_2             0.70710678118654752440084436210484903L /* sqrt (2) / 2 */
 
-static FILE *ulps_file;        /* File to document difference.  */
-static int output_ulps;        /* Should ulps printed?  */
+#define ulps_file_name "ULPs"  /* Name of the ULPs file.  */
+static FILE *ulps_file;                /* File to document difference.  */
+static int output_ulps;                /* Should ulps printed?  */
+static char *output_dir;       /* Directory where generated files will be written.  */
 
 static int noErrors;   /* number of errors */
 static int noTests;    /* number of tests (without testing exceptions) */
@@ -12985,6 +12987,8 @@ static const struct argp_option options[] =
     "Don't output results of functions invocations"},
   { "ignore-max-ulp", 'i', "yes/no", 0,
     "Ignore given maximal errors"},
+  { "output-dir", 'o', "DIR", 0,
+    "Directory where generated files will be placed"},
   { NULL, 0, NULL, 0, NULL }
 };
 
@@ -13016,6 +13020,13 @@ parse_opt (int key, char *arg, struct argp_state *state)
       else if (strcmp (arg, "no") == 0)
        ignore_max_ulp = 0;
       break;
+    case 'o':
+      output_dir = (char *) malloc (strlen (arg) + 1);
+      if (output_dir != NULL)
+       strcpy (output_dir, arg);
+      else
+        return errno;
+      break;
     case 'p':
       output_points = 0;
       break;
@@ -13065,11 +13076,14 @@ main (int argc, char **argv)
 {
 
   int remaining;
+  char *ulps_file_path;
+  size_t dir_len = 0;
 
   verbose = 1;
   output_ulps = 0;
   output_max_error = 1;
   output_points = 1;
+  output_dir = NULL;
   /* XXX set to 0 for releases.  */
   ignore_max_ulp = 0;
 
@@ -13085,7 +13099,16 @@ main (int argc, char **argv)
 
   if (output_ulps)
     {
-      ulps_file = fopen ("ULPs", "a");
+      if (output_dir != NULL)
+       dir_len = strlen (output_dir);
+      ulps_file_path = (char *) malloc (dir_len + strlen (ulps_file_name) + 1);
+      if (ulps_file_path == NULL)
+        {
+         perror ("can't allocate path for `ULPs' file: ");
+         exit (1);
+        }
+      sprintf (ulps_file_path, "%s%s", output_dir == NULL ? "" : output_dir, ulps_file_name);
+      ulps_file = fopen (ulps_file_path, "a");
       if (ulps_file == NULL)
        {
          perror ("can't open file `ULPs' for writing: ");
---

Cheers,
Carlos.


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