[mlir][GPU] introduce utilities for promotion to workgroup memory
authorAlex Zinenko <zinenko@google.com>
Tue, 7 Jan 2020 19:00:54 +0000 (20:00 +0100)
committerAlex Zinenko <zinenko@google.com>
Thu, 9 Jan 2020 09:06:00 +0000 (10:06 +0100)
commit08778d8c4fd8a6519c7f27bfa6b09c47262cb844
tree195cfbe336a349d0406283006228c0f8ed4e4cbb
parente93e0d413f3afa1df5c5f88df546bebcd1183155
[mlir][GPU] introduce utilities for promotion to workgroup memory

Introduce a set of function that promote a memref argument of a `gpu.func` to
workgroup memory using memory attribution. The promotion boils down to
additional loops performing the copy from the original argument to the
attributed memory in the beginning of the function, and back at the end of the
function using all available threads. The loop bounds are specified so as to
adapt to any size of the workgroup. These utilities are intended to compose
with other existing utilities (loop coalescing and tiling) in cases where the
distribution of work across threads is uneven, e.g. copying a 2D memref with
only the threads along the "x" dimension. Similarly, specialization of the
kernel to specific launch sizes should be implemented as a separate pass
combining constant propagation and canonicalization.

Introduce a simple attribute-driven pass to test the promotion transformation
since we don't have a heuristic at the moment.

Differential revision: https://reviews.llvm.org/D71904
mlir/include/mlir/Dialect/GPU/GPUDialect.h
mlir/include/mlir/Dialect/GPU/GPUOps.td
mlir/include/mlir/Dialect/GPU/MemoryPromotion.h [new file with mode: 0644]
mlir/include/mlir/IR/Block.h
mlir/lib/Dialect/GPU/CMakeLists.txt
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/lib/Dialect/GPU/Transforms/MemoryPromotion.cpp [new file with mode: 0644]
mlir/lib/IR/Block.cpp
mlir/test/Dialect/GPU/promotion.mlir [new file with mode: 0644]
mlir/test/lib/Transforms/CMakeLists.txt
mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp [new file with mode: 0644]