| 1 |
! { dg-do compile } |
| 2 |
|
| 3 |
module m |
| 4 |
implicit none (type, external) |
| 5 |
contains |
| 6 |
real function add(x, y, j) result(res) |
| 7 |
!$omp declare simd(add) uniform(x, y) linear(j : 1) simdlen(4) |
| 8 |
integer, value :: j |
| 9 |
real, intent(in) :: x(*), y(*) |
| 10 |
res = x(j) + y(j) |
| 11 |
end function |
| 12 |
end module m |
| 13 |
|
| 14 |
program main |
| 15 |
use m |
| 16 |
implicit none (type, external) |
| 17 |
real, allocatable :: A(:), B(:), C(:) |
| 18 |
integer :: i, N |
| 19 |
N = 128 |
| 20 |
A = [(3*i, i = 1, N)] |
| 21 |
B = [(7*i, i = 1, N)] |
| 22 |
allocate (C(N)) |
| 23 |
|
| 24 |
!$omp simd |
| 25 |
do i = 1, N |
| 26 |
C(i) = add(A, B, i) |
| 27 |
end do |
| 28 |
|
| 29 |
if (any (C /= [(10*i, i = 1, N)])) error stop |
| 30 |
end program main |