Add support for ARMv8-R architecture
[official-gcc.git] / libgomp / testsuite / libgomp.fortran / examples-4 / simd-3.f90
blob2c02945de87408ab2a2452bb83bcacda99d7bb24
1 ! { dg-do run }
2 ! { dg-additional-options "-msse2" { target sse2_runtime } }
3 ! { dg-additional-options "-mavx" { target avx_runtime } }
5 module SIMD3_mod
6 contains
7 subroutine work( a, b, n, sum )
8 implicit none
9 integer :: i, n
10 double precision :: a(n), b(n), sum, tmp
12 sum = 0.0d0
13 call init(a, b, n)
14 !$omp simd private(tmp) reduction(+:sum)
15 do i = 1,n
16 tmp = a(i) + b(i)
17 sum = sum + tmp
18 end do
20 end subroutine work
22 subroutine work_ref( a, b, n, sum )
23 implicit none
24 integer :: i, n
25 double precision :: a(n), b(n), sum, tmp
27 sum = 0.0d0
28 call init(a, b, n)
29 do i = 1,n
30 tmp = a(i) + b(i)
31 sum = sum + tmp
32 end do
34 end subroutine work_ref
36 subroutine init (a, b, n)
37 double precision :: a(*), b(*)
38 integer :: n, i, s
40 s = -1
41 do i = 1, n
42 a(i) = i * i * s
43 b(i) = i + i
44 s = -s
45 end do
47 end subroutine
48 end module
50 program SIMD3
51 use SIMD3_mod
52 double precision :: a(128), b(128), sum, sum_ref, diff
53 double precision, parameter :: EPS = 0.0000000000000001
55 call work(a, b, 128, sum)
56 call work_ref(a, b, 128, sum_ref)
58 diff = sum - sum_ref
60 if (diff > EPS .or. -diff > EPS) call abort
62 end program