#
fcb1591b |
| 13-Dec-2024 |
Kazu Hirata <kazu@google.com> |
[IR] Migrate away from PointerUnion::{is,get} (NFC) (#119802)
Note that PointerUnion::{is,get} have been soft deprecated in
PointerUnion.h:
// FIXME: Replace the uses of is(), get() and dyn_ca
[IR] Migrate away from PointerUnion::{is,get} (NFC) (#119802)
Note that PointerUnion::{is,get} have been soft deprecated in
PointerUnion.h:
// FIXME: Replace the uses of is(), get() and dyn_cast() with
// isa<T>, cast<T> and the llvm::dyn_cast<T>
I'm not touching PointerUnion::dyn_cast for now because it's a bit
complicated; we could blindly migrate it to dyn_cast_if_present, but
we should probably use dyn_cast when the operand is known to be
non-null.
show more ...
|
#
ea84897b |
| 16-Nov-2023 |
Guray Ozen <guray.ozen@gmail.com> |
[mlir][gpu] Introduce `gpu.dynamic_shared_memory` Op (#71546)
While the `gpu.launch` Op allows setting the size via the
`dynamic_shared_memory_size` argument, accessing the dynamic shared
memory i
[mlir][gpu] Introduce `gpu.dynamic_shared_memory` Op (#71546)
While the `gpu.launch` Op allows setting the size via the
`dynamic_shared_memory_size` argument, accessing the dynamic shared
memory is very convoluted. This PR implements the proposed Op,
`gpu.dynamic_shared_memory` that aims to simplify the utilization of
dynamic shared memory.
RFC:
https://discourse.llvm.org/t/rfc-simplifying-dynamic-shared-memory-access-in-gpu/
**Proposal from RFC**
This PR `gpu.dynamic.shared.memory` Op to use dynamic shared memory
feature efficiently. It is is a powerful feature that enables the
allocation of shared memory at runtime with the kernel launch on the
host. Afterwards, the memory can be accessed directly from the device. I
believe similar story exists for AMDGPU.
**Current way Using Dynamic Shared Memory with MLIR**
Let me illustrate the challenges of using dynamic shared memory in MLIR
with an example below. The process involves several steps:
- memref.global 0-sized array LLVM's NVPTX backend expects
- dynamic_shared_memory_size Set the size of dynamic shared memory
- memref.get_global Access the global symbol
- reinterpret_cast and subview Many OPs for pointer arithmetic
```
// Step 1. Create 0-sized global symbol. Manually set the alignment
memref.global "private" @dynamicShmem : memref<0xf16, 3> { alignment = 16 }
func.func @main() {
// Step 2. Allocate shared memory
gpu.launch blocks(...) threads(...)
dynamic_shared_memory_size %c10000 {
// Step 3. Access the global object
%shmem = memref.get_global @dynamicShmem : memref<0xf16, 3>
// Step 4. A sequence of `memref.reinterpret_cast` and `memref.subview` operations.
%4 = memref.reinterpret_cast %shmem to offset: [0], sizes: [14, 64, 128], strides: [8192,128,1] : memref<0xf16, 3> to memref<14x64x128xf16,3>
%5 = memref.subview %4[7, 0, 0][7, 64, 128][1,1,1] : memref<14x64x128xf16,3> to memref<7x64x128xf16, strided<[8192, 128, 1], offset: 57344>, 3>
%6 = memref.subview %5[2, 0, 0][1, 64, 128][1,1,1] : memref<7x64x128xf16, strided<[8192, 128, 1], offset: 57344>, 3> to memref<64x128xf16, strided<[128, 1], offset: 73728>, 3>
%7 = memref.subview %6[0, 0][64, 64][1,1] : memref<64x128xf16, strided<[128, 1], offset: 73728>, 3> to memref<64x64xf16, strided<[128, 1], offset: 73728>, 3>
%8 = memref.subview %6[32, 0][64, 64][1,1] : memref<64x128xf16, strided<[128, 1], offset: 73728>, 3> to memref<64x64xf16, strided<[128, 1], offset: 77824>, 3>
// Step.5 Use
"test.use.shared.memory"(%7) : (memref<64x64xf16, strided<[128, 1], offset: 73728>, 3>) -> (index)
"test.use.shared.memory"(%8) : (memref<64x64xf16, strided<[128, 1], offset: 77824>, 3>) -> (index)
gpu.terminator
}
```
Let’s write the program above with that:
```
func.func @main() {
gpu.launch blocks(...) threads(...) dynamic_shared_memory_size %c10000 {
%i = arith.constant 18 : index
// Step 1: Obtain shared memory directly
%shmem = gpu.dynamic_shared_memory : memref<?xi8, 3>
%c147456 = arith.constant 147456 : index
%c155648 = arith.constant 155648 : index
%7 = memref.view %shmem[%c147456][] : memref<?xi8, 3> to memref<64x64xf16, 3>
%8 = memref.view %shmem[%c155648][] : memref<?xi8, 3> to memref<64x64xf16, 3>
// Step 2: Utilize the shared memory
"test.use.shared.memory"(%7) : (memref<64x64xf16, 3>) -> (index)
"test.use.shared.memory"(%8) : (memref<64x64xf16, 3>) -> (index)
}
}
```
This PR resolves #72513
show more ...
|
#
47905788 |
| 10-Oct-2023 |
Ingo Müller <ingomueller@google.com> |
[mlir] Make overloads of SymbolTable::replaceAllSymbolUses consistent. (#68320)
This function has several overloads that allow to specify the symbol
that should be renamed and the scope for that re
[mlir] Make overloads of SymbolTable::replaceAllSymbolUses consistent. (#68320)
This function has several overloads that allow to specify the symbol
that should be renamed and the scope for that renaming in different
ways. The overloads were inconsistent in the following way (quoted
strings are `StringAttr`s, other variables are `Operation *`):
* `replaceAllSymbolUses(symbolOp, "new_symbol", scopeOp)` would traverse
into the nested regions of `scopeOp` and hence rename the symbol inside
of `scopeOp`.
* `replaceAllSymbolUses("symbol", "new_symbol", scopeOp)` would *not*
traverse into the nested regions of `scopeOp` and hence *not* rename the
symbol.
The underlying behavior was spread over different places and is somewhat
hard to understand. The two overloads above mainly differed by what
`collectSymbolScopes` computed, which is itself overloaded. If `scopeOp`
is a top-level module, then the overload on `(Operation *, Operation
*)`, which is used in the first of the above cases, computes a scope
where the body region of the module is the `limit`; however, the
overload on `(StringAttr, Operation *)` computed the module op itself as
the `limit`. Later, `walkSymbolTable` would walk the body of the module
if it was given as a region but it would *not* enter the regions of the
module op because that op has a symbol table (which was assumed to be a
*different* scope).
The fix in this commit is change the behavior of `collectSymbolScopes`
such that the `(StringAttr, Operation *)` overload returns a scope for
each region in the `limit` argument.
show more ...
|
#
e1f90b50 |
| 06-Oct-2023 |
Christian Sigg <chsigg@users.noreply.github.com> |
[mlir] Fix unused `from` after https://github.com/llvm/llvm-project/commit/787689943d027b062274f22097e7f30b0a52bd5b
|
#
78768994 |
| 06-Oct-2023 |
Ingo Müller <ingomueller@google.com> |
[mlir][transform] Fix handling of transitive include in interpreter. (#67560)
Until now, the interpreter would only load those symbols from the
provided library files that were declared in the main
[mlir][transform] Fix handling of transitive include in interpreter. (#67560)
Until now, the interpreter would only load those symbols from the
provided library files that were declared in the main transform module.
However, sequences in the library may include other sequences on their
own. Until now, if such sequences were not *also* declared in the main
transform module, the interpreter would fail to resolve them. Forward
declaring all of them is undesirable as it defeats the purpose of
encapsulation into library modules.
This PR implements a kind of linker for transform scripts to solve this
problem. The linker merges all symbols of the library module into the
main module before interpreting the latter. Symbols whose names collide
are handled as follows: (1) if they are both functions (in the sense of
`FunctionOpInterface`) with compatible signatures, one is external, and
the other one is public, then they are merged; (2) of one of them is
private, that one is renamed; and (3) an error is raised otherwise.
One consequence of this change is that the loading of the library files
in the interpreter pass is not idempotent anymore, i.e., subsequent
interpreter passes cannot (and need not) load the same library files again
since would lead to doubly defined symbols.
show more ...
|
#
68f58812 |
| 26-May-2023 |
Tres Popp <tpopp@google.com> |
[mlir] Move casting calls from methods to function calls
The MLIR classes Type/Attribute/Operation/Op/Value support cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast functionali
[mlir] Move casting calls from methods to function calls
The MLIR classes Type/Attribute/Operation/Op/Value support cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast functionality in addition to defining methods with the same name. This change begins the migration of uses of the method to the corresponding function call as has been decided as more consistent.
Note that there still exist classes that only define methods directly, such as AffineExpr, and this does not include work currently to support a functional cast/isa call.
Context: - https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…" - Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443
Implementation: This patch updates all remaining uses of the deprecated functionality in mlir/. This was done with clang-tidy as described below and further modifications to GPUBase.td and OpenMPOpsInterfaces.td.
Steps are described per line, as comments are removed by git: 0. Retrieve the change from the following to build clang-tidy with an additional check: main...tpopp:llvm-project:tidy-cast-check 1. Build clang-tidy 2. Run clang-tidy over your entire codebase while disabling all checks and enabling the one relevant one. Run on all header files also. 3. Delete .inc files that were also modified, so the next build rebuilds them to a pure state.
``` ninja -C $BUILD_DIR clang-tidy
run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\ -header-filter=mlir/ mlir/* -fix
rm -rf $BUILD_DIR/tools/mlir/**/*.inc ```
Differential Revision: https://reviews.llvm.org/D151542
show more ...
|
#
c1fa60b4 |
| 11-May-2023 |
Tres Popp <tpopp@google.com> |
[mlir] Update method cast calls to function calls
The MLIR classes Type/Attribute/Operation/Op/Value support cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast functionality in a
[mlir] Update method cast calls to function calls
The MLIR classes Type/Attribute/Operation/Op/Value support cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast functionality in addition to defining methods with the same name. This change begins the migration of uses of the method to the corresponding function call as has been decided as more consistent.
Note that there still exist classes that only define methods directly, such as AffineExpr, and this does not include work currently to support a functional cast/isa call.
Context:
* https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…" * Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443
Implementation: This follows a previous patch that updated calls `op.cast<T>()-> cast<T>(op)`. However some cases could not handle an unprefixed `cast` call due to occurrences of variables named cast, or occurring inside of class definitions which would resolve to the method. All C++ files that did not work automatically with `cast<T>()` are updated here to `llvm::cast` and similar with the intention that they can be easily updated after the methods are removed through a find-replace.
See https://github.com/llvm/llvm-project/compare/main...tpopp:llvm-project:tidy-cast-check for the clang-tidy check that is used and then update printed occurrences of the function to include `llvm::` before.
One can then run the following: ``` ninja -C $BUILD_DIR clang-tidy
run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\ -export-fixes /tmp/cast/casts.yaml mlir/*\ -header-filter=mlir/ -fix
rm -rf $BUILD_DIR/tools/mlir/**/*.inc ```
Differential Revision: https://reviews.llvm.org/D150348
show more ...
|
#
55bc18a7 |
| 22-Feb-2023 |
Jeff Niu <jeff@modular.com> |
[mlir] Fix typo causing build error
|
#
2cfc66a6 |
| 21-Feb-2023 |
Jeff Niu <jeff@modular.com> |
[mlir] Add a SharedSymbolTableCollection class
This class wraps a `SymbolTableCollection` to allow shared access to the collection of symbol tables (but not the individual symbol tables). This can b
[mlir] Add a SharedSymbolTableCollection class
This class wraps a `SymbolTableCollection` to allow shared access to the collection of symbol tables (but not the individual symbol tables). This can be used, for example, in a pass that shards work among symbols that requires symbol lookups.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D144507
show more ...
|
#
03d136cf |
| 21-Jan-2023 |
River Riddle <riddleriver@gmail.com> |
[mlir] Promote the SubElementInterfaces to a core Attribute/Type construct
This commit restructures the sub element infrastructure to be a core part of attributes and types, instead of being relegat
[mlir] Promote the SubElementInterfaces to a core Attribute/Type construct
This commit restructures the sub element infrastructure to be a core part of attributes and types, instead of being relegated to an interface. This establishes sub element walking/replacement as something "always there", which makes it easier to rely on for correctness/etc (which various bits of infrastructure want, such as Symbols).
Attribute/Type now have `walk` and `replace` methods directly accessible, which provide power API for interacting with sub elements. As part of this, a new AttrTypeWalker class is introduced that supports caching walked attributes/types, and a friendlier API (see the simplification of symbol walking in SymbolTable.cpp).
Differential Revision: https://reviews.llvm.org/D142272
show more ...
|
#
0a81ace0 |
| 14-Jan-2023 |
Kazu Hirata <kazu@google.com> |
[mlir] Use std::optional instead of llvm::Optional (NFC)
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h".
This is pa
[mlir] Use std::optional instead of llvm::Optional (NFC)
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h".
This is part of an effort to migrate from llvm::Optional to std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
show more ...
|
#
a1fe1f5f |
| 14-Jan-2023 |
Kazu Hirata <kazu@google.com> |
[mlir] Add #include <optional> (NFC)
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>.
I'll post a separate patch to actually replace llvm::Optiona
[mlir] Add #include <optional> (NFC)
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>.
I'll post a separate patch to actually replace llvm::Optional with std::optional.
This is part of an effort to migrate from llvm::Optional to std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
show more ...
|
#
e8bcc37f |
| 19-Dec-2022 |
Ramkumar Ramachandra <r@artagnon.com> |
mlir/{SPIRV,Bufferization}: use std::optional in .td files (NFC)
This is part of an effort to migrate from llvm::Optional to std::optional. 22426110c5ef changed the way mlir-tblgen generates .inc fi
mlir/{SPIRV,Bufferization}: use std::optional in .td files (NFC)
This is part of an effort to migrate from llvm::Optional to std::optional. 22426110c5ef changed the way mlir-tblgen generates .inc files, emitting std::optional when an Optional attribute is specified in a .td file. It also changed several .td files hard-coding llvm::Optional to use std::optional. However, the patch excluded a few .td files in SPIRV and Bufferization hard-coding llvm::Optional. This patch fixes that defect, and after this patch, references to llvm::Optional in .cpp and .h files can be replaced mechanically.
See also: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>
Differential Revision: https://reviews.llvm.org/D140329
show more ...
|
#
4f81805a |
| 11-Dec-2022 |
Kazu Hirata <kazu@google.com> |
[mlir] Use std::optional instead of None in comments (NFC)
This is part of an effort to migrate from llvm::Optional to std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasval
[mlir] Use std::optional instead of None in comments (NFC)
This is part of an effort to migrate from llvm::Optional to std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
show more ...
|
#
70c73d1b |
| 05-Dec-2022 |
Kazu Hirata <kazu@google.com> |
[mlir] Use std::nullopt instead of None in comments (NFC)
This is part of an effort to migrate from llvm::Optional to std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalu
[mlir] Use std::nullopt instead of None in comments (NFC)
This is part of an effort to migrate from llvm::Optional to std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
show more ...
|
#
1a36588e |
| 04-Dec-2022 |
Kazu Hirata <kazu@google.com> |
[mlir] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of ma
[mlir] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional.
This is part of an effort to migrate from llvm::Optional to std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
show more ...
|
#
e50941b8 |
| 10-Nov-2022 |
River Riddle <riddleriver@gmail.com> |
[mlir] Add a new AttrTypeReplacer class to simplify sub element replacements
We currently only have the SubElement interface API for attribute/type replacement, but this suffers from several issues;
[mlir] Add a new AttrTypeReplacer class to simplify sub element replacements
We currently only have the SubElement interface API for attribute/type replacement, but this suffers from several issues; namely that it doesn't allow caching across multiple replacements (very common), and also creates a somewhat awkward/limited API. The new AttrTypeReplacer class allows for registering replacements using a much cleaner API, similarly to the TypeConverter class, removes a lot of manual interaction with the sub element interfaces, and also better enables large scale replacements.
Differential Revision: https://reviews.llvm.org/D137764
show more ...
|
#
de49627d |
| 16-Oct-2022 |
Kazu Hirata <kazu@google.com> |
[mlir] Remove redundaunt typename (NFC)
|
#
b6a32d94 |
| 09-Sep-2022 |
River Riddle <riddleriver@gmail.com> |
[mlir:SymbolTable] Add "remove" method that drops a symbol without erasing it
There are various use cases where we don't want to immediately erase an operation when removing it from the symbol table
[mlir:SymbolTable] Add "remove" method that drops a symbol without erasing it
There are various use cases where we don't want to immediately erase an operation when removing it from the symbol table. This commit adds a "remove" method to support that.
Differential Revision: https://reviews.llvm.org/D133564
show more ...
|
#
00a52c75 |
| 28-Jul-2022 |
River Riddle <riddleriver@gmail.com> |
[mlir:SubElementsInterface] Add support for "skipping" when replacing attributes/types
This is used to fix a bug in SymbolTable::replaceAllSymbolUses where we replace symbols that we shouldn't.
Dif
[mlir:SubElementsInterface] Add support for "skipping" when replacing attributes/types
This is used to fix a bug in SymbolTable::replaceAllSymbolUses where we replace symbols that we shouldn't.
Differential Revision: https://reviews.llvm.org/D130693
show more ...
|
#
01eedbc7 |
| 26-Jul-2022 |
River Riddle <riddleriver@gmail.com> |
[mlir] Refactor SubElementInterface replace support
The current support was essentially the amount necessary to support replacing SymbolRefAttrs, but suffers from various deficiencies (both ergonomi
[mlir] Refactor SubElementInterface replace support
The current support was essentially the amount necessary to support replacing SymbolRefAttrs, but suffers from various deficiencies (both ergonomic and functional):
* Replace crashes if unsupported This makes it really hard to use safely, given that you don't know if you are going to crash or not when using it.
* Types aren't supported This seems like a simple missed addition when the attribute replacement support was originally added.
* The ergonomics are weird It currently uses an index based replacement, which makes the implementations quite clunky.
This commit refactors support to be a bit more ergonomic, and also adds support for types in the process. This was also a great oppurtunity to greatly simplify how replacement is done in the symbol table.
Fixes #56355
Differential Revision: https://reviews.llvm.org/D130589
show more ...
|
#
f92d319c |
| 08-Jul-2022 |
Nandor Licker <n@ndor.email> |
[mlir] Fixed double-free bug in SymbolUserMap
`SymbolUserMap` relied on `try_emplace` and `std::move` to relocate an entry to another key. However, if this triggered the resizing of the `DenseMap`,
[mlir] Fixed double-free bug in SymbolUserMap
`SymbolUserMap` relied on `try_emplace` and `std::move` to relocate an entry to another key. However, if this triggered the resizing of the `DenseMap`, the value was destroyed before it could be moved to the new storage location, leading to a dangling `users` reference to be inserted into the map. On destruction, since a new entry was created from one that was already freed, a double-free error occurred.
Fixed issue by re-fetching the iterator after the mutation of the container.
Differential Revision: https://reviews.llvm.org/D129345
show more ...
|
#
be0a7e9f |
| 07-Dec-2021 |
Mehdi Amini <joker.eph@gmail.com> |
Adjust "end namespace" comment in MLIR to match new agree'd coding style
See D115115 and this mailing list discussion: https://lists.llvm.org/pipermail/llvm-dev/2021-December/154199.html
Differenti
Adjust "end namespace" comment in MLIR to match new agree'd coding style
See D115115 and this mailing list discussion: https://lists.llvm.org/pipermail/llvm-dev/2021-December/154199.html
Differential Revision: https://reviews.llvm.org/D115309
show more ...
|
#
195730a6 |
| 16-Nov-2021 |
River Riddle <riddleriver@gmail.com> |
[mlir][NFC] Replace references to Identifier with StringAttr
This is part of the replacement of Identifier with StringAttr.
Differential Revision: https://reviews.llvm.org/D113953
|
#
feec2d90 |
| 02-Nov-2021 |
Alex Zinenko <zinenko@google.com> |
[mlir] return the updated symbol table after inserting into SymbolTable
Inserting a symbol into a SymbolTable may lead to the name of the symbol being changed in order to ensure uniqueness of symbol
[mlir] return the updated symbol table after inserting into SymbolTable
Inserting a symbol into a SymbolTable may lead to the name of the symbol being changed in order to ensure uniqueness of symbol names in the table. Return this new name to spare the caller the need to extract it from the symbol operation.
Depends On D112700
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D112886
show more ...
|