This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Parsing and sema support for the to clause
ClosedPublic

Authored by sfantao on Mar 30 2016, 7:42 AM.

Diff Detail

Event Timeline

kkwli0 updated this revision to Diff 52057.Mar 30 2016, 7:42 AM
kkwli0 retitled this revision from to [OpenMP] Parsing and sema support for the to clause.
kkwli0 updated this object.
ABataev added inline comments.Mar 30 2016, 8:49 AM
lib/Sema/SemaOpenMP.cpp
9765–9766

I believe this check is not required anymore, because later you check that VE is not dependent.

9823

Why did you remove this line and inserted an empty one?

lib/Serialization/ASTReaderStmt.cpp
2294–2296

Remove extra braces

kkwli0 marked 2 inline comments as done.Mar 30 2016, 11:04 AM

Thanks for the review.

lib/Sema/SemaOpenMP.cpp
9823

Will put it back.

kkwli0 updated this revision to Diff 52087.Mar 30 2016, 11:10 AM
kkwli0 marked an inline comment as done.

Update the patch based on the review comments.

ABataev added inline comments.Mar 30 2016, 9:17 PM
lib/Sema/SemaOpenMP.cpp
9758–9764

General problem of all map/to/from clauses - they don't know anything about captured decls.
If we have the next code, it will crash the compiler or lead to incorrect code:

struct S {
  int a;
  S() {
   #pragma omp parallel private(a)
   {
    #pragma omp target map(a:....)
    ...
    }
};

The same problem wil be with the to/from clauses. Try to write codegen/dump tests for this and check that private copy of a member decl is used

sfantao edited edge metadata.Apr 3 2016, 4:58 PM

Hi Alexey,

I have inlined comment.

Thanks!
Samuel

lib/Sema/SemaOpenMP.cpp
9758–9764

The example you just gave will work just fine for the same reason I gave in http://reviews.llvm.org/D16749. So, this does not pose any problem to map/to/from. Privatization is now changing the outline region signature (we now have the extra privatized fields), and the map codegen (as well as to/from) will attempt to emit the reference to the variable, whatever its local address currently is. So, it is is a private address that's the one that will be used, if it is something in this the right field would be used. Given that this is also implicitly mapped, the rules of default map will be used and the this pointee mapped as a to/from-aggregate along with all the individual declarations that have been privatized.

Map clause does not change the code emission inside the outlined region - it only matters to get the right information to pass the runtime library (and the eventual capture by copy). So, if something works in the generation of the region without the map clause (implicit map), there is no reason why it shouldn't when a map clause is used.

For 'to'/'from' is even more irrelevant because no outlined regions are created. Again, only the information passed to the runtime library is different.

In any case, I will add your example to the regression tests in http://reviews.llvm.org/D16749 just to add some peace of mind.

ABataev added inline comments.Apr 3 2016, 10:32 PM
lib/Sema/SemaOpenMP.cpp
9758–9764

Add tests, please, for all possible situations with the data members

kkwli0 added inline comments.Apr 12 2016, 9:44 PM
lib/Sema/SemaOpenMP.cpp
9758–9764

I will add the test cases under http://reviews.llvm.org/D15944 since the clauses rely on the support of target update construct. Is it okay?

sfantao commandeered this revision.May 24 2016, 6:11 PM
sfantao edited reviewers, added: kkwli0; removed: sfantao.
sfantao updated this object.
sfantao edited reviewers, added: arpith-jacob; removed: rsmith, fraggamuffin.
sfantao added subscribers: cfe-commits, caomhin.
sfantao updated this revision to Diff 58370.May 24 2016, 6:15 PM

Add implementation and tests only for the to clause. The implementation is based on the existing infrastructure used by the map clause already available upstream.

ABataev added inline comments.May 24 2016, 9:08 PM
lib/Sema/SemaOpenMP.cpp
9764–9766
  1. Use SmallVectorImpl<Expr *> instead of SmallVector<Expr *, n>.
  2. Is it possible to reduce number of arguments of this function by gathering them into a record?
9765–9766

Still think that this check is not required.

9877

You already get DKind few lines above, why need to update it?

test/OpenMP/nesting_of_regions.cpp
136 ↗(On Diff #58370)

Test 'nesting_of_regions.cpp' should be updated only when adding a new directive, not a clause.

sfantao updated this revision to Diff 58486.May 25 2016, 1:10 PM
sfantao marked 7 inline comments as done.
  • Address comments from the last review by Alexey.

Hi Alexey,

Thanks for the review.

lib/Sema/SemaOpenMP.cpp
9758–9765

Just noticed these things were unanswered. This comment was prior to the map clause patch, so now all data members cases are tested in the upstreamed regression tests.

9764–9766

Ok, I created a new container that I named MappableVarListInfo to keep all the required lists. I now pass that container instead of the four lists. Hope this is more or less what you had in mind.

9765–9766

Correct, this is not needed. Sorry, forgot to remove that in the previous diff.

9877

Right, I don't. I removed the latest diff.

test/OpenMP/nesting_of_regions.cpp
136 ↗(On Diff #58370)

Ok, I added the nesting tests to the dependence patch http://reviews.llvm.org/D15944.

I only do a few changes in this patch to use a clause because that allows me to remove the expected errors "need to/from clause" that are unrelated with nesting. These errors are already checked by the other tests.

ABataev accepted this revision.May 25 2016, 8:12 PM
ABataev edited edge metadata.

LG, with a small nit.

lib/Sema/SemaOpenMP.cpp
9760

Mark it as a 'final' struct

This revision is now accepted and ready to land.May 25 2016, 8:12 PM
sfantao updated this revision to Diff 58651.May 26 2016, 10:44 AM
sfantao edited edge metadata.
  • Mark MappableVarListInfo as final.
sfantao closed this revision.May 26 2016, 10:46 AM