From f85a8456f114d071fb5985ef2c4cd922ba8f29cf Mon Sep 17 00:00:00 2001 From: Raghu Maddhipatla Date: Wed, 3 May 2023 23:47:42 -0500 Subject: [OpenMP][Flang][Semantics] Add semantics support for USE_DEVICE_ADDR clause on OMP TARGET DATA directive. Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D149815 --- flang/docs/OpenMP-semantics.md | 15 +++++++++++++++ flang/include/flang/Semantics/symbol.h | 2 +- flang/lib/Parser/openmp-parsers.cpp | 3 +++ flang/lib/Semantics/check-omp-structure.cpp | 12 ++++++------ flang/lib/Semantics/resolve-directives.cpp | 8 +++++++- flang/test/Semantics/OpenMP/use_device_addr.f90 | 17 +++++++++++++++++ 6 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 flang/test/Semantics/OpenMP/use_device_addr.f90 (limited to 'flang') diff --git a/flang/docs/OpenMP-semantics.md b/flang/docs/OpenMP-semantics.md index 579c40692ba4..6f42b44726e9 100644 --- a/flang/docs/OpenMP-semantics.md +++ b/flang/docs/OpenMP-semantics.md @@ -418,6 +418,16 @@ More details are listed in the following table: OmpUseDevicePtr + + use_device_addr + + Yes + + New Symbol + + OmpUseDeviceAddr + + To determine the right data-sharing attribute, @@ -535,6 +545,11 @@ 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 so it is best to follow the representation for privatised variables i.e represent them with a new Symbol and `OmpUseDevicePtr` flag. +If a list item that appears in a use_device_addr clause has corresponding +storage in the device data environment, references to the list item in the +associated structured block are converted into references to the corresponding +list item so following the same i.e. represent them with a new Symbol and +`OmpUseDeviceAddr` flag. The basic steps to determine the data-mapping attribute are: diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h index 41a03a2b6a94..3e029c98fc2e 100644 --- a/flang/include/flang/Semantics/symbol.h +++ b/flang/include/flang/Semantics/symbol.h @@ -560,7 +560,7 @@ public: OmpShared, OmpPrivate, OmpLinear, OmpFirstPrivate, OmpLastPrivate, // OpenMP data-mapping attribute OmpMapTo, OmpMapFrom, OmpMapAlloc, OmpMapRelease, OmpMapDelete, - OmpUseDevicePtr, + OmpUseDevicePtr, OmpUseDeviceAddr, // OpenMP data-copying attribute OmpCopyIn, OmpCopyPrivate, // OpenMP miscellaneous flags diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp index 13ebb7f7efdc..6a5815236768 100644 --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -336,6 +336,9 @@ TYPE_PARSER( parenthesized(Parser{}))) || "USE_DEVICE_PTR" >> construct(construct( parenthesized(Parser{}))) || + "USE_DEVICE_ADDR" >> + construct(construct( + parenthesized(Parser{}))) || "UNIFIED_ADDRESS" >> construct(construct()) || "UNIFIED_SHARED_MEMORY" >> diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp index cd30441d5ad1..eb8de20a6b8b 100644 --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -2806,12 +2806,12 @@ const parser::OmpObjectList *OmpStructureChecker::GetOmpObjectList( const parser::OmpClause &clause) { // Clauses with OmpObjectList as its data member - using MemberObjectListClauses = - std::tuple; + using MemberObjectListClauses = std::tuple; // Clauses with OmpObjectList in the tuple using TupleObjectListClauses = std::tuple