-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[flang][openmp]Add UserReductionDetails and use in DECLARE REDUCTION #140066
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
base: main
Are you sure you want to change the base?
Conversation
This is a continuation of @Leporacanthicus's work in #131628. |
c4e01f6
to
c5f9768
Compare
ping for review |
// Store (and get a reference to the stored string) for mangled names | ||
// used for OpenMP DECLARE REDUCTION. | ||
std::string &StoreUserReductionName(const std::string &name); |
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 was hoping we could get this to work without the requirement for a string storage like this.
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.
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.
SaveTempName is used elsewhere for saving mangled names so I'm not adding any new confusion here. There's currently no code removing any strings that are added via that helper so the lifetime should be okay.
void OmpVisitor::ProcessReductionSpecifier( | ||
const parser::OmpReductionSpecifier &spec, | ||
const std::optional<parser::OmpClauseList> &clauses) { | ||
const std::optional<parser::OmpClauseList> &clauses, |
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 changes in this function looks a bit hacky.
Ideally we shouldn't have random parser::Name
not attached to the parse-tree and floating symbols.
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.
bb650c5
to
9a7d1ab
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
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.
LGTM overall. But please wait for another approval
|
||
UserReductionDetails() = default; | ||
|
||
void AddType(const DeclTypeSpec &type) { typeList_.push_back(&type); } |
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.
Nit (feel free to ignore): emplace_back
may be preferable for non-trivial types in std::vector
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 ignored here (because it is just adding a pointer). But the other one does benefit from emplace_back to construct the variant in place. Thanks
return CheckSymbolSupportsType( | ||
scope, MangleDefinedOperator(definedOp->v.symbol->name()), type); | ||
} | ||
DIE("Intrinsic Operator not found - parsing gone wrong?"); |
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.
Nit: Should this be DIE
or a semantic error that sources the offending source?
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'll replace this with unreachable to make it clearer
Could you check the format complaints again? |
This adds another puzzle piece for the support of OpenMP DECLARE REDUCTION functionality. This adds support for operators with derived types, as well as declaring multiple different types with the same name or operator. A new detail class for UserReductionDetials is introduced to hold the list of types supported for a given reduction declaration. Tests for parsing and symbol generation added. Declare reduction is still not supported to lowering, it will generate a "Not yet implemented" fatal error.
* Add two more tests (multiple operator-based declarations and re-using symbol already declared. * Add a few comments. * Fix up logical results.
Also print the reduction declaration in the module file. Fix trivial typo. Add/modify tests to cover all the new things, including fixing the duplicated typo in the test...
Also rebase, as the branch was quite a way behind. Small conflict was resolved.
Add code to better handle operators in parsing and semantics. Add a function to set the the scope when processign assignments, which caused a crash in "check for pure functions". Add three new tests and amend existing tests to cover a pure function.
ea6901d
to
d12203c
Compare
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.
const auto &details{symbol.get<UserReductionDetails>()}; | ||
// The module content for a OpenMP Declare Reduction is the OpenMP | ||
// declaration. There may be multiple declarations. | ||
// Decls are pointers, so do not use a referene. |
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.
// Decls are pointers, so do not use a referene. | |
// Decls are pointers, so do not use a reference. |
name = std::get_if<parser::Name>(&procDes->u); | ||
// This shouldn't be a procedure component: this is the name of the | ||
// reduction being declared. | ||
assert(name && "ProcedureDesignator contained ProcComponentRef"); |
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.
Could you use the CHECK
macro?
This adds another puzzle piece for the support of OpenMP DECLARE REDUCTION functionality.
This adds support for operators with derived types, as well as declaring multiple different types with the same name or operator.
A new detail class for UserReductionDetials is introduced to hold the list of types supported for a given reduction declaration.
Tests for parsing and symbol generation added.
Declare reduction is still not supported to lowering, it will generate a "Not yet implemented" fatal error.