Skip to content

Commit 8fb6bb3

Browse files
authored
[flang][openacc] Allow multiple device_type clauses on init and shutdown (llvm#135314)
Relax the restriction for init and shutdown directives for device_type clause. The clause can be allowed multiple times.
1 parent d995b2e commit 8fb6bb3

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

flang/test/Lower/OpenACC/acc-init.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,7 @@ subroutine acc_init
3535
!$acc init device_type(nvidia)
3636
!CHECK: acc.init attributes {device_types = [#acc.device_type<nvidia>]}
3737

38+
!$acc init device_type(host) device_type(multicore)
39+
!CHECK: acc.init attributes {device_types = [#acc.device_type<host>, #acc.device_type<multicore>]}
40+
3841
end subroutine acc_init

flang/test/Lower/OpenACC/acc-shutdown.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ subroutine acc_shutdown
2525
!CHECK: [[DEVNUM:%.*]] = arith.constant 1 : i32
2626
!CHECK: acc.shutdown device_num([[DEVNUM]] : i32) attributes {device_types = [#acc.device_type<default>, #acc.device_type<nvidia>]}
2727

28+
!$acc shutdown device_type(default) device_type(nvidia)
29+
!CHECK: acc.shutdown attributes {device_types = [#acc.device_type<default>, #acc.device_type<nvidia>]}
30+
2831
end subroutine acc_shutdown

flang/test/Semantics/OpenACC/acc-init-validity.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ program openacc_init_validity
9393
!ERROR: At most one DEVICE_NUM clause can appear on the INIT directive
9494
!$acc init device_num(1) device_num(i)
9595

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

9999
!ERROR: Must have LOGICAL or INTEGER type

flang/test/Semantics/OpenACC/acc-shutdown-validity.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ program openacc_shutdown_validity
9090
!ERROR: At most one DEVICE_NUM clause can appear on the SHUTDOWN directive
9191
!$acc shutdown device_num(1) device_num(i)
9292

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

9696
end program openacc_shutdown_validity

llvm/include/llvm/Frontend/OpenACC/ACC.td

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,9 @@ def ACC_Cache : Directive<"cache"> {
432432

433433
// 2.14.1
434434
def ACC_Init : Directive<"init"> {
435-
let allowedOnceClauses = [
436-
VersionedClause<ACCC_DeviceNum>,
437-
VersionedClause<ACCC_DeviceType>,
438-
VersionedClause<ACCC_If>
439-
];
435+
let allowedOnceClauses = [VersionedClause<ACCC_DeviceNum>,
436+
VersionedClause<ACCC_If>];
437+
let allowedClauses = [VersionedClause<ACCC_DeviceType>];
440438
let association = AS_None;
441439
let category = CA_Executable;
442440
}
@@ -480,11 +478,9 @@ def ACC_Set : Directive<"set"> {
480478

481479
// 2.14.2
482480
def ACC_Shutdown : Directive<"shutdown"> {
483-
let allowedOnceClauses = [
484-
VersionedClause<ACCC_DeviceNum>,
485-
VersionedClause<ACCC_DeviceType>,
486-
VersionedClause<ACCC_If>
487-
];
481+
let allowedOnceClauses = [VersionedClause<ACCC_DeviceNum>,
482+
VersionedClause<ACCC_If>];
483+
let allowedClauses = [VersionedClause<ACCC_DeviceType>];
488484
let association = AS_None;
489485
let category = CA_Executable;
490486
}

0 commit comments

Comments
 (0)