-
Notifications
You must be signed in to change notification settings - Fork 94
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
python pass registration #710
Conversation
3051584
to
c31854a
Compare
678214a
to
17fea38
Compare
c736e9c
to
342b598
Compare
I don't think there's a real problem compiling with RTTI: It just adds overhead that LLVM is mostly designed to avoid. IIRC there might also be some other c++ python interop problems, I seem to remember discussing with Stella at one point. |
342b598
to
ca628bb
Compare
I was under the same impression but after chatting with @stellaraccident offline about this, I think the consensus is it's best to avoid it if not needed. Well good news! Turns out you can indeed avoid it - the current version puts the pass behind a "blood-brain" barrier (just a separate TU with a pure Python C API interface) and compiles the object file with |
d91855d
to
232cbe9
Compare
Just don't cross the streams. Commingling c++ code compiled with and without it for the same types is a recipe for bad things. I doubt you'll get support for running rtti builds upstream to test. Ditto in iree. |
0d06871
to
d4cfee8
Compare
614d9f5
to
11b98d7
Compare
@AndraBisca @fifield I would like to merge this. Can you please take a look because you both are working on the bindings and tell me if there's anything you don't understand. Additionally, I have tested this locally (on Mac and Linux, the latter with with chess) but not Windows nor with Peano. If either of you could test locally to double check that would be helpful. |
200b0dc
to
8d4f183
Compare
8d4f183
to
954b627
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.
This looks really good! Thank you for all the helpful comments you added in the files as well!
289ee49
to
f59cfc5
Compare
f59cfc5
to
8ed3f7b
Compare
"../../lib/libmlir_runner_utils.so", | ||
"../../lib/libmlir_c_runner_utils.so", | ||
] |
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 guess this makes some assumptions about directory layout that I don't follow since I get a failure here. Is it possible to get cmake or something else to fill in the path?
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.
that directory is CMAKE_BIN/lib
but but you need to build LLVM/MLIR with the execution engine enabled for them to be copied to that location
mlir-aie/python/CMakeLists.txt
Line 236 in 8ed3f7b
${CMAKE_BINARY_DIR}/lib |
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 can gate this test by availability of the execution engine.
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.
Also it's possible if you built without DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON
then the .so
got version and the script doesn't pick it up (fixed in #771).
This PR implements routing/path-finding using ILP (using Gurobi/or-tools) through the python pass registration mechanism landed in #710.
This PR demonstrates linking C++ directly to the python bindings (without going through the C API).
In fact it demonstrates something more exciting: tunneling python callbacks all the way into MLIR passes:
This will print
by calling
print_ops
from inside the pass (where there's athis->getOperation()->walk([this](Operation *op) { func(wrap(op)); });
).The only thing that needs to be changed for this to work is to build MLIR with RTTI. This sounds scary (maybe?) but it doesn't seem to matter at all (my wheels are built and tested with RTTI now for months...).
In the future (very soon) this pass will do more than just demonstrate the capability (at which point it will be renamed appropriately).
Note, this is stacked on top of #711 so be sure to exclude the first commit from the diff view.