2018-03-25 Thomas Koenig <tkoenig@gcc.gnu.org>
[official-gcc.git] / libgomp / testsuite / libgomp.fortran / examples-4 / simd-4.f90
blobcb78e2c776553dbcab81b42522ec379b42b26e5e
1 ! { dg-do run }
2 ! { dg-additional-options "-msse2" { target sse2_runtime } }
3 ! { dg-additional-options "-mavx" { target avx_runtime } }
5 module SIMD4_mod
6 contains
7 subroutine work( b, n, m )
8 implicit none
9 real :: b(n)
10 integer :: i,n,m
12 call init(b, n)
14 !$omp simd safelen(16)
15 do i = m+1, n
16 b(i) = b(i-m) - 1.0
17 end do
18 end subroutine work
20 subroutine work_ref( b, n, m )
21 implicit none
22 real :: b(n)
23 integer :: i,n,m
25 call init(b, n)
27 do i = m+1, n
28 b(i) = b(i-m) - 1.0
29 end do
30 end subroutine work_ref
32 subroutine init (b, n)
33 real :: b(*)
34 integer :: n, i, s
36 s = -1
37 do i = 1, n
38 b(i) = i * i * s
39 s = -s
40 end do
42 end subroutine
44 subroutine check (a, b, n)
45 integer :: i, n
46 real, parameter :: EPS = 0.000001
47 real :: diff, a(*), b(*)
48 do i = 1, n
49 diff = a(i) - b(i)
50 if (diff > EPS .or. -diff > EPS) STOP 1
51 end do
52 end subroutine
54 end module
56 program SIMD4
57 use SIMD4_mod
58 real :: b(128), b_ref(128)
60 call work(b, 128, 32)
61 call work_ref(b_ref, 128, 32)
63 call check(b, b_ref, 128)
64 end program