* Re: [PATCH, libgfortran]: Fix PR59313, gfortran.dg/erf_3.F90 FAILs
@ 2013-12-01 20:38 FX
2013-12-01 20:51 ` Tobias Burnus
0 siblings, 1 reply; 6+ messages in thread
From: FX @ 2013-12-01 20:38 UTC (permalink / raw)
To: gcc-patches, gfortran, Uros Bizjak
> Currently, gfortran.dg/erf_3.F90 FAILs on targets with 128bit
> (quadruple) long double, since high-precision erfc_scaled_r16 gets
> defined only for __float128 quadruple precision.
I can’t approve it, but yes, it makes more sense than what I did earlier.
FX
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH, libgfortran]: Fix PR59313, gfortran.dg/erf_3.F90 FAILs
2013-12-01 20:38 [PATCH, libgfortran]: Fix PR59313, gfortran.dg/erf_3.F90 FAILs FX
@ 2013-12-01 20:51 ` Tobias Burnus
0 siblings, 0 replies; 6+ messages in thread
From: Tobias Burnus @ 2013-12-01 20:51 UTC (permalink / raw)
To: FX, gcc-patches, gfortran, Uros Bizjak
FX wrote:
> Uros Bizjak wrote:
>> Currently, gfortran.dg/erf_3.F90 FAILs on targets with 128bit
>> (quadruple) long double, since high-precision erfc_scaled_r16 gets
>> defined only for __float128 quadruple precision.
> [...] yes, it makes more sense than what I did earlier.
Looks also good to me. Thanks for the patch!
Tobias
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH, libgfortran]: Fix PR59313, gfortran.dg/erf_3.F90 FAILs
2013-12-05 22:18 ` Tobias Burnus
@ 2013-12-05 22:29 ` Rainer Orth
0 siblings, 0 replies; 6+ messages in thread
From: Rainer Orth @ 2013-12-05 22:29 UTC (permalink / raw)
To: Tobias Burnus; +Cc: Uros Bizjak, gcc-patches, Fortran List
Tobias Burnus <burnus@net-b.de> writes:
> Rainer Orth wrote:
>> Unfortunately, this breaks Solaris/SPARC bootstrap:
>>
>> /vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:64:22: error: 'M_2_SQRTPIl' undeclared (first use in this function)
>> # define _M_2_SQRTPI M_2_SQRTPIl
>>
>> It seems M_2_SQRTPI[lq] are GNU extensions, thus missing in Solaris
>> <math.h>. The following patch at least allows Solaris bootstrap to
>> continue:
>
> The patch is looks good to me.
Thanks. I'll commit it with a proper ChangeLog entry after testing completes.
>> diff --git a/libgfortran/intrinsics/erfc_scaled.c b/libgfortran/intrinsics/erfc_scaled.c
>> +# ifndef M_2_SQRTPIl
>> +# define M_2_SQRTPIl 1.128379167095512573896158903121545172L
>> +# endif
>>
>> I suppose the same should be done for M_2_SQRTPIq?
>
> I don't think so. That's defined in libquadmath's quadmath.h, which is part
> of GCC.
Ah, that explains why I couldn't find the definition even in current git
glibc :-)
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH, libgfortran]: Fix PR59313, gfortran.dg/erf_3.F90 FAILs
2013-12-05 21:30 ` Rainer Orth
@ 2013-12-05 22:18 ` Tobias Burnus
2013-12-05 22:29 ` Rainer Orth
0 siblings, 1 reply; 6+ messages in thread
From: Tobias Burnus @ 2013-12-05 22:18 UTC (permalink / raw)
To: Rainer Orth, Uros Bizjak; +Cc: gcc-patches, Fortran List
Rainer Orth wrote:
> Unfortunately, this breaks Solaris/SPARC bootstrap:
>
> /vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:64:22: error: 'M_2_SQRTPIl' undeclared (first use in this function)
> # define _M_2_SQRTPI M_2_SQRTPIl
>
> It seems M_2_SQRTPI[lq] are GNU extensions, thus missing in Solaris
> <math.h>. The following patch at least allows Solaris bootstrap to
> continue:
The patch is looks good to me.
> diff --git a/libgfortran/intrinsics/erfc_scaled.c b/libgfortran/intrinsics/erfc_scaled.c
> +# ifndef M_2_SQRTPIl
> +# define M_2_SQRTPIl 1.128379167095512573896158903121545172L
> +# endif
>
> I suppose the same should be done for M_2_SQRTPIq?
I don't think so. That's defined in libquadmath's quadmath.h, which is
part of GCC.
Tobias
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH, libgfortran]: Fix PR59313, gfortran.dg/erf_3.F90 FAILs
2013-12-01 19:29 Uros Bizjak
@ 2013-12-05 21:30 ` Rainer Orth
2013-12-05 22:18 ` Tobias Burnus
0 siblings, 1 reply; 6+ messages in thread
From: Rainer Orth @ 2013-12-05 21:30 UTC (permalink / raw)
To: Uros Bizjak; +Cc: gcc-patches, Fortran List
Uros Bizjak <ubizjak@gmail.com> writes:
> Currently, gfortran.dg/erf_3.F90 FAILs on targets with 128bit
> (quadruple) long double, since high-precision erfc_scaled_r16 gets
> defined only for __float128 quadruple precision.
>
> Attached patch defines this function also for 128bit long double targets.
>
> [BTW: The patch really implements what FX's ChangeLog says:
>
> * intrinsics/erfc_scaled_inc.c: Do not provide quadruple
> precision variant.]
>
> 2013-12-01 Uros Bizjak <ubizjak@gmail.com>
>
> PR libfortran/59313
> * intrinsics/erfc_scaled.c (erfc_scaled_r16): Also provide for
> quadruple precision long double variant.
>
> Tested on x86_64-pc-linux-gnu and alphaev68-pc-linux-gnu.
>
> OK for mainline?
Unfortunately, this breaks Solaris/SPARC bootstrap:
/vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c: In function 'erfc_scaled_r16':
/vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:64:22: error: 'M_2_SQRTPIl' undeclared (first use in this function)
# define _M_2_SQRTPI M_2_SQRTPIl
^
/vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:117:31: note: in expansion of macro '_M_2_SQRTPI'
return (1 + sum) / x * (_M_2_SQRTPI / 2);
^
/vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:64:22: note: each undeclared identifier is reported only once for each function it appears in
# define _M_2_SQRTPI M_2_SQRTPIl
^
/vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:117:31: note: in expansion of macro '_M_2_SQRTPI'
return (1 + sum) / x * (_M_2_SQRTPI / 2);
^
/vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:119:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
make[3]: *** [erfc_scaled.lo] Error 1
It seems M_2_SQRTPI[lq] are GNU extensions, thus missing in Solaris
<math.h>. The following patch at least allows Solaris bootstrap to
continue:
diff --git a/libgfortran/intrinsics/erfc_scaled.c b/libgfortran/intrinsics/erfc_scaled.c
--- a/libgfortran/intrinsics/erfc_scaled.c
+++ b/libgfortran/intrinsics/erfc_scaled.c
@@ -61,6 +61,9 @@ see the files COPYING3 and COPYING.RUNTI
#else
# define _THRESH -106.566990228185312813205074546585730L
+# ifndef M_2_SQRTPIl
+# define M_2_SQRTPIl 1.128379167095512573896158903121545172L
+# endif
# define _M_2_SQRTPI M_2_SQRTPIl
# define _INF __builtin_infl()
# ifdef HAVE_ERFCL
I suppose the same should be done for M_2_SQRTPIq?
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH, libgfortran]: Fix PR59313, gfortran.dg/erf_3.F90 FAILs
@ 2013-12-01 19:29 Uros Bizjak
2013-12-05 21:30 ` Rainer Orth
0 siblings, 1 reply; 6+ messages in thread
From: Uros Bizjak @ 2013-12-01 19:29 UTC (permalink / raw)
To: gcc-patches; +Cc: Fortran List
[-- Attachment #1: Type: text/plain, Size: 675 bytes --]
Hello!
Currently, gfortran.dg/erf_3.F90 FAILs on targets with 128bit
(quadruple) long double, since high-precision erfc_scaled_r16 gets
defined only for __float128 quadruple precision.
Attached patch defines this function also for 128bit long double targets.
[BTW: The patch really implements what FX's ChangeLog says:
* intrinsics/erfc_scaled_inc.c: Do not provide quadruple
precision variant.]
2013-12-01 Uros Bizjak <ubizjak@gmail.com>
PR libfortran/59313
* intrinsics/erfc_scaled.c (erfc_scaled_r16): Also provide for
quadruple precision long double variant.
Tested on x86_64-pc-linux-gnu and alphaev68-pc-linux-gnu.
OK for mainline?
Uros.
[-- Attachment #2: f.diff.txt --]
[-- Type: text/plain, Size: 2393 bytes --]
Index: intrinsics/erfc_scaled.c
===================================================================
--- intrinsics/erfc_scaled.c (revision 205539)
+++ intrinsics/erfc_scaled.c (working copy)
@@ -45,33 +45,50 @@ see the files COPYING3 and COPYING.RUNTIME respect
#include "erfc_scaled_inc.c"
#endif
-#if defined(HAVE_GFC_REAL_16) && defined(GFC_REAL_16_IS_LONG_DOUBLE)
-#undef KIND
-#define KIND 16
-#include "erfc_scaled_inc.c"
-#endif
+#ifdef HAVE_GFC_REAL_16
+/* For quadruple-precision, netlib's implementation is
+ not accurate enough. We provide another one. */
#ifdef GFC_REAL_16_IS_FLOAT128
-/* For quadruple-precision (__float128), netlib's implementation is
- not accurate enough. We provide another one. */
+# define _THRESH -106.566990228185312813205074546585730Q
+# define _M_2_SQRTPI M_2_SQRTPIq
+# define _INF __builtin_infq()
+# define _ERFC(x) erfcq(x)
+# define _EXP(x) expq(x)
+#else
+
+# define _THRESH -106.566990228185312813205074546585730L
+# define _M_2_SQRTPI M_2_SQRTPIl
+# define _INF __builtin_infl()
+# ifdef HAVE_ERFCL
+# define _ERFC(x) erfcl(x)
+# endif
+# ifdef HAVE_EXPL
+# define _EXP(x) expl(x)
+# endif
+
+#endif
+
+#if defined(_ERFC) && defined(_EXP)
+
extern GFC_REAL_16 erfc_scaled_r16 (GFC_REAL_16);
export_proto(erfc_scaled_r16);
GFC_REAL_16
erfc_scaled_r16 (GFC_REAL_16 x)
{
- if (x < -106.566990228185312813205074546585730Q)
+ if (x < _THRESH)
{
- return __builtin_infq();
+ return _INF;
}
if (x < 12)
{
/* Compute directly as ERFC_SCALED(x) = ERFC(x) * EXP(X**2).
This is not perfect, but much better than netlib. */
- return erfcq(x) * expq(x * x);
+ return _ERFC(x) * _EXP(x * x);
}
else
{
@@ -97,9 +114,10 @@ erfc_scaled_r16 (GFC_REAL_16 x)
n++;
}
- return (1 + sum) / x * (M_2_SQRTPIq / 2);
+ return (1 + sum) / x * (_M_2_SQRTPI / 2);
}
}
#endif
+#endif
Index: intrinsics/erfc_scaled_inc.c
===================================================================
--- intrinsics/erfc_scaled_inc.c (revision 205539)
+++ intrinsics/erfc_scaled_inc.c (working copy)
@@ -39,7 +39,7 @@ see the files COPYING3 and COPYING.RUNTIME respect
# define EXP(x) exp(x)
# define TRUNC(x) trunc(x)
-#elif (KIND == 10) || (KIND == 16 && defined(GFC_REAL_16_IS_LONG_DOUBLE))
+#elif (KIND == 10)
# ifdef HAVE_EXPL
# define EXP(x) expl(x)
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-12-05 22:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-01 20:38 [PATCH, libgfortran]: Fix PR59313, gfortran.dg/erf_3.F90 FAILs FX
2013-12-01 20:51 ` Tobias Burnus
-- strict thread matches above, loose matches on Subject: below --
2013-12-01 19:29 Uros Bizjak
2013-12-05 21:30 ` Rainer Orth
2013-12-05 22:18 ` Tobias Burnus
2013-12-05 22:29 ` Rainer Orth
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).