Repository navigation
[spirv] Migrate ConvertToGPUPass' invocation tiling logic - #5814
Conversation
|
Note that this depends on https://reviews.llvm.org/D102079, so it will fail tests right now. |
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Overall looks great. Just a few comments.
FYI, started the work on launch configurations here MaheshRavishankar@26144e2 . I am plumbing it through on the CPU side for now to see how it works with dynamic pass pipelines. Once it is stabilized we can adapt the SPIR-V/CUDA paths to use the same and unify all of them. We can chat about details offline. |
| // Remove trip-one loops created during cyclic loop distribution if we can | ||
| // prove the tiling was perfect. | ||
| RewritePatternSet canoncalizationPatterns(context); | ||
| populateAffineMinSCFCanonicalizationPattern(canoncalizationPatterns); |
There was a problem hiding this comment.
Ideally we should be able to use this pattern from core
AffineMinRangeCanonicalizationPattern instead that take the same range lambda. That would allow us to remove populateAffineMinSCFCanonicalizationPattern we have in MLIR eventually.
There was a problem hiding this comment.
Ah didn't know about that pattern.. I can take a look and do it later.
Awesome. I'll take a look and comment there. |
…ee-org#5814)" This reverts commit d7b3bb9 because it causes numeric issues on internal tests.
…ee-org#5814)" This reverts commit ff5a9ba.
This is another step towards cleaning up the SPIRVConvertToGPUPass after iree-org#5814. We still have sets of patterns in the pass, one for handling copying to workgroup memory, the other for tiling into global invocation IDs. These are relatively disjoint functionalities; both should be cleaned up in their own ways. So this commit is a prelimiary step towards that by shuffling code around to their proper places and properly naming stuff. This makes it clear for future dedicated improvements afterwards.
This is another step towards cleaning up the SPIRVConvertToGPUPass after iree-org#5814. We still have sets of patterns in the pass, one for handling copying to workgroup memory, the other for tiling into global invocation IDs. These are relatively disjoint functionalities; both should be cleaned up in their own ways. So this commit is a prelimiary step towards that by shuffling code around to their proper places and properly naming stuff. This makes it clear for future dedicated improvements afterwards in following up commits. The test for vectorized workgroup memory copy is disabled for now to make migration easier.
This is another step towards cleaning up the SPIRVConvertToGPUPass after iree-org#5814. We still have two sets of patterns in the pass, one for handling copying to workgroup memory, the other for tiling into global invocation IDs. These are relatively disjoint functionalities; both should be cleaned up in their own ways. So this commit is a prelimiary step towards that by shuffling code around to their proper places and properly naming stuff. This makes it clear for future dedicated improvements afterwards in following up commits. The test for vectorized workgroup memory copy is disabled for now to make migration easier.
This is another step towards cleaning up the SPIRVConvertToGPUPass after iree-org#5814. We still have two sets of patterns in the pass, one for handling copying to workgroup memory, the other for tiling into global invocation IDs. These are relatively disjoint functionalities; both should be cleaned up in their own ways. So this commit is a prelimiary step towards that by shuffling code around to their proper places and properly naming stuff. This makes it clear for future dedicated improvements afterwards in following up commits. This commit is NFC (just shuffling code around), except that the test for vectorized workgroup memory copy is disabled for now to make migration easier.
This is another step towards cleaning up the SPIRVConvertToGPUPass after iree-org#5814. We still have two sets of patterns in the pass, one for handling copying to workgroup memory, the other for tiling into global invocation IDs. These are relatively disjoint functionalities; both should be cleaned up in their own ways. So this commit is a prelimiary step towards that by shuffling code around to their proper places and properly naming stuff. This makes it clear for future dedicated improvements afterwards in following up commits. Along the way, this also cleans up the SPIRVVectorToGPU pass, which uses utilities from the SPIRVConvertToGPU pass. SPIRVVectorToGPUPass really just contains one pattern to handle copying to workgroup memory (with vectorization). So renaming it properly. Again, futher cleanup will be done in following up patches. This commit is NFC (just shuffling code around), except that the test for vectorized workgroup memory copy is disabled for now to make migration easier.
This is another step towards cleaning up the SPIRVConvertToGPUPass after #5814. We still have two sets of patterns in the pass, one for handling copying to workgroup memory, the other for tiling into global invocation IDs. These are relatively disjoint functionalities; both should be cleaned up in their own ways. So this commit is a prelimiary step towards that by shuffling code around to their proper places and properly naming stuff. This makes it clear for future dedicated improvements afterwards in following up commits. Along the way, this also cleans up the SPIRVVectorToGPU pass, which uses utilities from the SPIRVConvertToGPU pass. SPIRVVectorToGPUPass really just contains one pattern to handle copying to workgroup memory (with vectorization). So renaming it properly. Again, futher cleanup will be done in following up patches. This commit is NFC (just shuffling code around), except that the test for vectorized workgroup memory copy is disabled for now to make migration easier.
ConvertToGPUPassis a sink for lowering away all Linalg opsin the SPIR-V pipeline: it can distribute a Linalg op to both
global invocation IDs (if just having one-level distribution) or
local invocation IDs (if having two-level distribution).
This is mostly historical; now we have more proper layering
in the pipeline where we perform the first-level tiling and
distribution at flow level and the second/third level at
TileAndVectorizeInOneWorkgroupPass, the functionalityin
ConvertToGPUPassis overlapping with that, althoughin a complementary way: the tiling in the former pass does
not handle the cases where we cannot do imperfect tiling;
it requires perfectly tiled cases, as we are assuming number
of processors equal to number of iterations to avoid generating
scf.forloop from the start.ConvertToGPUPassis moregeneric and can handle all cases. This is all opaque and
complicated.
This commit relaxes the
TileAndVectorizeInOneWorkgroupPassto not assume the number of processors equal to the number
of iterations. Now we just tile and cyclically distribute using
scf.forloops. This causes issues for perfectly tiled casesas we need to canonicalize the
affine.minand one-tripscf.foraway to expose static sizes for further vectorization.That can be done by pulling in additional canonicalization
patterns.
Also in order to utilize
TileAndVectorizeInOneWorkgroupPassfor the second/third level tiling we need to have the corresponding
scheme in launch configuration for them. This commit also
adds the default second/third level tiling for all now supported
Linalg ops: no tiling on subgroup and tiling to 1 for invocations.
This at the same time helps to clean up a bunch of unwieldy
templated configurations for different ops..
Together, the above migrates the invocation tiling logic
in
ConvertToGPUPassto their proper places. This is thefirst step as reining in
ConvertToGPUPassand launchconfigurations.