[flang-commits] [flang] 86bbf8e - [flang][openacc] Fix wait-argument for wait clause + add tests
via flang-commits
flang-commits at lists.llvm.org
Sun Aug 23 17:01:34 PDT 2020
Author: Valentin Clement
Date: 2020-08-23T20:01:25-04:00
New Revision: 86bbf8e6fc2bf6396c1efae556bacda054f90b33
URL: https://github.com/llvm/llvm-project/commit/86bbf8e6fc2bf6396c1efae556bacda054f90b33
DIFF: https://github.com/llvm/llvm-project/commit/86bbf8e6fc2bf6396c1efae556bacda054f90b33.diff
LOG: [flang][openacc] Fix wait-argument for wait clause + add tests
This patch fix the usage of the wait-argument in a clause and add several tests and fix the unparsing of
the wait-argument.
Reviewed By: sscalpone
Differential Revision: https://reviews.llvm.org/D86325
Added:
Modified:
flang/lib/Parser/openacc-parsers.cpp
flang/lib/Parser/unparse.cpp
flang/test/Semantics/acc-clause-validity.f90
Removed:
################################################################################
diff --git a/flang/lib/Parser/openacc-parsers.cpp b/flang/lib/Parser/openacc-parsers.cpp
index 823fbaec0ace..4198ccbcc6ac 100644
--- a/flang/lib/Parser/openacc-parsers.cpp
+++ b/flang/lib/Parser/openacc-parsers.cpp
@@ -111,7 +111,7 @@ TYPE_PARSER("AUTO" >> construct<AccClause>(construct<AccClause::Auto>()) ||
construct<AccClause>(construct<AccClause::Vector>(maybe(
parenthesized(("LENGTH:" >> scalarIntExpr || scalarIntExpr))))) ||
"WAIT" >> construct<AccClause>(construct<AccClause::Wait>(
- maybe(Parser<AccWaitArgument>{}))) ||
+ maybe(parenthesized(Parser<AccWaitArgument>{})))) ||
"WORKER" >>
construct<AccClause>(construct<AccClause::Worker>(maybe(
parenthesized(("NUM:" >> scalarIntExpr || scalarIntExpr))))) ||
@@ -125,8 +125,10 @@ TYPE_PARSER(construct<AccObjectList>(nonemptyList(Parser<AccObject>{})))
TYPE_PARSER(construct<AccObjectListWithModifier>(
maybe(Parser<AccDataModifier>{}), Parser<AccObjectList>{}))
-TYPE_PARSER(construct<AccWaitArgument>(
- maybe("DEVNUM:" >> scalarIntExpr / ":"), nonemptyList(scalarIntExpr)))
+// 2.16.3 (2485) wait-argument is:
+// [devnum : int-expr :] [queues :] int-expr-list
+TYPE_PARSER(construct<AccWaitArgument>(maybe("DEVNUM:" >> scalarIntExpr / ":"),
+ "QUEUES:" >> nonemptyList(scalarIntExpr) || nonemptyList(scalarIntExpr)))
// 2.9 (1609) size-expr is one of:
// int-expr
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index 3dbf8fb8d961..faf2c9f1eb87 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -1937,6 +1937,10 @@ class UnparseVisitor {
Put("\n");
EndOpenACC();
}
+ void Unparse(const AccWaitArgument &x) {
+ Walk("DEVNUM:", std::get<std::optional<ScalarIntExpr>>(x.t), ":");
+ Walk(std::get<std::list<ScalarIntExpr>>(x.t), ",");
+ }
void Unparse(const OpenACCWaitConstruct &x) {
BeginOpenACC();
Word("!$ACC ");
diff --git a/flang/test/Semantics/acc-clause-validity.f90 b/flang/test/Semantics/acc-clause-validity.f90
index 207ca2ec72cd..4f8bd1406de5 100644
--- a/flang/test/Semantics/acc-clause-validity.f90
+++ b/flang/test/Semantics/acc-clause-validity.f90
@@ -187,6 +187,30 @@ program openacc_clause_validity
!ERROR: Unmatched END PARALLEL LOOP directive
!$acc end parallel loop
+ !$acc kernels wait(1, 2) async(3)
+ !$acc end kernels
+
+ !$acc kernels wait(queues: 1, 2) async(3)
+ !$acc end kernels
+
+ !$acc kernels wait(devnum: 1: 1, 2) async(3)
+ !$acc end kernels
+
+ !$acc kernels wait(devnum: 1: queues: 1, 2) async(3)
+ !$acc end kernels
+
+ !$acc wait(1)
+ !$acc wait(1, 2)
+
+ !$acc wait(queues: 1)
+ !$acc wait(queues: 1, 2)
+
+ !$acc wait(devnum: 1: 3)
+ !$acc wait(devnum: 1: 3, 4)
+
+ !$acc wait(devnum: 1: queues: 3)
+ !$acc wait(devnum: 1: queues: 3, 4)
+
contains
subroutine sub1(a)
More information about the flang-commits
mailing list