aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran/depobj-1.f90
blob: 273b10c09c54d50b0714b9bdd0a7c1fde7245ad9 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
module m
  use omp_lib, only: omp_depend_kind
  implicit none (type, external)
  integer :: xx
  integer(omp_depend_kind) :: dd1, dd2
contains
  subroutine dep
    integer :: x
    integer(omp_depend_kind) :: d1, d2
    x = 1

    !$omp depobj (d1) depend(in: x)
    !$omp depobj (d2) depend(in: x)
    !$omp depobj (d2) update(out)
    !$omp parallel
      !$omp single
        !$omp task shared (x) depend(depobj: d2)
          x = 2
        !$omp end task
        !$omp task shared (x) depend(depobj: d1)
          if (x /= 2) &
            stop 1
        !$omp end task
      !$omp end single
    !$omp end parallel
    !$omp depobj (d2) destroy
    !$omp depobj (d1) destroy
  end

  subroutine dep2
    integer(omp_depend_kind) :: d1, d2
    pointer :: d1
    allocate(d1)
    call dep2i(d1, d2)
    deallocate(d1)
  contains
   subroutine dep2i(d1, d2)
    integer(omp_depend_kind) :: d1
    integer(omp_depend_kind), optional :: d2
    pointer :: d1
    !$omp parallel
      !$omp single
        block
        integer :: x
        x = 1
        !$omp depobj (d1) depend(out: x)
        !$omp depobj (d2) depend (in:x)
        !$omp depobj(d2)update(in)
        !$omp task shared (x) depend(depobj:d1)
          x = 2
        !$omp end task
        !$omp task shared (x) depend(depobj : d2)
          if (x /= 2) &
            stop 2
        !$omp end task
        !$omp taskwait
        !$omp depobj(d1)destroy
        !$omp depobj(d2) destroy
        end block
     !$omp end single
   !$omp end parallel
  end
  end

  subroutine dep3
    integer(omp_depend_kind) :: d(2)
    !$omp parallel
      block
      integer :: x
      x = 1
      !$omp single
        !$omp depobj(d(1)) depend(out:x)
        !$omp depobj(d(2)) depend(in: x)
        !$omp task shared (x) depend(depobj: d(1))
          x = 2
        !$omp end task
        !$omp task shared (x) depend(depobj: d(2))
          if (x /= 2) &
            stop 3
        !$omp end task
      !$omp end single
      end block
    !$omp end parallel
    !$omp depobj(d(1)) destroy
    !$omp depobj(d(2)) destroy
  end

  subroutine antidep
    xx = 1
    !$omp parallel
      !$omp single
        !$omp task shared(xx) depend(depobj:dd2)
          if (xx /= 1) &
            stop 4
        !$omp end task
        !$omp task shared(xx) depend(depobj:dd1)
          xx = 2
        !$omp end task
      !$omp end single
    !$omp end parallel
  end
end module m

program main
  use m
  implicit none (type, external)
  call dep ()
  call dep2 ()
  call dep3 ()
  !$omp depobj (dd1) depend (inout: xx)
  !$omp depobj (dd2) depend (in : xx)
  call antidep ()
  !$omp depobj (dd2) destroy
  !$omp depobj (dd1) destroy
end program main