<?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 multiplication in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769319#M21776</link>
    <description>[#]$ ifort loop.f90&lt;BR /&gt;loop.f90(7): warning #7866: The statement following this DEC loop optimization directive must be an iterative do-stmt, a vector assignment, an OMP pdo-directive, or an OMP parallel-do-directive.&lt;BR /&gt;!dir$ unroll(0)&lt;BR /&gt;------^&lt;BR /&gt;&lt;BR /&gt;Is there anything I make mistake?</description>
    <pubDate>Fri, 04 May 2012 16:44:25 GMT</pubDate>
    <dc:creator>GHui</dc:creator>
    <dc:date>2012-05-04T16:44:25Z</dc:date>
    <item>
      <title>multiplication</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769317#M21774</link>
      <description>Is there any way to speed up the following code?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;[fortran]do i=1,1000000  
  s0=i*10+1  
  s1=i*10+10  
  do j=s0,s1  
    val(i) = val(i) + a(j)*c(j)  
  enddo    
enddo[/fortran] &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 May 2012 14:32:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769317#M21774</guid>
      <dc:creator>GHui</dc:creator>
      <dc:date>2012-05-04T14:32:46Z</dc:date>
    </item>
    <item>
      <title>multiplication</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769318#M21775</link>
      <description>It may help to replace the inner loop by&lt;BR /&gt;!dir$ unroll(0)&lt;BR /&gt;val(i)=val(i)+dot_product(a(so:s1),c(s0:s1))&lt;BR /&gt;&lt;BR /&gt;ifort should optimize this with default options. -assume protect_parens will not prevent this optiimation, but -fp-model source et al. will inhibit "vectorization."&lt;BR /&gt;Alternative to portable dot_product is intel-specific !dir$ simd reduction.&lt;BR /&gt;As your loop length is only 10, you dont't get full benefit of compiler vectorization when you can't specify data alignment. Compiler may say "seems inefficient" when it sees loop length 10 with unknown alignment.&lt;BR /&gt;Other traditional possibilites include writing it out in various non-sequential forms:&lt;BR /&gt;val(i)=val(i)+dot_product(a(s0:s0+1),c(so:s0+1)+dot_product(a(s0+2:s0+9),c(s0+2:s0+9)) .....&lt;BR /&gt;this also may depend strongly on alignment if any vectorization is involved.&lt;BR /&gt;Ideally, the compiler would not invoke alignment dependence when you use an option such as -xHost which should take advantage of current instruction sets.</description>
      <pubDate>Fri, 04 May 2012 15:17:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769318#M21775</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2012-05-04T15:17:16Z</dc:date>
    </item>
    <item>
      <title>multiplication</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769319#M21776</link>
      <description>[#]$ ifort loop.f90&lt;BR /&gt;loop.f90(7): warning #7866: The statement following this DEC loop optimization directive must be an iterative do-stmt, a vector assignment, an OMP pdo-directive, or an OMP parallel-do-directive.&lt;BR /&gt;!dir$ unroll(0)&lt;BR /&gt;------^&lt;BR /&gt;&lt;BR /&gt;Is there anything I make mistake?</description>
      <pubDate>Fri, 04 May 2012 16:44:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769319#M21776</guid>
      <dc:creator>GHui</dc:creator>
      <dc:date>2012-05-04T16:44:25Z</dc:date>
    </item>
    <item>
      <title>Multiplication</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769320#M21777</link>
      <description>&lt;DIV id="tiny_quote"&gt;&lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A jquery1336195313937="58" rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=548134" href="https://community.intel.com/en-us/profile/548134/" class="basic"&gt;GHui&lt;/A&gt;&lt;/DIV&gt;&lt;DIV style="background-color: #e5e5e5; margin-left: 2px; margin-right: 2px; border: 1px inset; padding: 5px;"&gt;&lt;I&gt;Is there any way to speed up the following code?...&lt;/I&gt;&lt;/DIV&gt;&lt;BR /&gt;...&lt;BR /&gt;do i = 1, 1000000&lt;BR /&gt; s0 = i * 10 + 1&lt;BR /&gt; s1 = s0 + 9&lt;BR /&gt; do j = s0, s1&lt;BR /&gt; val(i) = val(i) + a(j) * c(j)&lt;BR /&gt; enddo &lt;BR /&gt;enddo&lt;BR /&gt;...&lt;/DIV&gt;</description>
      <pubDate>Sat, 05 May 2012 05:28:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769320#M21777</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-05-05T05:28:25Z</dc:date>
    </item>
    <item>
      <title>multiplication</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769321#M21778</link>
      <description>Sorry, apparently you will need to omit the unroll directive when trying dot_product.</description>
      <pubDate>Sat, 05 May 2012 11:00:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769321#M21778</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2012-05-05T11:00:40Z</dc:date>
    </item>
    <item>
      <title>multiplication</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769322#M21779</link>
      <description>I try dot_product for several cases. There isn't better performance.</description>
      <pubDate>Fri, 18 May 2012 16:17:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769322#M21779</guid>
      <dc:creator>GHui</dc:creator>
      <dc:date>2012-05-18T16:17:08Z</dc:date>
    </item>
    <item>
      <title>multiplication</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769323#M21780</link>
      <description>&lt;OL start="1"&gt;&lt;LI class="alt"&gt;&lt;SPAN&gt;&lt;SPAN class="color2"&gt;&lt;/SPAN&gt;&lt;SPAN class="keyword bold"&gt;do&lt;/SPAN&gt;&lt;SPAN&gt;i=1,1000000 &lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;s0=i*10+1&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI class="alt"&gt;&lt;SPAN&gt;s1=i*10+10&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&lt;SPAN class="keyword bold"&gt;do&lt;/SPAN&gt;&lt;SPAN&gt;j=s0,s1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;SPAN&gt;&lt;SPAN&gt;First iteration does 11:20, second does 21:30, ...&lt;BR /&gt;&lt;BR /&gt;Shouldn't your i loop be &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN class="keyword bold"&gt;do&lt;/SPAN&gt;&lt;SPAN&gt;i=&lt;B&gt;0&lt;/B&gt;,1000000?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;(or i loop control reduced by /10?)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;Also, are val(:), a(:) and c(:) dimensioned at &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;1000000*10+10?&lt;BR /&gt;IOW 10x the size of the i loop iteration plus 10&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;
&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;Try creating temp array of proper size (same as size for &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;val(:), a(:) and c(:))&lt;BR /&gt;&lt;BR /&gt;! the following will vectorize quite well&lt;BR /&gt;! do the product part of the dot products&lt;BR /&gt;do i=1,1000000*10+10&lt;BR /&gt; temp(i) = a(i) * c(i)&lt;BR /&gt;end do&lt;BR /&gt;! now do the sum part of the small dot products&lt;BR /&gt;do i=1,1000000&lt;BR /&gt; s0=i*10+1&lt;BR /&gt; s1=i*10+10&lt;BR /&gt; t = 0.0&lt;BR /&gt; do j=s0,s1&lt;BR /&gt; t = t + temp(j)&lt;BR /&gt; end do&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; val(i) = val(i) + t&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;end do&lt;BR /&gt;&lt;BR /&gt;Start with that&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;/SPAN&gt;&lt;/SPAN&gt;</description>
      <pubDate>Fri, 18 May 2012 17:12:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/multiplication/m-p/769323#M21780</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2012-05-18T17:12:31Z</dc:date>
    </item>
  </channel>
</rss>

