Commit Graph

816 Commits

Author SHA1 Message Date
zhoujingya 319e10771e [VENTUS][fix] Add `.rodata.ventus.resource` in linker script 2023-09-15 16:41:21 +08:00
zhoujingya 0642d65513 Add align to section .tohost && add section _end and _edata 2023-03-31 11:35:31 +08:00
zhoujingya 7dc6ac967f Add customized linker script for ventus * Original linker script is from zcc build-system, we just make some modification
Signed-off-by: zhoujingya <jing.zhou@terapines.com>
2023-03-30 17:42:07 +08:00
Benjamin Kramer 35b6faff86 [bazel] Add a missing dependency after 786cbb09ed 2022-12-02 16:56:05 +01:00
Matthias Springer c1fef4e88a [mlir][bufferization] Make `TensorCopyInsertionPass` a test pass
TensorCopyInsertion should not have been exposed as a pass. This was a flaw in the original design. It is a preparation step for bufferization and certain transforms (that would otherwise be legal) are illegal between TensorCopyInsertion and actual rewrite to MemRef ops. Therefore, even if broken down as two separate steps internally, they should be exposed as a single pass.

This change affects the sparse compiler, which uses `TensorCopyInsertionPass`. A new `SparsificationAndBufferizationPass` is added to replace all passes in the sparse tensor pipeline from `TensorCopyInsertionPass` until the actual bufferization (rewrite to memref/non-tensor). It is generally unsafe to run arbitrary passes in-between, in particular passes that hoist tensor ops out of loops or change SSA use-def chains along tensor ops.

Differential Revision: https://reviews.llvm.org/D138915
2022-12-02 15:38:02 +01:00
Guillaume Chatelet 5bdada9c69 [libc] Make libc memory functions weak by default for bazel
This helps override llvm libc functions for experiment purposes.

Differential Revision: https://reviews.llvm.org/D138999
2022-12-02 08:41:57 +00:00
Guillaume Chatelet 436c8f4420 [reland][libc] Add bcopy
Differential Revision: https://reviews.llvm.org/D138994
2022-12-01 10:07:04 +00:00
Guillaume Chatelet c5fe7eb216 Revert D138994 "[libc] Add bcopy"
Broke build bot

This reverts commit 186a15f7a9.
2022-12-01 09:55:36 +00:00
Guillaume Chatelet 186a15f7a9 [libc] Add bcopy
Differential Revision: https://reviews.llvm.org/D138994
2022-12-01 09:52:10 +00:00
Jakub Kuderski 9ad215bb3d [mlir][spirv] Drop experimental LinalgToSPIRV pass
This experimental pass is unused and obsolete.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D139056
2022-11-30 19:25:40 -05:00
Sterling Augustine 6db9c34f56 Fix bazel build for https://reviews.llvm.org/D138980 2022-11-30 10:17:20 -08:00
Hanhan Wang 9b16d9d271 [mlir][linalg] Add a new pattern to handle folding unit reduction dims.
The output operands will be added to input operands if the generic op (on tensors)
becomes an elementwise operation. The outputs of the generic op is still the same.
They will be cleaned up by ReplaceWithEmptyTensorIfUnused pattern.

This is https://reviews.llvm.org/D138251, plus a cmake dep fix.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D138843
2022-11-28 14:14:43 -08:00
Nicolas Vasilache 6e92d3fead [mlir][Test] Add a test pass to act as a sink towards LLVM conversion
This allows writing simple e2e tests where we can check for the proper materialization
of specific LLVM IR (e.g. `llvm.intr.fmuladd`).

Differential Revision: https://reviews.llvm.org/D138776
2022-11-28 00:59:55 -08:00
Nicolas Vasilache 6ff1233304 [mlir][Vector] Add a LowerVectorsOp to VectorTransformOps
This op significantly improves transfor dialect usage when using vector abstractions.
It also brings us closer to writing simple end-to-end unit tests that guard against subtle regressions in how patterns combine.

Differential Revision: https://reviews.llvm.org/D138723
2022-11-25 08:27:36 -08:00
Nicolas Vasilache c4ce8a40fa [mlir][Vector] Vector transform skeleton
Differential Revision: https://reviews.llvm.org/D134722
2022-11-25 04:51:50 -08:00
Benjamin Kramer 9e1650951b [bazel] Add copts attribute to gentbl_cc_library macro. 2022-11-24 20:16:24 +01:00
Hanhan Wang a827c5c7ab Revert "[mlir][linalg] Add a new pattern to handle folding unit reduction dims."
This reverts commit 6eee66d12a.

It breaks builds, see https://lab.llvm.org/buildbot/#/builders/61/builds/35742

Differential Revision: https://reviews.llvm.org/D138633
2022-11-23 19:07:01 -08:00
Hanhan Wang 6eee66d12a [mlir][linalg] Add a new pattern to handle folding unit reduction dims.
The output operands will be added to input operands if the generic op (on tensors)
becomes an elementwise operation. The outputs of the generic op is still the same.
They will be cleaned up by ReplaceWithEmptyTensorIfUnused pattern.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D138251
2022-11-23 10:47:10 -08:00
Benjamin Kramer 021e2ad247 [bazel] Add missing dependencies after 7a69a9d7ae 2022-11-23 10:45:15 +01:00
Benjamin Kramer 65644125be [bazel] Add missing dependency after 9aa505a28d 2022-11-22 10:46:52 +01:00
Aart Bik 99b3849d89 [mlir][sparse] introduce vectorization pass for sparse loops
This brings back previous SIMD functionality, but in a separate pass.
The idea is to improve this new pass incrementally, going beyond for-loops
to while-loops for co-iteration as welll (masking), while introducing new
abstractions to make the lowering more progressive. The separation of
sparsification and vectorization is a very good first step on this journey.

Also brings back ArmSVE support

Still to be fine-tuned:
  + use of "index" in SIMD loop (viz. a[i] = i)
  + check that all ops really have SIMD support
  + check all forms of reductions
  + chain reduction SIMD values

Reviewed By: dcaballe

Differential Revision: https://reviews.llvm.org/D138236
2022-11-21 16:12:12 -08:00
Benjamin Kramer 7f9e89962b [bazel] Port d6abdf46bc 2022-11-21 18:18:25 +01:00
Guillaume Chatelet e7fb6c394f [libc][test][NFC] bump mpfr version to 4.1.1 2022-11-21 09:38:42 +00:00
Alex Zinenko 13b8362f02 [mlir] bazel for D137997 2022-11-21 10:21:02 +01:00
Tue Ly e205fc1836 [libc] Add sub_with_borrow to builtin_wrapper.h
Add sub_with_borrow to builtin_wrapper.h to be used in UInt.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D138182
2022-11-19 16:12:26 -05:00
Guillaume Chatelet d856e5feac [reland][libc][bazel] Add tests to the bazel build
This patch adds bazel tests for llvm-libc.

Some math tests rely on the `mpfr` library. This is controlled via the `--@llvm-project//libc:libc_math_mpfr` flag. It can take three values:
 - `external` (default) will build `mpfr` and `gmp` from source.
 - `system` will use the system installed `mpfr` library.
 - `disable` will skip tests relying on `mpfr`.

Reviewed By: sivachandra, GMNGeoffrey

Differential Revision: https://reviews.llvm.org/D119547
2022-11-18 13:20:52 +00:00
Adrian Kuegel 9e088effae [mlir][Bazel] Add DebugImporter sources to build target. 2022-11-18 10:19:30 +01:00
Alexander Shaposhnikov f102fe7304 Revert "Revert "[opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm""
This reverts commit 7f608a2497
and removes the dependency of Object on IRPrinter.
2022-11-18 08:58:31 +00:00
Adrian Kuegel 52301a188f [llvm][Bazel] Remove dependency to avoid cycyle.
Differential Revision: https://reviews.llvm.org/D138266
2022-11-18 08:47:35 +01:00
Alexander Shaposhnikov 34ab474348 [opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm
Enable using -module-summary with -S
(similarly to what currently can be achieved with opt <input> -o - | llvm-dis).
This is a recommit of ef9e62469.

Test plan: ninja check-all

Differential revision: https://reviews.llvm.org/D137768
2022-11-18 05:04:07 +00:00
Alexander Shaposhnikov 7059a6c32c [IR] Split out IR printing passes into IRPrinter
This diff splits out (from LLVMCore) IR printing passes into IRPrinter.
This structure is similar to what we already have for IRReader and
enables us to avoid circular dependencies between LLVMCore and Analysis
(this is a preparation for https://reviews.llvm.org/D137768).
The legacy interface is left unchanged, once the legacy pass manager
is removed (in the future) we will be able to clean it up further.
The bazel build configuration has been updated as well.

Test plan:
1/ Tested the following cmake configurations: static/dynamic linking * lld/gold * clang/gcc
2/ bazel build --config=generic_clang @llvm-project//...

Differential revision: https://reviews.llvm.org/D138081
2022-11-18 01:47:56 +00:00
Guillaume Chatelet 0e91a0913c Revert D119547 "[libc][bazel] Add tests to the bazel build"
The introducion of `constraint_setting` generated issues with downstream
integration.

This reverts commit 3c13d83ad5.
2022-11-17 20:20:57 +00:00
Jakub Kuderski 89399ad85d [bazel][mlir] Add missing dependency for D138178 2022-11-17 14:10:16 -05:00
Guillaume Chatelet 3c13d83ad5 [libc][bazel] Add tests to the bazel build
@GMNGeoffrey let me know it there's a better way to import MPFR and GMP for the purpose of testing libc math functions.

Differential Revision: https://reviews.llvm.org/D119547
2022-11-17 14:19:56 +00:00
wren romano 9d862992d1 [mlir][sparse] Adding safe comparison functions to MLIRSparseTensorRuntime.
Different platforms use different signedness for `StridedMemRefType::sizes` and `std::vector::size_type`, and this has been causing a lot of portability issues re [-Wsign-compare] warnings.  These new functions ensure that we need never worry about those signedness warnings ever again.

Also merging CheckedMul.h into ArithmeticUtils.h

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D138149
2022-11-16 16:16:46 -08:00
Guillaume Chatelet a5f4f12b5e [libc][NFC] move memmove implementation
Moving memmove implementation to its own file for symmetry with other mem functions.

Differential Revision: https://reviews.llvm.org/D136687
2022-11-16 10:36:14 +00:00
Guillaume Chatelet 534f4bca58 [libc] remove mem functions dead code
Let's wait a bit for https://reviews.llvm.org/D136595 to settle before
cleaning up. Just in case we would need to revert.

Differential Revision: https://reviews.llvm.org/D136673
2022-11-16 10:29:29 +00:00
Benjamin Kramer e8a83c8dbf [bazel] Remove reference to file removed in 70dc3b811e 2022-11-16 00:35:25 +01:00
Mahesh Ravishankar fc367dfa67 [mlir] Remove `Transforms/SideEffectUtils.h` and move the methods into `Interface/SideEffectInterfaces.h`.
The methods in `SideEffectUtils.h` (and their implementations in
`SideEffectUtils.cpp`) seem to have similar intent to methods already
existing in `SideEffectInterfaces.h`. Move the decleration (and
implementation) from `SideEffectUtils.h` (and `SideEffectUtils.cpp`)
into `SideEffectInterfaces.h` (and `SideEffectInterface.cpp`).

Also drop the `SideEffectInterface::hasNoEffect` method in favor of
`mlir::isMemoryEffectFree` which actually recurses into the operation
instead of just relying on the `hasRecursiveMemoryEffectTrait`
exclusively.

Differential Revision: https://reviews.llvm.org/D137857
2022-11-15 20:07:35 +00:00
Tue Ly bc10a41080 [libc][math] Improve the performance and error printing of UInt.
Use add_with_carry builtin to improve the performance of
addition and multiplication of UInt class.  For 128-bit, it is as
fast as using __uint128_t.

Microbenchmark for addition:
https://quick-bench.com/q/-5a6xM4T8rIXBhqMTtLE-DD2h8w

Microbenchmark for multiplication:
https://quick-bench.com/q/P2muLAzJ_W-VqWCuxEJ0CU0bLDg

Microbenchmark for shift right:
https://quick-bench.com/q/N-jkKXaVsGQ4AAv3k8VpsVkua5Y

Microbenchmark for shift left:
https://quick-bench.com/q/5-RzwF8UdslC-zuhNajXtXdzLRM

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D137871
2022-11-15 14:17:59 -05:00
Johannes Reifferscheid 67df73030f Update bazel files. 2022-11-15 07:48:51 +01:00
wren romano c518745bba [mlir][sparse] Making way for SparseTensorRuntime to support non-permutations
Systematically updates the SparseTensorRuntime to properly distinguish tensor-dimensions from storage-levels (and their associated ranks, shapes, sizes, indices, etc).  With a few exceptions which are noted in the code, this ensures the runtime has all the **semantic** changes necessary to support non-permutations.

(Whereas **operationally**, since we're still using `std::vector<uing64_t>` to represent the mappings, there's no way to pass in any interesting non-permutations.  Changing the representation to `std::function` will be done in a separate differential.)

Depends On D137680

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D137681
2022-11-14 13:48:41 -08:00
Benjamin Kramer b40126bf54 [bazel] Add another missing dependency after D137833
While there run buildifier.
2022-11-14 19:03:19 +01:00
Chenguang Wang c21915f5b4 [bazel] Fix Bufferization dialect build
D137833 added a new .td file and updated existing files to use it.
It broke bazel build.

Differential Revision: https://reviews.llvm.org/D137961
2022-11-14 18:58:02 +01:00
Christian Sigg e28cc9382e [mlir][bazel] NFC: change MLIR_GPU_TO_CUBIN_PASS_ENABLE from `defines` to `local_defines`. 2022-11-14 12:23:35 +01:00
Oleg Shyshkov e6598b053d Revert "Revert "[mlir][linalg] Replace "string" iterator_types attr with enums in LinalgInterface.""
With python code fixed.

This reverts commit 41280908e4.
2022-11-11 10:54:08 +01:00
Guray Ozen 6663f34704 [mlir] Introduce device mapper attribute for `thread_dim_map` and `mapped to dims`
`scf.foreach_thread` defines mapping its loops to processors via an integer array, see an example below. A lowering can use this mapping. However, expressing mapping as an integer array is very confusing, especially when there are multiple levels of parallelism. In addition, the op does not verify the integer array. This change introduces device mapping attribute to make mapping descriptive and verifiable. Then it makes GPU transform dialect use it.

```
scf.foreach_thread (%i, %j) in (%c1, %c2) {
	scf.foreach_thread (%i2, %j2) in (%c1, %c2)
	{...} { thread_dim_mapping = [0, 1]}
} { thread_dim_mapping = [0, 1]}
```

It first introduces a `DeviceMappingInterface` which is an attribute interface. `scf.foreach_thread` defines its mapping via this interface. A lowering must define its attributes and implement this interface as well. This way gives us a clear validation.

The change also introduces two new attributes (`#gpu.thread<x/y/z>` and `#gpu.block<x,y,z>` ). After this change, the above code prints as below, as seen here, this way clarifies the loop mappings. The change also implements consuming of these two new attribute by the transform dialect. Transform dialect binds the outermost loops to the thread blocks and innermost loops to threads.

```
scf.foreach_thread (%i, %j) in (%c1, %c2) {
	scf.foreach_thread (%i2, %j2) in (%c1, %c2)
	{...} { thread_dim_mapping = [#gpu.thread<x>, #gpu.thread<y>]}
} { thread_dim_mapping = [#gpu.block<x>, #gpu.block<y>]}
```

Reviewed By: ftynse, nicolasvasilache

Differential Revision: https://reviews.llvm.org/D137413
2022-11-11 08:44:57 +01:00
Benjamin Kramer 0caf2bac34 [bazel] Provide CLANG_VERSION_MAJOR_STRING for e1b88c8a09 2022-11-10 15:24:37 +01:00
Krasimir Georgiev f76d3f328a [bazel] Add LoongArch for 85f08c4197 2022-11-10 14:48:45 +01:00
Jordan Rupprecht f57557de70 [bazel] Update gtest move to third-party
a11cd0d94e moved googletest to third-party.

This creates a corresponding BUILD file in third-party/unittest, moved from the chunk in llvm/BUILD.bazel.

We must refine the .bazelignore which is setup to ignore the benchmarking library so that we don't ignore the new dir here.
2022-11-09 20:48:11 -08:00