Given the following simple code
!DEC$ ATTRIBUTES FORCEINLINE :: RESET elemental subroutine RESET(this ) !DIR$ ATTRIBUTES VECTOR :: RESET implicit none class(t_sources), intent(inout) :: this !---- local integer :: i !DIR$ VECTOR ALIGNED this% mass_n = this% mass !DIR$ VECTOR ALIGNED this% mom_n(:,1) = this% mom(:,1) !DIR$ VECTOR ALIGNED this% mom_n(:,2) = this% momentum(:,2) !DIR$ VECTOR ALIGNED this% mom_n(:,3) = this% mom(:,3) !--- initialise array !DIR$ VECTOR ALIGNED this% mass = 0. !DIR$ VECTOR ALIGNED this% mom(:,1) = 0. !DIR$ VECTOR ALIGNED this% mom(:,2) = 0. !DIR$ VECTOR ALIGNED this% mom(:,3) = 0.
I get the following optimisation report (SHOWN for line 16 but the same principle goes for the remaining)
LOOP BEGIN at test.f(16,7) remark #25399: memcopy generated remark #17104: loop was not parallelized: existence of parallel dependence remark #17106: parallel dependence: assumed OUTPUT dependence between this(:,2) (16:7) and this(:,2) (16:7) remark #17106: parallel dependence: assumed OUTPUT dependence between this(:,2) (16:7) and this(:,2) (16:7) remark #15542: loop was not vectorized: inner loop was already vectorized LOOP BEGIN at tes.f(16,7) remark #15388: vectorization support: reference this(:,2) has aligned access remark #15388: vectorization support: reference this(:,2) has aligned access remark #15305: vectorization support: vector length 4 remark #15300: LOOP WAS VECTORIZED remark #15448: unmasked aligned unit stride loads: 1 remark #15449: unmasked aligned unit stride stores: 1 remark #15475: --- begin vector cost summary --- remark #15476: scalar cost: 4 remark #15477: vector cost: 0.750 remark #15478: estimated potential speedup: 5.330 remark #15488: --- end vector cost summary --- remark #25015: Estimate of max trip count of loop=3 LOOP END
Question A) : How shall I interpret the difference between that the loop was not parallelised but vectorized? - I am compiling with -parallel but that would enable automatic vectorization? Can somebody please explain me the difference between these two reports
Question B) : As you see I have a the directive `!DIR$ ATTRIBUTES VECTOR :: RESET` - I am not sure when to use and when not to use it. I now it means that the function becomes vectorized but would that differ from not having the directive but rather having a !omp simd?
Thanks very much in advance