-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][OpenMP] Handle privatization for global values in MLIR->LLVM translation #104407
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
Conversation
@llvm/pr-subscribers-flang-openmp @llvm/pr-subscribers-mlir Author: Kareem Ergawy (ergawy) ChangesFix for #102939. The issues occurs because the CodeExtractor component only collect inputs This commit attempts to fix the issue by adding a flag to the Full diff: https://github.com/llvm/llvm-project/pull/104407.diff 6 Files Affected:
|
@llvm/pr-subscribers-flang-fir-hlfir Author: Kareem Ergawy (ergawy) ChangesFix for #102939. The issues occurs because the CodeExtractor component only collect inputs This commit attempts to fix the issue by adding a flag to the Full diff: https://github.com/llvm/llvm-project/pull/104407.diff 6 Files Affected:
|
5d93023
to
0dd676f
Compare
|
||
Extractor.findInputsOutputs(Inputs, Outputs, SinkingCands, | ||
/*CollectGlobalInputs=*/true); | ||
|
||
Inputs.remove_if([&](Value *I) { | ||
if (auto *GV = dyn_cast_if_present<GlobalVariable>(I)) | ||
return GV->getValueType() == OpenMPIRBuilder::Ident; | ||
|
||
return false; | ||
}); |
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.
Tbh, I do not know if this is cleanest or best approach to solve this issue. To get a better understanding of the problem, please take a look at the new test added in openmp-firstprivate.mlir
below as well as the 2 linked issues: #102939 and #102949.
Let me know if you disagree with the solution and/or have a better suggestion.
Extractor.findInputsOutputs(Inputs, Outputs, SinkingCands, | ||
/*CollectGlobalInputs=*/true); | ||
|
||
Inputs.remove_if([&](Value *I) { |
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.
Would it not be better to NOT add the global value in the first place, if it's an OpenMPIRBuilder::Ident
? You already do isa
in the code below, so doing a GV = dyn_cast_if_present
instead and follow that with a getValueType != OpenMPIRBuilder::Ident
?
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 problem with that is:
OpenMPIRBuilder::Ident
are created and maintained by the functions of theOpenMPIRBuilder
. So I think it would be preferable to keep the knowledge of these structs within the builder.- The
CodeExtractor
is not OpenMP-related and I think it would better not to leak any non-related OpenMP-details to it.
Of course it is better not to add something and then remove it. But I think it logically isolates things better this way.
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.
@Leporacanthicus is it fine with you merging this PR? Let me know if you do not agree with my reply above.
2ce7998
to
16f2d26
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.
LGTM. Thanks for the fix!
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.
Thank you Kareem, LGTM.
…ranslation Fix for llvm#102939. The issues occurs because the CodeExtractor component only collect inputs (to the parallel regions) that are defined in the same function in which the parallel regions is present. Howerver, this is problematic because if we are privatizing a global value (e.g. a `target` variable which is emitted as a global), then we miss finding that input and we do not privatize the variable. This commit attempts to fix the issue by adding a flag to the CodeExtractor so that we can collect global inputs.
16f2d26
to
66c94ea
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/179/builds/4972 Here is the relevant piece of the build log for the reference
|
Potential fix for #102939 and #102949.
The issues occurs because the CodeExtractor component only collect inputs (to the parallel regions) that are defined in the same function in which the parallel regions is present. Howerver, this is problematic because if we are privatizing a global value (e.g. a
target
variable which is emitted as a global), then we miss finding that input and we do not privatize the variable.This commit attempts to fix the issue by adding a flag to the CodeExtractor so that we can collect global inputs.