[mlir] support reductions in SCF to OpenMP conversion
authorAlex Zinenko <zinenko@google.com>
Wed, 25 Aug 2021 09:07:17 +0000 (11:07 +0200)
committerAlex Zinenko <zinenko@google.com>
Thu, 9 Sep 2021 11:04:27 +0000 (13:04 +0200)
commit1ce752b7415bef59200c32f64fcfac795813b11e
treeabbe1886a8db7fe4913607559ee64a24a49eae99
parent8089f9ed5a86cd4e6551b215765beeeb2cc39ea3
[mlir] support reductions in SCF to OpenMP conversion

OpenMP reductions need a neutral element, so we match some known reduction
kinds (integer add/mul/or/and/xor, float add/mul, integer and float min/max) to
define the neutral element and the atomic version when possible to express
using atomicrmw (everything except float mul). The SCF-to-OpenMP pass becomes a
module pass because it now needs to introduce new symbols for reduction
declarations in the module.

Reviewed By: chelini

Differential Revision: https://reviews.llvm.org/D107549
mlir/include/mlir/Conversion/Passes.td
mlir/include/mlir/Conversion/SCFToOpenMP/SCFToOpenMP.h
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
mlir/lib/Conversion/SCFToOpenMP/CMakeLists.txt
mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
mlir/test/Conversion/SCFToOpenMP/reductions.mlir [new file with mode: 0644]
mlir/test/Conversion/SCFToOpenMP/scf-to-openmp.mlir
utils/bazel/llvm-project-overlay/mlir/BUILD.bazel