<?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 Efficient use of arrays as procedure arguments in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Efficient-use-of-arrays-as-procedure-arguments/m-p/768559#M21391</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Quoting text from this web page &lt;A href="http://mvs.icc.ru/documentation/intel/f_ug2/prg_arrs.htm:" target="_blank"&gt;http://mvs.icc.ru/documentation/intel/f_ug2/prg_arrs.htm:&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;I&gt;Passing an assumed-shape array or array pointer to an explicit-shape 
 array can slow run-time performance. This is because the compiler needs 
 to create an array temporary for the entire array. The array temporary 
 is created because the passed array may not be contiguous and the receiving 
 (explicit-shape) array requires a contiguous array.&lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;Considereing the 3 type of procedures:&lt;BR /&gt;&lt;BR /&gt;(1) Case passing arrays's dimensions by arguments[fortran]subroutine Efficent_Arg( N1, N2, A1, A2 )
  implicit none
  integer                ,intent(in)  :: N1
  integer                ,intent(in)  :: N2
  integer ,dimension(N1) ,intent(in)  :: A1
  integer ,dimension(N2) ,intent(out) :: A2
...
end subroutine&lt;BR /&gt;&lt;BR /&gt;[/fortran](2) Case passing arrays's dimensions by host association &lt;BR /&gt; [fortran]subroutine Efficent_Mod( A1, A2 )
  use Dimension_Module ,only: N1, N2
  implicit none
  integer ,dimension(N1) ,intent(in)  :: A1
  integer ,dimension(N2) ,intent(out) :: A2
...
end subroutine[/fortran]&lt;BR /&gt;(3) Case of assumed-shape arrays[fortran]subroutine InEfficient( A1, A2 )
  implicit none
  integer ,dimension(:) ,intent(in)  :: A1
  integer ,dimension(:) ,intent(out) :: A2
...
end subroutine[/fortran] &lt;B&gt;&lt;BR /&gt;Does cases (1) and (2) really make the difference compared to case (3) ?&lt;BR /&gt;&lt;BR /&gt;Is there a performance difference between cases (1) and (2) ?&lt;BR /&gt;&lt;/B&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;</description>
    <pubDate>Thu, 19 Apr 2012 09:36:13 GMT</pubDate>
    <dc:creator>FlyingHermes</dc:creator>
    <dc:date>2012-04-19T09:36:13Z</dc:date>
    <item>
      <title>Efficient use of arrays as procedure arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Efficient-use-of-arrays-as-procedure-arguments/m-p/768559#M21391</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Quoting text from this web page &lt;A href="http://mvs.icc.ru/documentation/intel/f_ug2/prg_arrs.htm:" target="_blank"&gt;http://mvs.icc.ru/documentation/intel/f_ug2/prg_arrs.htm:&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;I&gt;Passing an assumed-shape array or array pointer to an explicit-shape 
 array can slow run-time performance. This is because the compiler needs 
 to create an array temporary for the entire array. The array temporary 
 is created because the passed array may not be contiguous and the receiving 
 (explicit-shape) array requires a contiguous array.&lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;Considereing the 3 type of procedures:&lt;BR /&gt;&lt;BR /&gt;(1) Case passing arrays's dimensions by arguments[fortran]subroutine Efficent_Arg( N1, N2, A1, A2 )
  implicit none
  integer                ,intent(in)  :: N1
  integer                ,intent(in)  :: N2
  integer ,dimension(N1) ,intent(in)  :: A1
  integer ,dimension(N2) ,intent(out) :: A2
...
end subroutine&lt;BR /&gt;&lt;BR /&gt;[/fortran](2) Case passing arrays's dimensions by host association &lt;BR /&gt; [fortran]subroutine Efficent_Mod( A1, A2 )
  use Dimension_Module ,only: N1, N2
  implicit none
  integer ,dimension(N1) ,intent(in)  :: A1
  integer ,dimension(N2) ,intent(out) :: A2
...
end subroutine[/fortran]&lt;BR /&gt;(3) Case of assumed-shape arrays[fortran]subroutine InEfficient( A1, A2 )
  implicit none
  integer ,dimension(:) ,intent(in)  :: A1
  integer ,dimension(:) ,intent(out) :: A2
...
end subroutine[/fortran] &lt;B&gt;&lt;BR /&gt;Does cases (1) and (2) really make the difference compared to case (3) ?&lt;BR /&gt;&lt;BR /&gt;Is there a performance difference between cases (1) and (2) ?&lt;BR /&gt;&lt;/B&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Apr 2012 09:36:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Efficient-use-of-arrays-as-procedure-arguments/m-p/768559#M21391</guid>
      <dc:creator>FlyingHermes</dc:creator>
      <dc:date>2012-04-19T09:36:13Z</dc:date>
    </item>
    <item>
      <title>Efficient use of arrays as procedure arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Efficient-use-of-arrays-as-procedure-arguments/m-p/768560#M21392</link>
      <description>Quite apart from possible performance differences, you should consider the potential&lt;BR /&gt;for making a mistake: both the first and the second cases use information that the &lt;BR /&gt;user has to provide himself/herself. The third case does not, it relies entirely on the&lt;BR /&gt;runtime information that is present in the two arguments.&lt;BR /&gt;&lt;BR /&gt;My guess about the performance is that:&lt;BR /&gt;- It does not really matter if the arrays are contiguous and the compiler recognises this.&lt;BR /&gt;- It does matter if they are not as copy-in/copy-out for the two array arguments will occur,&lt;BR /&gt; at least in the first two cases. &lt;BR /&gt;&lt;BR /&gt;However, it is very difficult to draw any general conclusions wrt performance. It heavily depends &lt;BR /&gt;on what the compiler can recognise.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Arjen</description>
      <pubDate>Thu, 19 Apr 2012 11:18:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Efficient-use-of-arrays-as-procedure-arguments/m-p/768560#M21392</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2012-04-19T11:18:24Z</dc:date>
    </item>
    <item>
      <title>Efficient use of arrays as procedure arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Efficient-use-of-arrays-as-procedure-arguments/m-p/768561#M21393</link>
      <description>What do you mean by "It does matter if they are not as copy-in/copy-out for the two array arguments will occur" ?&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 19 Apr 2012 14:06:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Efficient-use-of-arrays-as-procedure-arguments/m-p/768561#M21393</guid>
      <dc:creator>FlyingHermes</dc:creator>
      <dc:date>2012-04-19T14:06:59Z</dc:date>
    </item>
    <item>
      <title>Efficient use of arrays as procedure arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Efficient-use-of-arrays-as-procedure-arguments/m-p/768562#M21394</link>
      <description>If the ingoing arrays are not contiguous, an array section like array(1:1000:100) for instance,&lt;BR /&gt;the explicit-shape and assumed-size interfaces can not cope with that. The compiler must use&lt;BR /&gt;a temporary array that receives the values before the call (copy-in). The routine may then&lt;BR /&gt;update the values in that temporary array and upon return, the new values are copied back&lt;BR /&gt;into the original array section. This takes time. &lt;BR /&gt;&lt;BR /&gt;Compilers are getting smarter all the time in dealing with such situations, but in the case &lt;BR /&gt;of explicit-shape and assumed-size arrays they have no facilities to avoid such copies.&lt;BR /&gt;(At least that is my understanding ;))&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Arjen</description>
      <pubDate>Thu, 19 Apr 2012 14:13:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Efficient-use-of-arrays-as-procedure-arguments/m-p/768562#M21394</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2012-04-19T14:13:14Z</dc:date>
    </item>
    <item>
      <title>Efficient use of arrays as procedure arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Efficient-use-of-arrays-as-procedure-arguments/m-p/768563#M21395</link>
      <description>The Intel compiler, in a case where it does not know at compile time if a deferred-shape array actual argument is contiguous, will do a run-time test for contiguity and avoid the copy if it finds the argument to be contiguous. Fortran 2008 defines a CONTIGUOUS attribute that you can apply to a variable specifying that you promise it is contiguous. You can avoid issues by using ALLOCATABLE arrays, if you are allocating them dynamically. There is also an optional run-time diagnostic the program can emit should an argument copy be made; use -check arg_temp_created to enable this.</description>
      <pubDate>Thu, 19 Apr 2012 15:10:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Efficient-use-of-arrays-as-procedure-arguments/m-p/768563#M21395</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2012-04-19T15:10:23Z</dc:date>
    </item>
  </channel>
</rss>

