Let's continue to dissect compilers from nvidia. This time, I decided to examine compilers that are guaranteed to contain their custom MLIR dialects - tileiras and CuTe DSL
tileiras
As usual, their official repository is completely useless - it does not contain code for conversions/lowering so you can't build your own version of this compiler. So I used exactly the same techniques and scripts for its analysis from previous part
Strings from constructors - contain nothing of value
Passes shows 5 custom missed in vanilla llvm:
- nvptx-set-global-array-alignment (Find good alignment for statically sized global/shared arrays)
- nvptx-set-local-array-alignment (Find good alignment for statically sized alloca arrays)
- nvvm-peephole-optimizer (NVVM Peephole Optimizer)
- lower-aggr-copies (Lower Aggregate Copies)
- mergereturn (Unify function exit nodes)
As you can see this list differs from cicc and prompts some philosophical musings: just how many LLVM forks do they have, and are those dev-teams even aware of each other’s existence?
enumerate registered MLIR dialects
There is very good doc about MLIR capabilities from NPU compiler, however it does not contains answer to our question - how we can extract from LLVM binary all registered MLIR dialects
So I spent several days poking around megabytes of MLIR sources. It seems that perfect solution does not exist (due of heavy using of template black magic), but we can get practically good one - method MLIRContext::getOrLoadDialect:
- it can be identified by string "a dialect with namespace". Warning: there are another methods using this string like MLIRContext::getOrLoadDynamicDialect but fortunately they usually not linked with custom LLVM forks
- it's called from BytecodeDialect::load method and so we can catch all dialects allowed in input .bc files
So I wrote yet another dirty IDC script to extract MLIR dialects - total 30 unique
CuTe DSL
Official repository claims that you can build your own compiler with vanilla LLVM (I never verified if that is true). What they didn't said - in their python packages compiler based on their closed-source LLVM fork, in my case I dissected _cutlass_ir.cpython-313-x86_64-linux-gnu.so
First remarkable thing is its size - 144Mb, for example size of cicc is 78Mb and size of tileiras 89Mb. Highly unlikely that python bindings have size of ~60Mb, so lets check
strings from constructors
We could remark something very familiar - string like AddWaitForCCOrPOffDeck & co. Also section .rodata has huge blobs for "fermi macros", so we can conclude that it was linked with PTXAS
machineIR passes
+ 54 new passes, wow! Also it has 2767 nvvm intrinsics vs 1998 in plain LLVM
MLIR dialects
As you can see it contains 32, including our beloved cute & cute_nvgpu
Conclusion
It appears that CuTe DSL compiler based on the same LLVM fork as cicc and so produces fastest code, also it supports 32 MLIR dialects and scripting from python - just combo