<?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 Multiple module alignment of Fortran arrays in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Multiple-module-alignment-of-Fortran-arrays/m-p/1177347#M8092</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;I'm having some difficulty getting some alignment between fortran modules (in particular of a 2D array) to be recognised during vectorisation by the compiler.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;In module neighbours I declare the following array in the module:&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark;"&gt;    !&amp;gt; Linked cell list
    Integer( Kind = wi ), Allocatable, Public :: list(:,:)
    !DIR$ ATTRIBUTES ALIGN:64 :: list
&lt;/PRE&gt;

&lt;P&gt;and it is allocated with:&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark;"&gt;  Subroutine init_list(neigh,mxatdm)
    Class( neighbours_type ) :: neigh
    Integer( Kind = wi ), Intent( In    ) :: mxatdm
    Integer :: size_list

    size_list = neigh%max_list + 16-Mod(neigh%max_list,16)
    Allocate (neigh%list(-15:neigh%max_list,1:mxatdm))
&amp;nbsp;   !DIR$ ASSUME_ALIGNED neigh%list(-15,1) : 64
&lt;/PRE&gt;

&lt;P&gt;The code uses some of the negative indices, and the main indices start at 1 (for vectorised section of loop). As Kind=wi results in 4 byte integers this should result in alignment being correct I think, and with -check assume, there is no error here.&lt;/P&gt;

&lt;P&gt;In another module, this data is then used in a strip-mined loop:&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark;"&gt;    Do m=1,loop,STRIP_WIDTH
        !DIR$ NOFUSION
        Do n=0,STRIP_WIDTH-1,1
            t_ll(n) = -1
            t_kk(n) = -1
            ! atomic and type indices
            !DIR$ ASSUME_ALIGNED neigh%list(1,iatm) : 64
            jatm=neigh%list(m+n,iatm)
            aj=ltype(jatm)
&lt;/PRE&gt;

&lt;P&gt;....&lt;/P&gt;

&lt;P&gt;Since its a 2D array, i believe I need to tell the compiler that each row is aligned, and I hoped I could do it in this way, but I'm not sure I can. Either way, this ASSUME_ALIGNED fails with -check assume:&lt;/P&gt;

&lt;P&gt;forrtl: severe (408): fort: (28): Check for ASSUME_ALIGNED fails for 'NEIGH' in routine 'RDF_COLLECT' at line 188.&lt;/P&gt;

&lt;P&gt;Without this ASSUME_ALIGNED the optimisation report believes neigh%list is not aligned (though it gets confused and believes the variable name is loop - seperate issue however). With the ASSUME_ALIGNED the compiler believes neigh%list is aligned, however it breaks at runtime. This is compiled with Intel 18 update 3 with flags&amp;nbsp;-g -O3 -qopt-report=5 -xCOMMON-AVX512&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;What is the correct way to tell the compiler of the alignment of a 2D array that exists inside another module? Inside the neighbours module should I do&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark;"&gt;!DIR$ ASSUME_ALIGNED neigh%list(-15,1) : 64
!DIR$ ASSUME Mod(size_list,16) == 0&lt;/PRE&gt;

&lt;P&gt;or will that not be passed between modules?&lt;/P&gt;</description>
    <pubDate>Wed, 29 Aug 2018 16:45:05 GMT</pubDate>
    <dc:creator>aidan_c_</dc:creator>
    <dc:date>2018-08-29T16:45:05Z</dc:date>
    <item>
      <title>Multiple module alignment of Fortran arrays</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Multiple-module-alignment-of-Fortran-arrays/m-p/1177347#M8092</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;I'm having some difficulty getting some alignment between fortran modules (in particular of a 2D array) to be recognised during vectorisation by the compiler.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;In module neighbours I declare the following array in the module:&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark;"&gt;    !&amp;gt; Linked cell list
    Integer( Kind = wi ), Allocatable, Public :: list(:,:)
    !DIR$ ATTRIBUTES ALIGN:64 :: list
&lt;/PRE&gt;

&lt;P&gt;and it is allocated with:&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark;"&gt;  Subroutine init_list(neigh,mxatdm)
    Class( neighbours_type ) :: neigh
    Integer( Kind = wi ), Intent( In    ) :: mxatdm
    Integer :: size_list

    size_list = neigh%max_list + 16-Mod(neigh%max_list,16)
    Allocate (neigh%list(-15:neigh%max_list,1:mxatdm))
&amp;nbsp;   !DIR$ ASSUME_ALIGNED neigh%list(-15,1) : 64
&lt;/PRE&gt;

&lt;P&gt;The code uses some of the negative indices, and the main indices start at 1 (for vectorised section of loop). As Kind=wi results in 4 byte integers this should result in alignment being correct I think, and with -check assume, there is no error here.&lt;/P&gt;

&lt;P&gt;In another module, this data is then used in a strip-mined loop:&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark;"&gt;    Do m=1,loop,STRIP_WIDTH
        !DIR$ NOFUSION
        Do n=0,STRIP_WIDTH-1,1
            t_ll(n) = -1
            t_kk(n) = -1
            ! atomic and type indices
            !DIR$ ASSUME_ALIGNED neigh%list(1,iatm) : 64
            jatm=neigh%list(m+n,iatm)
            aj=ltype(jatm)
&lt;/PRE&gt;

&lt;P&gt;....&lt;/P&gt;

&lt;P&gt;Since its a 2D array, i believe I need to tell the compiler that each row is aligned, and I hoped I could do it in this way, but I'm not sure I can. Either way, this ASSUME_ALIGNED fails with -check assume:&lt;/P&gt;

&lt;P&gt;forrtl: severe (408): fort: (28): Check for ASSUME_ALIGNED fails for 'NEIGH' in routine 'RDF_COLLECT' at line 188.&lt;/P&gt;

&lt;P&gt;Without this ASSUME_ALIGNED the optimisation report believes neigh%list is not aligned (though it gets confused and believes the variable name is loop - seperate issue however). With the ASSUME_ALIGNED the compiler believes neigh%list is aligned, however it breaks at runtime. This is compiled with Intel 18 update 3 with flags&amp;nbsp;-g -O3 -qopt-report=5 -xCOMMON-AVX512&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;What is the correct way to tell the compiler of the alignment of a 2D array that exists inside another module? Inside the neighbours module should I do&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark;"&gt;!DIR$ ASSUME_ALIGNED neigh%list(-15,1) : 64
!DIR$ ASSUME Mod(size_list,16) == 0&lt;/PRE&gt;

&lt;P&gt;or will that not be passed between modules?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 16:45:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Multiple-module-alignment-of-Fortran-arrays/m-p/1177347#M8092</guid>
      <dc:creator>aidan_c_</dc:creator>
      <dc:date>2018-08-29T16:45:05Z</dc:date>
    </item>
    <item>
      <title>    size_list = neigh%max</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Multiple-module-alignment-of-Fortran-arrays/m-p/1177348#M8093</link>
      <description>&lt;PRE class="brush:fortran; class-name:dark;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; size_list = neigh%max_list + 16-Mod(neigh%max_list,16)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Allocate (neigh%list(-15:size_list,1:mxatdm))
    !                        ^^^^^^^^^

&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Does that help?&lt;/P&gt;

&lt;P&gt;IOW you wanted the first dimension to be a multiple of 16.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 12:19:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Multiple-module-alignment-of-Fortran-arrays/m-p/1177348#M8093</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2018-08-30T12:19:00Z</dc:date>
    </item>
    <item>
      <title>Looks like an embarrassing</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Multiple-module-alignment-of-Fortran-arrays/m-p/1177349#M8094</link>
      <description>&lt;P&gt;Looks like an embarrassing typo, too long of a day - thanks Jim&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 13:13:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Multiple-module-alignment-of-Fortran-arrays/m-p/1177349#M8094</guid>
      <dc:creator>aidan_c_</dc:creator>
      <dc:date>2018-08-30T13:13:36Z</dc:date>
    </item>
    <item>
      <title>Normally, of course, you</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Multiple-module-alignment-of-Fortran-arrays/m-p/1177350#M8095</link>
      <description>&lt;P&gt;Normally, of course, you would set compile option&amp;nbsp;-align:array32byte (or larger) to tell the compiler to align as many arrays as possible, although that shouldn't be necessary for allocatable arrays.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 12:14:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Multiple-module-alignment-of-Fortran-arrays/m-p/1177350#M8095</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2018-08-31T12:14:32Z</dc:date>
    </item>
    <item>
      <title>I might suggest that you not</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Multiple-module-alignment-of-Fortran-arrays/m-p/1177351#M8096</link>
      <description>&lt;P&gt;I might suggest that you not use the name &lt;STRONG&gt;size_list &lt;/STRONG&gt;as it may be misleading. Maybe &lt;STRONG&gt;allocation_max_list &lt;/STRONG&gt;might be a better choice of names.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 12:55:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Multiple-module-alignment-of-Fortran-arrays/m-p/1177351#M8096</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2018-08-31T12:55:43Z</dc:date>
    </item>
  </channel>
</rss>

