|
67 | 67 | #:enddef |
68 | 68 |
|
69 | 69 | #:def OMP_NOCREATE_STR(no_create) |
70 | | - #:if no_create is not None |
71 | | - #:stop 'no_create is not supported yet' |
72 | | - #:endif |
| 70 | + #! OpenMP has no no_create equivalent, so this is a documented no-op: the variable is |
| 71 | + #! left to whatever mapping the enclosing region already applies to it. Note that is |
| 72 | + #! NOT equivalent to no_create on most targets -- OMP_DEFAULT_STR emits nothing unless |
| 73 | + #! the caller passes default='present', and even then only CCE maps allocatables and |
| 74 | + #! pointers as present; NVHPC/PGI and the fallback map them tofrom, which copies rather |
| 75 | + #! than reuses, and LLVMFlang emits nothing at all. |
| 76 | + #! Do NOT #:stop here: GPU_DATA expands both backends before #if selects one, so |
| 77 | + #! aborting would break OpenACC builds, where no_create is supported natively. |
73 | 78 | #:set no_create_val = '' |
74 | 79 | $:no_create_val |
75 | 80 | #:enddef |
|
275 | 280 | & no_create_val.strip('\n') + present_val.strip('\n') + & |
276 | 281 | & deviceptr_val.strip('\n') + attach_val.strip('\n') + & |
277 | 282 | & default_val.strip('\n') |
| 283 | + #! An OpenMP `target data` region must carry at least one map, use_device_ptr or |
| 284 | + #! use_device_addr clause. no_create contributes none (it is a no-op here), and |
| 285 | + #! `default` is None by default, so GPU_DATA(no_create=x) with no other clause left |
| 286 | + #! clause_val empty and emitted a bare `!$omp target data` that no compiler accepts. |
| 287 | + #! Emit the body alone in that case -- a data region with nothing to map has nothing |
| 288 | + #! to do, which is what GPU_DATA's own #else branch already does when neither backend |
| 289 | + #! is enabled. A #:stop is not an option here, for the reason in OMP_NOCREATE_STR. |
| 290 | + #! Only no_create earns that silence. If the caller asked for some other clause and |
| 291 | + #! the backend produced nothing for it -- default='present' on LLVMFlang, where |
| 292 | + #! OMP_DEFAULT_STR returns an empty string -- keep emitting the bare directive so the |
| 293 | + #! build fails loudly rather than silently discarding a region that was asked for. |
| 294 | + #:set other_clause_requested = copy is not None or copyin is not None or & |
| 295 | + & copyinReadOnly is not None or copyout is not None or create is not None or & |
| 296 | + & present is not None or deviceptr is not None or attach is not None or & |
| 297 | + & default is not None |
| 298 | + #:set emitted_clause = clause_val.strip() != '' or extraOmpArgs_val.strip() != '' |
| 299 | + #:set has_clauses = emitted_clause or other_clause_requested |
278 | 300 | #:set omp_directive = '!$omp target data ' + clause_val + extraOmpArgs_val.strip('\n') |
279 | 301 | #:set end_omp_directive = '!$omp end target data' |
280 | | - $:omp_directive |
| 302 | + #:if has_clauses |
| 303 | + $:omp_directive |
| 304 | + #:endif |
281 | 305 | $:code |
282 | | - $:end_omp_directive |
| 306 | + #:if has_clauses |
| 307 | + $:end_omp_directive |
| 308 | + #:endif |
283 | 309 | #:enddef |
284 | 310 |
|
285 | 311 | #:def OMP_ENTER_DATA(copyin=None, copyinReadOnly=None, create=None, attach=None, extraOmpArgs=None) |
|
0 commit comments