Prev: code speed moving from fortran 77 compiler to f2003 compiler
Next: Call for benchmarks: proposals by 30 June
From: Richard Maine on 16 Jun 2010 01:41 <robert.corbett(a)oracle.com> wrote: > On Jun 14, 12:40 pm, Thomas Koenig <tkoe...(a)netcologne.de> wrote: > > Hello world, > > > > assume a is a REAL and contains a NaN. > > > > What could > > > > print *, a + 1 - a > > > > output? NaN would (obviously) be OK, but would 1 also permitted? > > > > What if all intrinsic IEEE modules are used? > > If none of the IEEE_* modules are USEd, the expression may be > simplified to the constant 1.0. If all of the IEEE_* modules > are used, the expression still may be simplified to the > constant 1.0. See Fortran standard interpretation F03/00078. It is not clear to me that the cited interp adresses the question of his thread. (I also note that, at least as of the latest version I see, that interp is not yet completely approved; it says it was passed by a J3 letter ballot, but that still leaves WG5 balloting, which has been known to send interps back for rework). The example in the cited interp used literal constants rather than variables. In particular, it asked whether 2.0+2.0 could be evaluated as the mathematically equivalent expression 220.0*(1.0/55.0). Although not explicitly stated in the question, I assume that part of the point is that the latter expression would be expected to do things like raise an inexact flag and get an inexact result. (I didn't check whether the particular case might get lucky in rounding, but the principle holds regardless). The answer (still tentative as noted above) in the interp was, in complete: No, the mathematical equivalence rule is not overridden by USE of the IEEE_ARITHMETIC or IEEE_FEATURES modules. Doing so would prevent many benign and useful compiler optimizations and thus have an unnecessarily deleterious effect on performance. The mathematical equivalence displayed in the example is not a reasonable one, but deciding which mathematical equivalences are reasonable or not is outwith the scope of the standard. Now I agree that this hints at an answer to the question in this thread in saying that the mathematical equivalence rule is not overridden. But it still fails to define what mathematical equivalence is. The only thing "interesting" that I can see about the example in the interp is the possibility of an inexact result, but that is not new at all. Inexact results are at the core of what the whole "floatting point stuff is always approximate" thing that we have had since the first Fortran standard. The answer just says that the IEEE doesn't override that, which I find unsurprsing. (I'd express it something like that IEEE defines the results of individual operations, but it does not define what language syntax translates to what operations; Fortran defines that and has always allowed some transformations.) But because the example in the cited interp used literal constants, it fails to explicitly address the questions raised by NaNs. In particular, it says nothing about whether x-x is mathematically equivalent to 0.0, even when NaNs are a possibility, which is the question at hand. It might be read as hinting at an answer, but I'd call it no more than a hint. I would say that it takes a bigger step of interpretation to go from the cited interp to the question in this thread than it took to go from the standard's words to the cited interp. I certainly would not regard it as definitive on the question. Mind that I'm not saying your answer is wrong. I'd even make it to be a decent guess that a direct interp might get a result that agrees with you. I'm just saying that the cited interp isn't adequate for the purpose and misses the central question. -- Richard Maine | Good judgment comes from experience; email: last name at domain . net | experience comes from bad judgment. domain: summertriangle | -- Mark Twain
From: David Duffy on 16 Jun 2010 02:29 robert.corbett(a)oracle.com wrote: > On Jun 14, 12:40?pm, Thomas Koenig <tkoe...(a)netcologne.de> wrote: >> Hello world, >> >> assume a is a REAL and contains a NaN. >> >> What could >> >> print *, a + 1 - a >> >> output? ?NaN would (obviously) be OK, but would 1 also permitted? >> >> What if all intrinsic IEEE modules are used? > If none of the IEEE_* modules are USEd, the expression may be > simplified to the constant 1.0. If all of the IEEE_* modules > are used, the expression still may be simplified to the > constant 1.0. See Fortran standard interpretation F03/00078. And then? b=a (a+1-b) == (a+1-a)
From: robert.corbett on 16 Jun 2010 23:29 On Jun 15, 11:29 pm, David Duffy <dav...(a)orpheus.qimr.edu.au> wrote: > robert.corb...(a)oracle.com wrote: > > On Jun 14, 12:40?pm, Thomas Koenig <tkoe...(a)netcologne.de> wrote: > >> Hello world, > > >> assume a is a REAL and contains a NaN. > > >> What could > > >> print *, a + 1 - a > > >> output? ?NaN would (obviously) be OK, but would 1 also permitted? > > >> What if all intrinsic IEEE modules are used? > > If none of the IEEE_* modules are USEd, the expression may be > > simplified to the constant 1.0. If all of the IEEE_* modules > > are used, the expression still may be simplified to the > > constant 1.0. See Fortran standard interpretation F03/00078. > > And then? > > b=a > (a+1-b) == (a+1-a)- Hide quoted text - > > - Show quoted text - The mathematical and relational equivalence rules work over single expressions. The assignment statement does not give a processor license to assume that a and b are equal in subsequent expressions for the purposes of the mathematical and relational equivalence rules. Bob Corbett
From: glen herrmannsfeldt on 17 Jun 2010 00:09 robert.corbett(a)oracle.com wrote: (big snip) > The mathematical and relational equivalence rules work over single > expressions. The assignment statement does not give a processor > license to assume that a and b are equal in subsequent expressions > for the purposes of the mathematical and relational equivalence rules. Likely true, but you lose a lot of optimization opportunity if you don't allow it. Well, only for the cases where it can be determined that the appropriate value is still in the variable, and that there is no VOLATILE attribute around. -- glen
From: robert.corbett on 21 Jun 2010 21:22 On Jun 15, 10:41 pm, nos...(a)see.signature (Richard Maine) wrote: > It is not clear to me that the cited interp adresses the question of his > thread. (I also note that, at least as of the latest version I see, that > interp is not yet completely approved; it says it was passed by a J3 > letter ballot, but that still leaves WG5 balloting, which has been known > to send interps back for rework). See paper N1816 on the SC22/WG5 website. Bob Corbett
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: code speed moving from fortran 77 compiler to f2003 compiler Next: Call for benchmarks: proposals by 30 June |