| 1 |
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp |
| 2 |
! OpenMP Version 4.5 |
| 3 |
! 2.15.3.4 firstprivate Clause |
| 4 |
! Variables that appear in a firstprivate clause on a distribute or |
| 5 |
! worksharing constructs must not appear in the private or |
| 6 |
! reduction clause in a teams or parallel constructs in the outer context |
| 7 |
! |
| 8 |
! A list item may appear in a firstprivate or lastprivate clause but not both on |
| 9 |
! a distribute directive |
| 10 |
|
| 11 |
program omp_firstprivate |
| 12 |
integer :: i, a(10), b(10), c(10) |
| 13 |
|
| 14 |
a = 10 |
| 15 |
b = 20 |
| 16 |
|
| 17 |
!ERROR: TARGET construct with nested TEAMS region contains statements or directives outside of the TEAMS construct |
| 18 |
!$omp target |
| 19 |
!$omp teams private(a, b) |
| 20 |
!ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context |
| 21 |
!$omp distribute firstprivate(a) |
| 22 |
do i = 1, 10 |
| 23 |
a(i) = a(i) + b(i) - i |
| 24 |
end do |
| 25 |
!$omp end distribute |
| 26 |
!$omp end teams |
| 27 |
!$omp teams reduction(+:a) |
| 28 |
!ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context |
| 29 |
!$omp distribute firstprivate(a) |
| 30 |
do i = 1, 10 |
| 31 |
b(i) = b(i) + a(i) + i |
| 32 |
end do |
| 33 |
!$omp end distribute |
| 34 |
!$omp end teams |
| 35 |
|
| 36 |
!$omp teams distribute firstprivate(a) lastprivate(b) |
| 37 |
do i = 1, 10 |
| 38 |
a(i) = a(i) + b(i) - i |
| 39 |
end do |
| 40 |
!$omp end teams distribute |
| 41 |
!ERROR: Variable 'b' may not appear on both FIRSTPRIVATE and LASTPRIVATE clauses on a TEAMS DISTRIBUTE construct |
| 42 |
!$omp teams distribute firstprivate(a,b) lastprivate(b) |
| 43 |
do i = 1, 10 |
| 44 |
a(i) = a(i) + b(i) - i |
| 45 |
end do |
| 46 |
!$omp end teams distribute |
| 47 |
!ERROR: Variable 'a' may not appear on both FIRSTPRIVATE and LASTPRIVATE clauses on a TEAMS DISTRIBUTE construct |
| 48 |
!ERROR: Variable 'b' may not appear on both FIRSTPRIVATE and LASTPRIVATE clauses on a TEAMS DISTRIBUTE construct |
| 49 |
!$omp teams distribute firstprivate(a,b) lastprivate(a,b) |
| 50 |
do i = 1, 10 |
| 51 |
a(i) = a(i) + b(i) - i |
| 52 |
end do |
| 53 |
!$omp end teams distribute |
| 54 |
!ERROR: Variable 'b' may not appear on both FIRSTPRIVATE and LASTPRIVATE clauses on a TEAMS DISTRIBUTE construct |
| 55 |
!$omp teams distribute lastprivate(a,b) firstprivate(b) |
| 56 |
do i = 1, 10 |
| 57 |
a(i) = a(i) + b(i) - i |
| 58 |
end do |
| 59 |
!$omp end teams distribute |
| 60 |
!ERROR: Variable 'b' may not appear on both FIRSTPRIVATE and LASTPRIVATE clauses on a TEAMS DISTRIBUTE construct |
| 61 |
!ERROR: Variable 'a' may not appear on both FIRSTPRIVATE and LASTPRIVATE clauses on a TEAMS DISTRIBUTE construct |
| 62 |
!$omp teams distribute lastprivate(a,b) firstprivate(b,a) |
| 63 |
do i = 1, 10 |
| 64 |
a(i) = a(i) + b(i) - i |
| 65 |
end do |
| 66 |
!$omp end teams distribute |
| 67 |
!$omp end target |
| 68 |
|
| 69 |
print *, a, b |
| 70 |
|
| 71 |
!$omp parallel private(a,b) |
| 72 |
!ERROR: FIRSTPRIVATE variable 'b' is PRIVATE in outer context |
| 73 |
!$omp do firstprivate(b) |
| 74 |
do i = 1, 10 |
| 75 |
c(i) = a(i) + b(i) + i |
| 76 |
end do |
| 77 |
!$omp end do |
| 78 |
!$omp end parallel |
| 79 |
|
| 80 |
!$omp parallel reduction(*:a) |
| 81 |
!ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context |
| 82 |
!$omp do firstprivate(a,b) |
| 83 |
do i = 1, 10 |
| 84 |
c(i) = c(i) * a(i) * b(i) * i |
| 85 |
end do |
| 86 |
!$omp end do |
| 87 |
!$omp end parallel |
| 88 |
|
| 89 |
!$omp parallel reduction(+:a) |
| 90 |
!ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context |
| 91 |
!$omp sections firstprivate(a, b) |
| 92 |
!$omp section |
| 93 |
c = c * a + b |
| 94 |
!$omp end sections |
| 95 |
!$omp end parallel |
| 96 |
|
| 97 |
!$omp parallel reduction(*:a) |
| 98 |
!ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context |
| 99 |
!$omp task firstprivate(a,b) |
| 100 |
c = c * a * b |
| 101 |
!$omp end task |
| 102 |
!$omp end parallel |
| 103 |
|
| 104 |
!$omp parallel reduction(+:b) |
| 105 |
!ERROR: FIRSTPRIVATE variable 'b' is PRIVATE in outer context |
| 106 |
!$omp taskloop firstprivate(b) |
| 107 |
do i = 1, 10 |
| 108 |
c(i) = a(i) + b(i) + i |
| 109 |
a = a+i |
| 110 |
b = b-i |
| 111 |
end do |
| 112 |
!$omp end taskloop |
| 113 |
!$omp end parallel |
| 114 |
|
| 115 |
!$omp parallel firstprivate(a) |
| 116 |
!ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context |
| 117 |
!$omp single firstprivate(a) |
| 118 |
print *, a |
| 119 |
!$omp end single |
| 120 |
!$omp end parallel |
| 121 |
|
| 122 |
print *, c |
| 123 |
|
| 124 |
end program omp_firstprivate |