[all-commits] [llvm/llvm-project] 6663f3: [mlir] Introduce device mapper attribute for `thre...

Guray Ozen via All-commits all-commits at lists.llvm.org
Thu Nov 10 23:45:11 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6663f3470417523141ee87923840d17b35d6b4c7
      https://github.com/llvm/llvm-project/commit/6663f3470417523141ee87923840d17b35d6b4c7
  Author: Guray Ozen <guray.ozen at gmail.com>
  Date:   2022-11-11 (Fri, 11 Nov 2022)

  Changed paths:
    M mlir/include/mlir/Dialect/GPU/IR/GPUDialect.h
    M mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
    M mlir/include/mlir/Dialect/GPU/TransformOps/CMakeLists.txt
    A mlir/include/mlir/Dialect/GPU/TransformOps/GPUDeviceMappingAttr.td
    M mlir/include/mlir/Dialect/GPU/TransformOps/GPUTransformOps.td
    M mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.h
    M mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
    M mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
    M mlir/include/mlir/Dialect/SCF/IR/CMakeLists.txt
    A mlir/include/mlir/Dialect/SCF/IR/DeviceMappingInterface.h
    A mlir/include/mlir/Dialect/SCF/IR/DeviceMappingInterface.td
    M mlir/include/mlir/Dialect/SCF/IR/SCF.h
    M mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
    M mlir/lib/Dialect/GPU/TransformOps/CMakeLists.txt
    M mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
    M mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
    M mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
    M mlir/lib/Dialect/SCF/IR/CMakeLists.txt
    A mlir/lib/Dialect/SCF/IR/DeviceMappingInterface.cpp
    M mlir/lib/Dialect/SCF/IR/SCF.cpp
    M mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/test/Dialect/GPU/transform-gpu-failing.mlir
    M mlir/test/Dialect/GPU/transform-gpu.mlir
    M mlir/test/Dialect/Linalg/tile-to-foreach-thread.mlir
    M mlir/test/Dialect/SCF/one-shot-bufferize-analysis.mlir
    M mlir/test/Dialect/SCF/one-shot-bufferize-tensor-copy-insertion.mlir
    M mlir/test/Dialect/SCF/ops.mlir
    M mlir/test/lib/Dialect/Tensor/TestTensorTransforms.cpp
    M utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

  Log Message:
  -----------
  [mlir] Introduce device mapper attribute for `thread_dim_map` and `mapped to dims`

`scf.foreach_thread` defines mapping its loops to processors via an integer array, see an example below. A lowering can use this mapping. However, expressing mapping as an integer array is very confusing, especially when there are multiple levels of parallelism. In addition, the op does not verify the integer array. This change introduces device mapping attribute to make mapping descriptive and verifiable. Then it makes GPU transform dialect use it.

```
scf.foreach_thread (%i, %j) in (%c1, %c2) {
	scf.foreach_thread (%i2, %j2) in (%c1, %c2)
	{...} { thread_dim_mapping = [0, 1]}
} { thread_dim_mapping = [0, 1]}
```

It first introduces a `DeviceMappingInterface` which is an attribute interface. `scf.foreach_thread` defines its mapping via this interface. A lowering must define its attributes and implement this interface as well. This way gives us a clear validation.

The change also introduces two new attributes (`#gpu.thread<x/y/z>` and `#gpu.block<x,y,z>` ). After this change, the above code prints as below, as seen here, this way clarifies the loop mappings. The change also implements consuming of these two new attribute by the transform dialect. Transform dialect binds the outermost loops to the thread blocks and innermost loops to threads.

```
scf.foreach_thread (%i, %j) in (%c1, %c2) {
	scf.foreach_thread (%i2, %j2) in (%c1, %c2)
	{...} { thread_dim_mapping = [#gpu.thread<x>, #gpu.thread<y>]}
} { thread_dim_mapping = [#gpu.block<x>, #gpu.block<y>]}
```

Reviewed By: ftynse, nicolasvasilache

Differential Revision: https://reviews.llvm.org/D137413




More information about the All-commits mailing list