-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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][semantics][OpenMP] no privatisation of stmt functions #106550
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2c6b70f
[flang][semantics][OpenMP] no privatisation of stmt functions
tblah 9a43a1d
Don't capitalise 'statement function'
tblah d3aa6da
Fix test
tblah 413e71c
Ensure that statement functions are not implicitly privatised
tblah 99572e6
Fix spelling and remove unused flag
tblah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -718,7 +718,7 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> { | |
void CheckDataCopyingClause( | ||
const parser::Name &, const Symbol &, Symbol::Flag); | ||
void CheckAssocLoopLevel(std::int64_t level, const parser::OmpClause *clause); | ||
void CheckObjectInNamelistOrAssociate( | ||
void CheckObjectIsPrivatisable( | ||
const parser::Name &, const Symbol &, Symbol::Flag); | ||
void CheckSourceLabel(const parser::Label &); | ||
void CheckLabelContext(const parser::CharBlock, const parser::CharBlock, | ||
|
@@ -2225,20 +2225,7 @@ void OmpAttributeVisitor::Post(const parser::Name &name) { | |
return; | ||
} | ||
|
||
if (auto *stmtFunction{symbol->detailsIf<semantics::SubprogramDetails>()}; | ||
stmtFunction && stmtFunction->stmtFunction()) { | ||
// Each non-dummy argument from a statement function must be handled too, | ||
// as if it was explicitly referenced. | ||
semantics::UnorderedSymbolSet symbols{ | ||
CollectSymbols(stmtFunction->stmtFunction().value())}; | ||
for (const auto &sym : symbols) { | ||
if (!IsStmtFunctionDummy(sym) && !IsObjectWithDSA(*sym)) { | ||
CreateImplicitSymbols(&*sym, Symbol::Flag::OmpFromStmtFunction); | ||
} | ||
} | ||
} else { | ||
CreateImplicitSymbols(symbol); | ||
} | ||
CreateImplicitSymbols(symbol); | ||
} // within OpenMP construct | ||
} | ||
|
||
|
@@ -2357,7 +2344,7 @@ void OmpAttributeVisitor::ResolveOmpObject( | |
CheckMultipleAppearances(*name, *symbol, ompFlag); | ||
} | ||
if (privateDataSharingAttributeFlags.test(ompFlag)) { | ||
CheckObjectInNamelistOrAssociate(*name, *symbol, ompFlag); | ||
CheckObjectIsPrivatisable(*name, *symbol, ompFlag); | ||
} | ||
|
||
if (ompFlag == Symbol::Flag::OmpAllocate) { | ||
|
@@ -2729,7 +2716,7 @@ void OmpAttributeVisitor::CheckDataCopyingClause( | |
} | ||
} | ||
|
||
void OmpAttributeVisitor::CheckObjectInNamelistOrAssociate( | ||
void OmpAttributeVisitor::CheckObjectIsPrivatisable( | ||
const parser::Name &name, const Symbol &symbol, Symbol::Flag ompFlag) { | ||
const auto &ultimateSymbol{symbol.GetUltimate()}; | ||
llvm::StringRef clauseName{"PRIVATE"}; | ||
|
@@ -2750,6 +2737,14 @@ void OmpAttributeVisitor::CheckObjectInNamelistOrAssociate( | |
"Variable '%s' in ASSOCIATE cannot be in a %s clause"_err_en_US, | ||
name.ToString(), clauseName.str()); | ||
} | ||
|
||
if (stmtFunctionExprSymbols_.find(ultimateSymbol) != | ||
stmtFunctionExprSymbols_.end()) { | ||
context_.Say(name.source, | ||
"Variable '%s' in statement function expression cannot be in a " | ||
"%s clause"_err_en_US, | ||
name.ToString(), clauseName.str()); | ||
} | ||
Comment on lines
+2741
to
+2747
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to change the name of this member function, to something like |
||
} | ||
|
||
void OmpAttributeVisitor::CheckSourceLabel(const parser::Label &label) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp | ||
! OpenMP Version 4.5 | ||
! Variables that appear in expressions for statement function definitions | ||
! may not appear in private, firstprivate or lastprivate clauses. | ||
|
||
subroutine stmt_function(temp) | ||
|
||
integer :: i, p, q, r | ||
real :: c, f, s, v, t(10) | ||
real, intent(in) :: temp | ||
|
||
c(temp) = p * (temp - q) / r | ||
f(temp) = q + (temp * r/p) | ||
v(temp) = c(temp) + f(temp)/2 - s | ||
|
||
p = 5 | ||
q = 32 | ||
r = 9 | ||
|
||
!ERROR: Variable 'p' in statement function expression cannot be in a PRIVATE clause | ||
!$omp parallel private(p) | ||
s = c(temp) | ||
!$omp end parallel | ||
|
||
!ERROR: Variable 's' in statement function expression cannot be in a FIRSTPRIVATE clause | ||
!$omp parallel firstprivate(s) | ||
s = s + f(temp) | ||
!$omp end parallel | ||
|
||
!ERROR: Variable 's' in statement function expression cannot be in a LASTPRIVATE clause | ||
!$omp parallel do lastprivate(s, t) | ||
do i = 1, 10 | ||
t(i) = v(temp) + i - s | ||
end do | ||
!$omp end parallel do | ||
|
||
print *, t | ||
|
||
end subroutine stmt_function |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed that sometimes
privatisable
(British English) is used and other times it'sprivatizable
.It would be nice to standardize one of the two in the code.
I suggest the latter, because that's how it's written in the OpenMP standard, that uses words such as
privatization
andprivatized
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree we should use the American spelling.