1003 Commits

Author SHA1 Message Date
Matthias Springer
2a4e61b342
[mlir][NFC] Move and improve ownership-based buffer dellocation docs (#89196)
Move the documentation of the ownership-based buffer deallocation pass
to a separate file. Also improve the documentation a bit and insert a
figure that explains the `bufferization.dealloc` op (copied from the
tutorial at the LLVM Dev Summit 2023).
2024-04-18 13:26:15 +02:00
Frederik Harwath
ac1f2de7b5
[MLIR][docs] Mention declarePromisedInterface in Interfaces doc (#88689)
Co-authored-by: Frederik Harwath <fharwath@amd.com>
Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
2024-04-16 14:09:25 +02:00
Fr4nk1in
6d234638f9
[docs][mlir] Fix broken links in 'llvm' dialects. (#88704)
Links to `llvm.mlir.global` and `llvm.mlir.addressof` in the ["Globals"
section of LLVM dialect
documentation](https://mlir.llvm.org/docs/Dialects/LLVM/#globals) are
broken.
2024-04-16 00:13:38 +02:00
Markus Böck
5b95c9e0ca
[mlir][ODS] Make prop-dict behave closer to attr-dict (#88659)
`attr-dict` currently prints any attribute (inherent or discardable)
that does not occur elsewhere in the assembly format. `prop-dict` on the
other hand, always prints and parses all properties (including inherent
attributes stored as properties) as part of the property dictionary,
regardless of whether the properties or attributes are used elsewhere.
(with the exception of default-valued attributes implemented recently in
https://github.com/llvm/llvm-project/pull/87970).

This PR changes the behavior of `prop-dict` to only print and parse
attributes and properties that do not occur elsewhere in the assembly
format. This is achieved by 1) adding used attributes and properties to
the elision list when printing and 2) using a custom version of
`setPropertiesFromAttr` called `setPropertiesFromParsedAttr` that is
sensitive to the assembly format and auto-generated by ODS.

The current and new behavior of `prop-dict` and `attr-dict` were also
documented.

Happens to also fix https://github.com/llvm/llvm-project/issues/88506
2024-04-15 12:13:06 +02:00
Andrzej Warzynski
5ed60ffd79 [mlir][test] Extend CMake logic for e2e tests
Adds two new CMake functions to query the host system:

  * `check_hwcap`,
  * `check_emulator`.

Together, these functions are used to check whether a given set of MLIR
integration tests require an emulator. If yes, then the corresponding
CMake var that defies the required emulator executable is also checked.

`check_hwcap` relies on ELF_HWCAP for discovering CPU features from
userspace on Linux systems. This is the recommended approach for Arm
CPUs running on Linux as outlined in this blog post:

  * https://community.arm.com/arm-community-blogs/b/operating-systems-blog/posts/runtime-detection-of-cpu-features-on-an-armv8-a-cpu

Other operating systems (e.g. Android) and CPU architectures will
most likely require some other approach. Right now these new hooks are
only used for SVE and SME integration tests.

This relands #86489 with the following changes:
  * Replaced:
      `set(hwcap_test_file ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/hwcap_check.c)`
    with:
      `set(hwcap_test_file ${CMAKE_BINARY_DIR}/temp/hwcap_check.c)`
    The former would trigger an infinite loop when running `ninja`
    (after the initial CMake configuration).
  * Fixed commit msg. Previous one was taken from the initial GH PR
    commit rather than the final re-worked solution (missed this when
    merging via GH UI).
  * A couple more NFCs/tweaks.
2024-04-05 08:43:37 +00:00
mlevesquedion
73fa6685c4
Fix a few broken links (#87098)
References to headings need to be preceded with a slash. Also,
references to headings on the same page do not need to contain the name
of the document (omitting the document name means if the name changes
the links will still be valid).

I double checked the links by building [the
website](https://github.com/llvm/mlir-www):

```shell
./mlir-www-helper.sh --install-docs ../llvm-project website
cd website && hugo serve
```
2024-04-05 09:52:53 +02:00
Andrzej Warzynski
d3fe2b538d Revert "[mlir][test] Make SME e2e tests require an emulator (#86489)"
This reverts commit 7b5255297dca377a37c8df066e9d9749ab96cfad.

Broken bot:
* https://lab.llvm.org/buildbot/#/builders/179/builds/9794
2024-04-04 17:12:37 +01:00
Andrzej Warzyński
7b5255297d
[mlir][test] Make SME e2e tests require an emulator (#86489)
Integration tests for ArmSME require an emulator (there's no hardware
available). Make sure that CMake complains if `MLIR_RUN_ARM_SME_TESTS`
is set while `ARM_EMULATOR_EXECUTABLE` is empty.

I'm also adding a note in the docs for future reference.
2024-04-04 13:40:08 +01:00
Hsiangkai Wang
362aa434cc
[mlir] Enhance TimingManager Printing Flexibility (#85821)
Revise the printing functionality of TimingManager to accommodate
various output formats. At present, TimingManager is limited to
outputting data solely in plain text format. To overcome this
limitation, I have introduced an abstract class that serves as the
foundation for printing. This approach allows users to implement
additional output formats by extending this abstract class. As part of
this update, I have integrated support for JSON as a new output format,
enhancing the ease of parsing for subsequent processing scripts.
2024-04-03 16:58:01 +01:00
Iman Hosseini
bc02c0825a
[documentation] [mlir] DataLayout.md: fix broken link to DLTI dialect (#86524)
The link to DLTI dialect was broken.
2024-03-25 15:54:05 -07:00
Tobias Gysi
adda597388
[MLIR] Add index bitwidth to the DataLayout (#85927)
When importing from LLVM IR the data layout of all pointer types
contains an index bitwidth that should be used for index computations.
This revision adds a getter to the DataLayout that provides access to
the already stored bitwidth. The function returns an optional since only
pointer-like types have an index bitwidth. Querying the bitwidth of a
non-pointer type returns std::nullopt.

The new function works for the built-in Index type and, using a type
interface, for the LLVMPointerType.
2024-03-21 09:07:57 +01:00
Oleksandr "Alex" Zinenko
5a9bdd85ee
[mlir] split transform interfaces into a separate library (#85221)
Transform interfaces are implemented, direction or via extensions, in
libraries belonging to multiple other dialects. Those dialects don't
need to depend on the non-interface part of the transform dialect, which
includes the growing number of ops and transitive dependency footprint.

Split out the interfaces into a separate library. This in turn requires
flipping the dependency from the interface on the dialect that has crept
in because both co-existed in one library. The interface shouldn't
depend on the transform dialect either.

As a consequence of splitting, the capability of the interpreter to
automatically walk the payload IR to identify payload ops of a certain
kind based on the type used for the entry point symbol argument is
disabled. This is a good move by itself as it simplifies the interpreter
logic. This functionality can be trivially replaced by a
`transform.structured.match` operation.
2024-03-20 22:15:17 +01:00
Tina Jung
0ddb122147
[mlir][emitc] Arith to EmitC conversion: constants (#83798)
* Add a conversion from `arith.constant` to `emitc.constant`.
* Drop the translation for `arith.constant`s.
2024-03-08 09:16:10 +01:00
mlevesquedion
267beb10f2
[MLIR] Fix a few links to passes in the documentation (#83221)
I double checked the links by building [the
website](https://github.com/llvm/mlir-www):

```
$ mlir-www-helper.sh --install-docs ../llvm-project website
$ cd website && hugo serve
```
2024-02-27 21:31:15 -08:00
Iman Hosseini
a3748d60ff
[MLIR] Update GPU.md: add gpu kernel outlining to doc example. (#83141)
gpu-kernel-outlining is needed for this example to work.
2024-02-27 14:55:45 -08:00
Kohei Yamaguchi
0c13a896df
[mlir][docs] Fix broken docs (#82308)
- Fixed OpenACC's spec link format
- Add missed `OpenACCPasses.md` into Passes.md
- Add missed `MyExtensionCh4.md` into Ch4.md of tutorial of transform
2024-02-21 10:11:22 +01:00
Marius Brehler
dfb70c3a7c
[mlir][EmitC] Remove func.constant from emitter (#82342)
As part of the renaming the Standard dialect to Func dialect, *support*
for the `func.constant` operation was added to the emitter. However, the
emitter cannot emit function types. Hence the emission for a snippet
like

```
%0 = func.constant @myfn : (f32) -> f32

func.func private @myfn(%arg0: f32) -> f32 {
  return %arg0 : f32
}
```

failes with `func.mlir:1:6: error: cannot emit type '(f32) -> f32'`.
This removes `func.constant` from the emitter.
2024-02-20 14:16:34 +01:00
mlevesquedion
a90a09fa2e
[mlir][docs] Fix broken links to traits documentation (#82131)
It seems the `Traits.md` file was turned into `Traits/_index.md` in
https://reviews.llvm.org/D153291, causing links to `Traits.md` to no
longer work (instead, `Traits` needs to be used).
2024-02-17 13:51:36 -08:00
Mehdi Amini
450462cbac
[MLIR] Document the stability and versioning aspect of the Bytecode (#81969)
See the two RFCs:


https://discourse.llvm.org/t/rfc-mlir-bytecode-a-stable-serialization-format/71062
https://discourse.llvm.org/t/rfc-ir-versioning/5893
2024-02-16 13:25:03 -08:00
Ronan Keryell
f1b2865b6a
[mlir][docs] Fix typos in TargetLLVMIR.md (#81549) 2024-02-14 13:26:48 +02:00
Oleksandr "Alex" Zinenko
b33b91a217
[mlir] update transform dialect tutorials (#81199)
Use the "main" transform-interpreter pass instead of the test pass.
This, along with the previously introduced debug extension, now allow
tutorials to no longer depend on test passes and extensions.
2024-02-09 17:35:14 +01:00
Jeremy Kun
3d71e4166d
[docs]: Add a note about using custom types with diagnostics (#73818) 2024-02-08 11:06:43 -08:00
Oleksandr "Alex" Zinenko
c1ac2cfac7
Use a markdown list in Affine dialect docs 2024-02-06 03:59:41 +01:00
Matthias Springer
0940be1581
[mlir][bufferization] Never pass ownership to functions (#80655)
Even when `private-function-dynamic-ownership` is set, ownership should
never be passed to the callee. This can lead to double deallocs (#77096)
or use-after-free in the caller because ownership is currently passed
regardless of whether there are any further uses of the buffer in the
caller or not.

Note: This is consistent with the fact that ownership is never passed to
nested regions.

This commit fixes #77096.
2024-02-05 12:11:49 +01:00
Boian Petkantchin
31fc0a12e1
[mlir][mesh] Refactoring code organization, tests and docs (#79606)
* Split out `MeshDialect.h` form `MeshOps.h` that defines the dialect
class. Reduces include clutter if you care only about the dialect and
not the ops.

* Expose functions `getMesh` and `collectiveProcessGroupSize`. There
functions are useful for outside users of the dialect.

* Remove unused code.

* Remove examples and tests of mesh.shard attribute in tensor encoding.
Per the decision that Spmdization would be performed on sharding
annotations and there will be no tensors with sharding specified in the
type.
For more info see this RFC comment:
https://discourse.llvm.org/t/rfc-sharding-framework-design-for-device-mesh/73533/81
2024-01-31 07:20:14 -08:00
Boian Petkantchin
c0f29e83db
[mlir][mesh] Make most collectives pure (#79643)
There are assumptions of matching/consistent paths of execution under SPMD that allow to have pure collective communication operations.
2024-01-30 06:57:47 -08:00
Rageking8
5f4c89edd0
Fix unsigned typos (#76670) 2024-01-27 22:20:08 -08:00
Marius Brehler
205e15c176 [mlir][docs] Fix broken link 2024-01-19 17:38:27 +01:00
Matthias Springer
5fcf907b34
[mlir][IR] Rename "update root" to "modify op" in rewriter API (#78260)
This commit renames 4 pattern rewriter API functions:
* `updateRootInPlace` -> `modifyOpInPlace`
* `startRootUpdate` -> `startOpModification`
* `finalizeRootUpdate` -> `finalizeOpModification`
* `cancelRootUpdate` -> `cancelOpModification`

The term "root" is a misnomer. The root is the op that a rewrite pattern
matches against
(https://mlir.llvm.org/docs/PatternRewriter/#root-operation-name-optional).
A rewriter must be notified of all in-place op modifications, not just
in-place modifications of the root
(https://mlir.llvm.org/docs/PatternRewriter/#pattern-rewriter). The old
function names were confusing and have contributed to various broken
rewrite patterns.

Note: The new function names use the term "modify" instead of "update"
for consistency with the `RewriterBase::Listener` terminology
(`notifyOperationModified`).
2024-01-17 11:08:59 +01:00
Oleksandr "Alex" Zinenko
2798b72ae7
[mlir] introduce debug transform dialect extension (#77595)
Introduce a new extension for simple print-debugging of the transform
dialect scripts. The initial version of this extension consists of two
ops that are printing the payload objects associated with transform
dialect values. Similar ops were already available in the test extenion
and several downstream projects, and were extensively used for testing.
2024-01-12 13:24:02 +01:00
Matthias Springer
21aacb0b4c
[mlir] Improve GreedyPatternRewriteDriver and pass documentation (#77614)
Clarify what kind of IR modifications are allowed. Also improve the
documentation of the greedy rewrite driver entry points.

Addressing comments in #76219.
2024-01-11 11:24:28 +01:00
Razvan Lupusoru
b565ee1ad3
[acc] Fix OpenACC documentation (#77502)
After PR#75548, the OpenACC documentation on the MLIR website has a few
issues. This change corrects them:
- Renames OpenACC.md to OpenACCDialect.md so that links remain
unchanged. In its current state, the links to
https://mlir.llvm.org/docs/Dialects/OpenACCDialect/ no longer work.
- Since the old OpenACCDialect.md (the one with operation definitions)
is being included in the new file, rename the old file to prevent name
ambiguity.
- A header is needed in the .md file, otherwise the index on website is
not properly created.
- Add a new section before including the operations .md file because
otherwise the separation is not clear.
2024-01-09 11:12:41 -08:00
Razvan Lupusoru
ab4af25d5d
[acc] OpenACC dialect design philosophy and details (#75548)
This document captures the design philosophy of the acc dialect. It also
shares the rationale behind the design and implementation of various
operations - and ties that back to the dialect design goals.

Co-authored-by: Valentin Clement <clementval@gmail.com>
Co-authored-by: Slava Zakharin <szakharin@nvidia.com>
2024-01-09 07:33:11 -08:00
Oleksandr "Alex" Zinenko
4cb2ef4fe3
[mlir] add a chapter on matchers to the transform dialect tutorial (#76725)
These operations has been available for a while, but were not described
in the tutorial. Add a new chapter on using and defining match
operations.
2024-01-09 13:19:41 +01:00
Kohei Yamaguchi
d5985d4c70
[mlir][docs] Fix a broken passes documentation (#77402)
- Add EmitC passes into Pass.md
- Modify header level of the pass description to under the
`LegalizeVectorStorage` pass
2024-01-09 11:45:40 +00:00
Guray Ozen
ace69e6b94
[mlir][gpu] Improve gpu-lower-to-nvvm-pipeline Documentation (#77062)
This PR improves the documentation for the `gpu-lower-to-nvvm-pipeline`
(as it was remaning item for #75775)

- Changes pipeline `gpu-lower-to-nvvm` -> `gpu-lower-to-nvvm-pipeline`
- Adds a section in GPU Dialect in website. It clarifies the pipeline's
functionality in lowering primary dialects to NVVM targets.
2024-01-05 12:51:25 +01:00
Andrzej Warzyński
ca5d34ec71
[mlir][TD] Fix the order of return handles (#76929)
Replace (in tests and docs):

    %forall, %tiled = transform.structured.tile_using_forall

with (updated order of return handles):

    %tiled, %forall = transform.structured.tile_using_forall

Similar change is applied to (in the TD tutorial):

    transform.structured.fuse_into_containing_op

This update makes sure that the tests/documentation are consistent with
the Op specifications. Follow-up for #67320 which updated the order of
the return handles for `tile_using_forall`.
2024-01-04 12:54:16 +00:00
Andrzej Warzyński
f8c034140b
[mlir][docs] Update TD tutorial - Ch0 (#76858)
Updates `generic` as `linalg.generic` (for consistency and to avoid
ambiguity) and a few other fixes.
2024-01-04 09:48:44 +01:00
Andrzej Warzyński
39298b09ec
[mlir][docs] Capitalize "Transform" in "transform dialect" (#76840)
A mix of "Transform dialect" and "transform dialect" is used ATM. This
patch capitalizes the outstanding instances of "transform".
2024-01-03 21:33:11 +00:00
Andrzej Warzyński
fb62a18615
[mlir][ArmSME] Update docs (#74527) 2023-12-06 21:35:23 +00:00
Boian Petkantchin
dff2f59be3
[mlir][mesh] Add TableGen deffinitions of more collective ops (#73842)
Add definitions for
broadcast, gather, receive, reduce, scatter, send and shift.
2023-12-04 09:11:47 -08:00
Kohei Yamaguchi
0817efc476
[mlir][docs] Add missing .md into Transform and Passes docs(NFC) (#73916)
Fix broken docs for MeshDialect's pass and Transform dialect's loop
extension.
2023-11-30 11:25:53 +01:00
Rik Huijzer
f1fba63f12
[mlir][vector][doc] 0D vectors (#73792)
Currently, the only mention of 0d vectors in the MLIR source code that I
could find was:

>     0D vectors are allowed by omitting the dimension: `vector<f32>`.

in
[`BuiltinTypes.td`](437a48b2d9/mlir/include/mlir/IR/BuiltinTypes.td (L1046-L1047)).

This patch adds a summary of
https://discourse.llvm.org/t/what-is-the-semantics-of-memref-0xf32-and-tensor-0xf32/3557
and https://discourse.llvm.org/t/should-we-have-0-d-vectors/3097/5.
2023-11-30 10:11:50 +01:00
Oleksandr "Alex" Zinenko
43bc81d748
[mlir] fix LLVM type converter for structs (#73231)
Existing implementation of the LLVM type converter for LLVM structs
containing incompatible types was attempting to change identifiers of
the struct in case of name clash post-conversion (all identified structs
have different names post-conversion since one cannot change the body of
the struct once initialized). Beyond a trivial error of not updating the
counter in renaming, this approach was broken for recursive structs that
can't be made aware of the renaming and would use the pre-existing
struct with clashing name instead.

For example, given

`!llvm.struct<"_Converted.foo", (struct<"_Converted.foo">, f32)>`

the following type

`!llvm.struct<"foo", (struct<"foo", index>)>`

would incorrectly convert to

```
!llvm.struct<"_Converted_1.foo",
             (struct<"_Converted.foo",
	             (struct<"_Converted.foo">, f32)>)>
```

Remove this incorrect renaming and simply refuse to convert types if it
would lead to identifier clashes for structs with different bodies.
Document the expectation that such generated names are reserved and must
not be present in the input IR of the converter. If we ever actually
need to use handle such cases, this can be achieved by temporarily
renaming structs with reserved identifiers to an unreserved name and
back in a pre/post-processing pass that does _not_ use the type
conversion infra.
2023-11-23 22:21:39 +01:00
Oleksandr "Alex" Zinenko
8134a8fc3f
[mlir] use TypeSize and uint64_t in DataLayout (#72874)
Data layout queries may be issued for types whose size exceeds the range
of 32-bit integer as well as for types that don't have a size known at
compile time, such as scalable vectors. Use best practices from LLVM IR
and adopt `llvm::TypeSize` for size-related queries and `uint64_t` for
alignment-related queries.

See #72678.
2023-11-21 16:12:27 +01:00
Boian Petkantchin
5f7c8c1068
[mlir][mesh] Add collective communication operations (#71960)
Add all-gather, all-reduce, all-to-all and reduce-scatter. These
operations have device mesh semantics.
2023-11-21 06:50:24 -08:00
Mehdi Amini
26a0b27736
Make MLIR Value more consistent in terms of const "correctness" (NFC) (#72765)
MLIR can't really be const-correct (it would need a `ConstValue` class
alongside the `Value` class really, like `ArrayRef` and
`MutableArrayRef`). This is however making is more consistent: method
that are directly modifying the Value shouldn't be marked const.
2023-11-20 20:52:15 -08:00
David Spickett
1716c5b614 [mlir][Docs] Code review is now done on GitHub 2023-11-20 13:18:39 +00:00
Marius Brehler
c4fd1fd6d4
[mlir][emitc] Rename call op to call_opaque (#72494)
This renames the `emitc.call` op to `emitc.call_opaque` as the existing
call op does not refer to the callee by symbol. The rename allows to
introduce a new call op alongside with a future `emitc.func` op to model
and facilitate functions and function calls.
2023-11-17 10:22:15 +01:00
David Spickett
a4fbe31f9e
[mlir][docs] Add link to Visual Studio Code extension (#71190)
The document talks a lot about it but never says explicitly that it
comes from the marketplace. At first I thought I had to install it
locally.
2023-11-06 09:21:07 +00:00