-
Notifications
You must be signed in to change notification settings - Fork 96
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
[WIP][CIR] Single-source C++ lowering with ClangIR MLIR CIR #1913
Draft
keryell
wants to merge
72
commits into
Xilinx:main
Choose a base branch
from
keryell:clangir
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Extend conflicting --mlir-to-llvmir option.
This avoids choking on some remaining CIR attributes like: Unable to parse module assembly: error: "-":1:101: #"cir"<"lang<cxx>"> : 'none' attribute created with unregistered dialect. If this is intended, please call allowUnregisteredDialects() on the MLIRContext, or use -allow-unregistered-dialect with the MLIR opt tool used This is simpler than adding the CIR dialect itself to the Python infrastructure which is quite complex.
Allow aie.device to appear anywhere.
For example to allow simpler transformations in a single-source framework.
Start the new CIR infrastructure in some separate CIR directories for a cleaner organization.
It is unclear how to pass information to a Pattern::matchAndRewrite.
Clean up some code too.
Add a "aie.device" attribute with the device name to make things clearer.
To do: integrate this into CMake infrastructure.
Also simplify some type names by removing some `_t`.
Also updated to new types in aie++.hpp header. Generate things like: %2 = builtin.unrealized_conversion_cast %1 : !cir.ptr<!ty_aie3A3Adevice3Caie3A3Anpu13E> to !cir.ptr<!ty_aie3A3Atile3C12C_43E> {"aie::tile" = ["1", "4"]}
For now only --cir-to-aie-prepare does something.
Generate also aie.tile and WIP hard-coded aie.buffer.
The problem was that at some point, the lowering was iterating along some mlir::Operation::getUsers() which were not in C++ program order, breaking some inter-operation dependencies. So now just use a single top-level walk<mlir::WalkOrder::PreOrder>. Just lower to the aie.device operations for now.
For example use aie-opt --debug-only=cir-to-aie --cir-to-aie ... to print the debug messages with a Debug build.
Improve also analysis and debug output.
During operation cloning, mlir::IRMapping is used to remap some leaf input operands but cannot remap some internal ones. In some case, ClangIR lower some lambda captures with aie::tile or with aie::device (). Having the aie::device is problematic since it is remapped to the aie.device output which leads to 2 issues for the verifyer: - this use is inside the device operation itself - the aie.device region is isolated from above. Since this aie::device is used only by an aie::tile, just remove the aie::device part.
Follow up the change made up-stream with llvm/clangir#1084
Previously, the mapping from an aie++ type to its lowered AIE operation was constructed lazily during the lowering itself, preventing another pass running later to have access to its information. Now CIRToAIETypesAnalysis can reconstruct this mapping if the lowering has already been done.
For now only inline the first call of the call chain.. Require a specific version of ClangIR to cope with inlining and the fact that CIR functions returning !cir.void do not actually return anything.
Optimize out the lambda capture leftover in aie.core.
Disable this option for now to keep the old behavior without any ClangIR MLIR C++ front-end feature.
Returning a handle was too disruptive to the MLIR AIE unit tests. Controlling a specific aie.device by the runtime can be done later without using the result as a handler.
All the AIE operations which are created have now a "cir.type" type attribute for any later introspection.
Take into account Xilinx#1936
This relies on llvm/clangir#1203 and llvm/clangir#1164 |
Now there is no type at all instead of a problematic !cir.void.
Improve also documentation and type-safety.
Extract the aie.device operation as the top-module operation. Anything else is removed. For now just keep the first aie.device.
The CIR lowering passes are aware of AIE dialects when going to LLVM dialect or MLIR standard dialects from aie-opt or aie-translate. Also expose the --cir-to-llvm pass to aie-opt.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a huge WIP for now and far from review.
It requires a specific branch of ClangIR instead of the usual Clang/LLVM/MLIR and it is not clear how to have this in current CI.