1238 Commits

Author SHA1 Message Date
Fangrui Song
43bec3376c Remove HAVE_STRERROR
Most systems support strerror_r. For the remaining systems (e.g. MSVC) strerror_s and
strerror can be used as fallbacks. We don't have a supported operating
system/compiler that doesn't provide `strerror`.

Close https://github.com/llvm/llvm-project/issues/62804

https://github.com/flang-compiler/f18/pull/1068 added a fallback
when strerror is unavailable, but I think the code path is dead.

Reviewed By: serge-sans-paille, vzakhari

Differential Revision: https://reviews.llvm.org/D151718
2023-05-30 14:12:20 -07:00
Benjamin Kramer
c644341c2c Revert "[mlir][bazel] Port for 660f714, third attempt"
This reverts commit 421a7f814fb15dedde1b0b13a9e4ddcf7b502086. Dependency
doesn't seem to be necessary and would pull in all of LLVM's codegen
into mlir users that don't require it.
2023-05-30 11:41:24 +02:00
Haojian Wu
d9118b9eea [bazel] Port for 9f6250f591057e68c0bda564716b6918b8e39a84, part2.
The part1 was missing the generation of
arm_sme_draft_spec_subject_to_change.h, this patch adds it.
2023-05-30 08:05:39 +02:00
Haojian Wu
a0b0bf38e5 [bazel] Port for 9f6250f591057e68c0bda564716b6918b8e39a84. 2023-05-29 07:19:57 +02:00
Eugene Burmako
421a7f814f [mlir][bazel] Port for 660f714, third attempt
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D151618
2023-05-27 13:26:06 -07:00
Eugene Burmako
35d7fa45bd [MLIR] Reformat the Bazel build
This patch normalizes formatting of the the root BUILD.bazel file by: 1) adjusting indentation a little bit, 2) alphabetically ordering dependencies. These small deviations were introduced by some yesterday's patches:
  * https://reviews.llvm.org/D151104
  * https://reviews.llvm.org/D151346
  * https://reviews.llvm.org/rG16fe2b37365c00b0c6d0ed22c2e6521f2d5de01a
  * https://reviews.llvm.org/rG4d1cd1d8caab13d6b76ce6fc4ff76a01a7931c34

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D151499
2023-05-27 13:00:52 -07:00
Benjamin Kramer
a218c99181 [bazel] Add missing dependency for ddeab07ca63235f8d952e1171b56fdb0f2d761c9 2023-05-27 12:04:36 +02:00
Haojian Wu
fe01c08424 [mlir][bazel] Port for 660f714e26999d266232a1fbb02712bb879bd34e, second
attempt.
2023-05-27 08:37:45 +02:00
Haojian Wu
5217498dc8 [mlir][bazel] Port for 660f714e26999d266232a1fbb02712bb879bd34e 2023-05-27 08:05:19 +02:00
Benjamin Kramer
198a887fcf [bazel][libc] Add another missing dependency 2023-05-26 13:12:21 +02:00
Benjamin Kramer
596887da2e [bazel][libc] Add file missing for 25174976e19b2ef916bb94f4613662646c95cd46 2023-05-26 12:24:36 +02:00
Benjamin Kramer
3d91caec4b [bazel][libc] Adjust for 4f1fe19df385445fabde47998affca50c7f1bc1e
This also required a build rule for error_to_string, so add that too.
2023-05-26 12:16:48 +02:00
Benjamin Kramer
e1d1cd43ff [bazel] Run buildifier on libc BUILD. NFC. 2023-05-26 12:16:47 +02:00
Eugene Burmako
ecc70b4474 [MLIR] Fixup Bazel build for Add a pattern for transforming gpu.global_id to thread + blockId * blockDim
This patch updates the Bazel build to catch up with changes in https://reviews.llvm.org/D148978.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D151496
2023-05-25 14:28:28 -07:00
Siva Chandra Reddy
daeee56798 [libc] Add macro LIBC_THREAD_LOCAL.
It resolves to thread_local on all platform except for the GPUs on which
it resolves to nothing. The use of thread_local in the source code has been
replaced with the new macro.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D151486
2023-05-25 19:53:52 +00:00
Sterling Augustine
023504f29a Add missing dependency for tests. 2023-05-25 10:52:18 -07:00
Matthias Springer
7d36a468aa [mlir][tensor] TrackingListener: Support cast-like InsertSliceOps with dynamic shape
When looking for payload op replacements, rank-expanding InsertSliceOps of dynamically-typed tensors are now supported.

Differential Revision: https://reviews.llvm.org/D151444
2023-05-25 19:15:13 +02:00
Matthias Springer
047e7ff253 [mlir][tensor] TrackingListener: Find replacement ops through cast-like InsertSliceOps
Certain InsertSliceOps, that do not use elements from the destination, are treated like casts when looking for replacement ops. Such InsertSliceOps are typically rank expansions.

Tensors with dynamic shape are not supported at the moment.

Also adds test cases for the TrackingListener.

Differential Revision: https://reviews.llvm.org/D151422
2023-05-25 18:49:24 +02:00
Guillaume Chatelet
298843cd66 [libc][test] Drastically reduce mem test runtime
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D151450
2023-05-25 15:05:21 +00:00
Aliia Khasanova
6a939aa80a Fix build file for 1264849299
Differential Revision: https://reviews.llvm.org/D151427
2023-05-25 15:44:48 +02:00
Tobias Hieta
f98ee40f4b
[NFC][Py Reformat] Reformat python files in the rest of the dirs
This is an ongoing series of commits that are reformatting our
Python code. This catches the last of the python files to
reformat. Since they where so few I bunched them together.

Reformatting is done with `black`.

If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours <yourfile> and then reformat it
with black.

If you run into any problems, post to discourse about it and
we will try to help.

RFC Thread below:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Reviewed By: jhenderson, #libc, Mordante, sivachandra

Differential Revision: https://reviews.llvm.org/D150784
2023-05-25 11:17:05 +02:00
Siva Chandra Reddy
aaf758c44a [libc][bazel] Add targets for fmod* and scalbn*.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D151354
2023-05-25 06:29:04 +00:00
Sterling Augustine
4d1cd1d8ca remove useless visibility spec from bazel build. 2023-05-24 15:11:31 -07:00
Eugene Burmako
9598fe54e2 [MLIR] Update Bazel build to finish moving PDL-related transform ops into an extension
https://reviews.llvm.org/D151104 moved PDL-related transform ops into an extension and updated the Bazel build, but one tiny thing fell through the cracks - TransformOpsPyFiles also needs to include the newly introduced `mlir/python/mlir/dialects/_transform_pdl_extension_ops_ext.py`.

Reviewed By: saugustine, bkramer

Differential Revision: https://reviews.llvm.org/D151368
2023-05-24 22:04:10 +02:00
Sterling Augustine
16fe2b3736 Disable MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS for bazel builds. 2023-05-24 11:05:43 -07:00
Sterling Augustine
1894c741b0 Fix bazel build for https://reviews.llvm.org/D144552
Differential Revision: https://reviews.llvm.org/D151346
2023-05-24 09:39:53 -07:00
Alex Zinenko
94d608d410 [mlir] move PDL-related transform ops into an extension
The initial bring-up of the Transform dialect relied on PDL to provide
the default handle type (`!pdl.operation`) and the matching capability.
Both are now provided natively by the Transform dialect removing the
reason to have a hard dependency on the PDL dialect and its interpreter.
Move PDL-related transform operations into a separate extension.

This requires us to introduce a dialect state extension mechanism into
the Transform dialect so it no longer needs to know about PDL constraint
functions that may be injected by extensions similarly to operations and
types. This mechanism will be reused to connect pattern application
drivers and the Transform dialect.

This completes the restructuring of the Transform dialect to remove
overrilance on PDL.

Note to downstreams: flow that are using `!pdl.operation` with Transform
dialect operations will now require `transform::PDLExtension` to be
applied to the transform dialect in order to provide the transform
handle type interface for `!pdl.operation`.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D151104
2023-05-24 12:25:06 +00:00
Tue Ly
a2ac3678cd [libc][bazel] Add log, log2, log10, log1p to bazel layout.
Add log, log2, log10, log1p and their unit tests to bazel layout.

Reviewed By: gchatelet

Differential Revision: https://reviews.llvm.org/D151252
2023-05-24 07:43:58 -04:00
Benjamin Kramer
b0a09bce8d [bazel] Fix build after 0bf120a82040f7ffaba0f0ab72a983f1cd9343ab 2023-05-24 11:14:18 +02:00
Aaron Siddhartha Mondal
75632fec58
[bazel] Add clang-offload-packager and clang-linker-wrapper
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D151131
2023-05-24 00:24:14 +02:00
Eugene Burmako
4edaacf04b [MLIR] Update Bazel build to remove references to PybindUtils.cpp
This file has been removed in https://reviews.llvm.org/D151167.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D151242
2023-05-23 12:40:22 -07:00
Tue Ly
a0c92a3817 [libc][math] Make log10 correctly rounded for non-FMA targets and improve itsperformance.
Make log10 correctly rounded for non-FMA targets and improve its
performance.

Implemented fast pass and accurate pass:

**Fast Pass**:

  - Range reduction step 0: Extract exponent and mantissa
```
  x = 2^(e_x) * m_x
```
  - Range reduction step 1: Use lookup tables of size 2^7 = 128 to reduce the argument to:
```
   -2^-8 <= v = r * m_x - 1 < 2^-7
  where r = 2^-8 * ceil( 2^8 * (1 - 2^-8) / (1 + k * 2^-7) )
  and k = trunc( (m_x - 1) * 2^7 )
```
  - Polynomial approximation: approximate `log(1 + v)` by a degree-7 polynomial generated by Sollya with:
```
 > P = fpminimax((log(1 + x) - x)/x^2, 5, [|D...|], [-2^-8, 2^-7]);
```
  - Combine the results:
```
  log10(x) ~ ( e_x * log(2) - log(r) + v + v^2 * P(v) ) * log10(e)
```
  - Perform additive Ziv's test with errors bounded by `P_ERR * v^2`.  Return the result if Ziv's test passed.

**Accurate Pass**:

  - Take `e_x`, `v`, and the lookup table index from the range reduction step of fast pass.
  - Perform 3 more range reduction steps:
    - Range reduction step 2: Use look-up tables of size 193 to reduce the argument to `[-0x1.3ffcp-15, 0x1.3e3dp-15]`
```
   v2 = r2 * (1 + v) - 1 = (1 + s2) * (1 + v) - 1 = s2 + v + s2 * v
  where r2 = 2^-16 * round ( 2^16 / (1 + k * 2^-14) )
  and k = trunc( v * 2^14 + 0.5 ).
```
    - Range reduction step 3: Use look-up tables of size 161 to reduce the argument to `[-0x1.01928p-22 , 0x1p-22]`
```
   v3 = r3 * (1 + v2) - 1 = (1 + s3) * (1 + v2) - 1 = s3 + v2 + s3 * v2
  where r3 = 2^-21 * round ( 2^21 / (1 + k * 2^-21) )
  and k = trunc( v * 2^21 + 0.5 ).
```
    - Range reduction step 4: Use look-up tables of size 130 to reduce the argument to `[-0x1.0002143p-29 , 0x1p-29]`
```
   v4 = r4 * (1 + v3) - 1 = (1 + s4) * (1 + v3) - 1 = s4 + v3 + s4 * v3
  where r4 = 2^-28 * round ( 2^28 / (1 + k * 2^-28) )
  and k = trunc( v * 2^28 + 0.5 ).
```
  - Polynomial approximation: approximate `log10(1 + v4)` by a degree-4 minimax polynomial generated by Sollya with:
```
  > P = fpminimax(log10(1 + x)/x, 3, [|128...|], [-0x1.0002143p-29 , 0x1p-29]);
```
  - Combine the results:
```
  log10(x) ~ e_x * log10(2) - log10(r) - log10(r2) - log10(r3) - log10(r4) + v * P(v)
```
  - The combined results are computed using floating points of 128-bit precision.

**Performance**

  - For `0.5 <= x <= 2`, the fast pass hitting rate is about 99.92%.

  - Reciprocal throughput from CORE-MATH's perf tool on Ryzen 5900X:
```
$ ./perf.sh log10
GNU libc version: 2.35
GNU libc release: stable

-- CORE-MATH reciprocal throughput -- with FMA
[####################] 100 %
Ntrial = 20 ; Min = 20.402 + 0.589 clc/call; Median-Min = 0.277 clc/call; Max = 22.752 clc/call;

-- CORE-MATH reciprocal throughput -- without FMA (-march=x86-64-v2)
[####################] 100 %
Ntrial = 20 ; Min = 75.797 + 3.317 clc/call; Median-Min = 3.407 clc/call; Max = 79.371 clc/call;

-- System LIBC reciprocal throughput --
[####################] 100 %
Ntrial = 20 ; Min = 22.668 + 0.184 clc/call; Median-Min = 0.181 clc/call; Max = 23.205 clc/call;

-- LIBC reciprocal throughput -- with FMA
[####################] 100 %
Ntrial = 20 ; Min = 25.977 + 0.183 clc/call; Median-Min = 0.138 clc/call; Max = 26.283 clc/call;

-- LIBC reciprocal throughput -- without FMA
[####################] 100 %
Ntrial = 20 ; Min = 22.140 + 0.980 clc/call; Median-Min = 0.853 clc/call; Max = 23.790 clc/call;

```
  - Latency from CORE-MATH's perf tool on Ryzen 5900X:
```
$ ./perf.sh log10 --latency
GNU libc version: 2.35
GNU libc release: stable

-- CORE-MATH latency -- with FMA
[####################] 100 %
Ntrial = 20 ; Min = 54.613 + 0.357 clc/call; Median-Min = 0.287 clc/call; Max = 55.701 clc/call;

-- CORE-MATH latency -- without FMA (-march=x86-64-v2)
[####################] 100 %
Ntrial = 20 ; Min = 79.681 + 0.482 clc/call; Median-Min = 0.294 clc/call; Max = 81.604 clc/call;

-- System LIBC latency --
[####################] 100 %
Ntrial = 20 ; Min = 61.532 + 0.208 clc/call; Median-Min = 0.199 clc/call; Max = 62.256 clc/call;

-- LIBC latency -- with FMA
[####################] 100 %
Ntrial = 20 ; Min = 41.510 + 0.205 clc/call; Median-Min = 0.244 clc/call; Max = 41.867 clc/call;

-- LIBC latency -- without FMA
[####################] 100 %
Ntrial = 20 ; Min = 55.669 + 0.240 clc/call; Median-Min = 0.280 clc/call; Max = 56.056 clc/call;
```
  - Accurate pass latency:
```
$ ./perf.sh log10 --latency --simple_stat
GNU libc version: 2.35
GNU libc release: stable

-- CORE-MATH latency -- with FMA
640.688

-- CORE-MATH latency -- without FMA (-march=x86-64-v2)
667.354

-- LIBC latency -- with FMA
495.593

-- LIBC latency -- without FMA
504.143
```

Reviewed By: zimmermann6

Differential Revision: https://reviews.llvm.org/D150014
2023-05-23 10:18:23 -04:00
Michael Jones
ae3b59e623 [libc] Use MPFR for strtofloat fuzzing
The previous string to float tests didn't check correctness, but due to
the atof differential test proving unreliable the strtofloat fuzz test
has been changed to use MPFR for correctness checking. Some minor bugs
have been found and fixed as well.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D150905
2023-05-22 11:04:53 -07:00
Aaron Siddhartha Mondal
7b5d6cd7fc
[bazel] Remove terminfo dependency
The only enabling configuration of this is irreproducible. Since
terminfo doesn't provide essential functionality, remove it so that all
external dependencies now follow the same config_setting pattern.

This should be an NFC for most setups and all CI setups.

Reviewed By: phosek, MaskRay

Differential Revision: https://reviews.llvm.org/D151006
2023-05-22 19:00:14 +02:00
Benjamin Kramer
27eadeee6b [bazel] Port 231a6959025b3101942701b214c64762b55222c6 2023-05-22 17:11:25 +02:00
Johannes Reifferscheid
a903c44025 [Bazel] Add missing tablegen.
(For MemorySlotTypeInterfaces)

Summary:

Reviewers: khasanovaa

Subscribers:
2023-05-22 13:19:26 +02:00
Krasimir Georgiev
bf497c0be2 [Bazel] Fixup for 612781918fb01a2a0985a1c4c9200f5d5d1581cc 2023-05-22 09:18:48 +00:00
Krasimir Georgiev
b727ff3393 [Bazel] Fixup for 3128b3105d7a226fc26174be265da479ff619f3e 2023-05-22 08:23:57 +00:00
NAKAMURA Takumi
75807297af [Bazel] Fixup for D149515 (MCTargetDesc/*.def) 2023-05-21 13:05:40 +09:00
Aaron Siddhartha Mondal
a268127736
[bazel] Rework zlib dependency
Switches the library to use the zlib-ng implementation since the
original implementation is warning-incompatible with recent versions of clang.

Removes the wrapper logic for zlib in the bazel build and introduces new
logic to handle `LLVM_ENABLE_ZLIB`.

Removes the `BAZEL_LLVM_ZLIB_STRATEGY` environment variable and instead
introduces a boolean `--@llvm_zlib//:llvm_enable_zlib` flag which defaults
to true.

To migrate:
    * The previous "external" strategy is the default. May be explicitly
      enabled with `--@llvm_zlib//:llvm_enable_zlib=true`. For custom zlib
      variants you can use the BUILD file at `third_party_build/zlib.BUILD`
      as reference and adjust the `@llvm_zlib` archive in the `WORKSPACE`
      directly.
    * The previous "disable" strategy may be enabled with
      `--@llvm_zlib//:llvm_enable_zlib=false`.
    * The previous "system" strategy has been removed since it breaks
      hermeticity. If you need the "system" setup, use the "external"
      strategy and override the zlib dependency.

Addresses breakages of downstream projects using upstream clang and the
previously "external" zlib strategy (D141553).

Reviewed By: MaskRay, GMNGeoffrey

Differential Revision: https://reviews.llvm.org/D143320
2023-05-19 23:41:07 +02:00
Benjamin Kramer
6f6fc7dd30 [bazel] Port 00bd8e90116d99499f9161914fa5e00eed14a5ff 2023-05-19 13:19:31 +02:00
Peiming Liu
afe78db770 [mlir][sparse] Make sparse_tensor::StorageLayout publicly available.
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D150739
2023-05-18 20:29:46 +00:00
Alex Zinenko
2f3ac28cb2 [mlir] don't hardcode PDL_Operation in Transform dialect extensions
Update operations in Transform dialect extensions defined in the Affine,
GPU, MemRef and Tensor dialects to use the more generic
`TransformHandleTypeInterface` type constraint instead of hardcoding
`PDL_Operation`. See
https://discourse.llvm.org/t/rfc-type-system-for-the-transform-dialect/65702
for motivation.

Remove the dependency on PDLDialect from these extensions.

Update tests to use `!transform.any_op` instead of `!pdl.operation`.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D150781
2023-05-17 15:10:12 +00:00
Benjamin Kramer
fbdd7856d5 [bazel] Port c8a581c331f27a1ece8e42206831e56b7a222d26 2023-05-17 14:50:01 +02:00
Dmitri Gribenko
2fa9598ef7 [bazel] Fix missing deps for layering check
Dependency was introduced by
2c874d2128
2023-05-17 14:18:08 +02:00
Guillaume Chatelet
324e9de75e [bazel] Fix missing dependencies for OpenMP
Differential Revision: https://reviews.llvm.org/D150764
2023-05-17 09:25:44 +00:00
Anlun Xu
c5291a2401 [bazel] Fix build
Differential Revision: https://reviews.llvm.org/D150734
2023-05-16 15:40:34 -07:00
Anlun Xu
114bc86773 [bazel] Fix build
Differential Revision: https://reviews.llvm.org/D150732
2023-05-16 14:56:35 -07:00
Goran Flegar
2f4c96097a [bazel] Fix build after 0c4d7d14e94d 2023-05-16 18:28:13 +02:00
Alex Zinenko
2fe4d90cac [mlir] make structured transform ops use types
Types have been introduced a while ago and provide for better
readability and transform-time verification. Use them in the ops from
the structured transform dialect extension.

In most cases, the types are appended as trailing functional types or a
derived format of the functional type that allows for an empty right
hand size without the annoying `-> ()` syntax (similarly to `func.func`
declaration that may omit the arrow). When handles are used inside mixed
static/dynamic lists, such as tile sizes, types of those handles follow
them immediately as in `sizes [%0 : !transform.any_value, 42]`. This
allows for better readability than matching the trailing type.

Update code to remove hardcoded PDL dependencies and expunge PDL from
structured transform op code.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D144515
2023-05-16 08:16:56 +00:00