llvm-project
575d6892 - [mlir][acc] Introduce acc loop tiling pass (#171692)

Commit
29 days ago
[mlir][acc] Introduce acc loop tiling pass (#171692) This pass implements the OpenACC loop tiling transformation for acc.loop operations that have the tile clause (OpenACC 3.4 spec, section 2.9.8). The tile clause specifies that the iterations of the associated loops should be divided into tiles (rectangular blocks). The pass transforms a single or nested acc.loop with tile clauses into a structure of "tile loops" (iterating over tiles) containing "element loops" (iterating within tiles). For example, tiling a 2-level nested loop with tile(T1, T2): ``` // Before tiling: acc.loop tile(T1, T2) control(%i, %j) = ... // After tiling: acc.loop control(%i) step (s1*T1) { // tile loop 1 acc.loop control(%j) step (s2*T2) { // tile loop 2 acc.loop control(%ii) = (%i) to (min(ub1, %i+s1*T1)) { acc.loop control(%jj) = (%j) to (min(ub2, %j+s2*T2)) { // loop body using %ii, %jj } } } } ``` Key features: - Handles constant tile sizes and wildcard tile sizes ('*') which use a configurable default tile size - Properly handles collapsed loops with tile counts exceeding collapse count by uncollapsing loops before tiling - Distributes gang/worker/vector attributes appropriately: gang -> tile loops, vector -> element loops - Validates that tile size types are not wider than loop IV types - Emits optimization remarks for tiling decisions Three test files are added: - acc-loop-tiling.mlir: Tests single and nested loop tiling with constant tile sizes, unknown tile sizes (*), and loops with collapse attributes - acc-loop-tiling-invalid.mlir: Tests error diagnostic when tile size type is wider than the loop IV type - acc-loop-tiling-remarks.mlir: Tests optimization remarks emitted for tiling decisions including default tile size selection Co-authored-by: Vijay Kandiah <vkandiah@nvidia.com>
Parents
Loading