public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Speed up math/test-tgmath2.c
@ 2016-10-25  0:16 Steve Ellcey
  2016-11-04 17:22 ` Steve Ellcey
  0 siblings, 1 reply; 9+ messages in thread
From: Steve Ellcey @ 2016-10-25  0:16 UTC (permalink / raw)
  To: libc-alpha

The test math/test-tgmath2.c takes a long time to compile with newer
versions of GCC due to variable tracking.  There was some discussion a
while back about using -fno-var-tracking on this test but that was not
considered to be the correct solution, it was thought that breaking up
the test into smaller pieces in order to speed up compilation was a
better solution.  Here is a patch that does that.  It does not break it
up into multiple tests but it breaks up the test function into multiple
functions so that there isn't one single giant function that gives the
GCC variable tracking phase a fit.

On a box where the original version takes 18 minutes to compile using a
pre-release GCC 7.0, the modified version compiles in 3 minutes.  GCC
5.4 took about 2.5 minutes on the same machine.

Original discussion:

https://sourceware.org/ml/libc-alpha/2012-10/msg00430.html


Does this seem like a reasonable way to speed up this test?


2016-10-24  Steve Ellcey  <sellcey@caviumnetworks.com>

        * math/test-tgmath2.c: Split up test function.


diff --git a/math/test-tgmath2.c b/math/test-tgmath2.c
index b376fd6..4d828fe 100644
--- a/math/test-tgmath2.c
+++ b/math/test-tgmath2.c
@@ -89,12 +89,6 @@ enum
 int count;
 int counts[Tlast][C_last];
 
-int
-test (const int Vint4, const long long int Vllong4)
-{
-  int result = 0;
-  int quo = 0;
-
 #define FAIL(str) \
   do								\
     {								\
@@ -138,6 +132,11 @@ test (const int Vint4, const long long int Vllong4)
   while (0)
 #define TEST(expr, type, fn) TEST2(expr, type, type, fn)
 
+int
+test_cos (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   TEST (cos (vfloat1), float, cos);
   TEST (cos (vdouble1), double, cos);
   TEST (cos (vldouble1), ldouble, cos);
@@ -155,6 +154,14 @@ test (const int Vint4, const long long int Vllong4)
   TEST (cos (Vcdouble1), cdouble, cos);
   TEST (cos (Vcldouble1), cldouble, cos);
 
+  return result;
+}
+
+int
+test_fabs (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   TEST (fabs (vfloat1), float, fabs);
   TEST (fabs (vdouble1), double, fabs);
   TEST (fabs (vldouble1), ldouble, fabs);
@@ -180,6 +187,13 @@ test (const int Vint4, const long long int Vllong4)
   TEST (fabs (Vcdouble1), double, cabs);
   TEST (fabs (Vcldouble1), ldouble, cabs);
 
+  return result;
+}
+
+int
+test_conj (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
   TEST (conj (vfloat1), cfloat, conj);
   TEST (conj (vdouble1), cdouble, conj);
   TEST (conj (vldouble1), cldouble, conj);
@@ -197,6 +211,14 @@ test (const int Vint4, const long long int Vllong4)
   TEST (conj (Vcdouble1), cdouble, conj);
   TEST (conj (Vcldouble1), cldouble, conj);
 
+  return result;
+}
+
+int
+test_expm1 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   TEST (expm1 (vfloat1), float, expm1);
   TEST (expm1 (vdouble1), double, expm1);
   TEST (expm1 (vldouble1), ldouble, expm1);
@@ -208,6 +230,13 @@ test (const int Vint4, const long long int Vllong4)
   TEST (expm1 (Vint1), double, expm1);
   TEST (expm1 (Vllong1), double, expm1);
 
+  return result;
+}
+
+int
+test_lrint (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
   TEST2 (lrint (vfloat1), float, long int, lrint);
   TEST2 (lrint (vdouble1), double, long int, lrint);
   TEST2 (lrint (vldouble1), ldouble, long int, lrint);
@@ -219,6 +248,14 @@ test (const int Vint4, const long long int Vllong4)
   TEST2 (lrint (Vint1), double, long int, lrint);
   TEST2 (lrint (Vllong1), double, long int, lrint);
 
+  return result;
+}
+
+int
+test_ldexp (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   TEST (ldexp (vfloat1, 6), float, ldexp);
   TEST (ldexp (vdouble1, 6), double, ldexp);
   TEST (ldexp (vldouble1, 6), ldouble, ldexp);
@@ -230,6 +267,9 @@ test (const int Vint4, const long long int Vllong4)
   TEST (ldexp (Vint1, 6), double, ldexp);
   TEST (ldexp (Vllong1, 6), double, ldexp);
 
+  return result;
+}
+
 #define FIRST(x, y) (y, x)
 #define SECOND(x, y) (x, y)
 #define NON_LDBL_TEST(fn, argm, arg, type, fnt) \
@@ -307,25 +347,82 @@ test (const int Vint4, const long long int Vllong4)
   NON_LDBL_CTEST (fn, FIRST, Vcdouble2, cdouble, fnt); \
   NON_LDBL_CTEST (fn, SECOND, Vcdouble2, cdouble, fnt);
 
+int
+test_atan2 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   BINARY_TEST (atan2, atan2);
 
+  return result;
+}
+
+int
+test_remquo (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+  int quo = 0;
+
 #define my_remquo(x, y) remquo (x, y, &quo)
   BINARY_TEST (my_remquo, remquo);
 #undef my_remquo
 
+  return result;
+}
+
+int
+test_pow (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   BINARY_CTEST (pow, pow);
 
-  /* Testing all arguments of fma would be just too expensive,
-     so test just some.  */
+  return result;
+}
+
+/* Testing all arguments of fma would be just too expensive,
+   so test just some.  */
+
+int
+test_fma_1 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
 #define my_fma(x, y) fma (x, y, vfloat3)
   BINARY_TEST (my_fma, fma);
 #undef my_fma
+
+  return result;
+}
+
+int
+test_fma_2 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
 #define my_fma(x, y) fma (x, vfloat3, y)
   BINARY_TEST (my_fma, fma);
 #undef my_fma
+
+  return result;
+}
+
+int
+test_fma_3 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
 #define my_fma(x, y) fma (Vfloat3, x, y)
   BINARY_TEST (my_fma, fma);
 #undef my_fma
+
+  return result;
+}
+
+int
+test_fma_4 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
   TEST (fma (vdouble1, Vdouble2, vllong3), double, fma);
   TEST (fma (vint1, Vint2, vint3), double, fma);
   TEST (fma (Vldouble1, vldouble2, Vldouble3), ldouble, fma);
@@ -337,7 +434,19 @@ test (const int Vint4, const long long int Vllong4)
 static int
 do_test (void)
 {
-  return test (vint1, vllong1);
+  return test_cos (vint1, vllong1)
+	 + test_fabs (vint1, vllong1)
+	 + test_conj (vint1, vllong1)
+	 + test_expm1 (vint1, vllong1)
+	 + test_lrint (vint1, vllong1)
+	 + test_ldexp (vint1, vllong1)
+	 + test_atan2 (vint1, vllong1)
+	 + test_remquo (vint1, vllong1)
+	 + test_pow (vint1, vllong1)
+	 + test_fma_1 (vint1, vllong1)
+	 + test_fma_2 (vint1, vllong1)
+	 + test_fma_3 (vint1, vllong1)
+	 + test_fma_4 (vint1, vllong1);
 }
 
 /* Now generate the three functions.  */

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Speed up math/test-tgmath2.c
  2016-10-25  0:16 [PATCH] Speed up math/test-tgmath2.c Steve Ellcey
@ 2016-11-04 17:22 ` Steve Ellcey
  2016-11-04 17:26   ` Joseph Myers
  0 siblings, 1 reply; 9+ messages in thread
From: Steve Ellcey @ 2016-11-04 17:22 UTC (permalink / raw)
  To: libc-alpha

Ping on this patch to speed up the compilation of math/test-tgmath2.c
when using the latest GCC.

Steve Ellcey
sellcey@caviumnetworks.com


On Mon, 2016-10-24 at 17:15 -0700, Steve Ellcey wrote:
> The test math/test-tgmath2.c takes a long time to compile with newer
> versions of GCC due to variable tracking.  There was some discussion a
> while back about using -fno-var-tracking on this test but that was not
> considered to be the correct solution, it was thought that breaking up
> the test into smaller pieces in order to speed up compilation was a
> better solution.  Here is a patch that does that.  It does not break it
> up into multiple tests but it breaks up the test function into multiple
> functions so that there isn't one single giant function that gives the
> GCC variable tracking phase a fit.
> 
> On a box where the original version takes 18 minutes to compile using a
> pre-release GCC 7.0, the modified version compiles in 3 minutes.  GCC
> 5.4 took about 2.5 minutes on the same machine.
> 
> Original discussion:
> 
> https://sourceware.org/ml/libc-alpha/2012-10/msg00430.html
> 
> 
> Does this seem like a reasonable way to speed up this test?
> 
> 
> 2016-10-24  Steve Ellcey  <sellcey@caviumnetworks.com>
> 
>         * math/test-tgmath2.c: Split up test function.
> 
> 
> diff --git a/math/test-tgmath2.c b/math/test-tgmath2.c
> index b376fd6..4d828fe 100644
> --- a/math/test-tgmath2.c
> +++ b/math/test-tgmath2.c
> @@ -89,12 +89,6 @@ enum
>  int count;
>  int counts[Tlast][C_last];
>  
> -int
> -test (const int Vint4, const long long int Vllong4)
> -{
> -  int result = 0;
> -  int quo = 0;
> -
>  #define FAIL(str) \
>    do								
> \
>      {								
> \
> @@ -138,6 +132,11 @@ test (const int Vint4, const long long int
> Vllong4)
>    while (0)
>  #define TEST(expr, type, fn) TEST2(expr, type, type, fn)
>  
> +int
> +test_cos (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
> +
>    TEST (cos (vfloat1), float, cos);
>    TEST (cos (vdouble1), double, cos);
>    TEST (cos (vldouble1), ldouble, cos);
> @@ -155,6 +154,14 @@ test (const int Vint4, const long long int
> Vllong4)
>    TEST (cos (Vcdouble1), cdouble, cos);
>    TEST (cos (Vcldouble1), cldouble, cos);
>  
> +  return result;
> +}
> +
> +int
> +test_fabs (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
> +
>    TEST (fabs (vfloat1), float, fabs);
>    TEST (fabs (vdouble1), double, fabs);
>    TEST (fabs (vldouble1), ldouble, fabs);
> @@ -180,6 +187,13 @@ test (const int Vint4, const long long int
> Vllong4)
>    TEST (fabs (Vcdouble1), double, cabs);
>    TEST (fabs (Vcldouble1), ldouble, cabs);
>  
> +  return result;
> +}
> +
> +int
> +test_conj (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
>    TEST (conj (vfloat1), cfloat, conj);
>    TEST (conj (vdouble1), cdouble, conj);
>    TEST (conj (vldouble1), cldouble, conj);
> @@ -197,6 +211,14 @@ test (const int Vint4, const long long int
> Vllong4)
>    TEST (conj (Vcdouble1), cdouble, conj);
>    TEST (conj (Vcldouble1), cldouble, conj);
>  
> +  return result;
> +}
> +
> +int
> +test_expm1 (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
> +
>    TEST (expm1 (vfloat1), float, expm1);
>    TEST (expm1 (vdouble1), double, expm1);
>    TEST (expm1 (vldouble1), ldouble, expm1);
> @@ -208,6 +230,13 @@ test (const int Vint4, const long long int
> Vllong4)
>    TEST (expm1 (Vint1), double, expm1);
>    TEST (expm1 (Vllong1), double, expm1);
>  
> +  return result;
> +}
> +
> +int
> +test_lrint (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
>    TEST2 (lrint (vfloat1), float, long int, lrint);
>    TEST2 (lrint (vdouble1), double, long int, lrint);
>    TEST2 (lrint (vldouble1), ldouble, long int, lrint);
> @@ -219,6 +248,14 @@ test (const int Vint4, const long long int
> Vllong4)
>    TEST2 (lrint (Vint1), double, long int, lrint);
>    TEST2 (lrint (Vllong1), double, long int, lrint);
>  
> +  return result;
> +}
> +
> +int
> +test_ldexp (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
> +
>    TEST (ldexp (vfloat1, 6), float, ldexp);
>    TEST (ldexp (vdouble1, 6), double, ldexp);
>    TEST (ldexp (vldouble1, 6), ldouble, ldexp);
> @@ -230,6 +267,9 @@ test (const int Vint4, const long long int
> Vllong4)
>    TEST (ldexp (Vint1, 6), double, ldexp);
>    TEST (ldexp (Vllong1, 6), double, ldexp);
>  
> +  return result;
> +}
> +
>  #define FIRST(x, y) (y, x)
>  #define SECOND(x, y) (x, y)
>  #define NON_LDBL_TEST(fn, argm, arg, type, fnt) \
> @@ -307,25 +347,82 @@ test (const int Vint4, const long long int
> Vllong4)
>    NON_LDBL_CTEST (fn, FIRST, Vcdouble2, cdouble, fnt); \
>    NON_LDBL_CTEST (fn, SECOND, Vcdouble2, cdouble, fnt);
>  
> +int
> +test_atan2 (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
> +
>    BINARY_TEST (atan2, atan2);
>  
> +  return result;
> +}
> +
> +int
> +test_remquo (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
> +  int quo = 0;
> +
>  #define my_remquo(x, y) remquo (x, y, &quo)
>    BINARY_TEST (my_remquo, remquo);
>  #undef my_remquo
>  
> +  return result;
> +}
> +
> +int
> +test_pow (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
> +
>    BINARY_CTEST (pow, pow);
>  
> -  /* Testing all arguments of fma would be just too expensive,
> -     so test just some.  */
> +  return result;
> +}
> +
> +/* Testing all arguments of fma would be just too expensive,
> +   so test just some.  */
> +
> +int
> +test_fma_1 (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
> +
>  #define my_fma(x, y) fma (x, y, vfloat3)
>    BINARY_TEST (my_fma, fma);
>  #undef my_fma
> +
> +  return result;
> +}
> +
> +int
> +test_fma_2 (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
> +
>  #define my_fma(x, y) fma (x, vfloat3, y)
>    BINARY_TEST (my_fma, fma);
>  #undef my_fma
> +
> +  return result;
> +}
> +
> +int
> +test_fma_3 (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
> +
>  #define my_fma(x, y) fma (Vfloat3, x, y)
>    BINARY_TEST (my_fma, fma);
>  #undef my_fma
> +
> +  return result;
> +}
> +
> +int
> +test_fma_4 (const int Vint4, const long long int Vllong4)
> +{
> +  int result = 0;
>    TEST (fma (vdouble1, Vdouble2, vllong3), double, fma);
>    TEST (fma (vint1, Vint2, vint3), double, fma);
>    TEST (fma (Vldouble1, vldouble2, Vldouble3), ldouble, fma);
> @@ -337,7 +434,19 @@ test (const int Vint4, const long long int
> Vllong4)
>  static int
>  do_test (void)
>  {
> -  return test (vint1, vllong1);
> +  return test_cos (vint1, vllong1)
> +	 + test_fabs (vint1, vllong1)
> +	 + test_conj (vint1, vllong1)
> +	 + test_expm1 (vint1, vllong1)
> +	 + test_lrint (vint1, vllong1)
> +	 + test_ldexp (vint1, vllong1)
> +	 + test_atan2 (vint1, vllong1)
> +	 + test_remquo (vint1, vllong1)
> +	 + test_pow (vint1, vllong1)
> +	 + test_fma_1 (vint1, vllong1)
> +	 + test_fma_2 (vint1, vllong1)
> +	 + test_fma_3 (vint1, vllong1)
> +	 + test_fma_4 (vint1, vllong1);
>  }
>  
>  /* Now generate the three functions.  */

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Speed up math/test-tgmath2.c
  2016-11-04 17:22 ` Steve Ellcey
@ 2016-11-04 17:26   ` Joseph Myers
  2016-11-04 18:06     ` Steve Ellcey
  2016-11-04 21:06     ` Steve Ellcey
  0 siblings, 2 replies; 9+ messages in thread
From: Joseph Myers @ 2016-11-04 17:26 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 948 bytes --]

On Fri, 4 Nov 2016, Steve Ellcey wrote:

> > +  return test_cos (vint1, vllong1)
> > +	 + test_fabs (vint1, vllong1)
> > +	 + test_conj (vint1, vllong1)
> > +	 + test_expm1 (vint1, vllong1)
> > +	 + test_lrint (vint1, vllong1)
> > +	 + test_ldexp (vint1, vllong1)
> > +	 + test_atan2 (vint1, vllong1)
> > +	 + test_remquo (vint1, vllong1)
> > +	 + test_pow (vint1, vllong1)
> > +	 + test_fma_1 (vint1, vllong1)
> > +	 + test_fma_2 (vint1, vllong1)
> > +	 + test_fma_3 (vint1, vllong1)
> > +	 + test_fma_4 (vint1, vllong1);

You don't want to add up test results like that; you should OR them 
together instead, to avoid the potential for test results adding up to 77 
and wrongly becoming UNSUPPORTED.  (In this case of course there aren't 
enough tests to get to 77, but the principle applies that you should avoid 
the test return being a count of something.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Speed up math/test-tgmath2.c
  2016-11-04 17:26   ` Joseph Myers
@ 2016-11-04 18:06     ` Steve Ellcey
  2016-11-04 21:22       ` Joseph Myers
  2016-11-04 21:06     ` Steve Ellcey
  1 sibling, 1 reply; 9+ messages in thread
From: Steve Ellcey @ 2016-11-04 18:06 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

On Fri, 2016-11-04 at 17:25 +0000, Joseph Myers wrote:
> On Fri, 4 Nov 2016, Steve Ellcey wrote:
> 
> > 
> > > 
> > > +  return test_cos (vint1, vllong1)
> > > +	 + test_fabs (vint1, vllong1)
> > > +	 + test_conj (vint1, vllong1)
> > > +	 + test_expm1 (vint1, vllong1)
> > > +	 + test_lrint (vint1, vllong1)
> > > +	 + test_ldexp (vint1, vllong1)
> > > +	 + test_atan2 (vint1, vllong1)
> > > +	 + test_remquo (vint1, vllong1)
> > > +	 + test_pow (vint1, vllong1)
> > > +	 + test_fma_1 (vint1, vllong1)
> > > +	 + test_fma_2 (vint1, vllong1)
> > > +	 + test_fma_3 (vint1, vllong1)
> > > +	 + test_fma_4 (vint1, vllong1);
> You don't want to add up test results like that; you should OR them 
> together instead, to avoid the potential for test results adding up
> to 77 and wrongly becoming UNSUPPORTED.  (In this case of course
> there aren't enough tests to get to 77, but the principle applies
> that you should avoid the test return being a count of something.)

I'll fix that and resubmit.  Is there documentation on what do_test
should return?  I looked at test-skeleton.c but there was nothing in
there about what do_test/TEST_FUNCTION should return for different
results (PASS/FAIL/UNSUPPORTED).  I didn't see anything in the Wiki
about return values from do_test either.

Steve Ellcey
sellcey@caviumnetworks.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Speed up math/test-tgmath2.c
  2016-11-04 17:26   ` Joseph Myers
  2016-11-04 18:06     ` Steve Ellcey
@ 2016-11-04 21:06     ` Steve Ellcey
  2016-11-04 21:27       ` Joseph Myers
  1 sibling, 1 reply; 9+ messages in thread
From: Steve Ellcey @ 2016-11-04 21:06 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 1237 bytes --]

On Fri, 2016-11-04 at 17:25 +0000, Joseph Myers wrote:
> On Fri, 4 Nov 2016, Steve Ellcey wrote:
> 
> > 
> > > 
> > > +  return test_cos (vint1, vllong1)
> > > +	 + test_fabs (vint1, vllong1)
> > > +	 + test_conj (vint1, vllong1)
> > > +	 + test_expm1 (vint1, vllong1)
> > > +	 + test_lrint (vint1, vllong1)
> > > +	 + test_ldexp (vint1, vllong1)
> > > +	 + test_atan2 (vint1, vllong1)
> > > +	 + test_remquo (vint1, vllong1)
> > > +	 + test_pow (vint1, vllong1)
> > > +	 + test_fma_1 (vint1, vllong1)
> > > +	 + test_fma_2 (vint1, vllong1)
> > > +	 + test_fma_3 (vint1, vllong1)
> > > +	 + test_fma_4 (vint1, vllong1);
> You don't want to add up test results like that; you should OR them 
> together instead, to avoid the potential for test results adding up
> to 77 
> and wrongly becoming UNSUPPORTED.  (In this case of course there
> aren't 
> enough tests to get to 77, but the principle applies that you should
> avoid 
> the test return being a count of something.)

Here is a modified and retested patch.

Steve Ellcey
sellcey@caviumnetworks.com


2016-11-04  Steve Ellcey  <sellcey@caviumnetworks.com>

	* math/test-tgmath2.c: Split up test function.





[-- Attachment #2: tgmath2.patch --]
[-- Type: text/x-patch, Size: 5399 bytes --]

diff --git a/math/test-tgmath2.c b/math/test-tgmath2.c
index b376fd6..b2cff6b 100644
--- a/math/test-tgmath2.c
+++ b/math/test-tgmath2.c
@@ -89,12 +89,6 @@ enum
 int count;
 int counts[Tlast][C_last];
 
-int
-test (const int Vint4, const long long int Vllong4)
-{
-  int result = 0;
-  int quo = 0;
-
 #define FAIL(str) \
   do								\
     {								\
@@ -138,6 +132,11 @@ test (const int Vint4, const long long int Vllong4)
   while (0)
 #define TEST(expr, type, fn) TEST2(expr, type, type, fn)
 
+int
+test_cos (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   TEST (cos (vfloat1), float, cos);
   TEST (cos (vdouble1), double, cos);
   TEST (cos (vldouble1), ldouble, cos);
@@ -155,6 +154,14 @@ test (const int Vint4, const long long int Vllong4)
   TEST (cos (Vcdouble1), cdouble, cos);
   TEST (cos (Vcldouble1), cldouble, cos);
 
+  return result;
+}
+
+int
+test_fabs (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   TEST (fabs (vfloat1), float, fabs);
   TEST (fabs (vdouble1), double, fabs);
   TEST (fabs (vldouble1), ldouble, fabs);
@@ -180,6 +187,13 @@ test (const int Vint4, const long long int Vllong4)
   TEST (fabs (Vcdouble1), double, cabs);
   TEST (fabs (Vcldouble1), ldouble, cabs);
 
+  return result;
+}
+
+int
+test_conj (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
   TEST (conj (vfloat1), cfloat, conj);
   TEST (conj (vdouble1), cdouble, conj);
   TEST (conj (vldouble1), cldouble, conj);
@@ -197,6 +211,14 @@ test (const int Vint4, const long long int Vllong4)
   TEST (conj (Vcdouble1), cdouble, conj);
   TEST (conj (Vcldouble1), cldouble, conj);
 
+  return result;
+}
+
+int
+test_expm1 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   TEST (expm1 (vfloat1), float, expm1);
   TEST (expm1 (vdouble1), double, expm1);
   TEST (expm1 (vldouble1), ldouble, expm1);
@@ -208,6 +230,13 @@ test (const int Vint4, const long long int Vllong4)
   TEST (expm1 (Vint1), double, expm1);
   TEST (expm1 (Vllong1), double, expm1);
 
+  return result;
+}
+
+int
+test_lrint (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
   TEST2 (lrint (vfloat1), float, long int, lrint);
   TEST2 (lrint (vdouble1), double, long int, lrint);
   TEST2 (lrint (vldouble1), ldouble, long int, lrint);
@@ -219,6 +248,14 @@ test (const int Vint4, const long long int Vllong4)
   TEST2 (lrint (Vint1), double, long int, lrint);
   TEST2 (lrint (Vllong1), double, long int, lrint);
 
+  return result;
+}
+
+int
+test_ldexp (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   TEST (ldexp (vfloat1, 6), float, ldexp);
   TEST (ldexp (vdouble1, 6), double, ldexp);
   TEST (ldexp (vldouble1, 6), ldouble, ldexp);
@@ -230,6 +267,9 @@ test (const int Vint4, const long long int Vllong4)
   TEST (ldexp (Vint1, 6), double, ldexp);
   TEST (ldexp (Vllong1, 6), double, ldexp);
 
+  return result;
+}
+
 #define FIRST(x, y) (y, x)
 #define SECOND(x, y) (x, y)
 #define NON_LDBL_TEST(fn, argm, arg, type, fnt) \
@@ -307,25 +347,82 @@ test (const int Vint4, const long long int Vllong4)
   NON_LDBL_CTEST (fn, FIRST, Vcdouble2, cdouble, fnt); \
   NON_LDBL_CTEST (fn, SECOND, Vcdouble2, cdouble, fnt);
 
+int
+test_atan2 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   BINARY_TEST (atan2, atan2);
 
+  return result;
+}
+
+int
+test_remquo (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+  int quo = 0;
+
 #define my_remquo(x, y) remquo (x, y, &quo)
   BINARY_TEST (my_remquo, remquo);
 #undef my_remquo
 
+  return result;
+}
+
+int
+test_pow (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   BINARY_CTEST (pow, pow);
 
-  /* Testing all arguments of fma would be just too expensive,
-     so test just some.  */
+  return result;
+}
+
+/* Testing all arguments of fma would be just too expensive,
+   so test just some.  */
+
+int
+test_fma_1 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
 #define my_fma(x, y) fma (x, y, vfloat3)
   BINARY_TEST (my_fma, fma);
 #undef my_fma
+
+  return result;
+}
+
+int
+test_fma_2 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
 #define my_fma(x, y) fma (x, vfloat3, y)
   BINARY_TEST (my_fma, fma);
 #undef my_fma
+
+  return result;
+}
+
+int
+test_fma_3 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
 #define my_fma(x, y) fma (Vfloat3, x, y)
   BINARY_TEST (my_fma, fma);
 #undef my_fma
+
+  return result;
+}
+
+int
+test_fma_4 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
   TEST (fma (vdouble1, Vdouble2, vllong3), double, fma);
   TEST (fma (vint1, Vint2, vint3), double, fma);
   TEST (fma (Vldouble1, vldouble2, Vldouble3), ldouble, fma);
@@ -337,7 +434,19 @@ test (const int Vint4, const long long int Vllong4)
 static int
 do_test (void)
 {
-  return test (vint1, vllong1);
+  return test_cos (vint1, vllong1)
+	 | test_fabs (vint1, vllong1)
+	 | test_conj (vint1, vllong1)
+	 | test_expm1 (vint1, vllong1)
+	 | test_lrint (vint1, vllong1)
+	 | test_ldexp (vint1, vllong1)
+	 | test_atan2 (vint1, vllong1)
+	 | test_remquo (vint1, vllong1)
+	 | test_pow (vint1, vllong1)
+	 | test_fma_1 (vint1, vllong1)
+	 | test_fma_2 (vint1, vllong1)
+	 | test_fma_3 (vint1, vllong1)
+	 | test_fma_4 (vint1, vllong1);
 }
 
 /* Now generate the three functions.  */

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Speed up math/test-tgmath2.c
  2016-11-04 18:06     ` Steve Ellcey
@ 2016-11-04 21:22       ` Joseph Myers
  0 siblings, 0 replies; 9+ messages in thread
From: Joseph Myers @ 2016-11-04 21:22 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 363 bytes --]

On Fri, 4 Nov 2016, Steve Ellcey wrote:

> I'll fix that and resubmit.  Is there documentation on what do_test
> should return?  I looked at test-skeleton.c but there was nothing in

0, 1 or 77.  (Any other nonzero value is equivalent to 1 as a FAIL, but 
remember that the shell only gets an 8-bit exit status.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Speed up math/test-tgmath2.c
  2016-11-04 21:06     ` Steve Ellcey
@ 2016-11-04 21:27       ` Joseph Myers
  2016-11-04 22:02         ` Steve Ellcey
  0 siblings, 1 reply; 9+ messages in thread
From: Joseph Myers @ 2016-11-04 21:27 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: libc-alpha

On Fri, 4 Nov 2016, Steve Ellcey wrote:

> Here is a modified and retested patch.

The expression ORing together lots of function call results has 
indeterminate order of evaluation.  While the test should work running the 
test functions in any order, on the whole I think it would be better to 
make the order determinate, by doing

result = test_cos (vint1, vllong1);
result |= test_fabs (vint1, vllong1);

etc.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Speed up math/test-tgmath2.c
  2016-11-04 21:27       ` Joseph Myers
@ 2016-11-04 22:02         ` Steve Ellcey
  2016-11-04 22:06           ` Joseph Myers
  0 siblings, 1 reply; 9+ messages in thread
From: Steve Ellcey @ 2016-11-04 22:02 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 791 bytes --]

On Fri, 2016-11-04 at 21:26 +0000, Joseph Myers wrote:
> On Fri, 4 Nov 2016, Steve Ellcey wrote:
> 
> > 
> > Here is a modified and retested patch.
> The expression ORing together lots of function call results has 
> indeterminate order of evaluation.  While the test should work
> running the 
> test functions in any order, on the whole I think it would be better
> to 
> make the order determinate, by doing
> 
> result = test_cos (vint1, vllong1);
> result |= test_fabs (vint1, vllong1);
> 
> etc.

Having a determinate order of execution would make it easier when
analyzing a failure.  Here is a new version.

Steve Ellcey
sellcey@caviumnetworks.com


2016-11-04  Steve Ellcey  <sellcey@caviumnetworks.com>

	* math/test-tgmath2.c: Split up test function.

[-- Attachment #2: tgmath2.patch --]
[-- Type: text/x-patch, Size: 5546 bytes --]

diff --git a/math/test-tgmath2.c b/math/test-tgmath2.c
index b376fd6..5919159 100644
--- a/math/test-tgmath2.c
+++ b/math/test-tgmath2.c
@@ -89,12 +89,6 @@ enum
 int count;
 int counts[Tlast][C_last];
 
-int
-test (const int Vint4, const long long int Vllong4)
-{
-  int result = 0;
-  int quo = 0;
-
 #define FAIL(str) \
   do								\
     {								\
@@ -138,6 +132,11 @@ test (const int Vint4, const long long int Vllong4)
   while (0)
 #define TEST(expr, type, fn) TEST2(expr, type, type, fn)
 
+int
+test_cos (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   TEST (cos (vfloat1), float, cos);
   TEST (cos (vdouble1), double, cos);
   TEST (cos (vldouble1), ldouble, cos);
@@ -155,6 +154,14 @@ test (const int Vint4, const long long int Vllong4)
   TEST (cos (Vcdouble1), cdouble, cos);
   TEST (cos (Vcldouble1), cldouble, cos);
 
+  return result;
+}
+
+int
+test_fabs (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   TEST (fabs (vfloat1), float, fabs);
   TEST (fabs (vdouble1), double, fabs);
   TEST (fabs (vldouble1), ldouble, fabs);
@@ -180,6 +187,13 @@ test (const int Vint4, const long long int Vllong4)
   TEST (fabs (Vcdouble1), double, cabs);
   TEST (fabs (Vcldouble1), ldouble, cabs);
 
+  return result;
+}
+
+int
+test_conj (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
   TEST (conj (vfloat1), cfloat, conj);
   TEST (conj (vdouble1), cdouble, conj);
   TEST (conj (vldouble1), cldouble, conj);
@@ -197,6 +211,14 @@ test (const int Vint4, const long long int Vllong4)
   TEST (conj (Vcdouble1), cdouble, conj);
   TEST (conj (Vcldouble1), cldouble, conj);
 
+  return result;
+}
+
+int
+test_expm1 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   TEST (expm1 (vfloat1), float, expm1);
   TEST (expm1 (vdouble1), double, expm1);
   TEST (expm1 (vldouble1), ldouble, expm1);
@@ -208,6 +230,13 @@ test (const int Vint4, const long long int Vllong4)
   TEST (expm1 (Vint1), double, expm1);
   TEST (expm1 (Vllong1), double, expm1);
 
+  return result;
+}
+
+int
+test_lrint (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
   TEST2 (lrint (vfloat1), float, long int, lrint);
   TEST2 (lrint (vdouble1), double, long int, lrint);
   TEST2 (lrint (vldouble1), ldouble, long int, lrint);
@@ -219,6 +248,14 @@ test (const int Vint4, const long long int Vllong4)
   TEST2 (lrint (Vint1), double, long int, lrint);
   TEST2 (lrint (Vllong1), double, long int, lrint);
 
+  return result;
+}
+
+int
+test_ldexp (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   TEST (ldexp (vfloat1, 6), float, ldexp);
   TEST (ldexp (vdouble1, 6), double, ldexp);
   TEST (ldexp (vldouble1, 6), ldouble, ldexp);
@@ -230,6 +267,9 @@ test (const int Vint4, const long long int Vllong4)
   TEST (ldexp (Vint1, 6), double, ldexp);
   TEST (ldexp (Vllong1, 6), double, ldexp);
 
+  return result;
+}
+
 #define FIRST(x, y) (y, x)
 #define SECOND(x, y) (x, y)
 #define NON_LDBL_TEST(fn, argm, arg, type, fnt) \
@@ -307,25 +347,82 @@ test (const int Vint4, const long long int Vllong4)
   NON_LDBL_CTEST (fn, FIRST, Vcdouble2, cdouble, fnt); \
   NON_LDBL_CTEST (fn, SECOND, Vcdouble2, cdouble, fnt);
 
+int
+test_atan2 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   BINARY_TEST (atan2, atan2);
 
+  return result;
+}
+
+int
+test_remquo (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+  int quo = 0;
+
 #define my_remquo(x, y) remquo (x, y, &quo)
   BINARY_TEST (my_remquo, remquo);
 #undef my_remquo
 
+  return result;
+}
+
+int
+test_pow (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
   BINARY_CTEST (pow, pow);
 
-  /* Testing all arguments of fma would be just too expensive,
-     so test just some.  */
+  return result;
+}
+
+/* Testing all arguments of fma would be just too expensive,
+   so test just some.  */
+
+int
+test_fma_1 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
 #define my_fma(x, y) fma (x, y, vfloat3)
   BINARY_TEST (my_fma, fma);
 #undef my_fma
+
+  return result;
+}
+
+int
+test_fma_2 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
 #define my_fma(x, y) fma (x, vfloat3, y)
   BINARY_TEST (my_fma, fma);
 #undef my_fma
+
+  return result;
+}
+
+int
+test_fma_3 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
+
 #define my_fma(x, y) fma (Vfloat3, x, y)
   BINARY_TEST (my_fma, fma);
 #undef my_fma
+
+  return result;
+}
+
+int
+test_fma_4 (const int Vint4, const long long int Vllong4)
+{
+  int result = 0;
   TEST (fma (vdouble1, Vdouble2, vllong3), double, fma);
   TEST (fma (vint1, Vint2, vint3), double, fma);
   TEST (fma (Vldouble1, vldouble2, Vldouble3), ldouble, fma);
@@ -337,7 +434,23 @@ test (const int Vint4, const long long int Vllong4)
 static int
 do_test (void)
 {
-  return test (vint1, vllong1);
+  int result;
+
+  result = test_cos (vint1, vllong1);
+  result |= test_fabs (vint1, vllong1);
+  result |= test_conj (vint1, vllong1);
+  result |= test_expm1 (vint1, vllong1);
+  result |= test_lrint (vint1, vllong1);
+  result |= test_ldexp (vint1, vllong1);
+  result |= test_atan2 (vint1, vllong1);
+  result |= test_remquo (vint1, vllong1);
+  result |= test_pow (vint1, vllong1);
+  result |= test_fma_1 (vint1, vllong1);
+  result |= test_fma_2 (vint1, vllong1);
+  result |= test_fma_3 (vint1, vllong1);
+  result |= test_fma_4 (vint1, vllong1);
+
+  return result;
 }
 
 /* Now generate the three functions.  */

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Speed up math/test-tgmath2.c
  2016-11-04 22:02         ` Steve Ellcey
@ 2016-11-04 22:06           ` Joseph Myers
  0 siblings, 0 replies; 9+ messages in thread
From: Joseph Myers @ 2016-11-04 22:06 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 776 bytes --]

On Fri, 4 Nov 2016, Steve Ellcey wrote:

> On Fri, 2016-11-04 at 21:26 +0000, Joseph Myers wrote:
> > On Fri, 4 Nov 2016, Steve Ellcey wrote:
> > 
> > > 
> > > Here is a modified and retested patch.
> > The expression ORing together lots of function call results has 
> > indeterminate order of evaluation.  While the test should work
> > running the 
> > test functions in any order, on the whole I think it would be better
> > to 
> > make the order determinate, by doing
> > 
> > result = test_cos (vint1, vllong1);
> > result |= test_fabs (vint1, vllong1);
> > 
> > etc.
> 
> Having a determinate order of execution would make it easier when
> analyzing a failure.  Here is a new version.

This version is OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-11-04 22:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25  0:16 [PATCH] Speed up math/test-tgmath2.c Steve Ellcey
2016-11-04 17:22 ` Steve Ellcey
2016-11-04 17:26   ` Joseph Myers
2016-11-04 18:06     ` Steve Ellcey
2016-11-04 21:22       ` Joseph Myers
2016-11-04 21:06     ` Steve Ellcey
2016-11-04 21:27       ` Joseph Myers
2016-11-04 22:02         ` Steve Ellcey
2016-11-04 22:06           ` Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).