[flang-commits] [flang] a749b32 - [flang][openacc] Support readonly modifier for declare copyin in module file
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Mon Aug 7 09:53:15 PDT 2023
Author: Valentin Clement
Date: 2023-08-07T09:53:09-07:00
New Revision: a749b32a11055aa680db7cdcb68687345132abe5
URL: https://github.com/llvm/llvm-project/commit/a749b32a11055aa680db7cdcb68687345132abe5
DIFF: https://github.com/llvm/llvm-project/commit/a749b32a11055aa680db7cdcb68687345132abe5.diff
LOG: [flang][openacc] Support readonly modifier for declare copyin in module file
Distinguish between copyin and copyin with the readonly modifier.
Depends on D157121
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D157125
Added:
Modified:
flang/include/flang/Semantics/symbol.h
flang/lib/Semantics/mod-file.cpp
flang/lib/Semantics/resolve-directives.cpp
flang/test/Semantics/OpenACC/acc-module.f90
Removed:
################################################################################
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index df1d9c2a58b83d..333f63b2c2842b 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -594,8 +594,8 @@ class Symbol {
// OpenACC data-sharing attribute
AccPrivate, AccFirstPrivate, AccShared,
// OpenACC data-mapping attribute
- AccCopy, AccCopyIn, AccCopyOut, AccCreate, AccDelete, AccPresent, AccLink,
- AccDeviceResident, AccDevicePtr,
+ AccCopy, AccCopyIn, AccCopyInReadOnly, AccCopyOut, AccCreate, AccDelete,
+ AccPresent, AccLink, AccDeviceResident, AccDevicePtr,
// OpenACC declare
AccDeclare,
// OpenACC data-movement attribute
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index 48226738ba24d1..c88e20965c1ebf 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -877,7 +877,8 @@ void PutOpenACCDirective(llvm::raw_ostream &os, const Symbol &symbol) {
os << "!$acc declare ";
if (symbol.test(Symbol::Flag::AccCopy)) {
os << "copy";
- } else if (symbol.test(Symbol::Flag::AccCopyIn)) {
+ } else if (symbol.test(Symbol::Flag::AccCopyIn) ||
+ symbol.test(Symbol::Flag::AccCopyInReadOnly)) {
os << "copyin";
} else if (symbol.test(Symbol::Flag::AccCopyOut)) {
os << "copyout";
@@ -892,7 +893,11 @@ void PutOpenACCDirective(llvm::raw_ostream &os, const Symbol &symbol) {
} else if (symbol.test(Symbol::Flag::AccLink)) {
os << "link";
}
- os << "(" << symbol.name() << ")\n";
+ os << "(";
+ if (symbol.test(Symbol::Flag::AccCopyInReadOnly)) {
+ os << "readonly: ";
+ }
+ os << symbol.name() << ")\n";
}
}
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index f317b27f7b1eaa..2a39d45701d13a 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -167,7 +167,14 @@ class AccAttributeVisitor : DirectiveAttributeVisitor<llvm::acc::Directive> {
bool Pre(const parser::AccClause::Copyin &x) {
const auto &objectList{std::get<parser::AccObjectList>(x.v.t)};
- ResolveAccObjectList(objectList, Symbol::Flag::AccCopyIn);
+ const auto &modifier{
+ std::get<std::optional<parser::AccDataModifier>>(x.v.t)};
+ if (modifier &&
+ (*modifier).v == parser::AccDataModifier::Modifier::ReadOnly) {
+ ResolveAccObjectList(objectList, Symbol::Flag::AccCopyInReadOnly);
+ } else {
+ ResolveAccObjectList(objectList, Symbol::Flag::AccCopyIn);
+ }
return false;
}
@@ -246,7 +253,8 @@ class AccAttributeVisitor : DirectiveAttributeVisitor<llvm::acc::Directive> {
Symbol::Flag::AccDevice, Symbol::Flag::AccHost, Symbol::Flag::AccSelf};
Symbol::Flags accFlagsRequireMark{Symbol::Flag::AccCreate,
- Symbol::Flag::AccCopyIn, Symbol::Flag::AccCopy, Symbol::Flag::AccCopyOut,
+ Symbol::Flag::AccCopyIn, Symbol::Flag::AccCopyInReadOnly,
+ Symbol::Flag::AccCopy, Symbol::Flag::AccCopyOut,
Symbol::Flag::AccDevicePtr, Symbol::Flag::AccDeviceResident,
Symbol::Flag::AccLink, Symbol::Flag::AccPresent};
diff --git a/flang/test/Semantics/OpenACC/acc-module.f90 b/flang/test/Semantics/OpenACC/acc-module.f90
index 1b29696958fd0a..d618650f5c439a 100644
--- a/flang/test/Semantics/OpenACC/acc-module.f90
+++ b/flang/test/Semantics/OpenACC/acc-module.f90
@@ -7,6 +7,9 @@ module acc_mod
real :: data_copyin(10)
!$acc declare copyin(data_copyin)
+ real :: data_copyinro(10)
+ !$acc declare copyin(readonly: data_copyinro)
+
real :: data_device_resident(20)
!$acc declare device_resident(data_device_resident)
@@ -20,6 +23,8 @@ module acc_mod
! !$acc declare create(data_create)
! real(4)::data_copyin(1_8:10_8)
! !$acc declare copyin(data_copyin)
+! real(4)::data_copyinro(1_8:10_8)
+! !$acc declare copyin(readonly: data_copyinro)
! real(4)::data_device_resident(1_8:20_8)
! !$acc declare device_resident(data_device_resident)
! integer(4)::data_link(1_8:50_8)
More information about the flang-commits
mailing list