[flang-commits] [flang] 218841a - [Flang][OpenMP] Add Todo for doconcurrent with worksharing loop

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Fri May 19 05:03:26 PDT 2023


Author: Kiran Chandramohan
Date: 2023-05-19T12:03:03Z
New Revision: 218841af7cd48468bcd43852f6089f36d108f018

URL: https://github.com/llvm/llvm-project/commit/218841af7cd48468bcd43852f6089f36d108f018
DIFF: https://github.com/llvm/llvm-project/commit/218841af7cd48468bcd43852f6089f36d108f018.diff

LOG: [Flang][OpenMP] Add Todo for doconcurrent with worksharing loop

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

Added: 
    flang/test/Lower/OpenMP/Todo/omp-doconcurrent.f90

Modified: 
    flang/lib/Lower/OpenMP.cpp
    flang/lib/Semantics/resolve-directives.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 6b03a92c956c2..96fd6762934f8 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -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);

diff  --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index c6cef99042a11..8c3067d1b0a36 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -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,

diff  --git a/flang/test/Lower/OpenMP/Todo/omp-doconcurrent.f90 b/flang/test/Lower/OpenMP/Todo/omp-doconcurrent.f90
new file mode 100644
index 0000000000000..a6d70fa445928
--- /dev/null
+++ b/flang/test/Lower/OpenMP/Todo/omp-doconcurrent.f90
@@ -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


        


More information about the flang-commits mailing list