From owner-sc22wg5@open-std.org  Thu Sep 23 16:02:10 2004
Return-Path: <owner-sc22wg5@open-std.org>
X-Original-To: sc22wg5-domo
Delivered-To: sc22wg5-domo@ghz.klid.dk
Received: by ghz.klid.dk (Postfix, from userid 521)
	id 32C3C37608; Thu, 23 Sep 2004 16:02:10 +0200 (CET DST)
X-Original-To: sc22wg5@open-std.org
Delivered-To: sc22wg5@open-std.org
Received: from dkuug.dk (ptah.dkuug.dk [195.215.30.66])
	by ghz.klid.dk (Postfix) with ESMTP id 85D9D37608
	for <sc22wg5@open-std.org>; Thu, 23 Sep 2004 16:02:07 +0200 (CET DST)
Received: from out3.mx.klmz.mi.voyager.net (out3.mx.klmz.mi.voyager.net [207.89.252.198])
	by dkuug.dk (8.12.10/8.9.2) with ESMTP id i8NE08jH091772
	for <sc22wg5@dkuug.dk>; Thu, 23 Sep 2004 16:00:11 +0200 (CEST)
	(envelope-from Craig_Dedo@execpc.com)
Received: from [127.0.0.1] (d19.as14.nwbl1.wi.core.com [169.207.88.19])
	by out3.mx.klmz.mi.voyager.net (Postfix) with ESMTP id DAD4977268;
	Thu, 23 Sep 2004 09:49:39 -0400 (EDT)
Message-ID: <4152D467.9060806@execpc.com>
Date: Thu, 23 Sep 2004 08:49:27 -0500
From: Craig Dedo <Craig_Dedo@execpc.com>
Reply-To: Craig Dedo <Craig_Dedo@execpc.com>
Organization: Elmbrook Computer Services
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax;nscd1)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Bernard Pichon <Bernard.Pichon@obs-nice.fr>
Cc: WG5 <sc22wg5@dkuug.dk>, Alain Noullez <anz@obs-nice.fr>,
	Steve Lionel <Steve.Lionel@intel.com>
Subject: Re: (j3.2004) (SC22WG5.3179) Forwarded message: Re: Why (standard
 conforming OR platform implementation)
References: <20040923083229.F08E437607@ghz.klid.dk>
In-Reply-To: <20040923083229.F08E437607@ghz.klid.dk>
Content-Type: multipart/mixed;
 boundary="------------070006070705000308020908"
X-Spam-Score: 0.609 () HTML_MESSAGE,HTML_TITLE_EMPTY
Sender: owner-sc22wg5@open-std.org
Precedence: bulk

This is a multi-part message in MIME format.
--------------070006070705000308020908
Content-Type: multipart/alternative;
 boundary="------------060607070802030403030109"


--------------060607070802030403030109
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Dear Mr. Pichon:
    Your program is standard conforming.  Unfortunately, you ran into a 
subtlety of the Fortran standard that is not very well known or understood.

    Short answer:  How values are computed is beyond the scope of the 
Fortran standard.

    Details:  Here are the gory details in case you are interested.

    One of the major exclusions from the scope of the Fortran standard 
is how a Fortran processor computes its values.  This is specifically 
excluded in section 1.4.  Here is the relevant text from the Fortran 95 
standard:

[Begin quote from F95 standard]
1.4 Exclusions
This standard does not specify
       . . .
(6) The physical properties of the representation of quantities and the 
method of rounding, approximating, or computing numeric values on a 
particular processor,
[End of quote from F95 standard]

    Thus, each compiler is free to choose its own methods of internal 
representation and how to compute values.  The Fortran compiler on the 
Alpha could do all of its work in single precision and the Fortran 
compiler on the Intel chip could do all of its work using Intel's 80-bit 
internal Floating-Point Unit (FPU) representation.

    That is in fact how things are done on these two platforms, if your 
program declares single-precision variables. 

    The Alpha chip has direct hardware support for both 32-bit and 
64-bit floating-point representations.  Therefore, the Fortran compiler 
for the Alpha chip generates hardware instructions for 32-bit 
floating-point. 

    In contrast, the Fortran compiler for the Intel chip generates the 
usual Intel floating-point instructions and performs the FP operations 
in the Intel FPU.  The Intel FPU only uses Intel's own 80-bit internal 
FPU representation.  When FP values are loaded into the Intel FPU, they 
are converted from their declared size and precision into the Intel 
80-bit internal representation.  When they are stored back into memory, 
they are converted from the Intel 80-bit representation back into their 
original representation.  Thus, on the Intel chip, internal calculations 
always have the greatest possible accuracy. 

    On the Intel chip, whether intermediate calculations are kept 
internal to the FPU registers or are stored back out to memory depends 
on the compiler and its switch settings. 

    To find out the exact details of how a particular compiler performs 
its arithmetic and what precision(s) it uses, you will need to RTFM 
(Read The Fine Manual).   

    This also means that you will need to examine this issue closely if 
you ever move a program from one platform to another.  This caution 
includes any change in these variables:  hardware, operating system, run 
time library, and compiler.  The same vendor can quite legally use one 
method in its Fortran compiler on one system and a different method for 
its Fortran compiler on a different system.  In fact, formerly DEC, 
formerly Compaq, now Intel has done exactly that with their Fortran 
compilers on the Alpha chip (both VMS and Unix) in contrast to the Intel 
chip (DVF --> CVF now IVF).  While I have no inside information, my 
guess is that the reason was what hardware support was available for FP 
operations on the various chips.

    Hope this helps.

John Reid wrote:

> Date: Wed, 22 Sep 2004 14:48:30 -0400
> Message-ID: 
> <6E93844AE9173945878F42EB2DBB51B34B0A1D@hdsmsx402.amr.corp.intel.com>
> X-MS-Has-Attach:
> X-MS-TNEF-Correlator:
> Thread-Topic: Why (standard conforming OR platform implementation)
> Thread-Index: AcSgzs48GIa8BHSkSDmP8Mz7RH0vIQAA6nKg
> From: "Lionel, Steve" <steve.lionel@intel.com>
> To: "Bernard PICHON" <Bernard.Pichon@obs-nice.fr>, <sc22wg5@dkuug.dk>
> Cc: "NOULLEZ, Alain" <anz@obs-nice.fr>
> X-OriginalArrivalTime: 22 Sep 2004 18:48:31.0454 (UTC) 
> FILETIME=[C195AFE0:01C4A0D4]
> X-Scanned-By: MIMEDefang 2.31 (www . roaringpenguin . com / mimedefang)
> X-Spam-Score: 0 ()
>
> The problem you're having is due to the use of the Intel X87 floating
> point registers where calculations involving single precision are
> actually computed in double precision. For performance, intermediate
> computations are kept in the registers as long as possible, which can
> lead to slightly different (though better!) results compared to
> computations that are rounded to single precision.
>
> CVF has a /fltconsistency switch which reduces the effects of this, but
> it does not help with your program.  Intel Fortran offers /Op which does
> help and gives the result you're looking for, though at a penalty in
> performance (as /fltconsistency does with CVF).
>
> The Alpha system is more "traditional" in that computations are always
> carried out in the declared precision.
>
> The Fortran standard is rather vague when it comes to defining the
> numerical results of computation.  It does not even state that 2+2=3D4!
> The CVF behavior is standard-conforming.
>
> Steve Lionel
> Software Products Development
> Intel Corporation
> Nashua, NH=20
>
> -----Original Message-----
> From: Bernard PICHON [mailto:Bernard.Pichon@obs-nice.fr]=20
> Sent: Wednesday, September 22, 2004 2:11 PM
> To: sc22wg5@dkuug.dk
> Cc: NOULLEZ, Alain; Lionel, Steve
> Subject: Why (standard conforming OR platform implementation)
>
> Dear Fortran !
> (expands in : Dear WG5 members, dear Lionel)
>
> This program seems to me standard conforming.
> But I don't understand its (different) behavior
>   between Alpha platforms (with True64) for
>       which the result is OK (for me)
>   and Windows/Intel platforms (with CVF V6.6B)
>       with a (very) strange result (in my opinion).


-- 
----------
Sincerely,
Craig T. Dedo
17130 W. Burleigh Place             Internet:     Craig_Dedo@execpc.com
Brookfield, WI   53005-2759         Voice Phone:  (262) 783-5869
USA                                 Fax Phone:    (262) 783-5928

"They that can give up essential liberty to obtain a little temporary
    safety deserve neither liberty nor safety."  -- Benjamin Franklin
    (1759)


--------------060607070802030403030109
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<big>Dear Mr. Pichon:<br>
&nbsp;&nbsp;&nbsp; Your program is standard conforming.&nbsp; Unfortunately, you ran into a
subtlety of the Fortran standard that is not very well known or
understood.<br>
<br>
&nbsp;&nbsp;&nbsp; Short answer:&nbsp; How values are computed is beyond the scope of the
Fortran standard.<br>
<br>
&nbsp;&nbsp;&nbsp; Details:&nbsp; Here are the gory details in case you are interested.<br>
<br>
&nbsp;&nbsp;&nbsp; One of the major exclusions from the scope of the Fortran standard
is how a Fortran processor computes its values.&nbsp; This is specifically
excluded in section 1.4.&nbsp; Here is the relevant text from the Fortran 95
standard:<br>
<br>
[Begin quote from F95 standard]<br>
1.4 Exclusions<br>
This standard does not specify<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; . . .<br>
(6) The physical properties of the representation of quantities and the
method of rounding, approximating, or computing numeric values on a
particular processor,<br>
</big><big>[End of quote from F95 standard]</big><br>
<big><br>
&nbsp;&nbsp;&nbsp; Thus, each compiler is free to choose its own methods of internal
representation and how to compute values.&nbsp; The Fortran compiler on the
Alpha could do all of its work in single precision and the Fortran
compiler on the Intel chip could do all of its work using Intel's
80-bit internal Floating-Point Unit (FPU) representation.<br>
<br>
&nbsp;&nbsp;&nbsp; That is in fact how things are done on these two platforms, if your
program declares single-precision variables.&nbsp; <br>
<br>
&nbsp;&nbsp;&nbsp; The Alpha chip has direct hardware support for both 32-bit and
64-bit floating-point representations.&nbsp; Therefore, the Fortran compiler
for the Alpha chip generates hardware instructions for 32-bit
floating-point.&nbsp; <br>
<br>
&nbsp;&nbsp;&nbsp; In contrast, the Fortran compiler for the Intel chip generates the
usual Intel floating-point instructions and performs the FP operations
in the Intel FPU.&nbsp; The Intel FPU only uses Intel's own 80-bit internal
FPU representation.&nbsp; When FP values are loaded into the Intel FPU, they
are converted from their declared size and precision into the Intel
80-bit internal representation.&nbsp; When they are stored back into memory,
they are converted from the Intel 80-bit representation back into their
original representation.&nbsp; Thus, on the Intel chip, internal
calculations always have the greatest possible accuracy.&nbsp; <br>
<br>
&nbsp;&nbsp;&nbsp; On the Intel chip, whether intermediate calculations are kept
internal to the FPU registers or are stored back out to memory depends
on the compiler and its switch settings.&nbsp; <br>
<br>
&nbsp;&nbsp;&nbsp; To find out the exact details of how a particular compiler performs
its arithmetic and what precision(s) it uses, you will need to </big><big>RTFM
</big><big>(</big><big>Read The Fine Manual)</big><big>.&nbsp;&nbsp;&nbsp; <br>
<br>
&nbsp;&nbsp;&nbsp; This also means that you will need to examine this issue closely if
you ever move a program from one platform to another.&nbsp; This caution
includes any change in these variables:&nbsp; hardware, operating system,
run time library, and compiler.&nbsp; The same vendor can quite legally use
one method in its Fortran compiler on one system and a different method
for its Fortran compiler on a different system.&nbsp; In fact, formerly DEC,
formerly Compaq, now Intel has done exactly that with their Fortran
compilers on the Alpha chip (both VMS and Unix) in contrast to the
Intel chip (DVF --&gt; CVF now IVF).&nbsp; While I have no inside
information, my guess is that the reason was what hardware support was
available for FP operations on the various chips.<br>
<br>
&nbsp;&nbsp;&nbsp; Hope this helps.<br>
<br>
John Reid wrote:<br>
</big>
<blockquote cite="mid20040923083229.F08E437607@ghz.klid.dk" type="cite"><big>Date:
Wed, 22 Sep 2004 14:48:30 -0400
  <br>
Message-ID:
<a class="moz-txt-link-rfc2396E" href="mailto:6E93844AE9173945878F42EB2DBB51B34B0A1D@hdsmsx402.amr.corp.intel.com">&lt;6E93844AE9173945878F42EB2DBB51B34B0A1D@hdsmsx402.amr.corp.intel.com&gt;</a>
  <br>
X-MS-Has-Attach:
  <br>
X-MS-TNEF-Correlator:
  <br>
Thread-Topic: Why (standard conforming OR platform implementation)
  <br>
Thread-Index: AcSgzs48GIa8BHSkSDmP8Mz7RH0vIQAA6nKg
  <br>
From: "Lionel, Steve" <a class="moz-txt-link-rfc2396E" href="mailto:steve.lionel@intel.com">&lt;steve.lionel@intel.com&gt;</a>
  <br>
To: "Bernard PICHON" <a class="moz-txt-link-rfc2396E" href="mailto:Bernard.Pichon@obs-nice.fr">&lt;Bernard.Pichon@obs-nice.fr&gt;</a>,
<a class="moz-txt-link-rfc2396E" href="mailto:sc22wg5@dkuug.dk">&lt;sc22wg5@dkuug.dk&gt;</a>
  <br>
Cc: "NOULLEZ, Alain" <a class="moz-txt-link-rfc2396E" href="mailto:anz@obs-nice.fr">&lt;anz@obs-nice.fr&gt;</a>
  <br>
X-OriginalArrivalTime: 22 Sep 2004 18:48:31.0454 (UTC)
FILETIME=[C195AFE0:01C4A0D4]
  <br>
X-Scanned-By: MIMEDefang 2.31 (www . roaringpenguin . com / mimedefang)
  <br>
X-Spam-Score: 0 ()
  <br>
  <br>
The problem you're having is due to the use of the Intel X87 floating
  <br>
point registers where calculations involving single precision are
  <br>
actually computed in double precision. For performance, intermediate
  <br>
computations are kept in the registers as long as possible, which can
  <br>
lead to slightly different (though better!) results compared to
  <br>
computations that are rounded to single precision.
  <br>
  <br>
CVF has a /fltconsistency switch which reduces the effects of this, but
  <br>
it does not help with your program.&nbsp; Intel Fortran offers /Op which
does
  <br>
help and gives the result you're looking for, though at a penalty in
  <br>
performance (as /fltconsistency does with CVF).
  <br>
  <br>
The Alpha system is more "traditional" in that computations are always
  <br>
carried out in the declared precision.
  <br>
  <br>
The Fortran standard is rather vague when it comes to defining the
  <br>
numerical results of computation.&nbsp; It does not even state that 2+2=3D4!
  <br>
The CVF behavior is standard-conforming.
  <br>
  <br>
Steve Lionel
  <br>
Software Products Development
  <br>
Intel Corporation
  <br>
Nashua, NH=20
  <br>
  <br>
-----Original Message-----
  <br>
From: Bernard PICHON [<a class="moz-txt-link-freetext" href="mailto:Bernard.Pichon@obs-nice.fr">mailto:Bernard.Pichon@obs-nice.fr</a>]=20
  <br>
Sent: Wednesday, September 22, 2004 2:11 PM
  <br>
To: <a class="moz-txt-link-abbreviated" href="mailto:sc22wg5@dkuug.dk">sc22wg5@dkuug.dk</a>
  <br>
Cc: NOULLEZ, Alain; Lionel, Steve
  <br>
Subject: Why (standard conforming OR platform implementation)
  <br>
  <br>
Dear Fortran !
  <br>
(expands in : Dear WG5 members, dear Lionel)
  <br>
  <br>
This program seems to me standard conforming.
  <br>
But I don't understand its (different) behavior
  <br>
&nbsp; between Alpha platforms (with True64) for
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; which the result is OK (for me)
  <br>
&nbsp; and Windows/Intel platforms (with CVF V6.6B)
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; with a (very) strange result (in my opinion).
  <br>
  </big></blockquote>
<big><br>
</big>
<pre class="moz-signature" cols="75">-- 
----------
Sincerely,
Craig T. Dedo
17130 W. Burleigh Place             Internet:     <a class="moz-txt-link-abbreviated" href="mailto:Craig_Dedo@execpc.com">Craig_Dedo@execpc.com</a>
Brookfield, WI   53005-2759         Voice Phone:  (262) 783-5869
USA                                 Fax Phone:    (262) 783-5928

"They that can give up essential liberty to obtain a little temporary
    safety deserve neither liberty nor safety."  -- Benjamin Franklin
    (1759)
</pre>
</body>
</html>

--------------060607070802030403030109--

--------------070006070705000308020908
Content-Type: text/x-vcard; charset=utf-8;
 name="Craig_Dedo.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="Craig_Dedo.vcf"

begin:vcard
fn:Craig Dedo
n:Dedo;Craig
adr:;;17130 W. Burleigh Place;Brookfield;WI;53005-2759;USA
email;internet:Craig_Dedo@execpc.com
tel;work:(262) 783-5869
tel;fax:(262) 783-5928
tel;home:(262) 783-5869
tel;cell:(414) 412-5869
x-mozilla-html:TRUE
version:2.1
end:vcard


--------------070006070705000308020908--

