aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flang/lib/Semantics/canonicalize-acc.cpp31
-rw-r--r--flang/test/Semantics/acc-canonicalization-validity.f9017
-rw-r--r--flang/test/Semantics/acc-clause-validity.f9048
3 files changed, 96 insertions, 0 deletions
diff --git a/flang/lib/Semantics/canonicalize-acc.cpp b/flang/lib/Semantics/canonicalize-acc.cpp
index 4916f22..0241508 100644
--- a/flang/lib/Semantics/canonicalize-acc.cpp
+++ b/flang/lib/Semantics/canonicalize-acc.cpp
@@ -64,6 +64,8 @@ private:
std::size_t tileArgNb = listTileExpr.size();
const auto &outer{std::get<std::optional<parser::DoConstruct>>(x.t)};
+ if (outer->IsDoConcurrent())
+ return; // Tile is not allowed on DO CONURRENT
for (const parser::DoConstruct *loop{&*outer}; loop && tileArgNb > 0;
--tileArgNb) {
const auto &block{std::get<parser::Block>(loop->t)};
@@ -82,6 +84,27 @@ private:
}
}
+ // Check constraint on line 1835 in Section 2.9
+ // A tile and collapse clause may not appear on loop that is associated with
+ // do concurrent.
+ template <typename C, typename D>
+ void CheckDoConcurrentClauseRestriction(const C &x) {
+ const auto &doCons{std::get<std::optional<parser::DoConstruct>>(x.t)};
+ if (!doCons->IsDoConcurrent())
+ return;
+ const auto &beginLoopDirective = std::get<D>(x.t);
+ const auto &accClauseList =
+ std::get<parser::AccClauseList>(beginLoopDirective.t);
+ for (const auto &clause : accClauseList.v) {
+ if (std::holds_alternative<parser::AccClause::Collapse>(clause.u) ||
+ std::holds_alternative<parser::AccClause::Tile>(clause.u)) {
+ messages_.Say(beginLoopDirective.source,
+ "TILE and COLLAPSE clause may not appear on loop construct "
+ "associated with DO CONCURRENT"_err_en_US);
+ }
+ }
+ }
+
void RewriteOpenACCLoopConstruct(parser::OpenACCLoopConstruct &x,
parser::Block &block, parser::Block::iterator it) {
// Check the sequence of DoConstruct in the same iteration
@@ -112,8 +135,12 @@ private:
"DO loop after the %s directive must have loop control"_err_en_US,
parser::ToUpperCaseLetters(dir.source.ToString()));
}
+
+ CheckDoConcurrentClauseRestriction<parser::OpenACCLoopConstruct,
+ parser::AccBeginLoopDirective>(x);
CheckTileClauseRestriction<parser::OpenACCLoopConstruct,
parser::AccBeginLoopDirective>(x);
+
return; // found do-loop
}
}
@@ -163,8 +190,12 @@ private:
"DO loop after the %s directive must have loop control"_err_en_US,
parser::ToUpperCaseLetters(dir.source.ToString()));
}
+
+ CheckDoConcurrentClauseRestriction<parser::OpenACCCombinedConstruct,
+ parser::AccBeginCombinedDirective>(x);
CheckTileClauseRestriction<parser::OpenACCCombinedConstruct,
parser::AccBeginCombinedDirective>(x);
+
return; // found do-loop
}
}
diff --git a/flang/test/Semantics/acc-canonicalization-validity.f90 b/flang/test/Semantics/acc-canonicalization-validity.f90
index 350f631..bb7afaf 100644
--- a/flang/test/Semantics/acc-canonicalization-validity.f90
+++ b/flang/test/Semantics/acc-canonicalization-validity.f90
@@ -13,6 +13,7 @@ program openacc_clause_validity
integer :: i, j
integer :: N = 256
real(8) :: a(256)
+ real(8) :: aa(256, 256)
!ERROR: A DO loop must follow the LOOP directive
!$acc loop
@@ -106,4 +107,20 @@ program openacc_clause_validity
a(i) = 3.14
end do
+ !$acc parallel
+ !ERROR: TILE and COLLAPSE clause may not appear on loop construct associated with DO CONCURRENT
+ !$acc loop collapse(2)
+ do concurrent (i = 1:N, j = 1:N)
+ aa(i, j) = 3.14
+ end do
+ !$acc end parallel
+
+ !$acc parallel
+ !ERROR: TILE and COLLAPSE clause may not appear on loop construct associated with DO CONCURRENT
+ !$acc loop tile(2, 2)
+ do concurrent (i = 1:N, j = 1:N)
+ aa(i, j) = 3.14
+ end do
+ !$acc end parallel
+
end program openacc_clause_validity
diff --git a/flang/test/Semantics/acc-clause-validity.f90 b/flang/test/Semantics/acc-clause-validity.f90
index 22b33284..9931198 100644
--- a/flang/test/Semantics/acc-clause-validity.f90
+++ b/flang/test/Semantics/acc-clause-validity.f90
@@ -220,6 +220,14 @@ program openacc_clause_validity
!$acc end parallel
!$acc parallel
+ !ERROR: SEQ and AUTO clauses are mutually exclusive and may not appear on the same LOOP directive
+ !$acc loop auto seq
+ do i = 1, N
+ a(i) = 3.14
+ end do
+ !$acc end parallel
+
+ !$acc parallel
!$acc loop tile(2)
do i = 1, N
a(i) = 3.14
@@ -288,6 +296,14 @@ program openacc_clause_validity
!$acc end parallel
!$acc parallel
+ !ERROR: At most one VECTOR clause can appear on the LOOP directive
+ !$acc loop vector vector(128)
+ do i = 1, N
+ a(i) = 3.14
+ end do
+ !$acc end parallel
+
+ !$acc parallel
!$acc loop vector
do i = 1, N
a(i) = 3.14
@@ -316,6 +332,14 @@ program openacc_clause_validity
!$acc end parallel
!$acc parallel
+ !ERROR: At most one WORKER clause can appear on the LOOP directive
+ !$acc loop worker worker(10)
+ do i = 1, N
+ a(i) = 3.14
+ end do
+ !$acc end parallel
+
+ !$acc parallel
!$acc loop worker
do i = 1, N
a(i) = 3.14
@@ -344,6 +368,14 @@ program openacc_clause_validity
!$acc end parallel
!$acc parallel
+ !ERROR: At most one GANG clause can appear on the LOOP directive
+ !$acc loop gang gang(gang_size)
+ do i = 1, N
+ a(i) = 3.14
+ end do
+ !$acc end parallel
+
+ !$acc parallel
!$acc loop gang(gang_size)
do i = 1, N
a(i) = 3.14
@@ -528,6 +560,22 @@ program openacc_clause_validity
end do
!$acc end parallel
+ !$acc parallel
+ !ERROR: Clause WORKER is not allowed if clause SEQ appears on the LOOP directive
+ !$acc loop worker seq
+ do i = 1, N
+ a(i) = 3.14
+ end do
+ !$acc end parallel
+
+ !$acc parallel
+ !ERROR: Clause VECTOR is not allowed if clause SEQ appears on the LOOP directive
+ !$acc loop vector seq
+ do i = 1, N
+ a(i) = 3.14
+ end do
+ !$acc end parallel
+
!ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the PARALLEL directive
!$acc parallel device_type(*) if(.TRUE.)
!$acc loop