Skip to content

Commit

Permalink
[Flang][OpenMP] Add Todo for doconcurrent with worksharing loop
Browse files Browse the repository at this point in the history
This is a valid usage. We do not handle it as of now. Gfortran/Ifx produces an error, possibly because `do concurrent` was not allowed in previous versions of the OpenMP standard.

Fixes #62649

Reviewed By: Leporacanthicus

Differential Revision: https://reviews.llvm.org/D150869
  • Loading branch information
kiranchandramohan committed May 19, 2023
1 parent ffd9d6e commit 218841a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions flang/lib/Lower/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,11 @@ static void genOMP(Fortran::lower::AbstractConverter &converter,

// Collect the loops to collapse.
auto *doConstructEval = &eval.getFirstNestedEvaluation();
if (doConstructEval->getIf<Fortran::parser::DoConstruct>()
->IsDoConcurrent()) {
TODO(converter.getCurrentLocation(),
"Do Concurrent in Worksharing loop construct");
}

std::int64_t collapseValue =
Fortran::lower::getCollapseValue(loopOpClauseList);
Expand Down
6 changes: 5 additions & 1 deletion flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,11 @@ const parser::Name *DirectiveAttributeVisitor<T>::GetLoopIndex(
const parser::DoConstruct &x) {
using Bounds = parser::LoopControl::Bounds;
if (x.GetLoopControl()) {
return &std::get<Bounds>(x.GetLoopControl()->u).name.thing;
if (const Bounds * b{std::get_if<Bounds>(&x.GetLoopControl()->u)}) {
return &b->name.thing;
} else {
return nullptr;
}
} else {
context_
.Say(std::get<parser::Statement<parser::NonLabelDoStmt>>(x.t).source,
Expand Down
10 changes: 10 additions & 0 deletions flang/test/Lower/OpenMP/Todo/omp-doconcurrent.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s

! CHECK: not yet implemented: Do Concurrent in Worksharing loop construct
subroutine sb()
!$omp do
do concurrent(i=1:10)
print *, i
end do
end subroutine

0 comments on commit 218841a

Please sign in to comment.