Commit Graph

1482 Commits

Author SHA1 Message Date
Razvan Lupusoru
61278ec348 [openacc][openmp] Add dialect representation for acc atomic operations (#65493)
The OpenACC standard specifies an `atomic` construct in section 2.12 (of
3.3 spec), used to ensure that a specific location is accessed or
updated atomically. Four different clauses are allowed: `read`, `write`,
`update`, or `capture`. If no clause appears, it is as if `update` is
used.

The OpenMP specification defines the same clauses for `omp atomic`. The
types of expression and the clauses in the OpenACC spec match the OpenMP
spec exactly. The main difference is that the OpenMP specification is a
superset - it includes clauses for `hint` and `memory order`. It also
allows conditional expression statements. But otherwise, the expression
definition matches.

Thus, for OpenACC, we refactor and reuse the OpenMP implementation as
follows:
* The atomic operations are duplicated in OpenACC dialect. This is
preferable so that each language's semantics are precisely represented
even if specs have divergence.
* However, since semantics overlap, a common interface between the
atomic operations is being added. The semantics for the interfaces are
not generic enough to be used outside of OpenACC and OpenMP, and thus
new folders were added to hold common pieces of the two dialects.
* The atomic interfaces define common accessors (such as getting `x` or
`v`) which match the OpenMP and OpenACC specs. It also adds common
verifiers intended to be called by each dialect's operation verifier.
* The OpenMP write operation was updated to use `x` and `expr` to be
consistent with its other operations (that use naming based on spec).

The frontend lowering necessary to generate the dialect can also be
reused. This will be done in a follow up change.
2023-09-06 13:54:39 -07:00
NAKAMURA Takumi
cd25a50a8f [Bazel] Introduce //compiler-rt:profile
At the moment,

  - Provide only `profile`
  - Will invoke error unless the platform is linux

Differential Revision: https://reviews.llvm.org/D156095
2023-09-06 22:10:30 +09:00
Guillaume Chatelet
4acc3ffbb0 [reland][libc][NFC] split type_traits / utility in separate files (#65314)
`type_traits` and `utility` refer to each other in their
implementations. Also `type_traits` starts to become too big to be
manageable. This PR splits each function into individual files. FTR this
is [how libcxx handles large headers as
well](https://github.com/llvm/llvm-project/tree/main/libcxx/include/__type_traits).

The reland adds two missing functions : is_destructible_v and is_reference_v
2023-09-06 09:23:00 +00:00
Guillaume Chatelet
bcdbd0bd0b Revert "[libc][NFC] split type_traits / utility in separate files (#65314)"
This reverts commit b793c7e530.
It broke the libc-x86_64-debian-gcc-fullbuild-dbg build bot.
https://lab.llvm.org/buildbot/#/builders/250/builds/9776
2023-09-06 08:47:45 +00:00
Guillaume Chatelet
b793c7e530 [libc][NFC] split type_traits / utility in separate files (#65314)
`type_traits` and `utility` refer to each other in their
implementations. Also `type_traits` starts to become too big to be
manageable. This PR splits each function into individual files. FTR this
is [how libcxx handles large headers as
well](https://github.com/llvm/llvm-project/tree/main/libcxx/include/__type_traits).
2023-09-06 10:31:08 +02:00
Guillaume Chatelet
56426c6cdf [libc] customizable namespace 1/4 (#65321)
This implements the first step of
https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079

Make required Bazel and CMake preparatory changes which define the var
for the customizable namespace and use it (pass it as a compile option
-DLIBC_NAMESPACE=<...>).

Differential Revision: https://reviews.llvm.org/D159112
2023-09-06 10:27:56 +02:00
Benjamin Kramer
1078627cf8 [bazel] Add missing dependency for e55e36de7a 2023-09-05 19:58:38 +02:00
Benjamin Kramer
e8144c7011 [bazel] Port bc45acbddc 2023-09-05 11:48:04 +02:00
Martin Erhart
8037deb7af [mlir][memref] Add pass to expand realloc operations, simplify lowering to LLVM
There are two motivations for this change:
1. It considerably simplifies adding support for the realloc operation to the
   new buffer deallocation pass by lowering the realloc such that no
   deallocation operation is inserted and the deallocation pass itself can
   insert that dealloc
2. The lowering is expressed on a higher level and thus easier to understand,
   and the lowerings of the memref operations it is composed of don't have to
   be duplicated in the MemRefToLLVM lowering (also see discussion in
   https://reviews.llvm.org/D133424)

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D159430
2023-09-05 08:58:40 +00:00
Christian Sigg
4ae0db4ee6 [bazel][mlir] Add missing file after @62e90db 2023-09-05 08:07:15 +02:00
Nicolas Vasilache
62e90db21b [mlir][Transform] Add an example of a preloaded reference lowering to LLVM
Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D159364
2023-09-04 16:20:24 +02:00
Adrian Kuegel
ba6af8f63c [mlir][Bazel] Adapt to 2ae5d1c790 2023-09-04 14:08:37 +02:00
Aart Bik
9ce445b8c7 [mlir][sparse] simplification of sparse runtime support lib
Incorporated two header files directly into other since
other parts were used (and it makes it hard to find the
definitions). Removed TODOs that are less likely to be done.

Reviewed By: yinying-lisa-li

Differential Revision: https://reviews.llvm.org/D159381
2023-09-01 14:00:19 -07:00
Hanhan Wang
c5dee18b63 [mlir][memref] Add support for erasing dead allocations.
Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D159135
2023-09-01 13:30:26 -07:00
Mehdi Amini
471004c5c9 Revert "[mlir][sparse] simplification of sparse runtime support lib"
This reverts commit 14c58cf5c3.

The gcc7 build is broken.
2023-09-01 11:50:14 -07:00
Aart Bik
14c58cf5c3 [mlir][sparse] simplification of sparse runtime support lib
Incorporated two header files directly into other since
other parts were used (and it makes it hard to find the
definitions). Removed TODOs that are less likely to be done.

Reviewed By: Peiming

Differential Revision: https://reviews.llvm.org/D159330
2023-09-01 09:28:48 -07:00
Martin Erhart
34a35a8b24 [mlir] Move FunctionInterfaces to Interfaces directory and inherit from CallableOpInterface
Functions are always callable operations and thus every operation
implementing the `FunctionOpInterface` also implements the
`CallableOpInterface`. The only exception was the FuncOp in the toy
example. To make implementation of the `FunctionOpInterface` easier,
this commit lets `FunctionOpInterface` inherit from
`CallableOpInterface` and merges some of their methods. More precisely,
the `CallableOpInterface` has methods to get the argument and result
attributes and a method to get the result types of the callable region.
These methods are always implemented the same way as their analogues in
`FunctionOpInterface` and thus this commit moves all the argument and
result attribute handling methods to the callable interface as well as
the methods to get the argument and result types. The
`FuntionOpInterface` then does not have to declare them as well, but
just inherits them from the `CallableOpInterface`.
Adding the inheritance relation also required to move the
`FunctionOpInterface` from the IR directory to the Interfaces directory
since IR should not depend on Interfaces.

Reviewed By: jpienaar, springerm

Differential Revision: https://reviews.llvm.org/D157988
2023-08-31 11:28:23 +00:00
pvanhout
54d0cf58fb [TableGen] Remove & Replace old GICombiner Backend
The MatchTable-based GlobalISel Combiner backend is the new default. There are no in-tree users left of the old backend.

- Removed implementation of old MatchDAG-based Combiner, including tests, the backend itself and all supporting code.
- Renamed MatchTable backend to `GlobalISelCombinerEmitter.cpp` + removed "-matchtable" from its CL option.
    - no need to have a verbose name as it's the only backend left now.

Reviewed By: aemerson

Differential Revision: https://reviews.llvm.org/D158710
2023-08-31 13:16:07 +02:00
Oleg Shyshkov
a84b09f894 [mlir][bazel] Fix bazel build for d774622. 2023-08-31 13:14:52 +02:00
Matthias Springer
6ecebb496c [mlir][bufferization] Support unstructured control flow
This revision adds support for unstructured control flow to the bufferization infrastructure. In particular: regions with multiple blocks, `cf.br`, `cf.cond_br`.

Two helper templates are added to `BufferizableOpInterface.h`, which can be implemented by ops that supported unstructured control flow in their regions (e.g., `func.func`) and ops that branch to another block (e.g., `cf.br`).

A block signature is always bufferized together with the op that owns the block.

Differential Revision: https://reviews.llvm.org/D158094
2023-08-31 12:55:53 +02:00
Martin Erhart
950f0944c9 [mlir][bufferization] Factor out bufferization.dealloc lowering into separate pass
Moves the lowering of `bufferization.dealloc` to memref into a separate pass,
but still registers the pattern in the conversion pass.  This is helpful when
some tensor values (and thus `to_memref` or `to_tensor` operations) still
remain, e.g., when the function boundaries are not converted, or when constant
tensors are converted to memref.get_global at a later point.

However, it is still recommended to perform all bufferization before
deallocation to avoid memory leaks as all memref allocations inserted after the
deallocation pass was applied, have to be handled manually.

Note: The buffer deallocation pass assumes that memref values defined by
`bufferization.to_memref` don't return ownership and don't have to be
deallocated. `bufferization.to_tensor` operations are handled similarly to
`bufferization.clone` operations with the exception that the result value is
not handled because it's a tensor (not a memref).

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D159180
2023-08-31 07:10:31 +00:00
Fangrui Song
c7dce0283b [Driver] Adjust -fsanitize=function & -mexecute-only interop after D158614
clangDriver depends on clangBasic, so clangBasic should not depend on
clangDriver, even just its header. Also remove clangBasic's dependency
on LLVMOption.

The issue can be seen through the bazel commit
d26dd681f9 which is reverted now.

Add hasFlagNoClaim and use it as we don't want to suppress
-Wunused-command-line-argument for -mexecute-only just because
-fsanitize= is specified.
2023-08-30 20:30:13 -07:00
Pranav Kant
39f6a31eaa [Bazel] Better fix for d26dd681
Don't use glob for specific files
2023-08-31 03:07:49 +00:00
Reid Kleckner
5bc514b74e [bazel] Remove the dependency on CodeGen from MCTargetDesc & Utils
This means llvm-mc should now build without depending on the target
CodeGen libraries.

Fix up a few includes in RISCV, AMDGPU, and X86 MCA to avoid transitive
deps on CodeGen.

Fixes #64166
2023-08-30 18:21:28 -07:00
Reid Kleckner
52abac26ef [bazel] Add missing dep from DwarfLinkerParallel to Object
llvm-dwarfutil now builds successfully with Bazel.
2023-08-30 16:26:44 -07:00
Pranav Kant
d26dd681f9 [Bazel] Fix build 2023-08-30 19:30:12 +00:00
Tue Ly
76bb278ebb [libc][math] Implement double precision exp10 function correctly rounded for all rounding modes.
Implement double precision exp10 function correctly rounded for all
rounding modes.  Using the same algorithm as double precision exp
(https://reviews.llvm.org/D158551) and exp2 (https://reviews.llvm.org/D158812)
functions.

Reviewed By: zimmermann6

Differential Revision: https://reviews.llvm.org/D159143
2023-08-30 08:43:50 -04:00
Aliia Khasanova
84072f7beb [bazel] Fix build files for adea7e7032 2023-08-29 19:32:13 +02:00
Aliia Khasanova
5f660839e4 Fix bazel build file for bbf0733030. 2023-08-29 09:52:52 +02:00
Tue Ly
eee564f20a [libc][bazel] Add missing math functions and tests (exp, exp2, erff) to bazel layout.
Add missing math functions and tests (exp, exp2, erff) to bazel layout.

Reviewed By: gchatelet

Differential Revision: https://reviews.llvm.org/D158989
2023-08-28 10:47:54 -04:00
Adrian Kuegel
e957bbe9e6 [mlir][Bazel] Add missing dependency after dc3dc97410 2023-08-28 07:57:38 +02:00
Tue Ly
b825808d8b [libc][bazel] Add missing triple_double header and target to bazel overlay.
Add missing triple_double header and target to bazel overlay.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D158877
2023-08-25 15:28:02 -04:00
Yijia Gu
2289c7f760 set correct mlir dir for td file 2023-08-23 21:42:02 -07:00
Yijia Gu
83cc73a3d4 add openmp python binding in bazel 2023-08-23 21:39:28 -07:00
Yijia Gu
7d889c044a fix format error in python/BUILD.bazel 2023-08-23 18:24:33 -07:00
Yijia Gu
ad7e6e90c2 update bazel for python binding 2023-08-23 17:50:29 -07:00
Krasimir Georgiev
4d4ed5b215 [bazel] keep args one-per-line
Allows more easily to manage custom additions and removals.
2023-08-23 08:44:13 +00:00
Benjamin Kramer
cb9b3ad50b [bazel] Port 23459f13fc 2023-08-22 12:16:35 +02:00
Christian Sigg
c78b6c059c [Bazel][mlir] Add more missing dependencies after 7c4e8c6 2023-08-22 08:02:00 +02:00
Christian Sigg
3eba48b84c [Bazel][mlir] Add missing dependencies after 7c4e8c6 2023-08-22 06:26:47 +02:00
Benjamin Kramer
b0ce19209f [bazel][libc] Add missing dependency for cd96aa7e10 2023-08-21 13:58:01 +02:00
Adrian Kuegel
45325a2de9 [mlir][Bazel] Add missing dependencies after 14de5a2a4f 2023-08-21 09:48:44 +02:00
Benjamin Kramer
e940926f3a [bazel] Make transitive OpBase.td inclusions visible to pdll tests 2023-08-19 20:02:02 +02:00
Benjamin Kramer
e51b21a1ff [bazel] Add new files from b448fe0c12 2023-08-19 19:56:24 +02:00
Dmitry Chernenkov
b7d304300a [Bazel] Add BitcodeConvenience.h 2023-08-18 12:25:01 +00:00
Dmitry Chernenkov
d2aff81285 [Bazel] Fix MLIR build 2023-08-18 09:40:34 +00:00
Dmitry Chernenkov
8f4a0b701f [Bazel] Fix for Enable multicall driver 2023-08-17 23:26:51 +00:00
Dmitry Chernenkov
c9f8aeec5f Revert "[Bazel] Fix for Enable multicall driver"
This reverts commit 4a235f65fa.
2023-08-17 08:33:52 +00:00
Dmitry Chernenkov
4a235f65fa [Bazel] Fix for Enable multicall driver 2023-08-17 07:56:24 +00:00
Adrian Kuegel
fb2264f269 [mlir][Bazel] Remove superfluous (?) strip_include_prefix settings.
Differential Revision: https://reviews.llvm.org/D157854
2023-08-14 13:07:36 +02:00