Skip to content

[flang][openacc] Allow multiple device_type clauses on init and shutdown #135314

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
3 changes: 3 additions & 0 deletions flang/test/Lower/OpenACC/acc-init.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ subroutine acc_init
!$acc init device_type(nvidia)
!CHECK: acc.init attributes {device_types = [#acc.device_type<nvidia>]}

!$acc init device_type(host) device_type(multicore)
!CHECK: acc.init attributes {device_types = [#acc.device_type<host>, #acc.device_type<multicore>]}

end subroutine acc_init
3 changes: 3 additions & 0 deletions flang/test/Lower/OpenACC/acc-shutdown.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ subroutine acc_shutdown
!CHECK: [[DEVNUM:%.*]] = arith.constant 1 : i32
!CHECK: acc.shutdown device_num([[DEVNUM]] : i32) attributes {device_types = [#acc.device_type<default>, #acc.device_type<nvidia>]}

!$acc shutdown device_type(default) device_type(nvidia)
!CHECK: acc.shutdown attributes {device_types = [#acc.device_type<default>, #acc.device_type<nvidia>]}

end subroutine acc_shutdown
2 changes: 1 addition & 1 deletion flang/test/Semantics/OpenACC/acc-init-validity.f90
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ program openacc_init_validity
!ERROR: At most one DEVICE_NUM clause can appear on the INIT directive
!$acc init device_num(1) device_num(i)

!ERROR: At most one DEVICE_TYPE clause can appear on the INIT directive
! OK
!$acc init device_type(nvidia) device_type(default, *)

!ERROR: Must have LOGICAL or INTEGER type
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Semantics/OpenACC/acc-shutdown-validity.f90
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ program openacc_shutdown_validity
!ERROR: At most one DEVICE_NUM clause can appear on the SHUTDOWN directive
!$acc shutdown device_num(1) device_num(i)

!ERROR: At most one DEVICE_TYPE clause can appear on the SHUTDOWN directive
! OK
!$acc shutdown device_type(*) device_type(host, default)

end program openacc_shutdown_validity
16 changes: 6 additions & 10 deletions llvm/include/llvm/Frontend/OpenACC/ACC.td
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,9 @@ def ACC_Cache : Directive<"cache"> {

// 2.14.1
def ACC_Init : Directive<"init"> {
let allowedOnceClauses = [
VersionedClause<ACCC_DeviceNum>,
VersionedClause<ACCC_DeviceType>,
VersionedClause<ACCC_If>
];
let allowedOnceClauses = [VersionedClause<ACCC_DeviceNum>,
VersionedClause<ACCC_If>];
let allowedClauses = [VersionedClause<ACCC_DeviceType>];
let association = AS_None;
let category = CA_Executable;
}
Expand Down Expand Up @@ -480,11 +478,9 @@ def ACC_Set : Directive<"set"> {

// 2.14.2
def ACC_Shutdown : Directive<"shutdown"> {
let allowedOnceClauses = [
VersionedClause<ACCC_DeviceNum>,
VersionedClause<ACCC_DeviceType>,
VersionedClause<ACCC_If>
];
let allowedOnceClauses = [VersionedClause<ACCC_DeviceNum>,
VersionedClause<ACCC_If>];
let allowedClauses = [VersionedClause<ACCC_DeviceType>];
let association = AS_None;
let category = CA_Executable;
}
Expand Down