This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][Flang][Semantics] Add semantics support for USE_DEVICE_PTR clause on OMP TARGET DATA directive.
ClosedPublic

Authored by raghavendhra on Apr 13 2023, 10:13 AM.

Diff Detail

Event Timeline

raghavendhra created this revision.Apr 13 2023, 10:13 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
raghavendhra requested review of this revision.Apr 13 2023, 10:13 AM

Are you planning to implement this check:

A list item that specifies a given variable may not appear in more than one use_device_ptr clause.

flang/test/Semantics/OpenMP/use_device_ptr.f90
22

New line here.

Are you planning to implement this check:

A list item that specifies a given variable may not appear in more than one use_device_ptr clause.

Yes, in a future patch in which I am thinking to add more checks related to restrictions.

kiranchandramohan requested changes to this revision.Apr 21 2023, 8:14 AM

Thanks for the patch. I have a few comments inline.

flang/lib/Semantics/resolve-directives.cpp
440

We probably need a debug-dump-symbols test to show that the SymbolFlag is applied.

510

From the standard:

Pointers that appear in a use_device_ptr clause are privatized and the device pointers to the corresponding list items in the device data environment are assigned into the private versions.

Since the pointer in the use_device_ptr is privatised, it is best to follow the representation for privatised variables i.e represent them with a new Symbol. It is probably good to add Symbol::Flag::OmpUseDevicePtr to ompFlagsRequireNewSymbol.

flang/test/Semantics/OpenMP/use_device_ptr.f90
16

If the location pointed to by b inside the region is different from the location pointed outside to by b then it is probably better to create a new symbol for b inside the region.

This revision now requires changes to proceed.Apr 21 2023, 8:14 AM
raghavendhra marked 4 inline comments as done.Apr 21 2023, 3:34 PM

Addressed review comments and rebased patch

Addressed review comments and rebased

At the moment a new symbol is not created because target data does not create a scope at the moment. We have to modify the OmpVisitor::NeedsScope function in resolve-names.cpp file to create a scope.

Please update the document (https://github.com/llvm/llvm-project/blob/main/flang/docs/OpenMP-semantics.md) to include that new scope is created for target data and new Symbol is created for use_device_pointer. Also include the reason.

flang/test/Semantics/OpenMP/use_device_ptr.f90
15

The test should check both the original symbol and the host-associated symbol.

raghavendhra marked an inline comment as done.Apr 25 2023, 4:14 PM

Also include the reason.

Can you please point me to the location where I should be adding the reason. Should it be mentioned in flang/docs/OpenMP-semantics.md? If so under which section should I mention it.

Addressed review comments and rebased

LGTM. Thanks for the patch and for addressing the review comments.

Also include the reason.

Can you please point me to the location where I should be adding the reason. Should it be mentioned in If so under which section should I mention it.

Yes, in flang/docs/OpenMP-semantics.md. Please add as additional info in the sections where you made changes.

This revision is now accepted and ready to land.Apr 26 2023, 6:10 AM

Rebased and now ready to land.

This revision was landed with ongoing or failed builds.Apr 26 2023, 6:17 PM
This revision was automatically updated to reflect the committed changes.