Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,12 @@ void OmpAttributeVisitor::PrivatizeAssociatedLoopIndexAndCheckLoopLevel(
const auto &outer{std::get<std::optional<parser::DoConstruct>>(x.t)};
if (outer.has_value()) {
for (const parser::DoConstruct *loop{&*outer}; loop && level > 0; --level) {
if (loop->IsDoConcurrent()) {
auto &stmt =
std::get<parser::Statement<parser::NonLabelDoStmt>>(loop->t);
context_.Say(stmt.source,
"DO CONCURRENT loops cannot form part of a loop nest."_err_en_US);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DO CONCURRENT is allowed in the LOOP construct, although, IIUC, only as the top-level loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ab3fba8 allows do concurrent as a single loop construct but not as part of a loop nest. Does that match your understanding of the standard?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's allowed in any worksharing-loop construct, only in the LOOP construct [6.0:424:1] "The collapsed loop may be a DO CONCURRENT loop." No other constructs in that chapter have this annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out.

If the collapsed loop is a DO CONCURRENT loop, neither the data-sharing attribute clauses nor the collapse clause may be specified.

I am taking this to mean that DO CONCURRENT is allowed with LOOP, but not when LOOP has a COLLAPSE clause. "Collapsed loop" seems elsewhere to refer to anything enclosed by the LOOP construct.

// go through all the nested do-loops and resolve index variables
const parser::Name *iv{GetLoopIndex(*loop)};
if (iv) {
Expand Down
10 changes: 0 additions & 10 deletions flang/test/Lower/OpenMP/Todo/omp-doconcurrent.f90

This file was deleted.

19 changes: 19 additions & 0 deletions flang/test/Semantics/OpenMP/do-concurrent-collapse.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
!RUN: %python %S/../test_errors.py %s %flang -fopenmp

integer :: i, j
!$omp parallel do collapse(2)
do i = 1, 1
! ERROR: DO CONCURRENT loops cannot form part of a loop nest.
do concurrent (j = 1:2)
print *, j
end do
end do

!$omp parallel do
do i = 1, 1
! This should not lead to an error because it is not part of a loop nest:
do concurrent (j = 1:2)
print *, j
end do
end do
end
Loading