Repository navigation
Disable LLVM's vectorizers by default - #9642
Conversation
Abbreviated x86_64 Benchmark Summary (experimental)@ commit 7e48ae6764051ba676d8698219baf0172a88d79a (vs. base 70503f2bd89e525482b24bf1cd8407eb6f769b06) Improved Latencies 🎉
[Top 3 out of 7 results showed] No improved or regressed compilation metrics 🏖️ For more information: |
big +1 for all this. I think relying on llvm vectorization hurt us in the past. I wonder if there is any benchmark we really don't want to regress we may want to look at. The only I'm thinking about is probably miniLM tracked by Nod team (cc @powderluv) but I think they can enable llvm vectorization on their side if there is a regression and they don't want to disturb their production flow. |
|
I approved but it would be good to have others weight in on this before merging it. |
|
If there is a regression, I would rather leave it on. |
|
+1, compiler auto vectorization was worth trying circa 2005 :-) |
interestingly there seem to be more improvements than regressions |
|
Yes, we won't be moving this PR forward unless everybody is ok with it and there are no relevant regressions. @powderluv, could you please give this a try and let us know? If there are major regressions we should at least identify where the gap is on our side and add it to our roadmap. On the unrolling side, things look worse (#9658) and, IMO, having LLVM unrolling enabled by default is much more misleading/problematic. If we can't disable it by default, you should seriously consider disabling it when running a search. |
|
It looks like there are no regressions for our tracking models. The flag was turned on by default long time ago. At that point, we haven't invested much effort on vectorization. It's good to see that we've improved the vectorization and we can disable the flag by default. It's easier to apply optimization ourselves and make sure LLVM doesn't break it. I'd suggest to disable them by default, and keep the flag for future evaluation/development. The MiniLM Bert on x86 side is tracking on our dashboard, and it looks good. Nod folks can control the flag on their side. If there are mismatch between the flags, we should investigate the reason and file issues for tracking them. |
It's not surprising that disabling unrolling causes more problem as we haven't been doing much unrolling for ops others than GEMM. I do agree that relying on heuristic outside of IREE makes things very hard to tune so I think having it off by default makes our job simpler but I can see how it is a harder problem than auto-vectorization. |
|
Unrolling is another interesting topic. IIRC, the flag was asked to be on by default for performance. We haven't prototyped loop/vector unrolling much at MLIR level in IREE, so I'm not surprised that there are regressions. |
|
|
I think everybody would like to get rid of using LLVM for vectorization and unrolling. There is a cost though associated with it. I think at this stage we might be relying on LLVM auto-vectorization only for pathological cases. So it shouldnt make a difference today w.r.t to performance whether we use it or not. So then not using makes sense. |
|
+1 Mahesh! We also haven't been looking at binary sizes enough - when not targeting HPC spending 400KB on a single dispatch isn't really a thing - unrolling the entire problem with an LLVM flag may let us punt on the hard solution but we're only punting it to ourselves: we also need to target non-HPC uses :) |
|
+1! Thanks for all the feedback and interesting discussion! I think we all agree on the direction. Disabling unrolling would require much more work so... let's take one step at a time :) |
|
Awesome! Glad to see that we are putting more stuff into our own control with less surprises! On the SPIR-V side we are forced to do that given no existing LLVM functionalities to reuse and we are required to fix lots of cases in MLIR's vector transforms while LLVM side things just seem to work. It is certainly much better now and stressing it further from LLVM side would be even nicer! |
|
So... should we give this a try and see what happens? Worst case, we will have to revert but we'll have some specific models to look into and analyze what is missing on our side. |
Based on the response I think we have a consensus that turning off auto-vectorization is the way to go right now |
|
I think everyone approved it :) |
Abbreviated Linux Benchmark Summary@ commit 957ae7d2bf336263c8f8f7dd6475047f1828fe9d (vs. base b16530057e05fb51d23a9a96946b46eb6eb83414) Improved Latencies 🎉
[Top 3 out of 9 results showed] Improved Compilation Times 🎉
[Top 3 out of 26 results showed] Improved Total Dispatch Sizes 🎉
[Top 3 out of 22 results showed] For more information: |
This PR disables both LLVM’s loop and SLP vectorizers from our pipeline by default. We can still enable them on demand with flags
iree-llvm-loop-vectorizationandiree-llvm-slp-vectorization. Relying on LLVM vectorization (and unrolling) is dangerous since we may inadvertently reach wrong conclusions when evaluating the performance of new tiling/vectorization/unrolling features/configurations. For example, we might enable new vectorization features in MLIR to target non-vectorized code and observe no performance change or even a regression because the target code was being vectorized/unrolled by LLVM. We can enable it back if we observe significant regressions but our current benchmarks don't seem to point to that.