diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2019-01-09 15:58:05 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2019-01-09 15:58:05 +0000 |
commit | 7e6803e07b98d6189c6f07da0f7a2e0c813e98af (patch) | |
tree | 65e0ca6a0d4dc34e3137454e3b151c857b8253d7 /clang/lib/Sema/SemaOpenMP.cpp | |
parent | 8abf680424cb50b104f423396ca6e6b48866469d (diff) | |
download | bcm5719-llvm-7e6803e07b98d6189c6f07da0f7a2e0c813e98af.tar.gz bcm5719-llvm-7e6803e07b98d6189c6f07da0f7a2e0c813e98af.zip |
Incorrect implicit data-sharing for nested tasks
Summary:
There is a minor issue in how the implicit data-sharings for nested tasks are computed.
For the following example:
```
int x;
#pragma omp task shared(x)
#pragma omp task
x++;
```
We compute an implicit data-sharing of shared for `x` in the second task although I think that it should be firstprivate. Below you can find the part of the OpenMP spec that covers this example:
- // In a task generating construct, if no default clause is present, a variable for which the data-sharing attribute is not determined by the rules above and that in the enclosing context is determined to be shared by all implicit tasks bound to the current team is shared.//
- //In a task generating construct, if no default clause is present, a variable for which the data-sharing attribute is not determined by the rules above is firstprivate.//
Since each implicit-task has its own copy of `x`, we shouldn't apply the first rule.
Reviewers: ABataev
Reviewed By: ABataev
Subscribers: cfe-commits, rogfer01
Tags: #openmp
Differential Revision: https://reviews.llvm.org/D56430
llvm-svn: 350734
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 140ccd15bbe..1166de752e3 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -676,9 +676,13 @@ public: } }; -bool isParallelOrTaskRegion(OpenMPDirectiveKind DKind) { - return isOpenMPParallelDirective(DKind) || isOpenMPTaskingDirective(DKind) || - isOpenMPTeamsDirective(DKind) || DKind == OMPD_unknown; + +bool isImplicitTaskingRegion(OpenMPDirectiveKind DKind) { + return isOpenMPParallelDirective(DKind) || isOpenMPTeamsDirective(DKind); +} + +bool isImplicitOrExplicitTaskingRegion(OpenMPDirectiveKind DKind) { + return isImplicitTaskingRegion(DKind) || isOpenMPTaskingDirective(DKind) || DKind == OMPD_unknown; } } // namespace @@ -819,7 +823,7 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(iterator &Iter, DVar.CKind = OMPC_firstprivate; return DVar; } - } while (I != E && !isParallelOrTaskRegion(I->Directive)); + } while (I != E && !isImplicitTaskingRegion(I->Directive)); DVar.CKind = (DVarTemp.CKind == OMPC_unknown) ? OMPC_firstprivate : OMPC_shared; return DVar; @@ -1066,7 +1070,7 @@ bool DSAStackTy::isOpenMPLocal(VarDecl *D, iterator Iter) const { if (!isStackEmpty()) { iterator I = Iter, E = Stack.back().first.rend(); Scope *TopScope = nullptr; - while (I != E && !isParallelOrTaskRegion(I->Directive) && + while (I != E && !isImplicitOrExplicitTaskingRegion(I->Directive) && !isOpenMPTargetExecutionDirective(I->Directive)) ++I; if (I == E) @@ -1292,7 +1296,7 @@ DSAStackTy::hasDSA(ValueDecl *D, if (FromParent && I != EndI) std::advance(I, 1); for (; I != EndI; std::advance(I, 1)) { - if (!DPred(I->Directive) && !isParallelOrTaskRegion(I->Directive)) + if (!DPred(I->Directive) && !isImplicitOrExplicitTaskingRegion(I->Directive)) continue; iterator NewI = I; DSAVarData DVar = getDSA(NewI, D); @@ -1636,7 +1640,7 @@ VarDecl *Sema::isOpenMPCapturedDecl(ValueDecl *D) { auto &&Info = DSAStack->isLoopControlVariable(D); if (Info.first || (VD && VD->hasLocalStorage() && - isParallelOrTaskRegion(DSAStack->getCurrentDirective())) || + isImplicitOrExplicitTaskingRegion(DSAStack->getCurrentDirective())) || (VD && DSAStack->isForceVarCapturing())) return VD ? VD : Info.second; DSAStackTy::DSAVarData DVarPrivate = @@ -2244,7 +2248,7 @@ public: // attribute, must have its data-sharing attribute explicitly determined // by being listed in a data-sharing attribute clause. if (DVar.CKind == OMPC_unknown && Stack->getDefaultDSA() == DSA_none && - isParallelOrTaskRegion(DKind) && + isImplicitOrExplicitTaskingRegion(DKind) && VarsWithInheritedDSA.count(VD) == 0) { VarsWithInheritedDSA[VD] = E; return; |