This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'
ClosedPublic

Authored by carlo.bertolli on Jun 30 2016, 12:41 PM.

Details

Reviewers
kkwli0
ABataev
Summary

This patch is similar to the implementation of 'private' clause: it adds a list of private pointers to be used within the target data region to store the device pointers returned by the runtime.
Please refer to the following document for a full description of what the runtime witll return in this case (page 10 and 11):
https://github.com/clang-omp/OffloadingDesign

I am happy to answer any question related to the runtime interface to help reviewing this patch.

Diff Detail

Repository
rL LLVM

Event Timeline

carlo.bertolli retitled this revision from to [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'.
carlo.bertolli updated this object.
carlo.bertolli added reviewers: ABataev, kkwli0.
carlo.bertolli set the repository for this revision to rL LLVM.

[OpenMP] Delete trailing whitespaces in regression test file and rebase.

ABataev added inline comments.Jun 30 2016, 7:56 PM
include/clang/Basic/DiagnosticSemaKinds.td
8318

It's better to rephrase this message: "expected a variable of pointer type" or something like this. Also, it would be good to have a corresponding note, describing the provided item.

lib/Sema/SemaOpenMP.cpp
11377

You should not skip the reference from the type, references are not allowed also

11382–11394

I don't think that this patch requires some private copies right now. They will be required only during codegen. I think the private copies must be excluded from parsing/sema patch

sfantao added inline comments.Jun 30 2016, 8:13 PM
lib/Sema/SemaOpenMP.cpp
11377

Hi Alexey, I think the item can be a reference to a pointer. I couldn't find that restriction in the spec, can you point me to what you are referring to? We should probably refer to that in the preceding comment.

Thanks!

ABataev added inline comments.Jun 30 2016, 8:41 PM
lib/Sema/SemaOpenMP.cpp
11377

Here is the restriction:
"2.10.1 target data Construct, restrictions. References in the construct to a list item that appears in a use_device_ptr clause must be to the address of the list item."
Does it mean that references are allowed?

sfantao added inline comments.Jun 30 2016, 8:57 PM
lib/Sema/SemaOpenMP.cpp
11377

Ok, thanks. My interpretation is that that restriction refers to references used in clauses (in the same construct) other than use_device_ptr to declarations used in use_device_ptr. I think the motivation is to restrict the use of the value of the pointer by other clauses given that value is going to change for that data environment because of the behavior implemented by use_device_ptr. Carlo, what is your interpretation?

kkwli0 added inline comments.Jun 30 2016, 9:17 PM
lib/Sema/SemaOpenMP.cpp
11377

I interpret the rule to the list item being used inside the construct instead of being used in the other clauses on the same construct.

I think that Kelvin is right. This is what that sentence refers to:
int * bla = ..;
#pragma omp target data use_device_ptr(bla)
{

.. bla .. // <-- this is the 'reference' that sentence is about

}

What puzzles me about that sentence is that it seems it is asking us to use bla as following:
int addr_bla = &bla;
// now can use addr_bla

I am specifically referring to this part of the sentence: "must be to the address of the list item"

Anyway, as Kelvin says, this has nothing to do with what we expect sema for use_device_ptr to accept. Samuel point, but I may be mistaken, is that a reference to a pointer should be considered as a pointer itself.
Alexey: if you do not think this is right, I can add a test that excludes references.

Finally, thanks for the very quick review and for all your comments

  • Carlo
ABataev edited edge metadata.Jun 30 2016, 10:01 PM

I think that Kelvin is right. This is what that sentence refers to:
int * bla = ..;
#pragma omp target data use_device_ptr(bla)
{

.. bla .. // <-- this is the 'reference' that sentence is about

}

What puzzles me about that sentence is that it seems it is asking us to use bla as following:
int addr_bla = &bla;
// now can use addr_bla

I am specifically referring to this part of the sentence: "must be to the address of the list item"

Anyway, as Kelvin says, this has nothing to do with what we expect sema for use_device_ptr to accept. Samuel point, but I may be mistaken, is that a reference to a pointer should be considered as a pointer itself.
Alexey: if you do not think this is right, I can add a test that excludes references.

Finally, thanks for the very quick review and for all your comments

  • Carlo

Carlo, I'm not sure about this sentence at all. If you think that this construct may accept references to pointers, then go ahead and ignore my previous comment.

carlo.bertolli edited edge metadata.

[OpenMP] Remove private variable creation from this patch as requested by comments and rebase.

ABataev added inline comments.Jul 5 2016, 8:12 PM
include/clang/AST/OpenMPClause.h
4221

No \brief's

include/clang/Basic/DiagnosticSemaKinds.td
8333

I think it 's better to use 'expected ...' form as in other errors/warnings

include/clang/Sema/Sema.h
8466

No \brief

lib/Sema/TreeTransform.h
1784

Remove \brief tag

carlo.bertolli marked 4 inline comments as done.Jul 6 2016, 8:06 AM

[OpenMP] Remove 'brief' comment tags and change error report to standard 'expected' form.

No positive tests for the construct

include/clang/Basic/DiagnosticSemaKinds.td
8333

Shall we accept refs to pointers and arrays?

lib/Sema/SemaOpenMP.cpp
11656–11658

It is better to add this code in codegen part

carlo.bertolli marked an inline comment as done.Jul 11 2016, 9:49 AM

No positive tests for the construct

Do you mean in the regression test? I thought I covered all negative and positive cases, but please let me know if I missed anything.

include/clang/Basic/DiagnosticSemaKinds.td
8333

I think that people of the OpenMP committee agreed that we can accept references to pointers. There is no indication in the specifications about arrays, so I will leave them out for the time being.
I will add a mention of references here.

[OpenMP] Apply comments: remove creation of private variable and update regression tests to include references to pointers.

I don't see successful test for the clause, which prints AST and checks serialization/deserialization. Also it should include a template test to check that dependent objects are handled correctly

include/clang/AST/OpenMPClause.h
4236

\brief

4258

\brief

4269

\brief

lib/Sema/SemaOpenMP.cpp
11648

What if Type is dependent?

carlo.bertolli marked 3 inline comments as done.Jul 12 2016, 9:20 AM
carlo.bertolli added inline comments.
lib/Sema/SemaOpenMP.cpp
11648

In that case at line 8084 (function getPrivateItem) will return the pair (nullptr, true) and at line 11640 I will push nullptr for later analysis.
If this is not enough, can you please explain what needs to be done? Thanks!!

[OpenMP] Add regression test to check correctness of ast building, remove 'brief's, and rebase.

ABataev accepted this revision.Jul 12 2016, 11:16 PM
ABataev edited edge metadata.

LG

This revision is now accepted and ready to land.Jul 12 2016, 11:16 PM

Committed revision 275271.