-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[flang][OpenMP]Add parsing support for MAP(MAPPER(name) ...) #116274
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1471,6 +1471,8 @@ class OmpVisitor : public virtual DeclarationVisitor { | |
|
|
||
| bool Pre(const parser::OpenMPDeclareMapperConstruct &); | ||
|
|
||
| bool Pre(const parser::OmpMapClause &); | ||
|
|
||
| void Post(const parser::OmpBeginLoopDirective &) { | ||
| messageHandler().set_currStmtSource(std::nullopt); | ||
| } | ||
|
|
@@ -1639,6 +1641,14 @@ bool OmpVisitor::Pre(const parser::OpenMPDeclareMapperConstruct &x) { | |
| return false; | ||
| } | ||
|
|
||
| bool OmpVisitor::Pre(const parser::OmpMapClause &x) { | ||
| const auto &mid{std::get<parser::OmpMapperIdentifier>(x.t)}; | ||
| if (const auto &mapperName{mid.v}) | ||
| mapperName->symbol = | ||
| &MakeSymbol(*mapperName, MiscDetails{MiscDetails::Kind::ConstructName}); | ||
|
||
| return true; | ||
| } | ||
|
|
||
| // Walk the parse tree and resolve names to symbols. | ||
| class ResolveNamesVisitor : public virtual ScopeHandler, | ||
| public ModuleVisitor, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ! RUN: not %flang_fc1 -emit-fir -fopenmp -fopenmp-version=50 %s 2>&1 | FileCheck %s | ||
| program p | ||
| integer, parameter :: n = 256 | ||
| real(8) :: a(256) | ||
| !$omp target map(mapper(xx), from:a) | ||
| !CHECK: not yet implemented: OmpMapClause(MAPPER(...)) | ||
| do i=1,n | ||
| a(i) = 4.2 | ||
| end do | ||
| !$omp end target | ||
| end program p |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| ! RUN: %flang_fc1 -fdebug-dump-symbols -fopenmp -fopenmp-version=50 %s | FileCheck %s | ||
| program main | ||
| !CHECK-LABEL: MainProgram scope: main | ||
| integer, parameter :: n = 256 | ||
| real(8) :: a(256) | ||
| !$omp target map(mapper(xx), from:a) | ||
| do i=1,n | ||
| a(i) = 4.2 | ||
| end do | ||
| !$omp end target | ||
| !CHECK: OtherConstruct scope: size=0 alignment=1 sourceRange=74 bytes | ||
| !CHECK: OtherClause scope: size=0 alignment=1 sourceRange=0 bytes | ||
| !CHECK: xx: Misc ConstructName | ||
| end program main |
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.
It reads a bit strangely to me that the optional mapper identifier looks non-optional (if one doesn't look up at the type definition). Could the
std::optionalbe moved outside of the type so it is visible here?Don't worry about it if it becomes a headache to do - this is very nitpicky
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.
So, this was my solution to making the
maybework. Since we need to parse the"MAPPER"and thenparenthesized(name)and a comma. If I move the optional around, the maybe parsing doesn't work.Unless someone can let me know how to make something
maybeparse to produce the wrapper thing optional.Everything I've tried (and that's a lot - I couldn't list them all, but
std::optional<Name>in thestd::tuplewas one of them.The
TypeModifierandIteratorModiferandTypegets away with it, because they don't have a keyword with a parenthesized "argument". so they can just do a list (which is allowed to be empty).I did try again just now, but I can't come up with something that compiles...
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.
The way this was intended to work is that
std::optional<std::list<YourModifier>>to the tuple in here.ModParserlist in MapModifiers in openmp-parsers.cpp.makeMapClauseand pass it to theOmpMapClauseconstructor.Then in check-omp-structure.cpp you can verify that there is at most one mapper modifier in the list, and print a meaningful message.
Having said that, I'm working on modifier verification right now, which will change how they are organized and parsed, so it's not a big deal if you leave it as is, since I'll have to change it anyway. (One problem with the current code that I'm trying to address is that the modifiers can be specified in any order, which the current parsers don't allow.)