[flang-commits] [flang] 60090a5 - [flang][openacc] Restrict number of device_type values on the set directive

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Wed Aug 23 11:59:55 PDT 2023


Author: Valentin Clement
Date: 2023-08-23T11:59:49-07:00
New Revision: 60090a50ff1bf480ac86db76d5537027b8aa0b5c

URL: https://github.com/llvm/llvm-project/commit/60090a50ff1bf480ac86db76d5537027b8aa0b5c
DIFF: https://github.com/llvm/llvm-project/commit/60090a50ff1bf480ac86db76d5537027b8aa0b5c.diff

LOG: [flang][openacc] Restrict number of device_type values on the set directive

The standard suggests that the value for the `device_type` clause on the
`set` directive is a list but this does not makes sense. Restrict the number
of value to one so it matches the runtime function.

Depends on D158644

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158645

Added: 
    

Modified: 
    flang/lib/Semantics/check-acc-structure.cpp
    flang/test/Semantics/OpenACC/acc-set-validity.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-acc-structure.cpp b/flang/lib/Semantics/check-acc-structure.cpp
index b72326571b4fb5..677a1d65b13ee5 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -351,7 +351,6 @@ CHECK_SIMPLE_CLAUSE(Delete, ACCC_delete)
 CHECK_SIMPLE_CLAUSE(Detach, ACCC_detach)
 CHECK_SIMPLE_CLAUSE(Device, ACCC_device)
 CHECK_SIMPLE_CLAUSE(DeviceNum, ACCC_device_num)
-CHECK_SIMPLE_CLAUSE(DeviceType, ACCC_device_type)
 CHECK_SIMPLE_CLAUSE(Finalize, ACCC_finalize)
 CHECK_SIMPLE_CLAUSE(Firstprivate, ACCC_firstprivate)
 CHECK_SIMPLE_CLAUSE(Host, ACCC_host)
@@ -487,6 +486,19 @@ void AccStructureChecker::Enter(const parser::AccClause::Copyout &c) {
       modifierClause, llvm::acc::Clause::ACCC_copyout);
 }
 
+void AccStructureChecker::Enter(const parser::AccClause::DeviceType &d) {
+  CheckAllowed(llvm::acc::Clause::ACCC_device_type);
+  if (GetContext().directive == llvm::acc::Directive::ACCD_set &&
+      d.v.v.size() > 1) {
+    context_.Say(GetContext().clauseSource,
+        "The %s clause on the %s directive accepts only one value"_err_en_US,
+        parser::ToUpperCaseLetters(
+            llvm::acc::getOpenACCClauseName(llvm::acc::Clause::ACCC_device_type)
+                .str()),
+        ContextDirectiveAsFortran());
+  }
+}
+
 void AccStructureChecker::Enter(const parser::AccClause::Gang &g) {
   CheckAllowed(llvm::acc::Clause::ACCC_gang);
 

diff  --git a/flang/test/Semantics/OpenACC/acc-set-validity.f90 b/flang/test/Semantics/OpenACC/acc-set-validity.f90
index f914e254cfd25b..896e39df6535c9 100644
--- a/flang/test/Semantics/OpenACC/acc-set-validity.f90
+++ b/flang/test/Semantics/OpenACC/acc-set-validity.f90
@@ -90,15 +90,17 @@ program openacc_clause_validity
   !$acc set device_num(1) device_num(i)
 
   !ERROR: At most one DEVICE_TYPE clause can appear on the SET directive
-  !$acc set device_type(i) device_type(2, i, j)
+  !$acc set device_type(i) device_type(2)
 
   !$acc set default_async(2)
   !$acc set default_async(i)
   !$acc set device_num(1)
   !$acc set device_num(i)
   !$acc set device_type(i)
-  !$acc set device_type(2, i, j)
-  !$acc set device_num(1) default_async(2) device_type(2, i, j)
+  !$acc set device_num(1) default_async(2) device_type(2)
+
+  !ERROR: The DEVICE_TYPE clause on the SET directive accepts only one value
+  !$acc set device_type(1, 2)
 
   !ERROR: At least one of DEFAULT_ASYNC, DEVICE_NUM, DEVICE_TYPE clause must appear on the SET directive
   !$acc set


        


More information about the flang-commits mailing list