Topic: switch for 'quad precision'

Before SF, I used lahey Fortran 95 v5.6 (LF95) extensively. With LF95, one can through a switch '-quad', cause a  'double precision'  program to be compiled as a 'quad precision' program. So therefore one can eventually see how the results would change if the computations are done in 'quad precision'.

I think that an option to do this should be eventually included in SF.

Re: switch for 'quad precision'

I think adding the option could make sense.  In the meantime, you can manually add flags to take similar steps.  In the Project Options window, you can open the Compiler Flags tab.  In the Fortran Compiler box, you can enter any of the following flags:

-freal-4-real-8
-freal-4-real-16
-freal-8-real-4
-freal-8-real-16

The above flags would, respectively:

1. Promote single precision (KIND=4) reals to double precision (KIND=8)
2. Promote single precision (KIND=4) reals to quad precision (KIND=16)
3. Demote double precision (KIND=8) reals to single precision (KIND=4)
4. Promote double precision (KIND=8) reals to quad precision (KIND=16)

Jeff Armstrong
Approximatrix, LLC

Re: switch for 'quad precision'

Sorry for dredging up this topic but I too am curious about quad precision.

If I run those compiler options, what about intrinsic functions used in the code like DSQRT, are there quad equivalent calls for these functions that. I don't see quad equivalents explicitly mentioned in the GNU documentation. Also, if using the compiler options like "-freal-8-real-16", will the real*8 intrinsic functions automatically be converted to real*16 (assuming they exist)?

Finally, what performance differences will be observed between double and quad precision can I expect for 32 and 64 bit applications?

Thanks!
Rod

Re: switch for 'quad precision'

Rod,

Generally speaking, I would suggest using the SQRT function rather than specifically calling DSQRT or similar.  The Fortran runtime should detect the input type as quad precision when using SQRT and route it to the appropriate routine.  As the documentation of SQRT says:

The return value is of type REAL or COMPLEX. The kind type parameter is the same as X.

As for speed, I would expect a possible decrease in speed when using quad precision, but I really can't predict how much the effect would be.  I would suggest trying a few simple example to get an idea.

Jeff Armstrong
Approximatrix, LLC

5 (edited by davidb 2015-04-01 17:08:40)

Re: switch for 'quad precision'

I would second what Jeff is saying here. The function SQRT is a generic function and the compiler should automatically do the correct thing when a quad precision argument is passed. Similarly you should use generic versions of the other "maths" functions.

This works with LF95 too if you still want to use it as well.

--
David

Re: switch for 'quad precision'

Thanks guys. I am still learning about the latest from FORTRAN. I  was introduced to FORTRAN 66 (I think it was), so some of this stuff is different from what I learned and old habits die hard.  I will definitely have to make some changes based on these comments. I will also experiment with quad precision and test what the impact is.

Rod