[mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops
authorLei Zhang <antiagainst@google.com>
Sun, 26 Jan 2020 16:10:29 +0000 (11:10 -0500)
committerLei Zhang <antiagainst@google.com>
Fri, 31 Jan 2020 14:37:04 +0000 (09:37 -0500)
commitdf71000d7d5df2eb310ba25ddbfd6ab33bef6c56
treeea6d501fd0f710d379a064e3173e2e7e4a7f5a41
parent0bb60e29f18bd45fc26d5f619150f28fc7541e9b
[mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

This commit adds a pattern to lower linalg.generic for reduction
to spv.GroupNonUniform* ops. Right now this only supports integer
reduction on 1-D input memref. Shader entry point ABI is queried
to make sure that the input memref's shape matches the local
workgroup's invocation configuration. This makes sure that the
workload fits in one local workgroup so that we can leverage
SPIR-V group non-uniform operations.

linglg.generic is a structured op that preserves the right level
of information. It is easier to recognize reduction at this level
than performing analysis on loops.

This commit also exposes `getElementPtr` in SPIRVLowering.h given
that it's a generally useful utility function.

Differential Revision: https://reviews.llvm.org/D73437
20 files changed:
mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h [new file with mode: 0644]
mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h [new file with mode: 0644]
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h
mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td
mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td
mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
mlir/lib/Conversion/CMakeLists.txt
mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt [new file with mode: 0644]
mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp [new file with mode: 0644]
mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp [new file with mode: 0644]
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/lib/Dialect/Linalg/Utils/Utils.cpp
mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir [new file with mode: 0644]
mlir/tools/mlir-opt/CMakeLists.txt