Skip to content

Commit cf8fc53

Browse files
authored
[Flang][LLVM][OpenMP] Relax target data restrictions to be more inline with the specification (#82537)
Currently we emit errors whenever a map is not provided on a target data directive, however, I believe that's incorrect behavior, the specification states: "At least one map, use_device_addr or use_device_ptr clause must appear on the directive" So provided one is present, the directive is legal in this case. Slightly different to its siblings (enter/exit/update) which don't have use_device_addr/use_device_ptr.
1 parent 9dbedca commit cf8fc53

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

flang/test/Semantics/OpenMP/device-constructs.f90

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
! Check OpenMP clause validity for the following directives:
33
! 2.10 Device constructs
44
program main
5+
use iso_c_binding
56

67
real(8) :: arrayA(256), arrayB(256)
78
integer :: N
9+
type(c_ptr) :: cptr
810

911
arrayA = 1.414
1012
arrayB = 3.14
@@ -135,7 +137,15 @@ program main
135137
enddo
136138
!$omp end target data
137139

138-
!ERROR: At least one of MAP clause must appear on the TARGET DATA directive
140+
!$omp target data device(0) use_device_addr(cptr)
141+
cptr = c_null_ptr
142+
!$omp end target data
143+
144+
!$omp target data device(0) use_device_addr(cptr)
145+
cptr = c_null_ptr
146+
!$omp end target data
147+
148+
!ERROR: At least one of MAP, USE_DEVICE_ADDR, USE_DEVICE_PTR clause must appear on the TARGET DATA directive
139149
!$omp target data device(0)
140150
do i = 1, N
141151
a = 3.14

llvm/include/llvm/Frontend/OpenMP/OMP.td

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -710,16 +710,14 @@ def OMP_Requires : Directive<"requires"> {
710710
}
711711
def OMP_Nothing : Directive<"nothing"> {}
712712
def OMP_TargetData : Directive<"target data"> {
713-
let allowedClauses = [
714-
VersionedClause<OMPC_UseDevicePtr>,
715-
VersionedClause<OMPC_UseDeviceAddr, 50>
716-
];
717713
let allowedOnceClauses = [
718714
VersionedClause<OMPC_Device>,
719715
VersionedClause<OMPC_If>
720716
];
721717
let requiredClauses = [
722-
VersionedClause<OMPC_Map>
718+
VersionedClause<OMPC_Map>,
719+
VersionedClause<OMPC_UseDevicePtr>,
720+
VersionedClause<OMPC_UseDeviceAddr, 50>
723721
];
724722
}
725723
def OMP_TargetEnterData : Directive<"target enter data"> {

0 commit comments

Comments
 (0)