Check CXXFLAGS, instead of CFLAGS, for NO_PIE_CFLAGS
[official-gcc.git] / libgomp / testsuite / libgomp.fortran / simd4.f90
bloba5b8ba0babdaed2dc361f9f22dc42d922c299232
1 ! { dg-do run }
2 ! { dg-additional-options "-msse2" { target sse2_runtime } }
3 ! { dg-additional-options "-mavx" { target avx_runtime } }
5 integer :: a(1024), b(1024), k, m, i, s, t
6 k = 4
7 m = 2
8 t = 1
9 do i = 1, 1024
10 a(i) = i - 513
11 b(i) = modulo (i - 52, 39)
12 if (i.lt.52.and.b(i).ne.0) b(i) = b(i) - 39
13 end do
14 s = foo (b)
15 do i = 1, 1024
16 if (a(i).ne.((i - 513) * b(i))) call abort
17 if (i.lt.52.and.modulo (i - 52, 39).ne.0) then
18 if (b(i).ne.(modulo (i - 52, 39) - 39)) call abort
19 else
20 if (b(i).ne.(modulo (i - 52, 39))) call abort
21 end if
22 a(i) = i - 513
23 end do
24 if (k.ne.(4 + 3 * 1024).or.s.ne.1596127) call abort
25 k = 4
26 m = 2
27 t = 1
28 s = bar (b)
29 do i = 1, 1024
30 if (a(i).ne.((i - 513) * b(i))) call abort
31 if (i.lt.52.and.modulo (i - 52, 39).ne.0) then
32 if (b(i).ne.(modulo (i - 52, 39) - 39)) call abort
33 else
34 if (b(i).ne.(modulo (i - 52, 39))) call abort
35 end if
36 a(i) = i - 513
37 end do
38 if (k.ne.(4 + 3 * 1024).or.s.ne.1596127) call abort
39 k = 4
40 m = 2
41 t = 1
42 s = baz (b)
43 do i = 1, 1024
44 if (a(i).ne.((i - 513) * b(i))) call abort
45 if (i.lt.52.and.modulo (i - 52, 39).ne.0) then
46 if (b(i).ne.(modulo (i - 52, 39) - 39)) call abort
47 else
48 if (b(i).ne.(modulo (i - 52, 39))) call abort
49 end if
50 end do
51 if (k.ne.(4 + 3 * 1024).or.s.ne.1596127) call abort
52 contains
53 function foo (p)
54 integer :: p(1024), u, v, i, s, foo
55 s = 0
56 !$omp parallel do simd linear(k : m + 1) reduction(+: s) &
57 !$omp & lastprivate(u, v) schedule (static, 32)
58 do i = 1, 1024
59 a(i) = a(i) * p(i)
60 u = p(i) + k
61 k = k + m + 1
62 v = p(i) + k
63 s = s + p(i) + k
64 end do
65 !$omp end parallel do simd
66 if (i.ne.1025) call abort
67 if (u.ne.(36 + 4 + 3 * 1023).or.v.ne.(36 + 4 + 3 * 1024)) call abort
68 foo = s
69 end function foo
70 function bar (p)
71 integer :: p(1024), u, v, i, s, bar
72 s = 0
73 !$omp parallel do simd linear(k : m + 1) reduction(+: s) &
74 !$omp & lastprivate(u, v) schedule (dynamic, 32)
75 do i = 1, 1024, t
76 a(i) = a(i) * p(i)
77 u = p(i) + k
78 k = k + m + 1
79 v = p(i) + k
80 s = s + p(i) + k
81 end do
82 !$omp endparalleldosimd
83 if (i.ne.1025) call abort
84 if (u.ne.(36 + 4 + 3 * 1023).or.v.ne.(36 + 4 + 3 * 1024)) call abort
85 bar = s
86 end function bar
87 function baz (p)
88 integer :: p(1024), u, v, i, s, baz
89 s = 0
90 !$omp parallel do simd linear(k : m + 1) reduction(+: s) &
91 !$omp & lastprivate(u, v) linear(i : t) schedule (static, 8)
92 do i = 1, 1024, t
93 a(i) = a(i) * p(i)
94 u = p(i) + k
95 k = k + m + 1
96 v = p(i) + k
97 s = s + p(i) + k
98 end do
99 if (i.ne.1025) call abort
100 if (u.ne.(36 + 4 + 3 * 1023).or.v.ne.(36 + 4 + 3 * 1024)) call abort
101 baz = s
102 end function baz