Patchwork RFC patch: Add libquadmath - and use it in gfortran (round two)

login
register
mail settings
Submitter Jerry DeLisle
Date Nov. 9, 2010, 3:28 a.m.
Message ID <4CD8BFEF.1060207@frontier.com>
Download mbox | patch
Permalink /patch/70490/
State New
Headers show

Comments

Jerry DeLisle - Nov. 9, 2010, 3:28 a.m.
On 11/08/2010 06:36 PM, Jack Howarth wrote:
> On Mon, Nov 08, 2010 at 06:20:41PM -0800, Jerry DeLisle wrote:
>> I am currently bootstrapping the patches.  I am curious what these tmp1
>> and tmp2 are about? Also see them on the real128 versions as well.
>>
>> #if defined(GFC_REAL_16_IS_FLOAT128)
>> void
>> transfer_complex128 (st_parameter_dt *dtp, void *p, int kind)
>> {
>>    static void *tmp1 = quadmath_strtopQ;
>>    static void *tmp2 = quadmath_dtoaq;
>>
>>    transfer_complex (dtp, p, kind);
>> }
>>
>>
>> void
>> transfer_complex_write128 (st_parameter_dt *dtp, void *p, int kind)
>> {
>>    static void *tmp1 = quadmath_strtopQ;
>>    static void *tmp2 = quadmath_dtoaq;
>>
>>    transfer_complex (dtp, p, kind);
>> }
>> #endif
>>
>>
>> Jerry
>
> Jerry,
>     With the corrections to libgfortran/transfer.c that I mentioned in...
>
> http://gcc.gnu.org/ml/gcc-patches/2010-11/msg00830.html
>
> the example...
>
> program test_qp
>    implicit none
>    integer, parameter :: QP = 16
>    real(QP), parameter :: Z1 = 1,HALF_PI = asin(Z1),PI = HALF_PI+HALF_PI
>    real(QP) :: x = 0.124_QP
>    print *, x
>    print *, PI
>    print *, 16*atan(0.2_QP)-4*atan(Z1/239)
>    print *, sin(PI)
>    print *, cos(HALF_PI)
>    print *, asinh(PI)
>    print *, erfc(Z1)
>    print *, epsilon(x)
>    print *, precision(x)
>    print *, digits(x)
> end program test_qp
>
> compiles without error and the resulting binary on x86_64-apple-darwin10
> produces the output...
>
>    0.12399999999999999999999999999999999
>     3.1415926535897932384626433832795028
>     3.1415926535897932384626433832795032
>    8.67181013012378102479704402604335225E-0035
>    4.33590506506189051239852201302167613E-0035
>     1.8622957433108482198883613251826206
>    0.15729920705028513065877936491739074
>    1.92592994438723585305597794258492732E-0034
>            33
>           113
>
>               Jack
>

I get this as well:

$ gfc test-qp.f90
$ ./a.out
   0.12399999999999999999999999999999999
    3.1415926535897932384626433832795028
    3.1415926535897932384626433832795032
   8.67181013012378102479704402604335225E-0035
   4.33590506506189051239852201302167613E-0035
    1.8622957433108482198883613251826206
   0.15729920705028513065877936491739074
   1.92592994438723585305597794258492732E-0034
           33
          113

I ended up with the attached diff for transfer.c.

(diff against trunk) Tobias, revert your local transfer.c and apply this one. I 
also tested with some other programs I had done previously and all looks OK. 
Regression testing is on going.

Regards,

Jerry
Jack Howarth - Nov. 9, 2010, 4:04 p.m.
Is anyone else having trouble getting...

make -k check-gfortran RUNTESTFLAGS="--target_board=unix'{-m32,-m64}'"

to work with the libquadmath support? I am finding that while gfortran
can find the libgfortran.spec to compile the test_qp.f90 testcase, the
testsuite run for check-gfortran fails with...

Native configuration is x86_64-apple-darwin10.5.0

		=== gfortran tests ===

Schedule of variations:
    unix/-m32
    unix/-m64

Running target unix/-m32
Using /sw/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /sw/share/dejagnu/config/unix.exp as generic interface file for target.
Using /sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20101109/gcc/testsuite/config/default.exp as tool-and-target-specific interface file.
Running /sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20101109/gcc/testsuite/gfortran.dg/debug/debug.exp ...
gfortran: error: libgfortran.spec: No such file or directory
    while executing
"exec $compiler --print-multi-lib"
    (procedure "gcc-set-multilib-library-path" line 14)
    invoked from within
"gcc-set-multilib-library-path $GFORTRAN_UNDER_TEST"
    (procedure "gfortran_link_flags" line 32)
    invoked from within
"gfortran_link_flags [get_multilibs] "
    invoked from within
"if [info exists TOOL_OPTIONS] {
	    lappend ALWAYS_GFORTRANFLAGS "ldflags=[gfortran_link_flags [get_multilibs ${TOOL_OPTIONS}] ]"
	} else {
	    lapp..."
    invoked from within
"if ![is_remote host] {
	if [info exists TOOL_OPTIONS] {
	    lappend ALWAYS_GFORTRANFLAGS "ldflags=[gfortran_link_flags [get_multilibs ${TOOL_OPTIONS}..."
    (procedure "gfortran_init" line 55)
    invoked from within
"${tool}_init $test_file_name"
    invoked from within
"if [info exists tool] {
	    if { [info procs "${tool}_init"] != "" } {
		${tool}_init $test_file_name
	    }
	}"
    invoked from within
"if [file exists $te
make[1]: [check-parallel-gfortran] Error 1 (ignored)
Jerry DeLisle - Nov. 9, 2010, 4:16 p.m.
On 11/09/2010 08:04 AM, Jack Howarth wrote:
>     Is anyone else having trouble getting...
>
> make -k check-gfortran RUNTESTFLAGS="--target_board=unix'{-m32,-m64}'"
>
> to work with the libquadmath support? I am finding that while gfortran
> can find the libgfortran.spec to compile the test_qp.f90 testcase, the
> testsuite run for check-gfortran fails with...
>
> Native configuration is x86_64-apple-darwin10.5.0
>
> 		=== gfortran tests ===
>
> Schedule of variations:
>      unix/-m32
>      unix/-m64
>
> Running target unix/-m32
> Using /sw/share/dejagnu/baseboards/unix.exp as board description file for target.
> Using /sw/share/dejagnu/config/unix.exp as generic interface file for target.
> Using /sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20101109/gcc/testsuite/config/default.exp as tool-and-target-specific interface file.
> Running /sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20101109/gcc/testsuite/gfortran.dg/debug/debug.exp ...
> gfortran: error: libgfortran.spec: No such file or directory
>      while executing
> "exec $compiler --print-multi-lib"
>      (procedure "gcc-set-multilib-library-path" line 14)
>      invoked from within
> "gcc-set-multilib-library-path $GFORTRAN_UNDER_TEST"
>      (procedure "gfortran_link_flags" line 32)
>      invoked from within
> "gfortran_link_flags [get_multilibs]"
>      invoked from within
> "if [info exists TOOL_OPTIONS] {
> 	    lappend ALWAYS_GFORTRANFLAGS "ldflags=[gfortran_link_flags [get_multilibs ${TOOL_OPTIONS}] ]"
> 	} else {
> 	    lapp..."
>      invoked from within
> "if ![is_remote host] {
> 	if [info exists TOOL_OPTIONS] {
> 	    lappend ALWAYS_GFORTRANFLAGS "ldflags=[gfortran_link_flags [get_multilibs ${TOOL_OPTIONS}..."
>      (procedure "gfortran_init" line 55)
>      invoked from within
> "${tool}_init $test_file_name"
>      invoked from within
> "if [info exists tool] {
> 	    if { [info procs "${tool}_init"] != "" } {
> 		${tool}_init $test_file_name
> 	    }
> 	}"
>      invoked from within
> "if [file exists $te
> make[1]: [check-parallel-gfortran] Error 1 (ignored)
>
>
Yes, Tobias is already on it.

Jerry

Patch

Index: transfer.c
===================================================================
--- transfer.c	(revision 166460)
+++ transfer.c	(working copy)
@@ -56,6 +56,8 @@  see the files COPYING3 and COPYING.RUNTIME respect
       transfer_character_wide
       transfer_real
       transfer_complex
+      transfer_real128
+      transfer_complex128
 
     These subroutines do not return status.
 
@@ -76,6 +78,14 @@  export_proto(transfer_real);
 extern void transfer_real_write (st_parameter_dt *, void *, int);
 export_proto(transfer_real_write);
 
+#if defined(GFC_REAL_16_IS_FLOAT128)
+extern void transfer_real128 (st_parameter_dt *, void *, int);
+export_proto(transfer_real128);
+
+extern void transfer_real_write128 (st_parameter_dt *, void *, int);
+export_proto(transfer_real_write128);
+#endif
+
 extern void transfer_logical (st_parameter_dt *, void *, int);
 export_proto(transfer_logical);
 
@@ -98,6 +108,14 @@  export_proto(transfer_character_wide_write);
 extern void transfer_complex (st_parameter_dt *, void *, int);
 export_proto(transfer_complex);
 
+#if defined(GFC_REAL_16_IS_FLOAT128)
+extern void transfer_complex128 (st_parameter_dt *, void *, int);
+export_proto(transfer_complex128);
+
+extern void transfer_complex_write128 (st_parameter_dt *, void *, int);
+export_proto(transfer_complex_write128);
+#endif
+
 extern void transfer_complex_write (st_parameter_dt *, void *, int);
 export_proto(transfer_complex_write);
 
@@ -1892,7 +1910,25 @@  transfer_real_write (st_parameter_dt *dtp, void *p
   transfer_real (dtp, p, kind);
 }
 
+/* Make sure that libquadmath is pulled in.  */
+
+#if defined(GFC_REAL_16_IS_FLOAT128)
 void
+transfer_real128 (st_parameter_dt *dtp, void *p, int kind)
+{
+  transfer_real (dtp, p, kind);
+}
+
+
+void
+transfer_real_write128 (st_parameter_dt *dtp, void *p, int kind)
+{
+  transfer_real (dtp, p, kind);
+}
+#endif
+
+
+void
 transfer_logical (st_parameter_dt *dtp, void *p, int kind)
 {
   if ((dtp->common.flags & IOPARM_LIBRETURN_MASK) != IOPARM_LIBRETURN_OK)
@@ -1964,13 +2000,33 @@  transfer_complex (st_parameter_dt *dtp, void *p, i
   dtp->u.p.transfer (dtp, BT_COMPLEX, p, kind, size, 1);
 }
 
+
 void
 transfer_complex_write (st_parameter_dt *dtp, void *p, int kind)
 {
   transfer_complex (dtp, p, kind);
 }
 
+
+/* Make sure that libquadmath is pulled in.  */
+
+#if defined(GFC_REAL_16_IS_FLOAT128)
 void
+transfer_complex128 (st_parameter_dt *dtp, void *p, int kind)
+{
+  transfer_complex (dtp, p, kind);
+}
+
+
+void
+transfer_complex_write128 (st_parameter_dt *dtp, void *p, int kind)
+{
+  transfer_complex (dtp, p, kind);
+}
+#endif
+
+
+void
 transfer_array (st_parameter_dt *dtp, gfc_array_char *desc, int kind,
 		gfc_charlen_type charlen)
 {