d: Add language reference section to documentation files.
[official-gcc.git] / libgomp / testsuite / libgomp.fortran / declare-simd-1.f90
blobcb8f4df8d62e662582ff34f11b2b6f3e4c67f730
1 ! { dg-do run { target vect_simd_clones } }
2 ! { dg-options "-fno-inline" }
3 ! { dg-additional-options "-msse2" { target sse2_runtime } }
4 ! { dg-additional-options "-mavx" { target avx_runtime } }
6 module declare_simd_1_mod
7 contains
8 real function foo (a, b, c)
9 !$omp declare simd (foo) simdlen (4) uniform (a) linear (b : 5) &
10 !$omp & notinbranch
11 double precision, value :: a
12 real, value :: c
13 !$omp declare simd (foo)
14 integer, value :: b
15 foo = a + b * c
16 end function foo
17 end module declare_simd_1_mod
18 use declare_simd_1_mod
19 interface
20 function bar (a, b, c)
21 !$omp declare simd (bar)
22 integer, value :: b
23 real, value :: c
24 real :: bar
25 !$omp declare simd (bar) simdlen (4) linear (b : 2)
26 !$omp declare simd (bar) simdlen (16) inbranch
27 double precision, value :: a
28 end function bar
29 end interface
30 integer :: i
31 double precision :: a(128)
32 real :: b(128), d(128)
33 data d /171., 414., 745., 1164., 1671., 2266., 2949., 3720., 4579., &
34 & 5526., 6561., 7684., 8895., 10194., 11581., 13056., 14619., &
35 & 16270., 18009., 19836., 21751., 23754., 25845., 28024., &
36 & 30291., 32646., 35089., 37620., 40239., 42946., 45741., &
37 & 48624., 51595., 54654., 57801., 61036., 64359., 67770., &
38 & 71269., 74856., 78531., 82294., 86145., 90084., 94111., &
39 & 98226., 102429., 106720., 111099., 115566., 120121., 124764., &
40 & 129495., 134314., 139221., 144216., 149299., 154470., 159729., &
41 & 165076., 170511., 176034., 181645., 187344., 193131., 199006., &
42 & 204969., 211020., 217159., 223386., 229701., 236104., 242595., &
43 & 249174., 255841., 262596., 269439., 276370., 283389., 290496., &
44 & 297691., 304974., 312345., 319804., 327351., 334986., 342709., &
45 & 350520., 358419., 366406., 374481., 382644., 390895., 399234., &
46 & 407661., 416176., 424779., 433470., 442249., 451116., 460071., &
47 & 469114., 478245., 487464., 496771., 506166., 515649., 525220., &
48 & 534879., 544626., 554461., 564384., 574395., 584494., 594681., &
49 & 604956., 615319., 625770., 636309., 646936., 657651., 668454., &
50 & 679345., 690324., 701391., 712546., 723789., 735120./
51 !$omp simd
52 do i = 1, 128
53 a(i) = 7.0 * i + 16.0
54 b(i) = 5.0 * i + 12.0
55 end do
56 !$omp simd
57 do i = 1, 128
58 b(i) = foo (a(i), 3, b(i))
59 end do
60 !$omp simd
61 do i = 1, 128
62 b(i) = bar (a(i), 2 * i, b(i))
63 end do
64 if (any (b.ne.d)) stop 1
65 !$omp simd
66 do i = 1, 128
67 b(i) = i * 2.0
68 end do
69 !$omp simd
70 do i = 1, 128
71 b(i) = baz (7.0_8, 2, b(i))
72 end do
73 do i = 1, 128
74 if (b(i).ne.(7.0 + 4.0 * i)) stop 2
75 end do
76 contains
77 function baz (x, y, z)
78 !$omp declare simd (baz) simdlen (8) uniform (x, y)
79 !$omp declare simd (baz)
80 integer, value :: y
81 real, value :: z
82 real :: baz
83 double precision, value :: x
84 baz = x + y * z
85 end function baz
86 end
87 function bar (a, b, c)
88 integer, value :: b
89 real, value :: c
90 real :: bar
91 double precision, value :: a
92 !$omp declare simd (bar)
93 !$omp declare simd (bar) simdlen (4) linear (b : 2)
94 bar = a + b * c
95 end function bar