This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Disentangle dialect and extension registrations.
ClosedPublic

Authored by fmorac on Aug 11 2023, 4:22 AM.

Details

Summary

This revision avoids the registration of dialect extensions in Pass::getDependentDialects.

Such registration of extensions can be dangerous because DialectRegistry::isSubsetOf is
always guaranteed to return false for extensions (i.e. there is no mechanism to track
whether a lambda is already in the list of already registered extensions).
When the context is already in a multi-threaded mode, this is guaranteed to assert.

Arguably a more structured registration mechanism for extensions with a unique ExtensionID
could be envisioned in the future.

In the process of cleaning this up, multiple usage inconsistencies surfaced around the
registration of translation extensions that this revision also cleans up.

Diff Detail

Event Timeline

Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
nicolasvasilache requested review of this revision.Aug 11 2023, 4:22 AM

Delete commented out code.

Note: I will be out for 2 weeks starting EoD, I would appreciate if this could be commandeered and ideally landed if possible.

Overall LGTM. My only concern is down-stream users having issues and don't knowing what's happening, because when those registration calls are removed from passes like gpu-to-cubin, they will fail.

But since we already request users to do most registration calls themselves, I think that a general warning in the page Deprecations & Current Refactoring might be enough, while a better registration mechanism is developed.

If no one has any other comments by Tuesday, I can approve & land it on your behalf.

fmorac commandeered this revision.Aug 15 2023, 8:46 AM
fmorac edited reviewers, added: nicolasvasilache; removed: fmorac.
fmorac updated this revision to Diff 550353.Aug 15 2023, 8:56 AM

Updated the diff to resolve all the conflicts and additions created by pushing all the commits of the new GPU pipeline.

My only mild concern now is having to add these:

registerNVVMTargetInterfaceExtension(registry);
registerROCDLTargetInterfaceExtension(registry);

To both InitAllExtensions.h & Target/LLVMIR/Dialect/All.h. This is needed because the promise mechanism crashes mlir-translate if the interfaces are not registered.

I think they need to be removed from Target/LLVMIR/Dialect/All.h, either by changing the promise mechanism, registering those interfaces on mlir-translate or removing the promises made by those extensions.

springerm accepted this revision.Aug 21 2023, 6:58 AM
springerm added inline comments.
mlir/include/mlir/InitAllExtensions.h
83–84

These look like external models. Can we register them in registerAllDialects together with the other external models?

This revision is now accepted and ready to land.Aug 21 2023, 6:58 AM
fmorac updated this revision to Diff 552048.Aug 21 2023, 9:16 AM

Addressed comments.

fmorac marked an inline comment as done.Aug 21 2023, 9:17 AM
fmorac added inline comments.
mlir/include/mlir/InitAllExtensions.h
83–84

They are, I've just moved them.

mehdi_amini added inline comments.Aug 21 2023, 1:49 PM
mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp
128–129

I don't get what calling the parent class getDependentDialects achieves here?

129

Why are these needed? Would the pass create GPU dialect constructs out of the blue?

fmorac marked an inline comment as done.Aug 21 2023, 2:08 PM
fmorac added inline comments.
mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp
128–129

Honestly me neither but this was already there, I'll remove it.

129

These are definitely not needed here as the register*DialectTranslation functions will also register the dialects, and the pass won't work without calling the registration functions. I'll remove them.

fmorac updated this revision to Diff 552156.Aug 21 2023, 3:49 PM
fmorac marked 2 inline comments as done.

Addressed comments.

This revision was automatically updated to reflect the committed changes.