<?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 Questions about parallelization. in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754085#M9630</link>
    <description>In fact, the compiler only sees that the terms do not depend on each other. Therefore, the loop could be arbitrary reordered in exact arithmetic. However, for floating point arithmetic, the compiler just assumes that reordering does not produce significant round-off errors. So you can never be sure in which order the terms are actually added up. This may depend on the system, number of threads etc.&lt;BR /&gt;&lt;BR /&gt;If you want to be sure, in which order terms are added up, you need to parallelize the program manually and split up the loop _by hand_ (using OpenMP reductions on loops are again not deterministic)&lt;BR /&gt;</description>
    <pubDate>Tue, 29 Mar 2011 08:21:30 GMT</pubDate>
    <dc:creator>fah10</dc:creator>
    <dc:date>2011-03-29T08:21:30Z</dc:date>
    <item>
      <title>Questions about parallelization.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754084#M9629</link>
      <description>Hi,&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I've written this code in fortran to compute the sum of 1/(k*(k+1)) for k from 1 to 10**9 with a double precision accuracy.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;===========================&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV id="_mcePaste"&gt;program main&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	implicit none&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	integer, parameter :: ip = 8&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	integer, parameter :: rp = kind(1.0d0)&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	integer, parameter :: size = 10**9&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	integer(kind=ip) :: i&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	real(kind=rp)  :: sum&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	sum =0.0_rp&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	do i = size,1,-1&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;sum = sum + 1.0_rp/real(i*(i+1),rp)&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	end do&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	write (*,*) "The result is : ",sum&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;end program main&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;===========================&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;I've realised that with the option -parallel, the program is 2 times faster than without it. I am quite amazed that the compiler can parallelize this program.&lt;/DIV&gt;&lt;DIV&gt;Of course, one core can compute the sum for i from 1 to 5*(10**8), another one can compute the sum for i from 5*(10**8)+1 to 10**9 and the 2 sums can be added. But for that, the compiler has to know that :&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;((((a_1+a_2)+a_3)+a_4)+...)+a_(10**9)&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;is the same as&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;((((a_1+a_2)+a_3)+a_4)+...)+a_(5*(10**8)) + ((((a_(5*(10**8)+1)+a_(5*(10**8)+2))+...)+a_(10**9))&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;which is not "obvious". Is it what the compiler does ?&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Thanks for your answers,&lt;/DIV&gt;&lt;DIV&gt;Francois&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 29 Mar 2011 04:23:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754084#M9629</guid>
      <dc:creator>velvia</dc:creator>
      <dc:date>2011-03-29T04:23:12Z</dc:date>
    </item>
    <item>
      <title>Questions about parallelization.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754085#M9630</link>
      <description>In fact, the compiler only sees that the terms do not depend on each other. Therefore, the loop could be arbitrary reordered in exact arithmetic. However, for floating point arithmetic, the compiler just assumes that reordering does not produce significant round-off errors. So you can never be sure in which order the terms are actually added up. This may depend on the system, number of threads etc.&lt;BR /&gt;&lt;BR /&gt;If you want to be sure, in which order terms are added up, you need to parallelize the program manually and split up the loop _by hand_ (using OpenMP reductions on loops are again not deterministic)&lt;BR /&gt;</description>
      <pubDate>Tue, 29 Mar 2011 08:21:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754085#M9630</guid>
      <dc:creator>fah10</dc:creator>
      <dc:date>2011-03-29T08:21:30Z</dc:date>
    </item>
    <item>
      <title>Questions about parallelization.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754086#M9631</link>
      <description>I doubt that &lt;I&gt;any&lt;/I&gt; compiler is "smart" enough to see that the sum from k=1:n is exactly 1 - 1 / ( n + 1 ).&lt;BR /&gt;</description>
      <pubDate>Tue, 29 Mar 2011 08:43:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754086#M9631</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-03-29T08:43:35Z</dc:date>
    </item>
    <item>
      <title>Questions about parallelization.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754087#M9632</link>
      <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=9662" class="basic" href="https://community.intel.com/en-us/profile/9662/"&gt;mecej4&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="background-color: #e5e5e5; padding: 5px; border: 1px; border-style: inset; margin-left: 2px; margin-right: 2px;"&gt;&lt;I&gt;I doubt that &lt;I&gt;any&lt;/I&gt; compiler is "smart" enough to see that the sum from k=1:n is exactly 1 - 1 / ( n + 1 ).&lt;BR /&gt;&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;It has been done on purpose, in order to check the result ;-)&lt;BR /&gt;It is interesting that, in this example, you get a wrong result when you sum from 1 to 10**9.</description>
      <pubDate>Tue, 29 Mar 2011 13:22:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754087#M9632</guid>
      <dc:creator>velvia</dc:creator>
      <dc:date>2011-03-29T13:22:12Z</dc:date>
    </item>
    <item>
      <title>Questions about parallelization.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754088#M9633</link>
      <description>In case you wished to sum to 10**10, you would need to take care to promote such expressions to 64-bit integers.</description>
      <pubDate>Tue, 29 Mar 2011 13:50:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754088#M9633</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2011-03-29T13:50:52Z</dc:date>
    </item>
    <item>
      <title>Questions about parallelization.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754089#M9634</link>
      <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=336549" class="basic" href="https://community.intel.com/en-us/profile/336549/"&gt;TimP (Intel)&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="background-color: #e5e5e5; padding: 5px; border: 1px; border-style: inset; margin-left: 2px; margin-right: 2px;"&gt;&lt;I&gt;In case you wished to sum to 10**10, you would need to take care to promote such expressions to 64-bit integers.&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a matter of fact, I already have to do that as I compute i*(i+1) as an integer expression for i = 10**9.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2011 15:58:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754089#M9634</guid>
      <dc:creator>velvia</dc:creator>
      <dc:date>2011-03-29T15:58:05Z</dc:date>
    </item>
    <item>
      <title>Questions about parallelization.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754090#M9635</link>
      <description>in the code you posted, you didn't use 64-bit integers in your parameter calculation, and you have an undefined variable in your write. So, it's hard to guess what you actually tested.</description>
      <pubDate>Tue, 29 Mar 2011 18:32:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754090#M9635</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2011-03-29T18:32:17Z</dc:date>
    </item>
    <item>
      <title>Questions about parallelization.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754091#M9636</link>
      <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=336549" class="basic" href="https://community.intel.com/en-us/profile/336549/"&gt;TimP (Intel)&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="background-color: #e5e5e5; padding: 5px; border: 1px; border-style: inset; margin-left: 2px; margin-right: 2px;"&gt;&lt;I&gt;in the code you posted, you didn't use 64-bit integers in your parameter calculation, and you have an undefined variable in your write. So, it's hard to guess what you actually tested.&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;Sorry. It was my mistake for the variable undefined (I've now corrected it in my first post).&lt;BR /&gt;&lt;BR /&gt;I am not using a 64 bit integer for size but I am using it for i.</description>
      <pubDate>Tue, 29 Mar 2011 19:39:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Questions-about-parallelization/m-p/754091#M9636</guid>
      <dc:creator>velvia</dc:creator>
      <dc:date>2011-03-29T19:39:46Z</dc:date>
    </item>
  </channel>
</rss>

