<?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 How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ? in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457568#M165171</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to vectorize the two nested loops because their length is small.&lt;/P&gt;
&lt;P&gt;The example is the following :&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;module mystuff

USE ISO_FORTRAN_ENV
integer :: nx
integer :: nz
real(REAL64) :: bega

contains

subroutine compute_Correction_Elem_Veloc (Accel, Forces, Displ, Veloc, V0, g1, ddt)
real(REAL64), dimension(1:nx-2, 1:nz-2, 0:1), intent(INOUT) :: Accel
real(REAL64), dimension(0:nx-1, 0:nz-1, 0:1), intent(INOUT) :: Forces
real(REAL64), dimension(1:nx-2, 1:nz-2, 0:1), intent(INOUT) :: Displ
real(REAL64), dimension(1:nx-2, 1:nz-2, 0:1), intent(INOUT) :: Veloc
real(REAL64), dimension(1:nx-2, 1:nz-2, 0:1), intent(IN)    :: V0
real(REAL64), intent(IN) :: g1, ddt
!
integer  :: ii, jj
real(REAL64) :: sc2
!
sc2 = bega * ddt
!$OMP SIMD COLLAPSE(2)
do jj = 1, nz-2
   do ii = 1, nx-2
      Veloc (ii,jj,0) = V0   (ii,jj,0) + ddt *  Forces(ii,jj,0)
      Accel (ii,jj,0) = Accel(ii,jj,0) + g1  *  Forces(ii,jj,0)
      Displ (ii,jj,0) = Displ(ii,jj,0) + sc2 * (Veloc(ii,jj,0) + V0(ii,jj,0) )
      Veloc (ii,jj,1) = V0   (ii,jj,1) + ddt *  Forces(ii,jj,1)
      Accel (ii,jj,1) = Accel(ii,jj,1) + g1  *  Forces(ii,jj,1)
      Displ (ii,jj,1) = Displ(ii,jj,1) + sc2 * (Veloc(ii,jj,1) + V0(ii,jj,1) )
   end do
end do
!
return
end subroutine compute_Correction_Elem_Veloc


end module mystuff&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The compilation sequence is&lt;/P&gt;
&lt;P&gt;ifort -c -O3 -xHost -ftz -g -traceback -implicitnone -qopt-report=5 -qopt-report-phase=vec -fpp -DGM_VEC -pad -align array64byte -c mystuff_v01.f90&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The report is&lt;/P&gt;
&lt;LI-CODE lang="none"&gt;Intel(R) Advisor can now assist with vectorization and show optimization
  report messages with your source code.
See "https://software.intel.com/en-us/intel-advisor-xe" for details.

Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.6.0 Build 20220226_000000

Compiler options: -c -O3 -xHost -ftz -g -traceback -implicitnone -qopt-report=5 -qopt-report-phase=vec -fpp -DGM_VEC -pad -align array64byte -c

Begin optimization report for: MYSTUFF::COMPUTE_CORRECTION_ELEM_VELOC

    Report from: Vector optimizations [vec]


LOOP BEGIN at mystuff_v01.f90(26,25)
   remark #15329: vectorization support: irregularly indexed store was emulated for the variable &amp;lt;veloc(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(25,7) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;v0(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(25,25) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;forces(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(25,49) ]
   remark #15329: vectorization support: irregularly indexed store was emulated for the variable &amp;lt;accel(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(26,7) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;accel(ii,jj,0)&amp;gt;, part of index is nonlinearly computed
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;forces(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(26,49) ]
   remark #15329: vectorization support: irregularly indexed store was emulated for the variable &amp;lt;displ(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(27,7) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;displ(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(27,25) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;veloc(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(27,49) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;v0(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(27,66) ]
   remark #15329: vectorization support: irregularly indexed store was emulated for the variable &amp;lt;veloc(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(28,7) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;v0(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(28,25) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;forces(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(28,49) ]
   remark #15329: vectorization support: irregularly indexed store was emulated for the variable &amp;lt;accel(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(29,7) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;accel(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(29,25) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;forces(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(29,49) ]
   remark #15329: vectorization support: irregularly indexed store was emulated for the variable &amp;lt;displ(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(30,7) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;displ(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(30,25) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;veloc(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(30,49) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;v0(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(30,66) ]
   remark #15305: vectorization support: vector length 2
   remark #15309: vectorization support: normalized vectorization overhead 0.073
   remark #15301: OpenMP SIMD LOOP WAS VECTORIZED
   remark #15462: unmasked indexed (or gather) loads: 14 
   remark #15463: unmasked indexed (or scatter) stores: 6 
   remark #15475: --- begin vector cost summary ---
   remark #15476: scalar cost: 134 
   remark #15477: vector cost: 191.500 
   remark #15478: estimated potential speedup: 0.690 
   remark #15482: vectorized math library calls: 2 
   remark #15488: --- end vector cost summary ---
LOOP END

LOOP BEGIN at mystuff_v01.f90(26,25)
&amp;lt;Remainder loop for vectorization&amp;gt;
LOOP END
===========================================================================&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I remove the OpenMP direction OMP SIMD COLLAPSE and I recompile, the new report is the following :&lt;/P&gt;
&lt;LI-CODE lang="none"&gt;Intel(R) Advisor can now assist with vectorization and show optimization
  report messages with your source code.
See "https://software.intel.com/en-us/intel-advisor-xe" for details.

Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.6.0 Build 20220226_000000

Compiler options: -c -O3 -xHost -ftz -g -traceback -implicitnone -qopt-report=5 -qopt-report-phase=vec -fpp -DGM_VEC -pad -align array64byte -c

Begin optimization report for: MYSTUFF::COMPUTE_CORRECTION_ELEM_VELOC

    Report from: Vector optimizations [vec]


LOOP BEGIN at mystuff_v00.f90(23,1)
   remark #15542: loop was not vectorized: inner loop was already vectorized

   LOOP BEGIN at mystuff_v00.f90(24,4)
   &amp;lt;Peeled loop for vectorization&amp;gt;
   LOOP END

   LOOP BEGIN at mystuff_v00.f90(24,4)
      remark #15389: vectorization support: reference veloc(ii,jj,1) has unaligned access   [ mystuff_v00.f90(28,7) ]
      remark #15389: vectorization support: reference v0(ii,jj,1) has unaligned access   [ mystuff_v00.f90(28,25) ]
      remark #15389: vectorization support: reference forces(ii,jj,1) has unaligned access   [ mystuff_v00.f90(28,49) ]
      remark #15389: vectorization support: reference veloc(ii,jj,0) has unaligned access   [ mystuff_v00.f90(25,7) ]
      remark #15389: vectorization support: reference v0(ii,jj,0) has unaligned access   [ mystuff_v00.f90(25,25) ]
      remark #15389: vectorization support: reference forces(ii,jj,0) has unaligned access   [ mystuff_v00.f90(25,49) ]
      remark #15389: vectorization support: reference accel(ii,jj,0) has unaligned access   [ mystuff_v00.f90(26,7) ]
      remark #15389: vectorization support: reference accel(ii,jj,0) has unaligned access   [ mystuff_v00.f90(26,25) ]
      remark #15389: vectorization support: reference forces(ii,jj,0) has unaligned access   [ mystuff_v00.f90(26,49) ]
      remark #15389: vectorization support: reference accel(ii,jj,1) has unaligned access   [ mystuff_v00.f90(29,7) ]
      remark #15389: vectorization support: reference accel(ii,jj,1) has unaligned access   [ mystuff_v00.f90(29,25) ]
      remark #15389: vectorization support: reference forces(ii,jj,1) has unaligned access   [ mystuff_v00.f90(29,49) ]
      remark #15389: vectorization support: reference displ(ii,jj,1) has unaligned access   [ mystuff_v00.f90(30,7) ]
      remark #15389: vectorization support: reference displ(ii,jj,1) has unaligned access   [ mystuff_v00.f90(30,25) ]
      remark #15389: vectorization support: reference veloc(ii,jj,1) has unaligned access   [ mystuff_v00.f90(30,49) ]
      remark #15389: vectorization support: reference v0(ii,jj,1) has unaligned access   [ mystuff_v00.f90(30,66) ]
      remark #15389: vectorization support: reference displ(ii,jj,0) has unaligned access   [ mystuff_v00.f90(27,7) ]
      remark #15389: vectorization support: reference displ(ii,jj,0) has unaligned access   [ mystuff_v00.f90(27,25) ]
      remark #15389: vectorization support: reference veloc(ii,jj,0) has unaligned access   [ mystuff_v00.f90(27,49) ]
      remark #15389: vectorization support: reference v0(ii,jj,0) has unaligned access   [ mystuff_v00.f90(27,66) ]
      remark #15381: vectorization support: unaligned access used inside loop body
      remark #15305: vectorization support: vector length 4
      remark #15309: vectorization support: normalized vectorization overhead 0.892
      remark #15300: LOOP WAS VECTORIZED
      remark #15442: entire loop may be executed in remainder
      remark #15450: unmasked unaligned unit stride loads: 10 
      remark #15451: unmasked unaligned unit stride stores: 6 
      remark #15475: --- begin vector cost summary ---
      remark #15476: scalar cost: 55 
      remark #15477: vector cost: 16.250 
      remark #15478: estimated potential speedup: 3.240 
      remark #15488: --- end vector cost summary ---
   LOOP END

   LOOP BEGIN at mystuff_v00.f90(24,4)
   &amp;lt;Remainder loop for vectorization&amp;gt;
   LOOP END
LOOP END
===========================================================================&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I look at the final lines of the first report, It seems to me that the estimated potential speedup with the OpenMP directive is very bad with respect to the last one. Is this normal ? What do I miss ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your comments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Feb 2023 16:19:07 GMT</pubDate>
    <dc:creator>Yann_D_</dc:creator>
    <dc:date>2023-02-20T16:19:07Z</dc:date>
    <item>
      <title>How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457568#M165171</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to vectorize the two nested loops because their length is small.&lt;/P&gt;
&lt;P&gt;The example is the following :&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;module mystuff

USE ISO_FORTRAN_ENV
integer :: nx
integer :: nz
real(REAL64) :: bega

contains

subroutine compute_Correction_Elem_Veloc (Accel, Forces, Displ, Veloc, V0, g1, ddt)
real(REAL64), dimension(1:nx-2, 1:nz-2, 0:1), intent(INOUT) :: Accel
real(REAL64), dimension(0:nx-1, 0:nz-1, 0:1), intent(INOUT) :: Forces
real(REAL64), dimension(1:nx-2, 1:nz-2, 0:1), intent(INOUT) :: Displ
real(REAL64), dimension(1:nx-2, 1:nz-2, 0:1), intent(INOUT) :: Veloc
real(REAL64), dimension(1:nx-2, 1:nz-2, 0:1), intent(IN)    :: V0
real(REAL64), intent(IN) :: g1, ddt
!
integer  :: ii, jj
real(REAL64) :: sc2
!
sc2 = bega * ddt
!$OMP SIMD COLLAPSE(2)
do jj = 1, nz-2
   do ii = 1, nx-2
      Veloc (ii,jj,0) = V0   (ii,jj,0) + ddt *  Forces(ii,jj,0)
      Accel (ii,jj,0) = Accel(ii,jj,0) + g1  *  Forces(ii,jj,0)
      Displ (ii,jj,0) = Displ(ii,jj,0) + sc2 * (Veloc(ii,jj,0) + V0(ii,jj,0) )
      Veloc (ii,jj,1) = V0   (ii,jj,1) + ddt *  Forces(ii,jj,1)
      Accel (ii,jj,1) = Accel(ii,jj,1) + g1  *  Forces(ii,jj,1)
      Displ (ii,jj,1) = Displ(ii,jj,1) + sc2 * (Veloc(ii,jj,1) + V0(ii,jj,1) )
   end do
end do
!
return
end subroutine compute_Correction_Elem_Veloc


end module mystuff&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The compilation sequence is&lt;/P&gt;
&lt;P&gt;ifort -c -O3 -xHost -ftz -g -traceback -implicitnone -qopt-report=5 -qopt-report-phase=vec -fpp -DGM_VEC -pad -align array64byte -c mystuff_v01.f90&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The report is&lt;/P&gt;
&lt;LI-CODE lang="none"&gt;Intel(R) Advisor can now assist with vectorization and show optimization
  report messages with your source code.
See "https://software.intel.com/en-us/intel-advisor-xe" for details.

Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.6.0 Build 20220226_000000

Compiler options: -c -O3 -xHost -ftz -g -traceback -implicitnone -qopt-report=5 -qopt-report-phase=vec -fpp -DGM_VEC -pad -align array64byte -c

Begin optimization report for: MYSTUFF::COMPUTE_CORRECTION_ELEM_VELOC

    Report from: Vector optimizations [vec]


LOOP BEGIN at mystuff_v01.f90(26,25)
   remark #15329: vectorization support: irregularly indexed store was emulated for the variable &amp;lt;veloc(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(25,7) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;v0(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(25,25) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;forces(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(25,49) ]
   remark #15329: vectorization support: irregularly indexed store was emulated for the variable &amp;lt;accel(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(26,7) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;accel(ii,jj,0)&amp;gt;, part of index is nonlinearly computed
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;forces(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(26,49) ]
   remark #15329: vectorization support: irregularly indexed store was emulated for the variable &amp;lt;displ(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(27,7) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;displ(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(27,25) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;veloc(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(27,49) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;v0(ii,jj,0)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(27,66) ]
   remark #15329: vectorization support: irregularly indexed store was emulated for the variable &amp;lt;veloc(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(28,7) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;v0(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(28,25) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;forces(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(28,49) ]
   remark #15329: vectorization support: irregularly indexed store was emulated for the variable &amp;lt;accel(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(29,7) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;accel(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(29,25) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;forces(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(29,49) ]
   remark #15329: vectorization support: irregularly indexed store was emulated for the variable &amp;lt;displ(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(30,7) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;displ(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(30,25) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;veloc(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(30,49) ]
   remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;v0(ii,jj,1)&amp;gt;, part of index is nonlinearly computed   [ mystuff_v01.f90(30,66) ]
   remark #15305: vectorization support: vector length 2
   remark #15309: vectorization support: normalized vectorization overhead 0.073
   remark #15301: OpenMP SIMD LOOP WAS VECTORIZED
   remark #15462: unmasked indexed (or gather) loads: 14 
   remark #15463: unmasked indexed (or scatter) stores: 6 
   remark #15475: --- begin vector cost summary ---
   remark #15476: scalar cost: 134 
   remark #15477: vector cost: 191.500 
   remark #15478: estimated potential speedup: 0.690 
   remark #15482: vectorized math library calls: 2 
   remark #15488: --- end vector cost summary ---
LOOP END

LOOP BEGIN at mystuff_v01.f90(26,25)
&amp;lt;Remainder loop for vectorization&amp;gt;
LOOP END
===========================================================================&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I remove the OpenMP direction OMP SIMD COLLAPSE and I recompile, the new report is the following :&lt;/P&gt;
&lt;LI-CODE lang="none"&gt;Intel(R) Advisor can now assist with vectorization and show optimization
  report messages with your source code.
See "https://software.intel.com/en-us/intel-advisor-xe" for details.

Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.6.0 Build 20220226_000000

Compiler options: -c -O3 -xHost -ftz -g -traceback -implicitnone -qopt-report=5 -qopt-report-phase=vec -fpp -DGM_VEC -pad -align array64byte -c

Begin optimization report for: MYSTUFF::COMPUTE_CORRECTION_ELEM_VELOC

    Report from: Vector optimizations [vec]


LOOP BEGIN at mystuff_v00.f90(23,1)
   remark #15542: loop was not vectorized: inner loop was already vectorized

   LOOP BEGIN at mystuff_v00.f90(24,4)
   &amp;lt;Peeled loop for vectorization&amp;gt;
   LOOP END

   LOOP BEGIN at mystuff_v00.f90(24,4)
      remark #15389: vectorization support: reference veloc(ii,jj,1) has unaligned access   [ mystuff_v00.f90(28,7) ]
      remark #15389: vectorization support: reference v0(ii,jj,1) has unaligned access   [ mystuff_v00.f90(28,25) ]
      remark #15389: vectorization support: reference forces(ii,jj,1) has unaligned access   [ mystuff_v00.f90(28,49) ]
      remark #15389: vectorization support: reference veloc(ii,jj,0) has unaligned access   [ mystuff_v00.f90(25,7) ]
      remark #15389: vectorization support: reference v0(ii,jj,0) has unaligned access   [ mystuff_v00.f90(25,25) ]
      remark #15389: vectorization support: reference forces(ii,jj,0) has unaligned access   [ mystuff_v00.f90(25,49) ]
      remark #15389: vectorization support: reference accel(ii,jj,0) has unaligned access   [ mystuff_v00.f90(26,7) ]
      remark #15389: vectorization support: reference accel(ii,jj,0) has unaligned access   [ mystuff_v00.f90(26,25) ]
      remark #15389: vectorization support: reference forces(ii,jj,0) has unaligned access   [ mystuff_v00.f90(26,49) ]
      remark #15389: vectorization support: reference accel(ii,jj,1) has unaligned access   [ mystuff_v00.f90(29,7) ]
      remark #15389: vectorization support: reference accel(ii,jj,1) has unaligned access   [ mystuff_v00.f90(29,25) ]
      remark #15389: vectorization support: reference forces(ii,jj,1) has unaligned access   [ mystuff_v00.f90(29,49) ]
      remark #15389: vectorization support: reference displ(ii,jj,1) has unaligned access   [ mystuff_v00.f90(30,7) ]
      remark #15389: vectorization support: reference displ(ii,jj,1) has unaligned access   [ mystuff_v00.f90(30,25) ]
      remark #15389: vectorization support: reference veloc(ii,jj,1) has unaligned access   [ mystuff_v00.f90(30,49) ]
      remark #15389: vectorization support: reference v0(ii,jj,1) has unaligned access   [ mystuff_v00.f90(30,66) ]
      remark #15389: vectorization support: reference displ(ii,jj,0) has unaligned access   [ mystuff_v00.f90(27,7) ]
      remark #15389: vectorization support: reference displ(ii,jj,0) has unaligned access   [ mystuff_v00.f90(27,25) ]
      remark #15389: vectorization support: reference veloc(ii,jj,0) has unaligned access   [ mystuff_v00.f90(27,49) ]
      remark #15389: vectorization support: reference v0(ii,jj,0) has unaligned access   [ mystuff_v00.f90(27,66) ]
      remark #15381: vectorization support: unaligned access used inside loop body
      remark #15305: vectorization support: vector length 4
      remark #15309: vectorization support: normalized vectorization overhead 0.892
      remark #15300: LOOP WAS VECTORIZED
      remark #15442: entire loop may be executed in remainder
      remark #15450: unmasked unaligned unit stride loads: 10 
      remark #15451: unmasked unaligned unit stride stores: 6 
      remark #15475: --- begin vector cost summary ---
      remark #15476: scalar cost: 55 
      remark #15477: vector cost: 16.250 
      remark #15478: estimated potential speedup: 3.240 
      remark #15488: --- end vector cost summary ---
   LOOP END

   LOOP BEGIN at mystuff_v00.f90(24,4)
   &amp;lt;Remainder loop for vectorization&amp;gt;
   LOOP END
LOOP END
===========================================================================&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I look at the final lines of the first report, It seems to me that the estimated potential speedup with the OpenMP directive is very bad with respect to the last one. Is this normal ? What do I miss ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your comments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 16:19:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457568#M165171</guid>
      <dc:creator>Yann_D_</dc:creator>
      <dc:date>2023-02-20T16:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457599#M165172</link>
      <description>&lt;P&gt;Due to (nz-2, and nx-2):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;do jj = 1, nz-2
   do ii = 1, nx-2
&lt;/LI-CODE&gt;
&lt;P&gt;You have gaps in the blocks of data. You can only vectorize the inner loop. IOW these loops cannot be collapsed.&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 18:13:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457599#M165172</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2023-02-20T18:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457612#M165173</link>
      <description>&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;I fail to see why the code uses NZ-2 etc..&amp;nbsp; &amp;nbsp;if this was lisp one would write a few functions to allow for the equations,&amp;nbsp; there has to be a more efficient method?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 19:09:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457612#M165173</guid>
      <dc:creator>JohnNichols</dc:creator>
      <dc:date>2023-02-20T19:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457680#M165174</link>
      <description>&lt;P&gt;Edit,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In looking closer at your code, you have Forces dimensioned as:&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;real(REAL64), dimension(0:nx-1, 0:nz-1, 0:1), intent(INOUT) :: Forces&lt;/LI-CODE&gt;
&lt;P&gt;Nothing inherently wrong with that, except that your loop is iterating the in indices from 1 to nx-2 and nz-2&lt;/P&gt;
&lt;P&gt;This means that indices 0 and nz-1 are skipped over in your do loop. This is the reason why you could not collapse the two loop with vectorization. The collapse requires the collapsed&amp;nbsp;indices to be contiguous.&lt;/P&gt;
&lt;P&gt;If you really need collapsing of these loops, then consider dimensioning Forces the same as the other arrays, and then, add the two boundary forces as a separate array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will have to trade off "looks odd" with "runs better".&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 21:41:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457680#M165174</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2023-02-20T21:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457684#M165175</link>
      <description>&lt;P&gt;John,&lt;/P&gt;
&lt;P&gt;Assume you have a string you wish to simulate.&lt;/P&gt;
&lt;P&gt;Assume the end points are affixed to some structure.&lt;/P&gt;
&lt;P&gt;Assume the dynamics of the string is simulated by synthesizing beads along the length of the string.&lt;/P&gt;
&lt;P&gt;The forces for motion applies to the beads (indices 1:nz-2)&lt;/P&gt;
&lt;P&gt;Yet the forces within the string extends to the two end point fixtures (the 0'th and nz-1'th indices). Thus the forces require two additional variables (in the string example). The OP had something akin to a 2D mesh.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 21:48:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457684#M165175</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2023-02-20T21:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457686#M165176</link>
      <description>&lt;P&gt;BTW if the value of nx is large, then a collapse (if possible) would be of negligible value.&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 21:50:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457686#M165176</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2023-02-20T21:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457693#M165177</link>
      <description>&lt;P&gt;Yann,&lt;/P&gt;
&lt;P&gt;If you do take the route of separating the interior forces from the perimeter force then consider&lt;/P&gt;
&lt;P&gt;1) In the caller (or module variables), attribute your arrays with:&lt;/P&gt;
&lt;P&gt;!DIR$ ATTRIBUTES ALIGN : bytesOfAlignment :: YourArray&lt;/P&gt;
&lt;P&gt;2) in your called subroutine use the compiler directive !DIR$ &lt;A href="https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/language-reference/a-to-z-reference/a-to-b/assume-aligned.html" target="_self"&gt;ASSUME_ALIGNED&lt;/A&gt; YourArray:bytesOfAlignment&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generally you use 64 for bytesOfAlignment&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*** Caution, it is the programmers responsibility to assure the calling arguments meet the assumptions of the called subroutine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 22:02:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457693#M165177</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2023-02-20T22:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457893#M165181</link>
      <description>&lt;P&gt;Hello Mr Dempsey,&lt;/P&gt;
&lt;P&gt;I'm glad to read your comments !&lt;/P&gt;
&lt;P&gt;Some time has passed since my previous thread on Intel's forums (&lt;A href="https://community.intel.com/t5/Intel-Fortran-Compiler/Can-t-understand-why-fortran-inner-loop-not-vectorized/m-p/1430701#M163587" target="_self"&gt;Can't understand why fortran inner loop not vectorized&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;It's the same application and your advices let me strongly improve its performances. Thank you very much for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some remarks to answer your replies.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. As the situation is a bit more complicated than I thought, I create a small program (attached below) that contains everything to mimic the way the whole application does the computations.&lt;/P&gt;
&lt;P&gt;- a module named mytypes.f90 with the simplified definition of the derived type Element&lt;/P&gt;
&lt;P&gt;- a module named mystuff.f90 with the computing routines&lt;/P&gt;
&lt;P&gt;- a main program to run it, its results are meaningless&lt;/P&gt;
&lt;P&gt;- a script compile.sh to compile the source files&lt;/P&gt;
&lt;P&gt;- a script run.sh to execute the program&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. The dimensions of array "Forces", are not really a problem for me here, one can change them to the same as other arrays, i.e.&amp;nbsp; 1:nx-2,&amp;nbsp; 1:nz-2&lt;/P&gt;
&lt;P&gt;It's done in the attached example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. nx and nz are less than ten (5 or 9 ), but not constants through all the spectral elements (spatial discretization method). Moreover if I put a directive like&lt;/P&gt;
&lt;PRE&gt;!DIR$ LOOP COUNT (3,7) &lt;/PRE&gt;
&lt;P&gt;which are the possible lengths for the loops (nx and nz are equal to 5 or 9 in my examples) the compiler does not vectorize anymore : the performances fall. So, even on short loops like these, vectorization gives a real gain. So no loop count directive. This is the reason why I try to collapse the two loops to get a longer one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. I try to put the two attribute directives you talked about in this example but the only place the compiler accepts the directive "!$DIR$ ASSUME_ALIGNED " is in mytypes.f90 not in the called routine. I don't manage to compile with it in mystuff.f90 . If I try, I get messages like this :&lt;/P&gt;
&lt;P&gt;mystuff.f90(26): remark #7867: This directive is misplaced or not supported on this platform.&lt;/P&gt;
&lt;P&gt;(I keep them in comments in mystuff.f90)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With 2. and 4. , I compile the code and in the reports, I still get lots of bad messages like&lt;/P&gt;
&lt;P&gt;remark #15328: vectorization support: irregularly indexed load was emulated for the variable &amp;lt;veloc(ii,jj,1)&amp;gt;, part of index is nonlinearly computed [ mystuff.f90(49,49) ]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I should have something wrong !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 13:58:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457893#M165181</guid>
      <dc:creator>Yann_D_</dc:creator>
      <dc:date>2023-02-21T13:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457955#M165194</link>
      <description>&lt;P&gt;I made changes to your code and it now vectorizes.&lt;/P&gt;
&lt;P&gt;main.f90 is unchanged.&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;module mystuff

use mytypes

real(REAL64) :: bega

contains

subroutine Correction_Elem_Veloc (Elem, bega, gam1, dt)
implicit none

type(Element), intent(INOUT) :: Elem
real(REAL64),  intent(IN)    :: bega, gam1, dt

real(REAL64) :: sc2
integer :: nx, nz

nx = Elem%ngllx
nz = Elem%ngllz

sc2 = bega * dt
CALL compute_correction_Elem_Veloc (Elem%Accel, Elem%Forces, Elem%Displ, &amp;amp;
                                    Elem%Veloc, Elem%V0,     gam1, dt, sc2, nx*nz)



end subroutine Correction_Elem_Veloc

    end module mystuff

! Move out of the module contained procedure
! IOW make it an external procedure
! External procedures take the passed arguments as-is
! meaning the arguments can change rank and shape (you specify the size)
! ***** Compile with interface checking off *****
    
subroutine compute_Correction_Elem_Veloc (Accel, Forces, Displ, Veloc, V0, g1, ddt, sc2, n)
use mytypes
implicit none
integer :: n
real(REAL64), dimension(n), intent(INOUT) :: Accel
real(REAL64), dimension(n), intent(INOUT) :: Forces
real(REAL64), dimension(n), intent(INOUT) :: Displ
real(REAL64), dimension(n), intent(INOUT) :: Veloc
real(REAL64), dimension(n), intent(IN)    :: V0
real(REAL64), intent(IN) :: g1, ddt, sc2

integer :: ii
!$OMP SIMD
do ii = 1, size(Accel)
     Veloc (ii) =V0   (ii) + ddt * Forces(ii)
     Accel (ii) =Accel(ii) + g1  * Forces(ii)
     Displ (ii) =Displ(ii) + sc2 * (Veloc (ii) +V0(ii) )
end do
!
return
end subroutine compute_Correction_Elem_Veloc
&lt;/LI-CODE&gt;&lt;LI-CODE lang="none"&gt;Using VTune, the majority of the time in compute_Correction_Elem_Veloc is in this section:
.B2.13::                        ; Preds .B2.13 .B2.12
                                ; Execution count [5.44e+00]
        vmovupd   ymm9, YMMWORD PTR [rax+r10*8]                 ;51.18
        vmovupd   ymm6, YMMWORD PTR [rdx+r10*8]                 ;51.36
        vmovupd   ymm7, YMMWORD PTR [rcx+r10*8]                 ;52.18
        vmovdqa   ymm8, ymm2                                    ;51.6
        vfmadd213pd ymm8, ymm6, ymm9                            ;51.6
        vfmadd231pd ymm7, ymm6, ymm1                            ;52.6
        vaddpd    ymm6, ymm8, ymm9                              ;53.48
        vmovupd   YMMWORD PTR [rbx+r10*8], ymm8                 ;51.6
        vmovupd   YMMWORD PTR [rcx+r10*8], ymm7                 ;52.6
        vfmadd213pd ymm6, ymm0, YMMWORD PTR [rsi+r10*8]         ;53.6
        vmovupd   YMMWORD PTR [rsi+r10*8], ymm6                 ;53.6
        add       r10, 4                                        ;50.1
        cmp       r10, r9                                       ;50.1
        jb        .B2.13        ; Prob 82%                      ;50.1
&lt;/LI-CODE&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 18:15:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457955#M165194</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2023-02-21T18:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457957#M165195</link>
      <description>&lt;P&gt;I used 9,9 for input and ran the main loop 30 billion times (then stopped VTune run after about 30 seconds).&lt;/P&gt;
&lt;P&gt;I did modify you main to loop the call for timing purposes.&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 18:19:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457957#M165195</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2023-02-21T18:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457958#M165196</link>
      <description>&lt;P&gt;OOPS&lt;/P&gt;
&lt;P&gt;Change:&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;CALL compute_correction_Elem_Veloc (Elem%Accel, Elem%Forces, Elem%Displ, &amp;amp;
                                    Elem%Veloc, Elem%V0,     gam1, dt, sc2, nx*nz)
&lt;/LI-CODE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;CALL compute_correction_Elem_Veloc (Elem%Accel, Elem%Forces, Elem%Displ, &amp;amp;
                                    Elem%Veloc, Elem%V0,     gam1, dt, sc2, size(Elem%Accel))&lt;/LI-CODE&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 18:21:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457958#M165196</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2023-02-21T18:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457966#M165198</link>
      <description>&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;I understand your points, the real issue is this is a computationally time intensive analysis.&amp;nbsp; You will seek to speed it up, but even the fastest horse in the world can only run so fast.&amp;nbsp; Sometimes you need a chevy.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good improvement, perhaps a small Honda civic.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 18:50:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1457966#M165198</guid>
      <dc:creator>JohnNichols</dc:creator>
      <dc:date>2023-02-21T18:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1458313#M165233</link>
      <description>&lt;P&gt;Thank you for your replies.&lt;/P&gt;
&lt;P&gt;I know the trick of changing a 3D array to a 1D array when passing it as an argument to get a longer loop but I thought there were a way to do the job without it.&lt;/P&gt;
&lt;P&gt;So I will implement your idea in the real application and see what I get back !&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 17:25:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1458313#M165233</guid>
      <dc:creator>Yann_D_</dc:creator>
      <dc:date>2023-02-22T17:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1458361#M165235</link>
      <description>&lt;P&gt;Would I be correct that your application will have a large number of these elements?&lt;/P&gt;
&lt;P&gt;If this be so, then consider:&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;type Elements
  ...
  real(REAL64) :: dimension(:,:,:,:) :: Forces ! allocate( Forces(nx, nz, 2, nElements) )
...

&lt;/LI-CODE&gt;
&lt;P&gt;IOW the entire blob of forces (etc...) can be worked upon in a single call.&lt;/P&gt;
&lt;P&gt;This will reduce the number of calls and more importantly, reduce the number of times the code performs the alignment checks and peel preamble, and post-able remainder to once for nElements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 19:36:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1458361#M165235</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2023-02-22T19:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1458688#M165249</link>
      <description>&lt;P&gt;The number of elements can be quite large but the treatment is not the same for all elements. It's an unstructured mesh. The boundary elements are treated differently. And there are some other kind of elements too. Maybe a reordering may help but it implies lots of modifications in different parts of the source code. I'll talk about this to the other developpers.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Yann&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 15:57:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1458688#M165249</guid>
      <dc:creator>Yann_D_</dc:creator>
      <dc:date>2023-02-23T15:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to vectorize two nested fortran loops with OpenMP directive with COLLAPSE clause ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1458767#M165257</link>
      <description>&lt;P&gt;Yann,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With some expansion of your simplified test program,&amp;nbsp;you can model the step integration for a representative number of elements. The same model would contain the two or more different structures and implementation for your elements. Making timing test runs will give you a metric for a cost/benefit ratio.&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&lt;SPAN&gt;treatment is not the same for all elements.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;When the treatment is static per element, then you can have different classes of elements, each executed using their specific treatment.&lt;/P&gt;
&lt;P&gt;When the treatment is dynamic per element, but the frequency and degree of change in treatment is small, then you may be able to employ a technique of incorporating "NULL" elements in each class. IOW elements that are computed, but have no effect on the results. To move an element from one class to another, you nullify it in the current class and then overlay a NULL element in the destination class. This technique permits the arrays to be allocated once (with spare entries of NULLs for element movement) or have a minimal amount of reallocation.&lt;/P&gt;
&lt;P&gt;You have to be careful about division by 0.0. Depending on your model, this might involve making the mass or charge 0.0 or other such property that facilitates no net change in results while avoiding an IF test and branch. The&lt;SPAN&gt;&amp;nbsp;idea is to get the most out of SIMD execution.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you need some consulting help, I am available.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jim Dempsey&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 19:24:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-vectorize-two-nested-fortran-loops-with-OpenMP-directive/m-p/1458767#M165257</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2023-02-23T19:24:23Z</dc:date>
    </item>
  </channel>
</rss>

