-
Notifications
You must be signed in to change notification settings - Fork 15k
[flang][acc] honor reduction clause's implied copy attribute #156982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flang][acc] honor reduction clause's implied copy attribute #156982
Conversation
@llvm/pr-subscribers-flang-openmp @llvm/pr-subscribers-openacc Author: Andre Kuhlenschmidt (akuhlens) ChangesThe Open ACC spec states that the reduction clause implies the copy clause. Account for this in the check for Full diff: https://github.com/llvm/llvm-project/pull/156982.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index a08e764ecf936..ac3794a95b065 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -304,6 +304,12 @@ class AccAttributeVisitor : DirectiveAttributeVisitor<llvm::acc::Directive> {
return false;
}
+ bool Pre(const parser::AccClause::Reduction &x) {
+ const auto &objectList{std::get<parser::AccObjectList>(x.v.t)};
+ ResolveAccObjectList(objectList, Symbol::Flag::AccReduction);
+ return false;
+ }
+
void Post(const parser::Name &);
private:
diff --git a/flang/test/Semantics/OpenACC/acc-reduction-validity.f90 b/flang/test/Semantics/OpenACC/acc-reduction-validity.f90
index 0cdf33a2adb94..fd83e411191db 100644
--- a/flang/test/Semantics/OpenACC/acc-reduction-validity.f90
+++ b/flang/test/Semantics/OpenACC/acc-reduction-validity.f90
@@ -177,13 +177,23 @@ program openacc_reduction_validity
end program
subroutine sum()
- ! ERROR: 'sum' is already declared in this scoping unit
+ !ERROR: 'sum' is already declared in this scoping unit
integer :: i,sum
sum = 0
- !$acc parallel
+ !$acc parallel
+ !ERROR: Only variables are allowed in data clauses on the LOOP directive
!$acc loop independent gang reduction(+:sum)
do i=1,10
sum = sum + i
enddo
!$acc end parallel
end subroutine
+
+subroutine reduce()
+ integer :: red = 0, ii
+ !$acc parallel loop default(none) reduction(+:red)
+ do ii = 1, 10
+ red = red + ii
+ end do
+ !$acc end parallel
+end subroutine
|
@llvm/pr-subscribers-flang-semantics Author: Andre Kuhlenschmidt (akuhlens) ChangesThe Open ACC spec states that the reduction clause implies the copy clause. Account for this in the check for Full diff: https://github.com/llvm/llvm-project/pull/156982.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index a08e764ecf936..ac3794a95b065 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -304,6 +304,12 @@ class AccAttributeVisitor : DirectiveAttributeVisitor<llvm::acc::Directive> {
return false;
}
+ bool Pre(const parser::AccClause::Reduction &x) {
+ const auto &objectList{std::get<parser::AccObjectList>(x.v.t)};
+ ResolveAccObjectList(objectList, Symbol::Flag::AccReduction);
+ return false;
+ }
+
void Post(const parser::Name &);
private:
diff --git a/flang/test/Semantics/OpenACC/acc-reduction-validity.f90 b/flang/test/Semantics/OpenACC/acc-reduction-validity.f90
index 0cdf33a2adb94..fd83e411191db 100644
--- a/flang/test/Semantics/OpenACC/acc-reduction-validity.f90
+++ b/flang/test/Semantics/OpenACC/acc-reduction-validity.f90
@@ -177,13 +177,23 @@ program openacc_reduction_validity
end program
subroutine sum()
- ! ERROR: 'sum' is already declared in this scoping unit
+ !ERROR: 'sum' is already declared in this scoping unit
integer :: i,sum
sum = 0
- !$acc parallel
+ !$acc parallel
+ !ERROR: Only variables are allowed in data clauses on the LOOP directive
!$acc loop independent gang reduction(+:sum)
do i=1,10
sum = sum + i
enddo
!$acc end parallel
end subroutine
+
+subroutine reduce()
+ integer :: red = 0, ii
+ !$acc parallel loop default(none) reduction(+:red)
+ do ii = 1, 10
+ red = red + ii
+ end do
+ !$acc end parallel
+end subroutine
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/41/builds/8765 Here is the relevant piece of the build log for the reference
|
The Open ACC spec states that the reduction clause implies the copy clause. Account for this in the check for
default(none)
variables. Add a test that shouldn't error, but did before this PR.