summaryrefslogtreecommitdiff
path: root/flang
diff options
context:
space:
mode:
authorRaghu Maddhipatla <Raghu.Maddhipatla@amd.com>2023-05-03 23:47:42 -0500
committerRaghu Maddhipatla <Raghu.Maddhipatla@amd.com>2023-05-10 19:17:47 -0500
commitf85a8456f114d071fb5985ef2c4cd922ba8f29cf (patch)
treef340500f68ad5d547d4f8f70b2124f186289ff79 /flang
parentee9875014ef72137bdcfb180e15b9694ab80ac90 (diff)
downloadllvm-f85a8456f114d071fb5985ef2c4cd922ba8f29cf.tar.gz
[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
Diffstat (limited to 'flang')
-rw-r--r--flang/docs/OpenMP-semantics.md15
-rw-r--r--flang/include/flang/Semantics/symbol.h2
-rw-r--r--flang/lib/Parser/openmp-parsers.cpp3
-rw-r--r--flang/lib/Semantics/check-omp-structure.cpp12
-rw-r--r--flang/lib/Semantics/resolve-directives.cpp8
-rw-r--r--flang/test/Semantics/OpenMP/use_device_addr.f9017
6 files changed, 49 insertions, 8 deletions
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:
<td>OmpUseDevicePtr
</td>
</tr>
+ <tr>
+ <td>use_device_addr
+ </td>
+ <td>Yes
+ </td>
+ <td>New Symbol
+ </td>
+ <td>OmpUseDeviceAddr
+ </td>
+ </tr>
</table>
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<OmpObjectList>{}))) ||
"USE_DEVICE_PTR" >> construct<OmpClause>(construct<OmpClause::UseDevicePtr>(
parenthesized(Parser<OmpObjectList>{}))) ||
+ "USE_DEVICE_ADDR" >>
+ construct<OmpClause>(construct<OmpClause::UseDeviceAddr>(
+ parenthesized(Parser<OmpObjectList>{}))) ||
"UNIFIED_ADDRESS" >>
construct<OmpClause>(construct<OmpClause::UnifiedAddress>()) ||
"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<parser::OmpClause::Copyprivate, parser::OmpClause::Copyin,
- parser::OmpClause::Firstprivate, parser::OmpClause::From,
- parser::OmpClause::Lastprivate, parser::OmpClause::Link,
- parser::OmpClause::Private, parser::OmpClause::Shared,
- parser::OmpClause::To, parser::OmpClause::UseDevicePtr>;
+ using MemberObjectListClauses = std::tuple<parser::OmpClause::Copyprivate,
+ parser::OmpClause::Copyin, parser::OmpClause::Firstprivate,
+ parser::OmpClause::From, parser::OmpClause::Lastprivate,
+ parser::OmpClause::Link, parser::OmpClause::Private,
+ parser::OmpClause::Shared, parser::OmpClause::To,
+ parser::OmpClause::UseDevicePtr, parser::OmpClause::UseDeviceAddr>;
// Clauses with OmpObjectList in the tuple
using TupleObjectListClauses = std::tuple<parser::OmpClause::Allocate,
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 1052c459632e..c6cef99042a1 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -441,6 +441,11 @@ public:
return false;
}
+ bool Pre(const parser::OmpClause::UseDeviceAddr &x) {
+ ResolveOmpObjectList(x.v, Symbol::Flag::OmpUseDeviceAddr);
+ return false;
+ }
+
void Post(const parser::Name &);
// Keep track of labels in the statements that causes jumps to target labels
@@ -511,7 +516,8 @@ private:
Symbol::Flag::OmpPrivate, Symbol::Flag::OmpLinear,
Symbol::Flag::OmpFirstPrivate, Symbol::Flag::OmpLastPrivate,
Symbol::Flag::OmpReduction, Symbol::Flag::OmpCriticalLock,
- Symbol::Flag::OmpCopyIn, Symbol::Flag::OmpUseDevicePtr};
+ Symbol::Flag::OmpCopyIn, Symbol::Flag::OmpUseDevicePtr,
+ Symbol::Flag::OmpUseDeviceAddr};
static constexpr Symbol::Flags ompFlagsRequireMark{
Symbol::Flag::OmpThreadprivate};
diff --git a/flang/test/Semantics/OpenMP/use_device_addr.f90 b/flang/test/Semantics/OpenMP/use_device_addr.f90
new file mode 100644
index 000000000000..67b274929647
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/use_device_addr.f90
@@ -0,0 +1,17 @@
+! RUN: %flang -fc1 -fopenmp -fdebug-dump-symbols %s | FileCheck %s
+! OpenMP Version 5.1
+! 2.14.2 use_device_addr clause
+! 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.
+
+subroutine omp_target_data
+ integer :: a(1024)
+ !CHECK: b, TARGET size=4096 offset=4096: ObjectEntity type: INTEGER(4) shape: 1_8:1024_8
+ integer, target :: b(1024)
+ a = 1
+ !$omp target data map(tofrom: a) use_device_addr(b)
+ !CHECK: b (OmpUseDeviceAddr): HostAssoc
+ b = a
+ !$omp end target data
+end subroutine omp_target_data