[PATCH] D88571: [flang][openacc] Fix device_num and device_type clauses for init directive
Valentin Clement via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 07:30:02 PDT 2020
clementval created this revision.
clementval added reviewers: sscalpone, kiranchandramohan, tskeith, klausler, DavidTruby.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
clementval requested review of this revision.
This patch fix the device_num and device_type clauses used in the init clause. device_num was not
spelled correctly in the parser and was to restrictive with scalarIntConstantExpr instead of scalarIntExpr.
device_type is now taking a list of ScalarIntExpr.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88571
Files:
flang/lib/Parser/openacc-parsers.cpp
flang/test/Semantics/acc-clause-validity.f90
llvm/include/llvm/Frontend/OpenACC/ACC.td
Index: llvm/include/llvm/Frontend/OpenACC/ACC.td
===================================================================
--- llvm/include/llvm/Frontend/OpenACC/ACC.td
+++ llvm/include/llvm/Frontend/OpenACC/ACC.td
@@ -106,7 +106,7 @@
// 2.14.1
def ACCC_DeviceNum : Clause<"device_num"> {
- let flangClassValue = "ScalarIntConstantExpr";
+ let flangClassValue = "ScalarIntExpr";
}
// 2.7.3
@@ -121,7 +121,7 @@
// 2.4
def ACCC_DeviceType : Clause<"device_type"> {
- let flangClassValue = "Name";
+ let flangClassValue = "ScalarIntExpr";
let defaultValue = "*";
let isValueOptional = 1;
let isValueList = 1;
Index: flang/test/Semantics/acc-clause-validity.f90
===================================================================
--- flang/test/Semantics/acc-clause-validity.f90
+++ flang/test/Semantics/acc-clause-validity.f90
@@ -25,11 +25,21 @@
real :: reduction_r
logical :: reduction_l
real(8), dimension(N, N) :: aa
+ logical :: ifCondition = .TRUE.
!ERROR: At least one clause is required on the DECLARE directive
!$acc declare
real(8), dimension(N) :: a
+ !$acc init
+ !$acc init if(.TRUE.)
+ !$acc init if(ifCondition)
+ !$acc init device_num(1)
+ !$acc init device_num(i)
+ !$acc init device_type(i)
+ !$acc init device_type(2, i, j)
+ !$acc init device_num(i) device_type(i, j) if(ifCondition)
+
!ERROR: At least one of ATTACH, COPYIN, CREATE clause must appear on the ENTER DATA directive
!$acc enter data
Index: flang/lib/Parser/openacc-parsers.cpp
===================================================================
--- flang/lib/Parser/openacc-parsers.cpp
+++ flang/lib/Parser/openacc-parsers.cpp
@@ -57,17 +57,17 @@
parenthesized(Parser<AccObjectList>{}))) ||
"DEVICEPTR" >> construct<AccClause>(construct<AccClause::Deviceptr>(
parenthesized(Parser<AccObjectList>{}))) ||
- "DEVICENUM" >> construct<AccClause>(construct<AccClause::DeviceNum>(
- parenthesized(scalarIntConstantExpr))) ||
+ "DEVICE_NUM" >> construct<AccClause>(construct<AccClause::DeviceNum>(
+ parenthesized(scalarIntExpr))) ||
"DEVICE_RESIDENT" >>
construct<AccClause>(construct<AccClause::DeviceResident>(
parenthesized(Parser<AccObjectList>{}))) ||
("DEVICE_TYPE"_tok || "DTYPE"_tok) >>
construct<AccClause>(construct<AccClause::DeviceType>(parenthesized(
- "*" >> construct<std::optional<std::list<Name>>>()))) ||
+ "*" >> construct<std::optional<std::list<ScalarIntExpr>>>()))) ||
("DEVICE_TYPE"_tok || "DTYPE"_tok) >>
construct<AccClause>(construct<AccClause::DeviceType>(
- parenthesized(maybe(nonemptyList(name))))) ||
+ parenthesized(maybe(nonemptyList(scalarIntExpr))))) ||
"FINALIZE" >> construct<AccClause>(construct<AccClause::Finalize>()) ||
"FIRSTPRIVATE" >> construct<AccClause>(construct<AccClause::Firstprivate>(
parenthesized(Parser<AccObjectList>{}))) ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88571.295275.patch
Type: text/x-patch
Size: 3051 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200930/8dea3cad/attachment.bin>
More information about the llvm-commits
mailing list