14634 Commits

Author SHA1 Message Date
Mehdi Amini
dfe1759614 Apply clang-tidy fixes for llvm-qualified-auto in CodeGenHelpers.cpp (NFC) 2024-02-15 16:02:40 -08:00
Peiming Liu
aaf916456a
Reapply "[mlir][sparse] remove LevelType enum, construct LevelType from LevelFormat and Properties" (#81923) (#81934) 2024-02-15 14:48:52 -08:00
Mehdi Amini
513448d28e
Revert "[mlir][sparse] remove LevelType enum, construct LevelType from LevelF…" (#81923)
Reverts llvm/llvm-project#81799 ; this broke the mlir gcc7 bot.
2024-02-15 13:26:44 -08:00
Boian Petkantchin
dc3258c617
[mlir][mesh] Add all-slice operation (#81218)
This op is the inverse of all-gather. It is useful to have an explicit
concise representation instead of having a blob of slicing logic.

Add lowering for the op that slices from the tensor based on the
in-group process index.

Make resharding generate an all-slice instead of inserting the slicing
logic directly.
2024-02-15 13:03:58 -08:00
Peiming Liu
235ec0f791
[mlir][sparse] remove LevelType enum, construct LevelType from LevelF… (#81799)
…ormat and properties instead.
2024-02-15 12:31:03 -08:00
Aart Bik
4d273b948e
[mlir][sparse] ensure [dis]assembler wrapper methods properly inline (#81907) 2024-02-15 11:39:32 -08:00
erman-gurses
04381c106f
[MLIR][AMDGPU]Add refactoring for shared-mem optimization (#81791)
Addressing the issues in this PR:
https://github.com/llvm/llvm-project/pull/81550
2024-02-15 13:53:15 -05:00
Mehdi Amini
6f2414261b Apply clang-tidy fixes for llvm-include-order in Timing.cpp (NFC) 2024-02-15 10:17:28 -08:00
Mehdi Amini
e8d09a5b44 Apply clang-tidy fixes for readability-identifier-naming in Operation.cpp (NFC) 2024-02-15 10:17:28 -08:00
Mehdi Amini
b39958c2e8 Apply clang-tidy fixes for llvm-else-after-return in BuiltinDialectBytecode.cpp (NFC) 2024-02-15 10:17:27 -08:00
Mehdi Amini
de2f5bcd79 Apply clang-tidy fixes for llvm-qualified-auto in AsmPrinter.cpp (NFC) 2024-02-15 10:17:27 -08:00
Mehdi Amini
9b514235fc Apply clang-tidy fixes for bugprone-argument-comment in ValueBoundsOpInterface.cpp (NFC) 2024-02-15 10:17:27 -08:00
Kunwar Grover
1fe8e2b6db
Revert "[mlir] Initial patch to add an MPI dialect (#68892)" (#81884)
This reverts commit 2d616ec4f040141e103965f98456ba523762735d.

Buildbot failures:
https://lab.llvm.org/buildbot/#/builders/177/builds/29364
2024-02-15 23:35:33 +05:30
Anton Lydike
2d616ec4f0
[mlir] Initial patch to add an MPI dialect (#68892)
This patch introduces the new MPI dialect into MLIR. The Message Passing
Interface (MPI) is a widely-used standard for distributed programs to
exchange data. This PR goes together with a talk later at today's LLVM
Dev Meeting.

This is just a first, small patch to get going and add the necessary
base files, so that we can add more operations in further patches.

Here's the documentation as generated by `ninja mlir-doc`:
# 'mpi' Dialect

This dialect models the Message Passing Interface (MPI), version 
4.0. It is meant to serve as an interfacing dialect that is targeted
by higher-level dialects. The MPI dialect itself can be lowered to 
multiple MPI implementations and hide differences in ABI. The dialect
models the functions of the MPI specification as close to 1:1 as
possible
while preserving SSA value semantics where it makes sense, and uses 
`memref` types instead of bare pointers.

This dialect is under active development, and while stability is an
eventual goal, it is not guaranteed at this juncture. Given the early 
state, it is recommended to inquire further prior to using this dialect.

For an in-depth documentation of the MPI library interface, please refer
to official documentation such as the 
[OpenMPI online documentation](https://www.open-mpi.org/doc/current/).

[TOC]

## Operation definition

### `mpi.comm_rank` (mpi::CommRankOp)

_Get the current rank, equivalent to `MPI_Comm_rank(MPI_COMM_WORLD,
&rank)`_


Syntax:

```
operation ::= `mpi.comm_rank` attr-dict `:` type(results)
```

Communicators other than `MPI_COMM_WORLD` are not supported for now.

This operation can optionally return an `!mpi.retval` value that can be
used
to check for errors.

#### Results:

| Result | Description |
| :----: | ----------- |
| `retval` | MPI function call return value
| `rank` | 32-bit signless integer


### `mpi.error_class` (mpi::ErrorClassOp)

_Get the error class from an error code, equivalent to the
`MPI_Error_class` function_


Syntax:

```
operation ::= `mpi.error_class` $val attr-dict `:` type($val)
```

`MPI_Error_class` maps return values from MPI calls to a set of
well-known
MPI error classes.

#### Operands:

| Operand | Description |
| :-----: | ----------- |
| `val` | MPI function call return value

#### Results:

| Result | Description |
| :----: | ----------- |
| `errclass` | MPI function call return value


### `mpi.finalize` (mpi::FinalizeOp)

_Finalize the MPI library, equivalent to `MPI_Finalize()`_


Syntax:

```
operation ::= `mpi.finalize` attr-dict (`:` type($retval)^)?
```

This function cleans up the MPI state. Afterwards, no MPI methods may 
be invoked (excpet for MPI_Get_version, MPI_Initialized, and
MPI_Finalized).
Notably, MPI_Init cannot be called again in the same program.

This operation can optionally return an `!mpi.retval` value that can be
used
to check for errors.

#### Results:

| Result | Description |
| :----: | ----------- |
| `retval` | MPI function call return value


### `mpi.init` (mpi::InitOp)

_Initialize the MPI library, equivalent to `MPI_Init(NULL, NULL)`_


Syntax:

```
operation ::= `mpi.init` attr-dict (`:` type($retval)^)?
```

This operation must preceed most MPI calls (except for very few
exceptions,
please consult with the MPI specification on these).

Passing &argc, &argv is not supported currently.

This operation can optionally return an `!mpi.retval` value that can be
used
to check for errors.

#### Results:

| Result | Description |
| :----: | ----------- |
| `retval` | MPI function call return value


### `mpi.recv` (mpi::RecvOp)

_Equivalent to `MPI_Recv(ptr, size, dtype, dest, tag, MPI_COMM_WORLD,
MPI_STATUS_IGNORE)`_


Syntax:

```
operation ::= `mpi.recv` `(` $ref `,` $tag `,` $rank `)` attr-dict `:` type($ref) `,` type($tag) `,` type($rank)(`->` type($retval)^)?
```

MPI_Recv performs a blocking receive of `size` elements of type `dtype` 
from rank `dest`. The `tag` value and communicator enables the library
to
determine the matching of multiple sends and receives between the same 
ranks.

Communicators other than `MPI_COMM_WORLD` are not supprted for now.
The MPI_Status is set to `MPI_STATUS_IGNORE`, as the status object 
is not yet ported to MLIR.

This operation can optionally return an `!mpi.retval` value that can be
used
to check for errors.

#### Operands:

| Operand | Description |
| :-----: | ----------- |
| `ref` | memref of any type values
| `tag` | 32-bit signless integer
| `rank` | 32-bit signless integer

#### Results:

| Result | Description |
| :----: | ----------- |
| `retval` | MPI function call return value


### `mpi.retval_check` (mpi::RetvalCheckOp)

_Check an MPI return value against an error class_


Syntax:

```
operation ::= `mpi.retval_check` $val `=` $errclass attr-dict `:` type($res)
```

This operation compares MPI status codes to known error class
constants such as `MPI_SUCCESS`, or `MPI_ERR_COMM`.

#### Attributes:

<table>
<tr><th>Attribute</th><th>MLIR Type</th><th>Description</th></tr>

<tr><td><code>errclass</code></td><td>::mlir::mpi::MPI_ErrorClassEnumAttr</td><td><details><summary>MPI
error class name</summary>{{% markdown %}}Enum cases:
* MPI_SUCCESS (`MPI_SUCCESS`)
* MPI_ERR_ACCESS (`MPI_ERR_ACCESS`)
* MPI_ERR_AMODE (`MPI_ERR_AMODE`)
* MPI_ERR_ARG (`MPI_ERR_ARG`)
* MPI_ERR_ASSERT (`MPI_ERR_ASSERT`)
* MPI_ERR_BAD_FILE (`MPI_ERR_BAD_FILE`)
* MPI_ERR_BASE (`MPI_ERR_BASE`)
* MPI_ERR_BUFFER (`MPI_ERR_BUFFER`)
* MPI_ERR_COMM (`MPI_ERR_COMM`)
* MPI_ERR_CONVERSION (`MPI_ERR_CONVERSION`)
* MPI_ERR_COUNT (`MPI_ERR_COUNT`)
* MPI_ERR_DIMS (`MPI_ERR_DIMS`)
* MPI_ERR_DISP (`MPI_ERR_DISP`)
* MPI_ERR_DUP_DATAREP (`MPI_ERR_DUP_DATAREP`)
* MPI_ERR_ERRHANDLER (`MPI_ERR_ERRHANDLER`)
* MPI_ERR_FILE (`MPI_ERR_FILE`)
* MPI_ERR_FILE_EXISTS (`MPI_ERR_FILE_EXISTS`)
* MPI_ERR_FILE_IN_USE (`MPI_ERR_FILE_IN_USE`)
* MPI_ERR_GROUP (`MPI_ERR_GROUP`)
* MPI_ERR_INFO (`MPI_ERR_INFO`)
* MPI_ERR_INFO_KEY (`MPI_ERR_INFO_KEY`)
* MPI_ERR_INFO_NOKEY (`MPI_ERR_INFO_NOKEY`)
* MPI_ERR_INFO_VALUE (`MPI_ERR_INFO_VALUE`)
* MPI_ERR_IN_STATUS (`MPI_ERR_IN_STATUS`)
* MPI_ERR_INTERN (`MPI_ERR_INTERN`)
* MPI_ERR_IO (`MPI_ERR_IO`)
* MPI_ERR_KEYVAL (`MPI_ERR_KEYVAL`)
* MPI_ERR_LOCKTYPE (`MPI_ERR_LOCKTYPE`)
* MPI_ERR_NAME (`MPI_ERR_NAME`)
* MPI_ERR_NO_MEM (`MPI_ERR_NO_MEM`)
* MPI_ERR_NO_SPACE (`MPI_ERR_NO_SPACE`)
* MPI_ERR_NO_SUCH_FILE (`MPI_ERR_NO_SUCH_FILE`)
* MPI_ERR_NOT_SAME (`MPI_ERR_NOT_SAME`)
* MPI_ERR_OP (`MPI_ERR_OP`)
* MPI_ERR_OTHER (`MPI_ERR_OTHER`)
* MPI_ERR_PENDING (`MPI_ERR_PENDING`)
* MPI_ERR_PORT (`MPI_ERR_PORT`)
* MPI_ERR_PROC_ABORTED (`MPI_ERR_PROC_ABORTED`)
* MPI_ERR_QUOTA (`MPI_ERR_QUOTA`)
* MPI_ERR_RANK (`MPI_ERR_RANK`)
* MPI_ERR_READ_ONLY (`MPI_ERR_READ_ONLY`)
* MPI_ERR_REQUEST (`MPI_ERR_REQUEST`)
* MPI_ERR_RMA_ATTACH (`MPI_ERR_RMA_ATTACH`)
* MPI_ERR_RMA_CONFLICT (`MPI_ERR_RMA_CONFLICT`)
* MPI_ERR_RMA_FLAVOR (`MPI_ERR_RMA_FLAVOR`)
* MPI_ERR_RMA_RANGE (`MPI_ERR_RMA_RANGE`)
* MPI_ERR_RMA_SHARED (`MPI_ERR_RMA_SHARED`)
* MPI_ERR_RMA_SYNC (`MPI_ERR_RMA_SYNC`)
* MPI_ERR_ROOT (`MPI_ERR_ROOT`)
* MPI_ERR_SERVICE (`MPI_ERR_SERVICE`)
* MPI_ERR_SESSION (`MPI_ERR_SESSION`)
* MPI_ERR_SIZE (`MPI_ERR_SIZE`)
* MPI_ERR_SPAWN (`MPI_ERR_SPAWN`)
* MPI_ERR_TAG (`MPI_ERR_TAG`)
* MPI_ERR_TOPOLOGY (`MPI_ERR_TOPOLOGY`)
* MPI_ERR_TRUNCATE (`MPI_ERR_TRUNCATE`)
* MPI_ERR_TYPE (`MPI_ERR_TYPE`)
* MPI_ERR_UNKNOWN (`MPI_ERR_UNKNOWN`)
* MPI_ERR_UNSUPPORTED_DATAREP (`MPI_ERR_UNSUPPORTED_DATAREP`)
* MPI_ERR_UNSUPPORTED_OPERATION (`MPI_ERR_UNSUPPORTED_OPERATION`)
* MPI_ERR_VALUE_TOO_LARGE (`MPI_ERR_VALUE_TOO_LARGE`)
* MPI_ERR_WIN (`MPI_ERR_WIN`)
* MPI_ERR_LASTCODE (`MPI_ERR_LASTCODE`){{% /markdown
%}}</details></td></tr>
</table>

#### Operands:

| Operand | Description |
| :-----: | ----------- |
| `val` | MPI function call return value

#### Results:

| Result | Description |
| :----: | ----------- |
| `res` | 1-bit signless integer


### `mpi.send` (mpi::SendOp)

_Equivalent to `MPI_Send(ptr, size, dtype, dest, tag, MPI_COMM_WORLD)`_


Syntax:

```
operation ::= `mpi.send` `(` $ref `,` $tag `,` $rank `)` attr-dict `:` type($ref) `,` type($tag) `,` type($rank)(`->` type($retval)^)?
```

MPI_Send performs a blocking send of `size` elements of type `dtype` to
rank
`dest`. The `tag` value and communicator enables the library to
determine
the matching of multiple sends and receives between the same ranks.

Communicators other than `MPI_COMM_WORLD` are not supprted for now.

This operation can optionally return an `!mpi.retval` value that can be
used
to check for errors.

#### Operands:

| Operand | Description |
| :-----: | ----------- |
| `ref` | memref of any type values
| `tag` | 32-bit signless integer
| `rank` | 32-bit signless integer

#### Results:

| Result | Description |
| :----: | ----------- |
| `retval` | MPI function call return value


## Attribute definition

### MPI_ErrorClassEnumAttr

MPI error class name

Syntax:

```
#mpi.errclass<
  ::mlir::mpi::MPI_ErrorClassEnum   # value
>
```

Enum cases:
* MPI_SUCCESS (`MPI_SUCCESS`)
* MPI_ERR_ACCESS (`MPI_ERR_ACCESS`)
* MPI_ERR_AMODE (`MPI_ERR_AMODE`)
* ... *all other MPI error codes*

#### Parameters:

| Parameter | C++ type | Description |
| :-------: | :-------: | ----------- |
| value | `::mlir::mpi::MPI_ErrorClassEnum` | an enum of type
MPI_ErrorClassEnum |

## Type definition

### RetvalType

MPI function call return value

Syntax: `!mpi.retval`

This type represents a return value from an MPI function vall.
This value can be MPI_SUCCESS, MPI_ERR_IN_STATUS, or any error code.

This return value can be compared agains the known MPI error classes
represented by `#mpi.errclass` using the `mpi.retval_check` operation.
2024-02-15 21:43:04 +05:30
Leandro Lupori
e71369fcb0
[mlir][OpenMP] Add copyprivate support to omp.single (#80477)
This adds a new custom CopyPrivateVarList to the single operation.
Each list item is formed by a reference to the variable to be
updated, its type and the function to be used to perform the copy.

It will be translated to LLVM IR using OpenMP builder, that will
use the information in the copyprivate list to call
__kmpc_copyprivate.

This is patch 2 of 4, to add support for COPYPRIVATE in Flang.
Original PR: https://github.com/llvm/llvm-project/pull/73128
2024-02-15 08:29:24 -03:00
Abhinav271828
562790f371
[MLIR][Presburger] Implement vertex enumeration and chamber decomposition for polytope generating function computation. (#78987)
We implement a function to compute the generating function corresponding
to a full-dimensional parametric polytope whose tangent cones are all
unimodular.
We fix a bug in unimodGenFunc to check the absolute value of the index.
We also implement Matrix<T>::negateMatrix() and Matrix<T>::scaleRow for
convenience.
2024-02-15 11:03:32 +05:30
Diego Caballero
d592c8ec8f
Reapply "[mlir][vector] Drop inner unit dims for transfer ops on dynamic shapes." (#80712) (#81778)
This reverts commit b4c7152eb4f7971c111e3e2f60b55892def58d5d.

Downstream regression due to another issue that this PR exposes. We have identified the work-items to fix the new issue here: https://github.com/openxla/iree/issues/16406

Co-authored-by: Han-Chung Wang <hanchung@google.com>
2024-02-14 11:38:52 -08:00
Mehdi Amini
d99d258e3e Apply clang-tidy fixes for llvm-include-order in InferIntRangeInterface.cpp (NFC) 2024-02-14 10:11:38 -08:00
Mehdi Amini
bf4480d923 Apply clang-tidy fixes for readability-identifier-naming in SparseTensorRuntime.cpp (NFC) 2024-02-14 10:11:37 -08:00
Mehdi Amini
89dc313af9 Apply clang-tidy fixes for llvm-qualified-auto in VectorUnroll.cpp (NFC) 2024-02-14 10:11:37 -08:00
Mehdi Amini
8383bf2307 Apply clang-tidy fixes for llvm-else-after-return in IndexingUtils.cpp (NFC) 2024-02-14 10:11:37 -08:00
Mehdi Amini
1ddc5413b1 Apply clang-tidy fixes for readability-simplify-boolean-expr in TransformOps.cpp (NFC) 2024-02-14 10:11:37 -08:00
Javed Absar
7c4c274643
[MLIR][NFC] Fix some comments in padding transform. (#81741) 2024-02-14 17:00:42 +00:00
Matthias Springer
8f4cd2c7e3
[mlir][Transforms] Support moveOpBefore/After in dialect conversion (#81240)
Add a new rewrite class for "operation movements". This rewrite class
can roll back `moveOpBefore` and `moveOpAfter`.

`RewriterBase::moveOpBefore` and `RewriterBase::moveOpAfter` is no
longer virtual. (The dialect conversion can gather all required
information for rollbacks from listener notifications.)
2024-02-14 17:39:59 +01:00
Matthias Springer
8faefe36ed
[mlir][Transforms][NFC] Modularize block actions (#81237)
Throughout the rewrite process, the dialect conversion maintains a list
of "block actions" that can be rolled back upon failure. This commit
encapsulates the existing block actions into separate classes, making it
easier to add additional actions in the future.

This commit also renames "block actions" to "IR rewrites". In a
subsequent commit, an "operation rewrite" class that allows rolling back
movements of single operations is added. This is to support
`moveOpBefore` in the dialect conversion.

Rewrites have two methods: `commit()` commits an action. It can no
longer be rolled back afterwards. `rollback()` undoes a rewrite. It can
no longer be committed afterwards.
2024-02-14 17:15:30 +01:00
Matthias Springer
ea2d9383a2
[mlir][Transforms][NFC] Improve listener layering in dialect conversion (#81236)
Context: Conversion patterns provide a `ConversionPatternRewriter` to
modify the IR. `ConversionPatternRewriter` provides the public API. Most
function calls are forwarded/handled by `ConversionPatternRewriterImpl`.
The dialect conversion uses the listener infrastructure to get notified
about op/block insertions.

In the current design, `ConversionPatternRewriter` inherits from both
`PatternRewriter` and `Listener`. The conversion rewriter registers
itself as a listener. This is problematic because listener functions
such as `notifyOperationInserted` are now part of the public API and can
be called from conversion patterns; that would bring the dialect
conversion into an inconsistent state.

With this commit, `ConversionPatternRewriter` no longer inherits from
`Listener`. Instead `ConversionPatternRewriterImpl` inherits from
`Listener`. This removes the problematic public API and also simplifies
the code a bit: block/op insertion notifications were previously
forwarded to the `ConversionPatternRewriterImpl`. This is no longer
needed.
2024-02-14 16:51:28 +01:00
Oleksandr "Alex" Zinenko
bd8fcf75df
[mlir][python] expose LLVMStructType API (#81672)
Expose the API for constructing and inspecting StructTypes from the LLVM
dialect. Separate constructor methods are used instead of overloads for
better readability, similarly to IntegerType.
2024-02-14 15:03:04 +01:00
Sergei Lebedev
82f3cbc860
[MLIR][Python] Added a base class to all builtin floating point types (#81720)
This allows to

* check if a given ir.Type is a floating point type via isinstance() or
issubclass()
* get the bitwidth of a floating point type

See motivation and discussion in
https://discourse.llvm.org/t/add-floattype-to-mlir-python-bindings/76959.
2024-02-14 13:02:49 +01:00
Guray Ozen
b5d694ba14
[mlir][nvvm] Introduce nvvm.barrier OP (#81487)
This PR that introduces the `nvvm.barrier` OP to the NVVM dialect.
Currently, NVVM only supports the `nvvm.barrier0`, which synchronizes
all threads using barrier resource 0.

The new `nvvm.barrier` has two essential arguments: the barrier resource
and the number of threads. This added flexibility allows for selective
synchronization of threads within a CTA, aligning with the capabilities
provided by LLVM intrinsics or the PTX model.

I think we can deprecate `nvvm.barrier0` in favor of the more generic
`nvvm.barrier`.

```
// Equivalent to nvvm.barrier0 (or __syncthreads() in CUDA)
nvvm.barrier

// Synchronize all threads using the 3rd barrier resource.
nvvm.barrier id = 3

// Synchronize %numberOfThreads threads using the 3rd barrier resource.
nvvm.barrier id = 3 number_of_threads = %numberOfThreads
```
2024-02-14 08:28:45 +01:00
Mehdi Amini
70ebc78efb Apply clang-tidy fixes for performance-unnecessary-value-param in TransformOps.cpp (NFC) 2024-02-13 20:56:05 -08:00
Mehdi Amini
153661db5c Apply clang-tidy fixes for llvm-qualified-auto in TransformOps.cpp (NFC) 2024-02-13 20:56:05 -08:00
Mehdi Amini
d2f067693b Apply clang-tidy fixes for readability-identifier-naming in TosaOps.cpp (NFC) 2024-02-13 20:56:05 -08:00
Mehdi Amini
a854982aa1 Apply clang-tidy fixes for readability-simplify-boolean-expr in TensorOps.cpp (NFC) 2024-02-13 20:56:05 -08:00
Mehdi Amini
69bcb69bba Apply clang-tidy fixes for llvm-qualified-auto in TensorOps.cpp (NFC) 2024-02-13 20:56:05 -08:00
Han-Chung Wang
bc08cc2ac8
[mlir][tensor] Add support for tensor.pack static shapes inference. (#80848)
Fixes https://github.com/openxla/iree/issues/16317
2024-02-13 20:20:24 -08:00
erman-gurses
29d1aca05c
[AMDGPU][MLIR]Add shmem-optimization as an op using transform dialect (#81550)
This PR adds functionality to use shared memory optimization as an op
using transform dialect.
2024-02-13 17:42:04 -08:00
Peiming Liu
429919e328
[mlir][sparse][pybind][CAPI] remove LevelType enum from CAPI, constru… (#81682)
…ct LevelType from LevelFormat and properties instead.

**Rationale**
We used to explicitly declare every possible combination between
`LevelFormat` and `LevelProperties`, and it now becomes difficult to
scale as more properties/level formats are going to be introduced.
2024-02-13 16:45:22 -08:00
Kazu Hirata
f5cc961240 [mlir] Fix a warning
This patch fixes:

  mlir/lib/Target/LLVMIR/AttrKindDetail.h:65:1: error: unused function
  'getAttrNameToKindMapping' [-Werror,-Wunused-function]
2024-02-13 11:41:32 -08:00
David Truby
be9f8ffd81
[mlir][flang][openmp] Rework wsloop reduction operations (#80019)
This patch reworks the way that wsloop reduction operations function to
better match the expected semantics from the OpenMP specification,
following the rework of parallel reductions.

The new semantics create a private reduction variable as a block
argument which should be used normally for all operations on that
variable in the region; this private variable is then combined with the
others into the shared variable. This way no special omp.reduction
operations are needed inside the region. These block arguments follow
the loop control block arguments.

---------

Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
2024-02-13 19:13:54 +00:00
Ivan Butygin
35ef3994bf
[mlir][vector] ND vectors linearization pass (#81159)
Common backends (LLVM, SPIR-V) only supports 1D vectors, LLVM conversion
handles ND vectors (N >= 2) as `array<array<... vector>>` and SPIR-V
conversion doesn't handle them at all at the moment. Sometimes it's
preferable to treat multidim vectors as linearized 1D. Add pass to do
this. Only constants and simple elementwise ops are supported for now.

@krzysz00 I've extracted yours result type conversion code from
LegalizeToF32 and moved it to common place.

Also, add ConversionPattern class operating on traits.
2024-02-13 15:30:58 +03:00
Pranav Bhandarkar
55d6643ccf
[mlir][openmp] - Add the depend clause to omp.target and related offloading directives (#81081)
This patch adds support for the depend clause in a number of OpenMP
directives/constructs related to offloading. Specifically, it adds the
handling of the depend clause when it is used with the following
constructs

- target
- target enter data
- target update data
- target exit data
2024-02-13 11:15:51 +00:00
Benjamin Maxwell
79ce2c93ae
[mlir][VectorOps] Add conversion of 1-D vector.interleave ops to LLVM (#80966)
The 1-D case directly maps to LLVM intrinsics. The n-D case will be
handled by unrolling to 1-D first (in a later patch).

Depends on: #80965
2024-02-13 10:47:33 +00:00
Guray Ozen
0a600c34c8
[mlir][nvgpu] Make phaseParity of mbarrier.try_wait i1 (#81460)
Currently, `phaseParity` argument of `nvgpu.mbarrier.try_wait.parity` is
index. This can cause a problem if it's passed any value different than
0 or 1. Because the PTX instruction only accepts even or odd phase. This
PR makes phaseParity argument i1 to avoid misuse.

Here is the information from PTX doc:

```
The .parity variant of the instructions test for the completion of the phase indicated 
by the operand phaseParity, which is the integer parity of either the current phase or 
the immediately preceding phase of the mbarrier object. An even phase has integer 
parity 0 and an odd phase has integer parity of 1. So the valid values of phaseParity 
operand are 0 and 1.
```
See for more information:

https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-test-wait-mbarrier-try-wait
2024-02-13 09:50:34 +01:00
Guray Ozen
e892f323ea
[mlir][nvgpu] Allow TMA's last dim to be non-128B without swizzling (#81499)
Allow TMA's last dimension to be non-128B when swizzling mode is not
set.

Test `tma_load_64x8_8x128_noswizzle.mlir` is failing due to the
verifier. This PR will fix that
2024-02-13 09:17:09 +01:00
Guray Ozen
d7f59c8fb8
[mlir] Lower math dialect later in gpu-lower-to-nvvm-pipeline (#81489)
This PR moves lowering of math dialect later in the pipeline. Because
math dialect is lowered correctly by createConvertGpuOpsToNVVMOps for
GPU target, and it needs to run it first.

Reland #78556
2024-02-13 08:31:42 +01:00
Kareem Ergawy
070fad4228
[MLIR][OpenMP] Add omp.private op (#80955)
This PR adds a new op to the OpenMP dialect: `PrivateClauseOp`. This op
will be later used to model `[first]private` clauses for differnt OpenMP
directives.

This is part of productizing the "delayed privatization" PoC which can
be found in #79862.
2024-02-13 05:10:18 +01:00
Mehdi Amini
61f64d1c23 Apply clang-tidy fixes for llvm-qualified-auto in SparseTensorRewriting.cpp (NFC) 2024-02-12 13:27:49 -08:00
Mehdi Amini
56c385cd67 Apply clang-tidy fixes for modernize-loop-convert in SparseGPUCodegen.cpp (NFC) 2024-02-12 13:27:49 -08:00
Mehdi Amini
e546a6e95d Apply clang-tidy fixes for modernize-loop-convert in Utils.cpp (NFC) 2024-02-12 13:27:49 -08:00
Mehdi Amini
8189db978f Apply clang-tidy fixes for performance-unnecessary-value-param in BufferizableOpInterfaceImpl.cpp (NFC) 2024-02-12 13:27:48 -08:00