Commit Graph

10049 Commits

Author SHA1 Message Date
Jeremy Furtek 33185e66f2 [mlir] Add ODS support for enum attributes with grouped bit cases
This diff modifies the tablegen specification and code generation for
BitEnumAttr attributes in MLIR Operation Definition Specification (ODS) files.
Specifically:

- there is a new tablegen class for "none" values (i.e. no bits set)
- single-bit enum cases are specified via bit index (i.e. [0, 31]) instead of
  the resulting enum integer value
- there is a new tablegen class to represent a "grouped" bitwise OR of other
  enum values

This diff is intended as an initial step towards improving "fastmath"
optimization support in MLIR, to allow more precise control of whether certain
floating point optimizations are applied in MLIR passes. "Fast" math options
for floating point MLIR operations would (following subsequent RFC and
discussion) be specified by using the improved enum bit support in this diff.
For example, a "fast" enum value would act as an alias for a group of other
cases (e.g. finite-math-only, no-signed-zeros, etc.), in a way that is similar
to support in C/C++ compilers (clang, gcc).

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D117029
2022-01-26 21:01:01 +00:00
River Riddle 632a4f8829 [mlir] Move std.generic_atomic_rmw to the memref dialect
This is part of splitting up the standard dialect. The move makes sense anyways,
given that the memref dialect already holds memref.atomic_rmw which is the non-region
sibling operation of std.generic_atomic_rmw (the relationship is even more clear given
they have nearly the same description % how they represent the inner computation).

Differential Revision: https://reviews.llvm.org/D118209
2022-01-26 11:52:01 -08:00
River Riddle 480cd4cb85 [mlir] Move the complex support of std.constant to a new complex.constant operation
This is part of splitting up the standard dialect.

Differential Revision: https://reviews.llvm.org/D118182
2022-01-26 11:52:00 -08:00
River Riddle b88a4d72d9 [mlir:GPU] Replace reference to LLVMFuncOp with FuncOpInterface
The GPU dialect currently contains an explicit reference to  LLVMFuncOp
during verification to handle the situation where the kernel has already been
converted. This commit changes that reference to instead use FunctionOpInterface,
which has two main benefits:

* It allows for removing an otherwise unnecessary dependency on the LLVM dialect
* It removes hardcoded assumptions about the lowering path and use of the GPU dialect

Differential Revision: https://reviews.llvm.org/D118172
2022-01-26 11:52:00 -08:00
Benjamin Kramer f15014ff54 Revert "Rename llvm::array_lengthof into llvm::size to match std::size from C++17"
This reverts commit ef82063207.

- It conflicts with the existing llvm::size in STLExtras, which will now
  never be called.
- Calling it without llvm:: breaks C++17 compat
2022-01-26 16:55:53 +01:00
serge-sans-paille ef82063207 Rename llvm::array_lengthof into llvm::size to match std::size from C++17
As a conquence move llvm::array_lengthof from STLExtras.h to
STLForwardCompat.h (which is included by STLExtras.h so no build
breakage expected).
2022-01-26 16:17:45 +01:00
Matthias Springer 268524238e [mlir][bufferization] Add an option to use memref types without layout maps
This is for compatibility with existing bufferization passes. Also clean up memref type generation a bit.

Differential Revision: https://reviews.llvm.org/D118243
2022-01-27 00:03:34 +09:00
Nicolas Vasilache e6ce2c0b8d [mlir][LLVM] Add support for operand_attrs to InlineAsmOp
This revision adds enough support to allow InlineAsmOp to work properly with indirect memory constraints "*m".
These require an explicit "elementtype" TypeAttr on the operands to pass LLVM verification and need to be provided.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D118006
2022-01-26 07:42:35 -05:00
Nicolas Vasilache 9b6c2ea302 [mlir][Linalg] Add GenericOp self-copy on buffers folding
Reviewed By: pifon2a

Differential Revision: https://reviews.llvm.org/D118116
2022-01-26 05:56:31 -05:00
Alexander Batashev e9b4239fef [mlir][openmp] Custom syntax for `omp.target` operation
Add a custom parser and printer for `omp.target` operation.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D117539
2022-01-26 10:26:19 +00:00
Matthias Springer 18778b8863 [mlir] Fix merging of delayed registrations during DialectRegistry::appendTo
The existing implementation called DenseMap::insert, which is a no-op if the map already contains an entry with the same key.

Differential Revision: https://reviews.llvm.org/D118165
2022-01-26 17:28:42 +09:00
Rob Suderman 7c984be21a [mlir] Propagate arith.index_cast past tensor.extract
If we are extracting it is more useful to push the index_cast past the
extraction. This increases the chance the tensor.extract can evaluated at
compile time.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D118204
2022-01-25 22:16:07 -08:00
Rob Suderman d81a3c51e7 [mlir] Fold tensor.reshape operations into tensor.from_elements.
There is not much of a benefit to reshape a from element vs reloading it.
Updated to progagate shape manipulations into the output type of
tensor.from_elements.

Reviewed By: NatashaKnk

Differential Revision: https://reviews.llvm.org/D118201
2022-01-25 15:54:57 -08:00
MaheshRavishankar f3ab0ccd00 [mlir][Linalg] Add couple of convenience methods to `LinalgInterface`.
Add methods to
- Get block argument that is tied with an opOperand
- Get the yield value that is tied with a output opOperand.

Differential Revision: https://reviews.llvm.org/D118085
2022-01-25 11:46:11 -08:00
MaheshRavishankar ea1ac183f4 [mlir][Linalg] Fix incorrect fusion with reshape ops by linearization.
Fusion of reshape ops by linearization incorrectly inverted the
indexing map before linearizing dimensions. This leads to incorrect
indexing maps used in the fused operation.

Differential Revision: https://reviews.llvm.org/D117908
2022-01-25 11:42:58 -08:00
MaheshRavishankar e5a315f57a [mlir][Linalg] Disallow ops with index semantics in `PushExpandingReshape`.
This pattern is not written to handle operations with `linalg.index`
operations in its body, i.e. operations that have index semantics.

Differential Revision: https://reviews.llvm.org/D117856
2022-01-25 10:37:30 -08:00
Benjamin Kramer 2c8a77ab21 [mlir] Move duplicated BufferizableOpInterface::kBufferLayoutAttrName defs to a single place 2022-01-25 15:20:30 +01:00
Matthias Springer d581c94d6b [mlir][linalg][bufferize] Support tensor.from_elements
This is mostly a copy of the existing tensor.from_elements bufferization. Once TensorInterfaceImpl.cpp is moved to the tensor dialect, the existing rewrite pattern can be deleted.

Differential Revision: https://reviews.llvm.org/D117775
2022-01-25 22:19:59 +09:00
Matthias Springer 71bbb78b8f [mlir][linalg][bufferize] Support tensor.generate
This is mostly a copy of the existing tensor.generate bufferization. Once TensorInterfaceImpl.cpp is moved to the tensor dialect, the existing rewrite pattern can be deleted.

Differential Revision: https://reviews.llvm.org/D117770
2022-01-25 22:19:22 +09:00
Matthias Springer 694df0f0a8 [mlir][linalg][bufferize] Fix build
This fixes a linker error related to ModuleBufferization.cpp.

Differential Revision: https://reviews.llvm.org/D118127
2022-01-25 21:59:23 +09:00
Chuanqi Xu dbbe010908 [MLIR] [AsyncToLLVM] Use llvm.coro.align intrinsic
Use llvm.coro.align to align coroutine frame properly.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D117978
2022-01-25 19:28:25 +08:00
Nikita Popov 22487280dc [NFC] Remove more uses of PointerType::getElementType() (NFC)
Replace more uses which I missed in the first pass with
Type::getPointerElementType().
2022-01-25 10:13:53 +01:00
Lorenzo Chelini bca2d85153 [MLIR][Interfaces] Silence -Wparentheses warning (NFC)
warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
2022-01-25 09:02:49 +01:00
River Riddle 881ff4e4eb [mlir] Remove unnecessary dependency on Tensor from MemRef 2022-01-24 22:59:01 -08:00
Shraiysh Vaishay 320dc8c4df [mlir][OpenMP] Added omp.atomic.capture operation
This patch supports the atomic construct (capture) following section 2.17.7 of OpenMP 5.0 standard. Also added tests for the same.

Reviewed By: peixin, kiranchandramohan

Differential Revision: https://reviews.llvm.org/D115851
2022-01-25 12:25:54 +05:30
River Riddle 633f5badbf [mlir] Add more missing dependencies after D118062
These used to be covered transitively, but now need to be explicit.
2022-01-24 22:12:03 -08:00
Uday Bondhugula 8676e10f74 [MLIR] Improve doc for -mlir-print-local-scope and unhide
This is a pretty important debugging option to stay hidden. Also,
improve its cmd-line description; the current description gives no hint
that this is the one to use to have locations printed inline.
Out-of-line locations are also unproductive to work with in many cases
where the locations are actually compact, which is also why this option
should be more visible.  This revision doesn't change the default on it
though.

Reviewed By: rriddle, jpienaar

Differential Revision: https://reviews.llvm.org/D117186
2022-01-25 11:13:48 +05:30
River Riddle e697b97148 [mlir] Add more missing dependencies after D118062
These used to be covered transitively, but now need to be explicit.
2022-01-24 21:36:31 -08:00
River Riddle b827b6340b [mlir] Add missing dependencies after D118062
These used to be covered transitively, but now need to be explicit.
2022-01-24 21:31:37 -08:00
River Riddle 61b81e0f49 [mlir:MLIRAffineUtils] Add missing dependency on MLIRAffineAnalysis
This was missed in a70aa7bb0d.
2022-01-24 21:23:39 -08:00
Mehdi Amini e51a20e166 Fix python test to register all passes before using "normalize-memrefs"
The pass moved from mlir.transforms to the Memref dialect.
2022-01-25 05:15:42 +00:00
River Riddle 63b8018468 [mlir:LoopLikeInterface] Add missing dependency on SideEffectInterfaces
This was missed when moveLoopInvariantCode was added.
2022-01-24 21:13:31 -08:00
River Riddle 65e7cd13bb [mlir] Remove a bunch of unnecessary dialect dependencies
A lot of dialects have dependencies that are unnecessary, either because of copy/paste
of files when creating things or some other means. This commit cleans up a bunch of
the simple ones:

* Copy/Paste or missed during refactoring
Most of the dependencies cleaned up here look like copy/paste errors when creating
new dialects/transformations, or because the dependency wasn't removed during a
refactoring (e.g. when splitting the standard dialect).

* Unnecessary hard coding of constant operations in matchers
There are a few instances where a dialect had a dependency because it
was hardcoding checks for constant operations instead of using the better m_Constant
approach.

Differential Revision: https://reviews.llvm.org/D118062
2022-01-24 19:25:53 -08:00
River Riddle 88c1df64bd [mlir:ArmSVE][NFC] Remove dead code and unnecessary dependencies
Differential Revision: https://reviews.llvm.org/D117981
2022-01-24 19:25:53 -08:00
River Riddle a70aa7bb0d [mlir:Transforms] Move out the remaining non-dialect independent transforms and utilities
This has been a major TODO for a very long time, and is necessary for establishing a proper
dialect-free dependency layering for the Transforms library. Code was moved to effectively
two main locations:

* Affine/
There was quite a bit of affine dialect related code in Transforms/ do to historical reasons
(of a time way into MLIR's past). The following headers were moved to:
Transforms/LoopFusionUtils.h -> Dialect/Affine/LoopFusionUtils.h
Transforms/LoopUtils.h -> Dialect/Affine/LoopUtils.h
Transforms/Utils.h -> Dialect/Affine/Utils.h

The following transforms were also moved:
AffineLoopFusion, AffinePipelineDataTransfer, LoopCoalescing

* SCF/
Only one SCF pass was in Transforms/ (likely accidentally placed here): ParallelLoopCollapsing
The SCF specific utilities in LoopUtils have been moved to SCF/Utils.h

* Misc:
mlir::moveLoopInvariantCode was also moved to LoopLikeInterface.h given
that it is a simple utility defined in terms of LoopLikeOpInterface.

Differential Revision: https://reviews.llvm.org/D117848
2022-01-24 19:25:53 -08:00
River Riddle 2e2c0738e8 [mlir:Transforms] Move NormalizeMemRefs to MemRef/Transforms/
Transforms/  should only contain transformations that are dialect-independent and
this pass interacts with MemRef operations (making it a better fit for living in that
dialect).

Differential Revision: https://reviews.llvm.org/D117841
2022-01-24 19:25:53 -08:00
River Riddle 0e9a4a3b65 [mlir] Move the Buffer related source files out of Transforms/
Transforms/ should only contain dialect-independent transformations,
and these files are a much better fit for the bufferization dialect anyways.

Differential Revision: https://reviews.llvm.org/D117839
2022-01-24 19:25:52 -08:00
harsh e01e4c9115 Fix bugs in GPUToNVVM lowering
The current lowering from GPU to NVVM does
not correctly handle the following cases when
lowering the gpu shuffle op.

1. When the active width is set to 32 (all lanes),
then the current approach computes (1 << 32) -1 which
results in poison values in the LLVM IR. We fix this by
defining the active mask as (-1) >> (32 - width).

2. In the case of shuffle up, the computation of the third
operand c has to be different from the other 3 modes due to
the op definition in the ISA reference.
(https://docs.nvidia.com/cuda/parallel-thread-execution/index.html)
Specifically, the predicate value is computed as j >= maxLane
for up and j <= maxLane for all other modes. We fix this by
computing maskAndClamp as 32 - width for this mode.

TEST: We modify the existing test and add more checks for the up mode.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D118086
2022-01-25 03:24:14 +00:00
Mehdi Amini ff8f7904d1 Remove null check after dereferencing the pointer (NFC)
Flagged by Coverity
2022-01-25 02:08:16 +00:00
Aart Bik 92c1c63dae [mlir][sparse] integration test for sparse output operation
Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D118079
2022-01-24 17:41:09 -08:00
Rob Suderman 3e746c6d9e [mlir] Add support for ExpM1 to GLSL/OpenCL SPIRV Backends
Adding a similar decomposition for exponential minus one to the SPIRV
backends along with the necessary tests.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D118081
2022-01-24 15:38:34 -08:00
Mogball 3628febcf8 [mlir] NFC control-flow sink cleanup 2022-01-24 23:34:42 +00:00
Mogball 572fa9642c [mlir] Add a ControlFlowSink pass.
Control-Flow Sink moves operations whose only uses are in conditionally-executed regions into those regions so that paths in which their results are not needed do not perform unnecessary computation.

Depends on D115087

Reviewed By: jpienaar, rriddle, bondhugula

Differential Revision: https://reviews.llvm.org/D115088
2022-01-24 23:08:34 +00:00
Arjun P 0e98fadc79 [MLIR][Presburger] use braces for single-line loop when inner if uses braces [NFC] 2022-01-25 04:18:20 +05:30
Arjun P c1562683ee [MLIR][Presburger] LinearTransform: rename multiplication functions to be more intuitive 2022-01-25 04:18:19 +05:30
Rahul Joshi adb6494660 [MLIR] Add generic walk support to OpState
- This allows calling the generic walkers on specific operation instances.

Differential Revision: https://reviews.llvm.org/D117949
2022-01-24 13:35:29 -08:00
gysit e494278cee [mlir][linalg] Add transpose support to hoist padding.
Add a transpose option to hoist padding to transpose the padded tensor before storing it into the packed tensor. The early transpose improves the memory access patterns of the actual compute kernel. The patch introduces a transpose right after the hoisted pad tensor and a second transpose inside the compute loop. The second transpose can either be fused into the compute operation or will canonicalize away when lowering to vector instructions.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D117893
2022-01-24 16:33:05 +00:00
Matthias Springer b00ee46b5e [mlir][bufferize][NFC] Implement BufferizableOpInterface on bufferization ops directly
No longer go through an external model. Also put BufferizableOpInterface into the same build target as the BufferizationDialect. This allows for some code reuse between BufferizationOps canonicalizers and BufferizableOpInterface implementations.

Differential Revision: https://reviews.llvm.org/D117987
2022-01-25 01:23:26 +09:00
Lorenzo Chelini 217570b03b [MLIR][OpenMP] Suppress -Wreturn-type warnings (NFC) 2022-01-24 16:50:56 +01:00
Matthias Springer c30d2893a4 [mlir][bufferize] Change insertion point for ToTensorOps
Both insertion points are valid. This is to make BufferizableOpInteface-based bufferization compatible with existing partial bufferization test cases. (So less changes are necessary to unit tests.)

Differential Revision: https://reviews.llvm.org/D117986
2022-01-25 00:43:04 +09:00