Debian Codegraph @

gcc/testsuite/gfortran.dg/gomp/declare-variant-5.f90

raw
1 ! { dg-do compile { target i?86-*-* x86_64-*-* } }
2 ! { dg-additional-options "-mavx2" }
3
4 module main
5 implicit none
6 contains
7 function f1 (x, y, z)
8 integer, dimension(4) :: f1
9 real, dimension(4), intent(in) :: x, y
10 real, intent(out) :: z
11
12 f1 = x
13 end function
14
15 function f2 (x, y, z)
16 integer, dimension(8) :: f2
17 real, dimension(8), intent(in) :: x, y
18 real, intent(out) :: z
19
20 f2 = x
21 end function
22
23 function f3 (x, y, z)
24 integer, dimension(4) :: f3
25 real, dimension(4), intent(in) :: x, z
26 integer, intent(in) :: y
27
28 f3 = x
29 end function
30
31 integer function f4 (x, y, z)
32 real, intent(in) :: x, y
33 real, intent(out) :: z
34 !$omp declare variant (f1) match (construct={parallel,do,simd(simdlen(4),notinbranch,uniform(z),aligned(z:16))})
35 !$omp declare variant (f2) match (construct={do,simd(uniform(z),simdlen(8),notinbranch)})
36 end function
37
38 integer function f5 (x, y)
39 integer, intent(in) :: x, y
40 !$omp declare variant (f3) match (construct={simd(simdlen(4),inbranch,linear(y:1))})
41 end function
42
43 subroutine test (x, y, z, w)
44 integer, dimension(8192), intent(inout) :: x
45 real, dimension(8192), intent(inout) :: y, z
46 real, pointer, intent(out) :: w
47 integer :: i
48
49 !$omp parallel
50 !$omp do simd aligned (w:16)
51 do i = 1, 1024
52 x(i) = f4 (y(i), z(i), w)
53 end do
54 !$omp end do simd
55 !$omp end parallel
56
57 !$omp parallel do simd aligned (w:16) simdlen(4)
58 do i = 1025, 2048
59 x(i) = f4 (y(i), z(i), w)
60 end do
61 !$omp end parallel do simd
62
63 !$omp simd aligned (w:16)
64 do i = 2049, 4096
65 x(i) = f4 (y(i), z(i), w)
66 end do
67 !$omp end simd
68
69 !$omp simd
70 do i = 4097, 8192
71 if (x(i) .gt. 10) x(i) = f5 (x(i), i)
72 end do
73 !$omp end simd
74 end subroutine
75 end module