<?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 Re: ifort 11 bug with function arguments, loop optimization, an in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ifort-11-bug-with-function-arguments-loop-optimization-and-O3/m-p/759289#M14776</link>
    <description>this bug was fixed in 11.1.064 and greater compilers, including 'Composer XE 2011' versions (aka v12.0)&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;ron&lt;/DIV&gt;</description>
    <pubDate>Mon, 27 Dec 2010 23:19:03 GMT</pubDate>
    <dc:creator>Ron_Green</dc:creator>
    <dc:date>2010-12-27T23:19:03Z</dc:date>
    <item>
      <title>ifort 11 bug with function arguments, loop optimization, and -O3 -ipo</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ifort-11-bug-with-function-arguments-loop-optimization-and-O3/m-p/759285#M14772</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;I believe that I found a bug in ifort 11.0/11.1. As I understood I have to file my bug-report here, since I'm user of a non-commercial license.&lt;BR /&gt;&lt;BR /&gt;The simplest code I could find that reproduces the problem is the following. It is mandatory that compilation was performed with both -O3 and -ipo.&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;[plain]module c_module&lt;BR /&gt;    implicit none&lt;BR /&gt;    integer,parameter :: c(2) = (/0,1/)&lt;BR /&gt;end module c_module&lt;BR /&gt;&lt;BR /&gt;integer(2) function cmp_function(a1,a2)&lt;BR /&gt;    implicit none&lt;BR /&gt;    integer(2) a1,a2&lt;BR /&gt;    cmp_function = int(a1-a2,kind=2)&lt;BR /&gt;end function cmp_function&lt;BR /&gt;&lt;BR /&gt;program bug&lt;BR /&gt;    use c_module&lt;BR /&gt;    use ifport&lt;BR /&gt;    implicit none&lt;BR /&gt;&lt;BR /&gt;    integer,save :: i,j&lt;BR /&gt;    integer,save :: blah(2),blub(2)&lt;BR /&gt;    integer,save :: s(2)&lt;BR /&gt;&lt;BR /&gt;    integer(8),parameter :: len = 10,isize = 2&lt;BR /&gt;    integer(2),save :: array(len)&lt;BR /&gt;    integer(2),external :: cmp_function&lt;BR /&gt;&lt;BR /&gt;    do i=1,2&lt;BR /&gt;       blah = 0&lt;BR /&gt;       blub = 0&lt;BR /&gt;&lt;BR /&gt;       if (blah(1)==blah(2)) then&lt;BR /&gt;          s = 0&lt;BR /&gt;          do j=1,2&lt;BR /&gt;             s = s + c&lt;BR /&gt;          end do&lt;BR /&gt;       end if&lt;BR /&gt;    end do&lt;BR /&gt;    print *,s(2)&lt;BR /&gt;&lt;BR /&gt;    s = 0&lt;BR /&gt;    do j=1,2&lt;BR /&gt;       s = s + c&lt;BR /&gt;    end do&lt;BR /&gt;    print *,s(2)&lt;BR /&gt;&lt;BR /&gt;    array = (/3,4,2,9,8,7,1,6,5,0/)&lt;BR /&gt;    call qsort(array,len,isize,cmp_function)&lt;BR /&gt;    print *,array&lt;BR /&gt;end program bug&lt;BR /&gt;[/plain]&lt;/PRE&gt;
The output of both print statements should be '2' since s is reset to 0 before both j-loops.&lt;BR /&gt;&lt;BR /&gt;However, the first print writes a '1' and this misbehavior depends on funny things (This unfortunately bloats the example code...) like&lt;BR /&gt;
&lt;UL&gt;
&lt;LI&gt;the existence of the assignment blub = 0&lt;/LI&gt;
&lt;LI&gt;the definition of c in a module outside the program&lt;/LI&gt;
&lt;LI&gt;c being a vector&lt;/LI&gt;
&lt;LI&gt;the existence of the qsort call&lt;/LI&gt;
&lt;/UL&gt;
The last point is probably the most interesting. I choose qsort here as an example because it should be available everywhere, is simple, and (hopefully) correct. However, the problem occurred whenever somewhere in the code (even in a never-called module function) there was a call to a subroutine with a function or a subroutine as argument.&lt;BR /&gt;&lt;BR /&gt;Looking at the machine code produced revealed that both additions and loops are all optimized away. Instead the results of both summations were directly mov'ed into some memory location. These constants, however were dependent on whether the subroutine call was commented out or not.&lt;BR /&gt;&lt;BR /&gt;I hope I could help somebody with my report and of course I am curious about when this will be fixed...</description>
      <pubDate>Tue, 22 Sep 2009 15:34:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ifort-11-bug-with-function-arguments-loop-optimization-and-O3/m-p/759285#M14772</guid>
      <dc:creator>Florian_Janoschek</dc:creator>
      <dc:date>2009-09-22T15:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: ifort 11 bug with function arguments, loop optimization, an</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ifort-11-bug-with-function-arguments-loop-optimization-and-O3/m-p/759286#M14773</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;Sounds like a very interesting issue. Thanks for the convenient reproducer. I will investigate and post again with updated information.</description>
      <pubDate>Tue, 22 Sep 2009 15:47:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ifort-11-bug-with-function-arguments-loop-optimization-and-O3/m-p/759286#M14773</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2009-09-22T15:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: ifort 11 bug with function arguments, loop optimization, an</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ifort-11-bug-with-function-arguments-loop-optimization-and-O3/m-p/759287#M14774</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
The bug report is DPD200139988&lt;BR /&gt;&lt;BR /&gt;Kevin asked me to look into this error.&lt;BR /&gt;&lt;BR /&gt;There is an interaction between -O3 and -ipo. I have found several good workarounds. You can use any of the below to avoid the issue. I've sorted this top to bottom, the top being what will probably be the least performance impact, the lower sets are probably higher impact (roughly, hard to tell without the actual code):&lt;BR /&gt;&lt;BR /&gt;-O3 -ipo -no-ansi-alias&lt;BR /&gt;-O2 -ipo&lt;BR /&gt;-O3 -ip&lt;BR /&gt;-O1 &lt;BR /&gt;-O0&lt;BR /&gt;&lt;BR /&gt;I think adding -no-ansi-alias will be the least impact, but it can depend on the real code. I am assuming this example is a much stripped down version of an actual code.&lt;BR /&gt;&lt;BR /&gt;I cannot guarantee when a fix will appear. We just missed an update compiler release, so the next release may be 3 months away. And high-risk fixes that affect the internals of the high-level optimizer and IPO (fixes that impact a lot of code paths) may get rolled up into the next major release which is over a year away.&lt;BR /&gt;&lt;BR /&gt;For the time being, try the first 2 sets of options above. Either of these should balance performance with correct results.&lt;BR /&gt;&lt;BR /&gt;ron&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Sep 2009 19:56:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ifort-11-bug-with-function-arguments-loop-optimization-and-O3/m-p/759287#M14774</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2009-09-22T19:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: ifort 11 bug with function arguments, loop optimization, an</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ifort-11-bug-with-function-arguments-loop-optimization-and-O3/m-p/759288#M14775</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
Thanks for the quick reply and the information about compiler releases!&lt;BR /&gt;&lt;BR /&gt;I actually encountered this issue in an interpolation function that was part of a fluid mechanics simulation code. As you assumed, the first three of the sets of options do not show a significant effect on its performance, so I will probably use "-O3 -ipo -no-ansi-alias" now.&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Sep 2009 10:06:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ifort-11-bug-with-function-arguments-loop-optimization-and-O3/m-p/759288#M14775</guid>
      <dc:creator>Florian_Janoschek</dc:creator>
      <dc:date>2009-09-23T10:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: ifort 11 bug with function arguments, loop optimization, an</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ifort-11-bug-with-function-arguments-loop-optimization-and-O3/m-p/759289#M14776</link>
      <description>this bug was fixed in 11.1.064 and greater compilers, including 'Composer XE 2011' versions (aka v12.0)&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;ron&lt;/DIV&gt;</description>
      <pubDate>Mon, 27 Dec 2010 23:19:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ifort-11-bug-with-function-arguments-loop-optimization-and-O3/m-p/759289#M14776</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2010-12-27T23:19:03Z</dc:date>
    </item>
  </channel>
</rss>

