Repository navigation
[Codegen] Add pass to further tile large linalg ops - #19010
Conversation
6bec75b to
322a428
Compare
nirvedhmeshram
left a comment
There was a problem hiding this comment.
LGTM, with some minor nits.
hanhanW
left a comment
There was a problem hiding this comment.
Drive by: I don't really like the "solution" that I'm going to suggest, but at least it should make user experience better. There is an option in GenericVectorization that allows you to not vectorize a linalg op when the total elements are greater than the threshold. The performance would be bad for sure, but it does not create huge vectors.
iree/compiler/src/iree/compiler/Codegen/Common/Passes.td
Lines 336 to 338 in c651ba9
In certain cases/configurations we can end up with excessively large static `linalg.generic` ops that will then vectorize and emit code with huge vector sizes. This at a minimum will yield terrible code, and can even crash/hang LLVM when trying to compile such an enormous function. The implementation here only looks at parallel dims and linalg ops. Large reductions and other vectorizable ops will likely need handling as well, but "vectorizability" isn't really queryable today. The pass has an options for a maximum vector size to tile to, but the logic here could potentially use some future improvement (e.g. maybe expose a target vector size too to use when we choose to tile). Also note that in many cases where we hit this is likely to generate poor code because we can often end up with large local/stack allocations, but by the time we get to this point there isn't much else we can do. Better to ask for an allocation than 10k lines of unrolled IR.
322a428 to
2127c14
Compare
Hmmm that sounds like it's probably worth enabling as well. This pass should in theory also give us better vectorization of dynamic cases so I'm going to keep it for now. The example that this fixes is already encoded as a pipeline test anyway so we won't regress on the part that matters if we want to change it in the future. |
In certain cases/configurations we can end up with excessively large static `linalg.generic` ops that will then vectorize and emit code with huge vector sizes. This at a minimum will yield terrible code, and can even crash/hang LLVM when trying to compile such an enormous function. The implementation here only looks at parallel dims and linalg ops. Large reductions and other vectorizable ops will likely need handling as well, but "vectorizability" isn't really queryable today. The pass has an options for a maximum vector size to tile to, but the logic here could potentially use some future improvement (e.g. maybe expose a target vector size too to use when we choose to tile). Also note that in many cases where we hit this is likely to generate poor code because we can often end up with large local/stack allocations, but by the time we get to this point there isn't much else we can do. Better to ask for an allocation than 10k lines of unrolled IR.
In certain cases/configurations we can end up with excessively large static `linalg.generic` ops that will then vectorize and emit code with huge vector sizes. This at a minimum will yield terrible code, and can even crash/hang LLVM when trying to compile such an enormous function. The implementation here only looks at parallel dims and linalg ops. Large reductions and other vectorizable ops will likely need handling as well, but "vectorizability" isn't really queryable today. The pass has an options for a maximum vector size to tile to, but the logic here could potentially use some future improvement (e.g. maybe expose a target vector size too to use when we choose to tile). Also note that in many cases where we hit this is likely to generate poor code because we can often end up with large local/stack allocations, but by the time we get to this point there isn't much else we can do. Better to ask for an allocation than 10k lines of unrolled IR. Signed-off-by: Giacomo Serafini <[email protected]>
In certain cases/configurations we can end up with excessively large static
linalg.genericops that will then vectorize and emit code with huge vector sizes. This at a minimum will yield terrible code, and can even crash/hang LLVM when trying to compile such an enormous function.The implementation here only looks at parallel dims and linalg ops. Large reductions and other vectorizable ops will likely need handling as well, but "vectorizability" isn't really queryable today.
The pass has an options for a maximum vector size to tile to, but the logic here could potentially use some future improvement (e.g. maybe expose a target vector size too to use when we choose to tile).
Also note that in many cases where we hit this is likely to generate poor code because we can often end up with large local/stack allocations, but by the time we get to this point there isn't much else we can do. Better to ask for an allocation than 10k lines of unrolled IR.