[Openmp-commits] [PATCH] D108132: Add implicit map for a list item appears in a reduction clause.
Jennifer Yu via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Tue Aug 17 12:15:56 PDT 2021
jyu2 added inline comments.
================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:5825
+ for (Expr *E : RC->varlists())
+ if (!dyn_cast<DeclRefExpr>(E))
+ ImplicitExprs.emplace_back(E);
----------------
ABataev wrote:
> jyu2 wrote:
> > ABataev wrote:
> > > `isa`. Also, what if this is a `MemberExpr`?
> > Yes isa. Changed. Thanks.
> >
> > For reduction MemeberExpr is not allowed, it is only allowed variable name, array element or array section.
> I would also do this check if it is a not template parsing/analysis mode + also would do this for `E->IgnoreParensImpCasts()`
The code already under non DependentContext(). I add IgnoreParenImpCasts(). Thanks.
if (AStmt && !CurContext->isDependentContext() && Kind != OMPD_atomic &&
Kind != OMPD_critical && Kind != OMPD_section && Kind != OMPD_master &&
Kind != OMPD_masked && !isOpenMPLoopTransformationDirective(Kind))
================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:19481-19482
if (VD && DSAS->isThreadPrivate(VD)) {
+ if (NoDiagnose)
+ continue;
DSAStackTy::DSAVarData DVar = DSAS->getTopDSA(VD, /*FromParent=*/false);
----------------
ABataev wrote:
> jyu2 wrote:
> > ABataev wrote:
> > > Hmm, should not we still diagnose this case?
> > The rule is skip the error as well as skip adding implicit map clause. So that we don't get regression for old code.
> I think we already have the check for it for the reduction clause, so I think we can skip this check here.
In general yes. But not for some special case, please look clang/test/OpenMP/reduction_implicit_map.cpp, in the first test, if I remove this change the error will be emit. In CUDA device code, the local variable is implicitly threat as thridprivate.
#if defined(CUDA)
// expected-no-diagnostics
int foo(int n) {
double *e;
//no error and no implicit map generated for e[:1]
#pragma omp target parallel reduction(+: e[:1])
*e=10;
;
return 0;
}
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108132/new/
https://reviews.llvm.org/D108132
More information about the Openmp-commits
mailing list