<?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 What is being done can be in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/In-OpenMP-if-I-didn-t-initialize-an-array-the-result-will-be/m-p/974417#M97944</link>
    <description>What is being done can be called elimination of dead code. Dead code historically has been defined as code in program that could never run (no flow into section of code). Intel (and others) have expanded the scope of the dead code elimination process to include computational results never used (and the code that produced the unused results). There may be an Intel internal definition (name) of this process.

Users typically run into this situation when they construct a synthetic benchmark that fills in a results array that is not subsequently used, then report exceptionally good scaling of their code. Only to be embarrassed later when someone points out the folly of the test.

Jim Dempsey
(I forgot to sign the earlier post)</description>
    <pubDate>Tue, 18 Dec 2012 14:07:03 GMT</pubDate>
    <dc:creator>jimdempseyatthecove</dc:creator>
    <dc:date>2012-12-18T14:07:03Z</dc:date>
    <item>
      <title>In OpenMP, if I didn't initialize an array, the result will be wrong.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/In-OpenMP-if-I-didn-t-initialize-an-array-the-result-will-be/m-p/974414#M97941</link>
      <description>&lt;P&gt;First the code. Througn judging a large number a prime, I test the OpenMP Parallel.&lt;/P&gt;
&lt;P&gt;[fortran]&lt;/P&gt;
&lt;P&gt;program main&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; use portlib&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; implicit none&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer :: i, j&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer :: x(10000) = 0&amp;nbsp; ! #1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer :: a(10000) = (/(i,i=100000001,100010000)/)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; real :: Elapsed_time&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Elapsed_time = TIMEF()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; !$omp parallel do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1, 10000&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x(i) = is_prime(a(i))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; !$omp end parallel do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Elapsed_time = TIMEF()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; write(*,*) ' Elapsed_time = ', Elapsed_time&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; write(*,*) 'end'&lt;BR /&gt;contains&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; function is_prime(num) result(prime)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer, intent(in) :: num&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer :: prime&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer :: i&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prime = num&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=2,int(num/2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(mod(num,i)==0) then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prime = 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end if&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end function is_prime&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;end program main&lt;/P&gt;
&lt;P&gt;[/fortran]&lt;/P&gt;
&lt;P&gt;Second, In line #1, now i initialize the x(10000) to 0, if i didn't do this, the result of x will be totally wrong, which you can see in the monitor. If I dellete all the OpenMP Directive and disable the setting in the proerties, even if i didn't initialize the x array ,the result will be correct.&lt;/P&gt;
&lt;P&gt;I understand the share memory mechanism of the OpenMP, But i cannot understand these from this mechanism. Anyone can help me , thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2012 12:54:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/In-OpenMP-if-I-didn-t-initialize-an-array-the-result-will-be/m-p/974414#M97941</guid>
      <dc:creator>史_建鑫</dc:creator>
      <dc:date>2012-12-17T12:54:03Z</dc:date>
    </item>
    <item>
      <title>In your code, the</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/In-OpenMP-if-I-didn-t-initialize-an-array-the-result-will-be/m-p/974415#M97942</link>
      <description>In your code, the initialization of x to 0 is not required as all values in x are written by the do loop (at least they ought to be written). Your listed code above should run without error.

The Intel compiler, with full optimizations, aggressivly removes code that generates values not used. As a test for this situation, following "Elapsed_time = TIMEF()", insert some code to use x. Note, in your actual program you would use values calculated. However for this test program, insert something to use x, such as:

do i=1,10000
   if(x(i) .lt. 0) write(*,*) i, x
end do

For information that you can provide to Intel support, modify your above code to initialize x array to -1. Run your test to see if you have any -1's, invalid primes, or missed primes.</description>
      <pubDate>Mon, 17 Dec 2012 13:58:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/In-OpenMP-if-I-didn-t-initialize-an-array-the-result-will-be/m-p/974415#M97942</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2012-12-17T13:58:56Z</dc:date>
    </item>
    <item>
      <title>thank you jimdempseyatthecove</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/In-OpenMP-if-I-didn-t-initialize-an-array-the-result-will-be/m-p/974416#M97943</link>
      <description>thank you jimdempseyatthecove. I test what you said, you are right. Oh your name is tooooooooooooooooo long :P

But i still have a question. I check the properties of the project. the optimization is disable(/Od), why the intel compile still do the optimization for me ?</description>
      <pubDate>Tue, 18 Dec 2012 00:47:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/In-OpenMP-if-I-didn-t-initialize-an-array-the-result-will-be/m-p/974416#M97943</guid>
      <dc:creator>史_建鑫</dc:creator>
      <dc:date>2012-12-18T00:47:29Z</dc:date>
    </item>
    <item>
      <title>What is being done can be</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/In-OpenMP-if-I-didn-t-initialize-an-array-the-result-will-be/m-p/974417#M97944</link>
      <description>What is being done can be called elimination of dead code. Dead code historically has been defined as code in program that could never run (no flow into section of code). Intel (and others) have expanded the scope of the dead code elimination process to include computational results never used (and the code that produced the unused results). There may be an Intel internal definition (name) of this process.

Users typically run into this situation when they construct a synthetic benchmark that fills in a results array that is not subsequently used, then report exceptionally good scaling of their code. Only to be embarrassed later when someone points out the folly of the test.

Jim Dempsey
(I forgot to sign the earlier post)</description>
      <pubDate>Tue, 18 Dec 2012 14:07:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/In-OpenMP-if-I-didn-t-initialize-an-array-the-result-will-be/m-p/974417#M97944</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2012-12-18T14:07:03Z</dc:date>
    </item>
  </channel>
</rss>

