| 1 |
module m |
| 2 |
use omp_lib, only: omp_depend_kind |
| 3 |
implicit none (type, external) |
| 4 |
integer :: xx |
| 5 |
integer(omp_depend_kind) :: dd1, dd2 |
| 6 |
contains |
| 7 |
subroutine dep |
| 8 |
integer :: x |
| 9 |
integer(omp_depend_kind) :: d1, d2 |
| 10 |
x = 1 |
| 11 |
|
| 12 |
!$omp depobj (d1) depend(in: x) |
| 13 |
!$omp depobj (d2) depend(in: x) |
| 14 |
!$omp depobj (d2) update(out) |
| 15 |
!$omp parallel |
| 16 |
!$omp single |
| 17 |
!$omp task shared (x) depend(depobj: d2) |
| 18 |
x = 2 |
| 19 |
!$omp end task |
| 20 |
!$omp task shared (x) depend(depobj: d1) |
| 21 |
if (x /= 2) & |
| 22 |
stop 1 |
| 23 |
!$omp end task |
| 24 |
!$omp end single |
| 25 |
!$omp end parallel |
| 26 |
!$omp depobj (d2) destroy |
| 27 |
!$omp depobj (d1) destroy |
| 28 |
end |
| 29 |
|
| 30 |
subroutine dep2 |
| 31 |
integer(omp_depend_kind) :: d1, d2 |
| 32 |
pointer :: d1 |
| 33 |
allocate(d1) |
| 34 |
call dep2i(d1, d2) |
| 35 |
deallocate(d1) |
| 36 |
contains |
| 37 |
subroutine dep2i(d1, d2) |
| 38 |
integer(omp_depend_kind) :: d1 |
| 39 |
integer(omp_depend_kind), optional :: d2 |
| 40 |
pointer :: d1 |
| 41 |
!$omp parallel |
| 42 |
!$omp single |
| 43 |
block |
| 44 |
integer :: x |
| 45 |
x = 1 |
| 46 |
!$omp depobj (d1) depend(out: x) |
| 47 |
!$omp depobj (d2) depend (in:x) |
| 48 |
!$omp depobj(d2)update(in) |
| 49 |
!$omp task shared (x) depend(depobj:d1) |
| 50 |
x = 2 |
| 51 |
!$omp end task |
| 52 |
!$omp task shared (x) depend(depobj : d2) |
| 53 |
if (x /= 2) & |
| 54 |
stop 2 |
| 55 |
!$omp end task |
| 56 |
!$omp taskwait |
| 57 |
!$omp depobj(d1)destroy |
| 58 |
!$omp depobj(d2) destroy |
| 59 |
end block |
| 60 |
!$omp end single |
| 61 |
!$omp end parallel |
| 62 |
end |
| 63 |
end |
| 64 |
|
| 65 |
subroutine dep3 |
| 66 |
integer(omp_depend_kind) :: d(2) |
| 67 |
!$omp parallel |
| 68 |
block |
| 69 |
integer :: x |
| 70 |
x = 1 |
| 71 |
!$omp single |
| 72 |
!$omp depobj(d(1)) depend(out:x) |
| 73 |
!$omp depobj(d(2)) depend(in: x) |
| 74 |
!$omp task shared (x) depend(depobj: d(1)) |
| 75 |
x = 2 |
| 76 |
!$omp end task |
| 77 |
!$omp task shared (x) depend(depobj: d(2)) |
| 78 |
if (x /= 2) & |
| 79 |
stop 3 |
| 80 |
!$omp end task |
| 81 |
!$omp end single |
| 82 |
end block |
| 83 |
!$omp end parallel |
| 84 |
!$omp depobj(d(1)) destroy |
| 85 |
!$omp depobj(d(2)) destroy |
| 86 |
end |
| 87 |
|
| 88 |
subroutine antidep |
| 89 |
xx = 1 |
| 90 |
!$omp parallel |
| 91 |
!$omp single |
| 92 |
!$omp task shared(xx) depend(depobj:dd2) |
| 93 |
if (xx /= 1) & |
| 94 |
stop 4 |
| 95 |
!$omp end task |
| 96 |
!$omp task shared(xx) depend(depobj:dd1) |
| 97 |
xx = 2 |
| 98 |
!$omp end task |
| 99 |
!$omp end single |
| 100 |
!$omp end parallel |
| 101 |
end |
| 102 |
end module m |
| 103 |
|
| 104 |
program main |
| 105 |
use m |
| 106 |
implicit none (type, external) |
| 107 |
call dep () |
| 108 |
call dep2 () |
| 109 |
call dep3 () |
| 110 |
!$omp depobj (dd1) depend (inout: xx) |
| 111 |
!$omp depobj (dd2) depend (in : xx) |
| 112 |
call antidep () |
| 113 |
!$omp depobj (dd2) destroy |
| 114 |
!$omp depobj (dd1) destroy |
| 115 |
end program main |