[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

Jennifer Yu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 22 07:56:35 PDT 2021


jyu2 added a comment.

Hi Alexey, Thanks for review.



================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:8653
                 ? (DSAStack->hasMutipleLoops() ? OMPC_lastprivate : OMPC_linear)
-                : OMPC_private;
-        if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-              DVar.CKind != PredeterminedCKind && DVar.RefExpr &&
-              (LangOpts.OpenMP <= 45 || (DVar.CKind != OMPC_lastprivate &&
-                                         DVar.CKind != OMPC_private))) ||
-             ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
-               DKind == OMPD_master_taskloop ||
-               DKind == OMPD_parallel_master_taskloop ||
-               isOpenMPDistributeDirective(DKind)) &&
-              !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-              DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&
-            (DVar.CKind != OMPC_private || DVar.RefExpr)) {
+            : DVar.CKind == OMPC_lastprivate ? OMPC_lastprivate
+                                             : OMPC_private;
----------------
ABataev wrote:
> Why need this change?
The rule:
The loop iteration variable in any associated loop of a loop construct is lastprivate.

So if there is lastprivate clause, should be predetermined as lastprivate.


================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:8662-8667
+        if (LangOpts.OpenMP > 45 && isOpenMPSimdDirective(DKind)) {
+          if (DVar.CKind == OMPC_lastprivate)
+            PredeterminedCKind = OMPC_lastprivate;
+          else if (DVar.CKind == OMPC_private)
+            PredeterminedCKind = OMPC_private;
+        }
----------------
ABataev wrote:
> Again, why do we need this?
In the comment:  for OpenMP 5.0 and up:

If a simd construct has just one associated loop, the variable may be  listed in a private, lastprivate or linear.

The linear part is set on line 8652, there just need to set private and lastprivate.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292



More information about the cfe-commits mailing list