24th March 1999
Pierre Hugonnet wrote:
> Alois Steindl wrote:
> >
> > Hello,
> > let me give it another try:
> > Pierre Hugonnet wrote:
> > >> On a 64bits machine,
> > >>
> > >> REAL(selected_real_kind(p=6)) :: X
> > >> will select the default REAL (precision=15). So the compiler
> > >> will select the default REAL version of MYSUM. In this version
> > >>
> > >> REAL(selected_real_kind(precision(1.0)+1) :: accu
> > >> will select the available 30digits kind (once again assuming that
> > >> nothing exist between 15 and 30). But my original request for
> > >> X was only 6 digits, so that a 12digits (15 in fact on this machine)
> > >> accumulator would fit. Using the 30digits kind in that case
> > >> will waste a lot of CPU (since these kinds are most of time
> > >> emulated) and memory (not a lot here, for a scalar variable :-)).
> > >>
> >
> > Let us assume that 15 and 30 digits are available.
> >
> > I would think that if your X has 6 digits precision and you want 12
> > digits for the accu, then 15 digits for the accu - and also for X -
> > should be sufficient. Can the result be worse than that by using
> > arrays with less precision?
> >
> > If 15 digits is insufficient, you need to use 30 digits for that
> > machine. What's your point?
> >
>
> THE point is the following: on a 64bit machine where the
> smaller precision kind has 15 digits, both
> REAL(selected_real_kind(6)) :: X6
> REAL(selected_real_kind(12)) :: X12
>
> will select in fact the default REAL with 15 digits. At
> this point it of course not a problem. But since the kinds are
> equal, the compiler will call the same version of MYSUM (say
> MYSUM_SINGLE) for both X6 and X12. So in this routine, what
> should be the precision of accu in MYSUM_SINGLE??
> for CALL MYSUM(X6), a REAL accu (15 digits) is sufficient
> for CALL MYSUM(X12), we need a DOUBLE PRECISION (30 digits) accu
>
> Of course, one can use for both cases a 30 digits accu: it
> works but it is not acceptable when processing X6, to use
> an emulated quad precision where a hardware double precision
> would be sufficient.
As it's a 64-bit machine, it will be using single precision for X6,
with a double-precision intermediate summation. No quadruple precision
is involved.
I think you are confusing with a 32-bit machine.
In the case of a 32-bit machine, only single and double precision would be used
anyway for X6. On a 32-bit machine, for X12, double and quadruple precision
(if available) would be used. And in that case, quad precision is necessary.
> The problem is that in MYSUM_SINGLE you have no way to know
> what was the original requested precision of the actual
> argument (X6 or X12).
Is that a problem? You can distingish the two cases on the number of
arguments.
> Best regards,
> | Pierre Hugonnet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|