Repository navigation
Mmt4d ukernel: Condition the lowering on the existence of an architecture-specific tile function. - #16880
Mmt4d ukernel: Condition the lowering on the existence of an architecture-specific tile function.#16880bjacob wants to merge 3 commits into
Conversation
01f0b27 to
726b960
Compare
726b960 to
0589a83
Compare
0d79812 to
89cb712
Compare
89cb712 to
03a6ef2
Compare
03a6ef2 to
1f2e9c0
Compare
Abbreviated Benchmark Summary@ commit 833bcfc18d390e5d3446607199d03d227b37a778 (vs. base aa72368e1c9803ea1bfc37aac984d08a4c274cb4) Data-Tiling Comparison TableClick to show
Regressed Latencies 🚩
Improved Latencies 🎉
[Top 3 out of 14 results showed] No improved or regressed compilation metrics 🏖️ For more information: |
This -650 lines shrink comes from introducing tables (the .inl files) where we declare the mmt4d tile functions. From that, we can generate not only the declarations but also the whole `select_tile_func` logic. While this PR stands on its own, there is a subtext here that in a subsequent PR (#16880) I'm going to argue --- against all common sense! --- for actually exporting these tables, as an interim solution to the problem discussed in #16848 until the better solutions outlined there can land. Don't want this to be a distraction on this PR as the tables are not being exported here, and they are justified by independent reasons here. That is entirely within the `arch/` subdir. The only other part of this PR outside of `arch` is a renaming: `mmt4d_tile.c` only contains the generic (fallback) tile functions, so made its name reflect that. I tried hard to also drop the whole CMake configure-checks and configured-headers and for `IREE_UK_BUILD...`, tried moving that back into the C files as checks of compiler versions, but ran again into the mystery about the CI jobs `build_test_all_windows` and `build_test_runtime_windows` having a very different MSVC behavior there despite being the exact same version, as noted earlier in #16637.
There was a problem hiding this comment.
Hmm this is not moving in a good direction IMO as it's adding magic arch values tied to ukernel code and including mmt4d-specific tables/behavior that makes it impossible to handle out-of-tree mmt4d ukernels with differing features, mmt4d ukernels for new architectures without patching the compiler, or non-mmt4d ukernels to the same fidelity.
If we're keeping the ukernels separate from the compiler (which I still think is valuable for all the original reasons we went that way) there's alternatives we should explore here instead. Functions can have arbitrary string annotations plumbed all the way from C, for example: https://bholt.org/posts/llvm-quick-tricks.html - we could use that and query the functions from the loaded bitcode instead of compiling in the table. We can also embed the selection logic by inverting it: a tile function declares what it works with (features, etc) in a structured fashion (either via function multi-versioning attributes like cpu_specific/target, or string annotations with +/-feature,..., whatever) and we just ask the LLVM target machine info instead of needing to hardcode things. Data types can also be included if needed and matched without awareness of the particular ukernel: declaring "operands 0,1,2 have data types f16,f16,f32" and matching that against op.getDps...() for each makes it work with arbitrary functions instead of just mmt4d as done in the pattern.
In other words: if we're going to have magic strings coupling the compiler and the ukernel library across the bitcode boundary we really need to think of those as an API/ABI instead of something we can just reach around for an mmt4d-specific thing. I think we have options there that allow us to have fallbacks for arbitrary ukernels instead of just mmt4d and still allow for out-of-tree bitcode to be produced without needing to modify the compiler. We must do this for non-mmt4d ukernels so adding something mmt4d-specific has a very high bar if we don't want to have to rewrite it all again or continue to not be able to use ukernels effectively for non-mmt4d operations.
Happy to hop on a call and brainstorm some ways we can do this!
|
Thanks for the explanation. Closing for now, keeping around in case we end up wanting to do something like this. |
Following the discussion in #16848, I would like to propose this instead of the approach pursued earlier in #15784, at least as an interim solution until the arguably better approaches outlined in #16848 can be implemented, not precluding getting there - see how the diff in this PR is fairly small and contained.
The approach that we had long pursued in #15784 would, if carried out today, result in losing the large compilation-time benefits of ukernels discussed in #16848. Two solutions for that have been discussed in #16848:
Neither of the above approaches is simultaneously close to being a complete solution and easy to implement in the short term. Both would incur complexity of their own. By contrast, the solution in the present PR is a well-contained +160 lines of code. I know it's not our first choice that it increases the contact surface of ukernels, but I still think it's the best trade-off for now.