So I have some code that is from a model where many of the loops appear something like the following where one is doing stride one accesses through dynamically allocatable arrays. Now, despite the arrays being at the end of pointer lists, I know that the arrays do no overlap in memory. Using IVDEP or VECTOR directives will not convince the compiler to vectorize this code (no surprises there). Prior to the v14 compiler, the compiler would also not vectorize this code despite using !DIR$ SIMD or !$OMP SIMD directives. The v14 compiler, however, does as is evidenced by both the vec report messages and the associated assembly code.
!$OMP PARALLEL PRIVATE(block) block => domain % blocklist do while (associated(block)) !$OMP DO SCHEDULE(RUNTIME) PRIVATE(k) do j = 1, block % mesh % nEdges !$OMP SIMD do i = 1, block % mesh % nVertLevels block % state % time_levs(2) % state % a % array(i,j) = & block % mesh % edgeMask % array(i,j) * ( & block % state % time_levs(2) % state % b % array(i,j) + & block % state % time_levs(1) % state % c % array(i,j) ) end do end do !$OMP END DO block => block % next end do ! block !$OMP END PARALLEL
While the latest compiler that we now have does indeed vectorize the code through the !DIR$/!$OMP SIMD directive, it fails at run time, either through a seg fault or silently when using OpenMP. Indeed, in the agove loop, I've observed the following behavior:
With > 1 thread does not work at run time with !$OMP SIMD or !DIR$ SIMD. Fails silently
With 1 thread, seg faults
Without OpenMP: seg faults using !DIR$ SIMD
Would gladly attach the short test code and the assembler output if this forum let me do that.