<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Floating point model confusion in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1597584#M172136</link>
    <description>&lt;P&gt;I´m comparing the behaviour using ifort and ifx and floating point models fast, precise and source. I cannot relate the observed behaviour to the documentation. The compiler references both for 2023 and 2024.1 claim that "source" is the same as "precise", and there is no special note on any different behaviour between ifort and ifx. The &lt;A href="https://www.intel.com/content/www/us/en/developer/articles/guide/porting-guide-for-ifort-to-ifx.html" target="_self"&gt;ifort to ifx porting guide&lt;/A&gt; however states: "&lt;SPAN class=""&gt;-fp-model=source&lt;/SPAN&gt; (&lt;SPAN class=""&gt;/fp:source&lt;/SPAN&gt;) is not supported because it is equivalent to &lt;SPAN class=""&gt;-fp-model=precise [...]&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;So I made my own little test (with exception handling /fpe:0):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="fortran"&gt;  subroutine test()
    real :: a, b, c
    integer :: i
    a = 1e-10
    b = 1e-11
    i = 0
    do while(.true.)
      i = i + 1
      c = a * b
      if(c .eq. 0.0) exit
      b = b / 1.00001
    enddo

    write (*, '(i8,x,3(g15.8,x))') i, a, b, c
  end subroutine test&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I would have expected that at least with ifort "source" and "precise" give the same result. The table shows the number of iterations until c becomes zero:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uha_0-1715696198340.png" style="width: 400px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/54706i1F9C7E5C1BDB7B0B/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="uha_0-1715696198340.png" alt="uha_0-1715696198340.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So it looks like both compilers treat "source" as "fast" instead of "precise"? If that is the case, do you know if it has always been like that with ifort, or if not, when it started to do that?&lt;/P&gt;</description>
    <pubDate>Tue, 14 May 2024 14:35:26 GMT</pubDate>
    <dc:creator>uha</dc:creator>
    <dc:date>2024-05-14T14:35:26Z</dc:date>
    <item>
      <title>Floating point model confusion</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1597584#M172136</link>
      <description>&lt;P&gt;I´m comparing the behaviour using ifort and ifx and floating point models fast, precise and source. I cannot relate the observed behaviour to the documentation. The compiler references both for 2023 and 2024.1 claim that "source" is the same as "precise", and there is no special note on any different behaviour between ifort and ifx. The &lt;A href="https://www.intel.com/content/www/us/en/developer/articles/guide/porting-guide-for-ifort-to-ifx.html" target="_self"&gt;ifort to ifx porting guide&lt;/A&gt; however states: "&lt;SPAN class=""&gt;-fp-model=source&lt;/SPAN&gt; (&lt;SPAN class=""&gt;/fp:source&lt;/SPAN&gt;) is not supported because it is equivalent to &lt;SPAN class=""&gt;-fp-model=precise [...]&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;So I made my own little test (with exception handling /fpe:0):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="fortran"&gt;  subroutine test()
    real :: a, b, c
    integer :: i
    a = 1e-10
    b = 1e-11
    i = 0
    do while(.true.)
      i = i + 1
      c = a * b
      if(c .eq. 0.0) exit
      b = b / 1.00001
    enddo

    write (*, '(i8,x,3(g15.8,x))') i, a, b, c
  end subroutine test&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I would have expected that at least with ifort "source" and "precise" give the same result. The table shows the number of iterations until c becomes zero:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uha_0-1715696198340.png" style="width: 400px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/54706i1F9C7E5C1BDB7B0B/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="uha_0-1715696198340.png" alt="uha_0-1715696198340.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So it looks like both compilers treat "source" as "fast" instead of "precise"? If that is the case, do you know if it has always been like that with ifort, or if not, when it started to do that?&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 14:35:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1597584#M172136</guid>
      <dc:creator>uha</dc:creator>
      <dc:date>2024-05-14T14:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point model confusion</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1597683#M172144</link>
      <description>&lt;P&gt;I cannot reproduce your numbers.&amp;nbsp; On my system I get 5554341 for both precise and source.&amp;nbsp; This was with v2024.1.0, linux, Fedora 40,&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Intel(R) Core(TM) i5-7600.&amp;nbsp; -O2 and -O2 -xhost&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;When the Porting Guide was written, it was true that source and precise were the same.&amp;nbsp; Now there are some differences in the backend compiler options that they invoke. You can examine all compiler defines and backend options by adding this option&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;-#&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Doing so and diff'ing the results&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;precise&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;-noftz&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;-fp-model precise&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;-fp-modbits no_ftz&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;source&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;-assume protect_parens&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Note that source does not set ftz but adds assum protect_parens.&amp;nbsp; &amp;nbsp;precise passes this option to the backend to prevent value unsafe optimizations, source does not.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;I will ask the Support team to edit the Porting Guide to remove the old information on precise and source&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 23:38:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1597683#M172144</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2024-05-14T23:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point model confusion</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1597687#M172145</link>
      <description>&lt;P&gt;I stand corrected.&amp;nbsp; I spoke to a backend developer for our fp model.&amp;nbsp; Although the driver does pass different options to the backend, the backend processes source as precise.&amp;nbsp; You can confirm by saving binaries from both option cases.&amp;nbsp; You will see that the binaries are identical.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 00:08:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1597687#M172145</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2024-05-15T00:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point model confusion</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1597947#M172151</link>
      <description>&lt;P&gt;Thanks Ron for looking into this. I´m on v2024.1.0, Windows 10, 11th Gen Intel(R) Core(TM) i7-11850H.&lt;/P&gt;&lt;P&gt;I did some more tests using command line builds - I don´t usually do that so bear with me if something is not optimal. These are my builds:&lt;/P&gt;&lt;LI-CODE lang="none"&gt;ifx FpModel.f90 Console1.f90 /O2 /fpe:0 /module:"x64\Release\\" /object:"x64\Release\\" /libs:dll /threads -o "ifx\Console_fpe0_Ftz_fast.exe"
ifx FpModel.f90 Console1.f90 /O2 /fpe:0 /module:"x64\Release\\" /object:"x64\Release\\" /libs:dll /threads /fp:source -o "ifx\Console_fpe0_Ftz_source.exe"
ifx FpModel.f90 Console1.f90 /O2 /fpe:0 /module:"x64\Release\\" /object:"x64\Release\\" /libs:dll /threads /fp:precise -o "ifx\Console_fpe0_Ftz_precise.exe"
ifx FpModel.f90 Console1.f90 /O2 /fpe:0 /module:"x64\Release\\" /object:"x64\Release\\" /libs:dll /threads /Qftz- -o "ifx\Console_fpe0_NoFtz_fast.exe"
ifx FpModel.f90 Console1.f90 /O2 /fpe:0 /module:"x64\Release\\" /object:"x64\Release\\" /libs:dll /threads /fp:source /Qftz- -o "ifx\Console_fpe0_NoFtz_source.exe"
ifx FpModel.f90 Console1.f90 /O2 /fpe:0 /module:"x64\Release\\" /object:"x64\Release\\" /libs:dll /threads /fp:precise /Qftz- -o "ifx\Console_fpe0_NoFtz_precise.exe"&lt;/LI-CODE&gt;&lt;P&gt;My results:&lt;/P&gt;&lt;LI-CODE lang="none"&gt;Console_fpe0_Ftz_fast.exe:     3893013
Console_fpe0_Ftz_source.exe:   3893013
Console_fpe0_Ftz_precise.exe:  5554341
Console_fpe0_NoFtz_fast.exe:   5554341
Console_fpe0_NoFtz_source.exe: 5554341
Console_fpe0_NoFtz_precise.exe:5554341&lt;/LI-CODE&gt;&lt;P&gt;The only 2 that are binary identical are&amp;nbsp;Console_fpe0_NoFtz_fast.exe and Console_fpe0_NoFtz_source.exe.&lt;/P&gt;&lt;P&gt;This _does_ look like "source" and "precise" differ in the ftz setting? Just on Windows maybe?&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 15:18:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1597947#M172151</guid>
      <dc:creator>uha</dc:creator>
      <dc:date>2024-05-15T15:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point model confusion</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1597950#M172152</link>
      <description>&lt;P&gt;I see fpe:0 in your options.&amp;nbsp; That has a dramatic effect on optimizations.&amp;nbsp; Can you remove that option and try again?&lt;/P&gt;
&lt;P&gt;Also, Windows ifx does accept the option&lt;/P&gt;
&lt;P&gt;-#&lt;/P&gt;
&lt;P&gt;to dump all the defines and backend options used by the compiler.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can try this test on my Windows machine as well.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 15:37:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1597950#M172152</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2024-05-15T15:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point model confusion</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1598226#M172168</link>
      <description>&lt;P&gt;I tried with all combinations of source/precise, fpe0/none, and ftz-/none and using the -# switch. In summary these are the relevant settings and the resulting settings to the backend:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uha_0-1715858395773.png" style="width: 400px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/54777iB09B007616AD7F32/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="uha_0-1715858395773.png" alt="uha_0-1715858395773.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;(+: specified, -: not set)&lt;/P&gt;&lt;P&gt;So the only case where source and precise are the same is when you do _not_ set fpe0 and _do_ set ftz, and in this case the executables indeed are binary identical.&lt;/P&gt;&lt;P&gt;So when the docs (or your developer) say "source" and "precise" are the same, does that just refer to the backend, but the front end setting does more than just setting the backend fp-model?&lt;/P&gt;&lt;P&gt;Interesting you say "fpe0" has "dramatic" effects on optimization. We´ve had it like that probably for decades, I doubt there is still anybody around remembering the exact reasoning behind it. Maybe it´s time for a review.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 11:46:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1598226#M172168</guid>
      <dc:creator>uha</dc:creator>
      <dc:date>2024-05-16T11:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point model confusion</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1598640#M172204</link>
      <description>&lt;P&gt;The architect for our FP model is on the C++ team.&amp;nbsp; So he was unfamiliar with our Fortran driver and was indeed speaking of the backend fpmodel.&amp;nbsp; What I wonder is if our Fortran drivers should be setting ftz automatically for precise AND source.&amp;nbsp; I will consult with our Fortran architect and driver developer to see what we should be doing for these 2 fp models with respect to ftz.&amp;nbsp; &amp;nbsp;The question is from a very high level, should "source" expression evaluation preclude flush to zero, or allow flush to zero?&amp;nbsp; "Source" means evaluate the expressions according to the rules of Fortran expression evaluation.&amp;nbsp; Something I will research.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;fpe0 allows floating point exceptions.&amp;nbsp; Without going into great detail on compiler optimizations and design, any time you can have an early exit or exception exit will cause the compiler to avoid certain optimizations.&amp;nbsp; it's complicated to explain all the cases.&amp;nbsp; If you have some familiarity with compiler terminology, there is an optimization called 'basic block reordering' as an example.&amp;nbsp; This optimization is disabled in the presence of fpe0.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, if your application does work with very small numbers, very large numbers, or can create NaNs or underflow/overflow then you do want to enable FP exceptions.&amp;nbsp; And certainly when you are making modifications to the code and want to check for unusual conditions during debug you do want fp exceptions.&amp;nbsp; For production,for a stable code that is unlikely to generate NaNs, underflow or overflow, etc then you probably don't want or need fpe0.&amp;nbsp; But if your code is used by humans prone to error and their faulty input for a run can cause bizarre side effects, I'd want fpe0 and -g -traceback in my application build.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 16:40:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-model-confusion/m-p/1598640#M172204</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2024-05-17T16:40:04Z</dc:date>
    </item>
  </channel>
</rss>

