aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran/pr66199-8.f90
blob: 8a21c6f2b2a50f7ae4167c4184d33cdf80e6473c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
! { dg-do run }
!
! PR fortran/94690
! PR middle-end/66199

module m
  implicit none
  integer u(0:1023), v(0:1023), w(0:1023)
  !$omp declare target (u, v, w)

contains

integer function f1 (a, b)
  integer :: a, b, d
  !$omp target map(from: d)
  !$omp teams default(none) shared(a, b, d, u, v, w)
  !$omp distribute simd firstprivate (a, b)
  do d = a, b-1
    u(d) = v(d) + w(d)
  end do
  !$omp end teams
  !$omp end target
  f1 = d
end

integer function f2 (a, b, c)
  integer a, b, c, d, e
  !$omp target map(from: d, e)
  !$omp teams default(none) firstprivate (a, b, c) shared(d, e, u, v, w)
  !$omp distribute simd linear(d) lastprivate(e)
  do d = a, b-1
    u(d) = v(d) + w(d)
    e = c + d * 5
  end do
  !$omp end teams
  !$omp end target
  f2 = d + e
end

integer function f3 (a1, b1, a2, b2)
  integer a1, b1, a2, b2, d1, d2
  !$omp target map(from: d1, d2)
  !$omp teams default(none) shared(a1, b1, a2, b2, d1, d2, u, v, w)
  !$omp distribute simd firstprivate (a1, b1, a2, b2) lastprivate(d1, d2) collapse(2)
  do d1 = a1, b1-1
    do d2 = a2, b2-1
      u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
    end do
  end do
  !$omp end teams
  !$omp end target
  f3 = d1 + d2
end

integer function f4 (a1, b1, a2, b2)
  integer a1, b1, a2, b2, d1, d2
  !$omp target map(from: d1, d2)
  !$omp teams default(none) firstprivate (a1, b1, a2, b2) shared(d1, d2, u, v, w)
  !$omp distribute simd collapse(2)
  do d1 = a1, b1-1
    do d2 = a2, b2-1
      u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
    end do
  end do
  !$omp end teams
  !$omp end target
  f4 = d1 + d2
end
end module m

use m
  if (f1 (0, 1024) /= 1024) stop 1
  if (f2 (0, 1024, 17) /= 1024 + (17 + 5 * 1023)) stop 2
  if (f3 (0, 32, 0, 32) /= 64) stop 3
  if (f4 (0, 32, 0, 32) /= 64) stop 4
end