1! RUN: %python %S/../test_errors.py %s %flang -fopenmp 2! Check OpenMP clause validity for the following directives: 3! 2.10 Device constructs 4program main 5 6 real(8) :: arrayA(256), arrayB(256) 7 integer :: N 8 9 arrayA = 1.414 10 arrayB = 3.14 11 N = 256 12 13 !$omp target map(arrayA) 14 do i = 1, N 15 a = 3.14 16 enddo 17 !$omp end target 18 19 !$omp target device(0) 20 do i = 1, N 21 a = 3.14 22 enddo 23 !$omp end target 24 25 !ERROR: At most one DEVICE clause can appear on the TARGET directive 26 !$omp target device(0) device(1) 27 do i = 1, N 28 a = 3.14 29 enddo 30 !$omp end target 31 32 !ERROR: SCHEDULE clause is not allowed on the TARGET directive 33 !$omp target schedule(static) 34 do i = 1, N 35 a = 3.14 36 enddo 37 !$omp end target 38 39 !$omp target defaultmap(tofrom:scalar) 40 do i = 1, N 41 a = 3.14 42 enddo 43 !$omp end target 44 45 !ERROR: The argument TOFROM:SCALAR must be specified on the DEFAULTMAP clause 46 !$omp target defaultmap(tofrom) 47 do i = 1, N 48 a = 3.14 49 enddo 50 !$omp end target 51 52 !ERROR: At most one DEFAULTMAP clause can appear on the TARGET directive 53 !$omp target defaultmap(tofrom:scalar) defaultmap(tofrom:scalar) 54 do i = 1, N 55 a = 3.14 56 enddo 57 !$omp end target 58 59 !$omp teams num_teams(3) thread_limit(10) default(shared) private(i) shared(a) 60 do i = 1, N 61 a = 3.14 62 enddo 63 !$omp end teams 64 65 !ERROR: At most one NUM_TEAMS clause can appear on the TEAMS directive 66 !$omp teams num_teams(2) num_teams(3) 67 do i = 1, N 68 a = 3.14 69 enddo 70 !$omp end teams 71 72 !ERROR: The parameter of the NUM_TEAMS clause must be a positive integer expression 73 !$omp teams num_teams(-1) 74 do i = 1, N 75 a = 3.14 76 enddo 77 !$omp end teams 78 79 !ERROR: At most one THREAD_LIMIT clause can appear on the TEAMS directive 80 !$omp teams thread_limit(2) thread_limit(3) 81 do i = 1, N 82 a = 3.14 83 enddo 84 !$omp end teams 85 86 !ERROR: The parameter of the THREAD_LIMIT clause must be a positive integer expression 87 !$omp teams thread_limit(-1) 88 do i = 1, N 89 a = 3.14 90 enddo 91 !$omp end teams 92 93 !ERROR: At most one DEFAULT clause can appear on the TEAMS directive 94 !$omp teams default(shared) default(private) 95 do i = 1, N 96 a = 3.14 97 enddo 98 !$omp end teams 99 100 !$omp target teams num_teams(2) defaultmap(tofrom:scalar) 101 do i = 1, N 102 a = 3.14 103 enddo 104 !$omp end target teams 105 106 !$omp target map(tofrom:a) 107 do i = 1, N 108 a = 3.14 109 enddo 110 !$omp end target 111 112 !ERROR: Only the TO, FROM, TOFROM, ALLOC map types are permitted for MAP clauses on the TARGET directive 113 !$omp target map(delete:a) 114 do i = 1, N 115 a = 3.14 116 enddo 117 !$omp end target 118 119 !$omp target data device(0) map(to:a) 120 do i = 1, N 121 a = 3.14 122 enddo 123 !$omp end target data 124 125 !ERROR: At least one of MAP clause must appear on the TARGET DATA directive 126 !$omp target data device(0) 127 do i = 1, N 128 a = 3.14 129 enddo 130 !$omp end target data 131 132 !ERROR: The parameter of the DEVICE clause must be a positive integer expression 133 !$omp target enter data map(alloc:A) device(-2) 134 135 !ERROR: The parameter of the DEVICE clause must be a positive integer expression 136 !$omp target exit data map(delete:A) device(-2) 137 138 !ERROR: At most one IF clause can appear on the TARGET ENTER DATA directive 139 !$omp target enter data map(to:a) if(.true.) if(.false.) 140 141 !ERROR: Only the TO, ALLOC map types are permitted for MAP clauses on the TARGET ENTER DATA directive 142 !$omp target enter data map(from:a) 143 144 !$omp target exit data map(delete:a) 145 146 !ERROR: At most one DEVICE clause can appear on the TARGET EXIT DATA directive 147 !$omp target exit data map(from:a) device(0) device(1) 148 149 !ERROR: Only the FROM, RELEASE, DELETE map types are permitted for MAP clauses on the TARGET EXIT DATA directive 150 !$omp target exit data map(to:a) 151 152 !$omp target 153 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region. 154 !$omp distribute 155 do i = 1, N 156 a = 3.14 157 enddo 158 !$omp end distribute 159 !$omp end target 160 161 !$omp target 162 !$omp teams 163 !$omp distribute 164 do i = 1, N 165 a = 3.14 166 enddo 167 !$omp end distribute 168 !$omp end teams 169 !$omp end target 170 171 !$omp target 172 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region. 173 !ERROR: At most one COLLAPSE clause can appear on the DISTRIBUTE directive 174 !$omp distribute collapse(2) collapse(3) 175 do i = 1, N 176 do j = 1, N 177 do k = 1, N 178 a = 3.14 179 enddo 180 enddo 181 enddo 182 !$omp end distribute 183 !$omp end target 184 185 !$omp target 186 !$omp teams 187 !ERROR: At most one COLLAPSE clause can appear on the DISTRIBUTE directive 188 !$omp distribute collapse(2) collapse(3) 189 do i = 1, N 190 do j = 1, N 191 do k = 1, N 192 a = 3.14 193 enddo 194 enddo 195 enddo 196 !$omp end distribute 197 !$omp end teams 198 !$omp end target 199 200 !$omp target 201 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region. 202 !$omp distribute dist_schedule(static, 2) 203 do i = 1, N 204 a = 3.14 205 enddo 206 !$omp end distribute 207 !$omp end target 208 209 !$omp target 210 !$omp teams 211 !$omp distribute dist_schedule(static, 2) 212 do i = 1, N 213 a = 3.14 214 enddo 215 !$omp end distribute 216 !$omp end teams 217 !$omp end target 218 219 !$omp target 220 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region. 221 !ERROR: At most one DIST_SCHEDULE clause can appear on the DISTRIBUTE directive 222 !$omp distribute dist_schedule(static, 2) dist_schedule(static, 3) 223 do i = 1, N 224 a = 3.14 225 enddo 226 !$omp end distribute 227 !$omp end target 228 229 !$omp target 230 !$omp teams 231 !ERROR: At most one DIST_SCHEDULE clause can appear on the DISTRIBUTE directive 232 !$omp distribute dist_schedule(static, 2) dist_schedule(static, 3) 233 do i = 1, N 234 a = 3.14 235 enddo 236 !$omp end distribute 237 !$omp end teams 238 !$omp end target 239 240end program main 241