Passing an array/array recommendation to an ELEMENTAL function/subroutine is creating a dependency that prevents vectorization. To fix:
- Enforce vectorization of the source loop using SIMD instructions and/or create a SIMD version of the function(s) using a directive:
Target Directive Source loop !$OMP SIMD Inner function definition or declaration !$OMP DECLARE SIMD - Call from a DO loop.
elemental subroutine callee(t,q,r)
...
end subroutine callee
...
do k = 1,nlev
call callee(a(:,k), b(:,k), c(:,k))
...elemental subroutine callee(t,q,r)
real, intent(in) :: t, q
real, intent(out) :: r
r = t + q
end subroutine callee
...
do k = 1,nlev
call callee(a(:,k), b(:,k), c(:,k))
end do
... subroutine callee(t,q,r)
!$OMP DECLARE SIMD(callee)
...
end subroutine callee
...
do k = 1,nlev
!$OMP SIMD
do i = 1,n
call callee(a(i,k), b(i,k), c(i,k))
...
subroutine callee(t,q,r)
!$OMP DECLARE SIMD(callee)
real, intent(in) :: t, q
real, intent(out) :: r
r = t + q
end subroutine callee
...
do k = 1,nlev
!$OMP SIMD
do i = 1,n
call callee(a(i,k), b(i,k), c(i,k))
end do
end do
...