Skip to content

[flang][openacc] Allow if_present multiple times on host_data and update #135422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions flang/test/Lower/OpenACC/acc-host-data.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ subroutine acc_host_data()

! CHECK: %[[DA:.*]] = acc.use_device varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) -> !fir.ref<!fir.array<10xf32>> {name = "a"}
! CHECK: acc.host_data dataOperands(%[[DA]] : !fir.ref<!fir.array<10xf32>>) {
! CHECK: } attributes {ifPresent}

!$acc host_data use_device(a) if_present if_present
!$acc end host_data
! CHECK: acc.host_data dataOperands(%{{.*}} : !fir.ref<!fir.array<10xf32>>) {
! CHECK: } attributes {ifPresent}

!$acc host_data use_device(a) if(ifCondition)
Expand Down
3 changes: 3 additions & 0 deletions flang/test/Lower/OpenACC/acc-update.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ subroutine acc_update
! CHECK: acc.update dataOperands(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>) attributes {ifPresent}{{$}}
! CHECK: acc.update_host accPtr(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>) to varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10x10xf32>>) {name = "a", structured = false}

!$acc update host(a) if_present if_present
! CHECK: acc.update dataOperands(%{{.*}} : !fir.ref<!fir.array<10x10xf32>>) attributes {ifPresent}{{$}}

!$acc update self(a)
! CHECK: %[[DEVPTR_A:.*]] = acc.getdeviceptr varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10x10xf32>>) -> !fir.ref<!fir.array<10x10xf32>> {dataClause = #acc<data_clause acc_update_self>, name = "a", structured = false}
! CHECK: acc.update dataOperands(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Semantics/OpenACC/acc-host-data.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ program openacc_host_data_validity
!$acc host_data use_device(aa, bb) if_present
!$acc end host_data

!ERROR: At most one IF_PRESENT clause can appear on the HOST_DATA directive
! OK
!$acc host_data use_device(aa, bb) if_present if_present
!$acc end host_data

Expand Down
2 changes: 1 addition & 1 deletion flang/test/Semantics/OpenACC/acc-update-validity.f90
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ program openacc_update_validity
!ERROR: At most one IF clause can appear on the UPDATE directive
!$acc update device(aa) if(.true.) if(ifCondition)

!ERROR: At most one IF_PRESENT clause can appear on the UPDATE directive
! OK
!$acc update device(bb) if_present if_present

!ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the UPDATE directive
Expand Down
20 changes: 7 additions & 13 deletions llvm/include/llvm/Frontend/OpenACC/ACC.td
Original file line number Diff line number Diff line change
Expand Up @@ -487,15 +487,11 @@ def ACC_Shutdown : Directive<"shutdown"> {

// 2.14.4
def ACC_Update : Directive<"update"> {
let allowedClauses = [
VersionedClause<ACCC_DeviceType>,
VersionedClause<ACCC_Wait>
];
let allowedOnceClauses = [
VersionedClause<ACCC_Async>,
VersionedClause<ACCC_If>,
VersionedClause<ACCC_IfPresent>
];
let allowedClauses = [VersionedClause<ACCC_DeviceType>,
VersionedClause<ACCC_IfPresent>,
VersionedClause<ACCC_Wait>];
let allowedOnceClauses = [VersionedClause<ACCC_Async>,
VersionedClause<ACCC_If>];
let requiredClauses = [
VersionedClause<ACCC_Device>,
VersionedClause<ACCC_Host>,
Expand Down Expand Up @@ -554,10 +550,8 @@ def ACC_ExitData : Directive<"exit data"> {

// 2.8
def ACC_HostData : Directive<"host_data"> {
let allowedOnceClauses = [
VersionedClause<ACCC_If>,
VersionedClause<ACCC_IfPresent>
];
let allowedClauses = [VersionedClause<ACCC_IfPresent>];
let allowedOnceClauses = [VersionedClause<ACCC_If>];
let requiredClauses = [
VersionedClause<ACCC_UseDevice>
];
Expand Down