-
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
Changes from all 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 |
---|---|---|
|
@@ -1548,7 +1548,16 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel( | |
BasicBlock *CommonExit = nullptr; | ||
SetVector<Value *> Inputs, Outputs, SinkingCands, HoistingCands; | ||
Extractor.findAllocas(CEAC, SinkingCands, HoistingCands, CommonExit); | ||
Extractor.findInputsOutputs(Inputs, Outputs, SinkingCands); | ||
|
||
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; | ||
}); | ||
Comment on lines
+1551
to
+1560
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. 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 Let me know if you disagree with the solution and/or have a better suggestion. |
||
|
||
LLVM_DEBUG(dbgs() << "Before privatization: " << *OuterFn << "\n"); | ||
|
||
|
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 doisa
in the code below, so doing aGV = dyn_cast_if_present
instead and follow that with agetValueType != 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.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.