Commit Graph

647 Commits

Author SHA1 Message Date
Romaric Jodin
9160f49e08
libclc: generic: add half implementation for erf/erfc (#66901)
libclc does not have a half implementation for erf/erfc
Add one based on the float implementation by extending the input and
truncating the output.
2024-01-09 16:47:53 +00:00
Jakub Chlanda
5ec9faf007
[LIBCLC] Teach prepare-builtins how to handle text based IR (#66993) 2023-10-03 14:28:01 +02:00
Fraser Cormack
37a3de1e2e libclc: Fix signed integer underflow in abs_diff
We noticed this same issue in our own implementation of abs_diff, and
the same issue also came up in the abs_diff reference function in the
OpenCL CTS.

Reviewed By: rjodinchr

Differential Revision: https://reviews.llvm.org/D159275
2023-08-31 14:28:16 +01:00
Mark de Wever
cbaa3597aa Reland "[CMake] Bumps minimum version to 3.20.0.
This reverts commit d763c6e5e2.

Adds the patch by @hans from
https://github.com/llvm/llvm-project/issues/62719
This patch fixes the Windows build.

d763c6e5e2 reverted the reviews

D144509 [CMake] Bumps minimum version to 3.20.0.

This partly undoes D137724.

This change has been discussed on discourse
https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193

Note this does not remove work-arounds for older CMake versions, that
will be done in followup patches.

D150532 [OpenMP] Compile assembly files as ASM, not C

Since CMake 3.20, CMake explicitly passes "-x c" (or equivalent)
when compiling a file which has been set as having the language
C. This behaviour change only takes place if "cmake_minimum_required"
is set to 3.20 or newer, or if the policy CMP0119 is set to new.

Attempting to compile assembly files with "-x c" fails, however
this is workarounded in many cases, as OpenMP overrides this with
"-x assembler-with-cpp", however this is only added for non-Windows
targets.

Thus, after increasing cmake_minimum_required to 3.20, this breaks
compiling the GNU assembly for Windows targets; the GNU assembly is
used for ARM and AArch64 Windows targets when building with Clang.
This patch unbreaks that.

D150688 [cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump

The build uses other mechanism to select the runtime.

Fixes #62719

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D151344
2023-05-27 12:51:21 +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
Thomas Debesse
382b56d5bd [libclc] Fix linking against libLLVMSupport
Fixes https://github.com/llvm/llvm-project/issues/62018.
2023-05-22 12:22:05 +02:00
Nico Weber
d763c6e5e2 Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""
This reverts commit 65429b9af6.

Broke several projects, see https://reviews.llvm.org/D144509#4347562 onwards.

Also reverts follow-up commit "[OpenMP] Compile assembly files as ASM, not C"

This reverts commit 4072c8aee4.

Also reverts fix attempt  "[cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump"

This reverts commit 7d47dac5f8.
2023-05-17 10:53:33 -04:00
Mark de Wever
65429b9af6 Reland "[CMake] Bumps minimum version to 3.20.0."
The owner of the last two failing buildbots updated CMake.

This reverts commit e8e8707b4a.
2023-05-13 11:42:25 +02:00
Kévin Petit
21508fa769 libclc: clspv: fix fma, add vstore and fix inlining issues
https://reviews.llvm.org/D147773

Patch by Romaric Jodin <rjodin@google.com>
2023-05-09 16:52:13 +01:00
Mark de Wever
e8e8707b4a Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""
Unfortunatly not all buildbots are updated.

This reverts commit ffb807ab53.
2023-05-06 17:03:56 +02:00
Mark de Wever
ffb807ab53 Reland "[CMake] Bumps minimum version to 3.20.0."
All build bots should be updated now.

This reverts commit 44d38022ab.
2023-05-06 11:43:02 +02:00
Mark de Wever
44d38022ab Revert "Revert "Revert "[CMake] Bumps minimum version to 3.20.0."""
This reverts commit 1ef4c3c859.

Two buildbots still haven't been updated.
2023-04-15 20:12:24 +02:00
Mark de Wever
1ef4c3c859 Revert "Revert "[CMake] Bumps minimum version to 3.20.0.""
This reverts commit 92523a35a8.

Reland to see whether CIs are updated.
2023-04-15 13:12:04 +02:00
Mark de Wever
d0398d3593 Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""
This reverts commit a72165e5df.

Some buildbots have not been updated yet.
2023-03-18 20:32:43 +01:00
Mark de Wever
a72165e5df Reland "[CMake] Bumps minimum version to 3.20.0."
This reverts commit 92523a35a8.

Test whether all CI runners are updated.
2023-03-18 13:33:42 +01:00
Mark de Wever
92523a35a8 Revert "[CMake] Bumps minimum version to 3.20.0."
Some build bots have not been updated to the new minimal CMake version.
Reverting for now and ping the buildbot owners.

This reverts commit 44c6b905f8.
2023-03-04 18:28:13 +01:00
Mark de Wever
44c6b905f8 [CMake] Bumps minimum version to 3.20.0.
This partly undoes D137724.

This change has been discussed on discourse
https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193

Note this does not remove work-arounds for older CMake versions, that
will be done in followup patches.

Reviewed By: mehdi_amini, MaskRay, ChuanqiXu, to268, thieta, tschuett, phosek, #libunwind, #libc_vendors, #libc, #libc_abi, sivachandra, philnik, zibi

Differential Revision: https://reviews.llvm.org/D144509
2023-03-04 12:40:57 +01:00
Kévin Petit
1da2085a51 libclc: add clspv to targets exempt from alwaysinline
https://reviews.llvm.org/D132362

Patch by: Aaron Greig <aaron.greig@codeplay.com>
2023-02-14 18:26:42 +00:00
Kévin Petit
290308a99e libclc: add generated convert.cl to clspv/clspv64 targets
https://reviews.llvm.org/D136772

Patch by: Aaron Greig <aaron.greig@codeplay.com>
2023-02-14 18:23:35 +00:00
Kévin Petit
f6cd46e07f libclc: add more generic implementations to clspv SOURCES
https://reviews.llvm.org/D134887

Patch by: Aaron Greig <aaron.greig@codeplay.com>
2023-02-14 18:11:01 +00:00
Kévin Petit
f11ab8353f libclc: remove sqrt/rsqrt from clspv SOURCES
https://reviews.llvm.org/D134040

Patch by: Aaron Greig <aaron.greig@codeplay.com>
2023-02-13 21:27:40 +00:00
Tom Stellard
8040e3a4de libclc: Fix building against an llvm build directory
Reviewed By: thieta

Differential Revision: https://reviews.llvm.org/D142718
2023-01-27 11:16:03 -08:00
Tom Stellard
409f42b10a libclc: Set CMAKE_CXX_STANDARD to 17 to match llvm
Reviewed By: thieta

Differential Revision: https://reviews.llvm.org/D142720
2023-01-27 10:50:29 -08:00
Matt Arsenault
4ddba3a706 libclc: Add parentheses to silence warning
Fixes #59209
2022-12-29 18:19:55 -05:00
Tom Stellard
b264787453 libclc: Use cmake files instead of llvm-config
Reviewed By: mgorny

Differential Revision: https://reviews.llvm.org/D137854
2022-11-22 22:57:46 -08:00
Nikita Popov
a11e2d7366 [libclc] Quote addition of CLC/LLAsm flags
Otherwise cmake will insert a semicolon if flags are already set.

Differential Revision: https://reviews.llvm.org/D131490
2022-08-31 11:10:24 +02:00
tlattner
44f81dfba4 Remove references to old mailing lists that have moved to discourse. Replace with links to discourse.
Reviewed By: #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D129675
2022-07-22 09:59:03 -07:00
Kévin Petit
ec0a880d54 libclc: Add clspv64 target
Add a variant of the clspv target that is built using spir64.
This is a pre-requisite to supporting spir64 in clspv which is
required to take advantage of SPV_KHR_physical_storage_buffer which
in turn enables more OpenCL C programs to be compiled with clspv.

https://reviews.llvm.org/D116668
2022-01-13 09:28:19 +00:00
John Ericson
ddcc02dbcc Quote some more destination paths with variables
Just defensive CMake-ing. I pulled this from D115544 and D99484 which
are blocked on some lldb CI failures I don't yet understand. Hoping to land
something smaller in the meantime.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D115566
2021-12-13 17:29:08 +00:00
Med Ismail Bennani
30fc88bf1d Revert "Revert "Revert "Use GNUInstallDirs to support custom installation dirs. -- LLVM"""
This reverts commit 492de35df4.

I tried to apply John's changes in 8d897ec915 that were expected to
fix his patch but that didn't work unfortunately.

Reverting this again to fix the macOS bots and leave him more time to
investigate the issue.
2021-12-10 17:33:54 -08:00
John Ericson
492de35df4 Revert "Revert "Use GNUInstallDirs to support custom installation dirs. -- LLVM""
This reverts commit 797b50d4be.

See the original D99484. @mib who noticed the original problem could not longer
reproduce it, after I tried and also failed. We are threfore hoping it went
away on its own!

Reviewed By: mib

Differential Revision: https://reviews.llvm.org/D115544
2021-12-10 20:59:43 +00:00
Med Ismail Bennani
797b50d4be Revert "Use GNUInstallDirs to support custom installation dirs. -- LLVM"
This reverts commit 6fd2db04d0 since it
broke GreenDragon LLDB-Incremental bot:

https://green.lab.llvm.org/green/job/lldb-cmake/37560/console

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-11-02 19:11:44 +01:00
John Ericson
6fd2db04d0 Use GNUInstallDirs to support custom installation dirs. -- LLVM
This is a new draft of D28234. I previously did the unorthodox thing of
pushing to it when I wasn't the original author, but since this version

- Uses `GNUInstallDirs`, rather than mimics it, as the original author
  was hesitant to do but others requested.

- Is much broader, effecting many more projects than LLVM itself.

I figured it was time to make a new revision.

I am using this patch (and many back-ports) as the basis of
https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS). It
looked like people were generally on board in D28234, but I make note of
this here in case extra motivation is useful.

---

As pointed out in the original issue, a central tension is that LLVM
already has some partial support for these sorts of things. For example
`LLVM_LIBDIR_SUFFIX`, or `COMPILER_RT_INSTALL_PATH`. Because it's not
quite clear yet what to do about those, we are holding off on changing
libdirs and `compiler-rt`. for this initial PR.

---

On the advice of @lebedev.ri, I am splitting this up a bit per
subproject, starting with LLVM. To allow it to be more easily reviewed. This and the subsequent patch must be landed together, as this will not build alone. But the rest can be landed on their own.

Reviewed By: compnerd

Differential Revision: https://reviews.llvm.org/D100810
2021-11-02 10:23:30 -04:00
Daniel Stone
59510c4212 libclc: Fix rounding during type conversion
The rounding during type conversion uses multiple conversions, selecting
between them to try to discover if rounding occurred. This appears to
not have been tested, since it would generate code of the form:
    float convert_float_rtp(char x)
    {
      float r = convert_float(x);
      char y = convert_char(y);
      [...]
    }

which will access uninitialised data. The idea appears to have been to
have done a char -> float -> char roundtrip in order to discover the
rounding, so do this.

Discovered by inspection.

Signed-off-by: Daniel Stone <daniels@collabora.com>

Reviewed By: jvesely

Differential Revision: https://reviews.llvm.org/D81999
2021-08-19 22:24:19 -07:00
Jan Vesely
ea469b08b8 libclc: Add -cl-no-stdinc to clang flags on clang >=13
cf3ef15a6e ("[OpenCL] Add builtin
declarations by default.")
 switched behaviour to include "opencl-c-base.h". We don't want or need
 that for libclc so pass the flag to revert to old behaviour.

Fixes build since cf3ef15a6e

Reviewed By: tstellar

Differential Revision: https://reviews.llvm.org/D99794
2021-07-15 10:43:26 +10:00
Duncan P. N. Exon Smith
518d955f9d Support: Stop using F_{None,Text,Append} compatibility synonyms, NFC
Stop using the compatibility spellings of `OF_{None,Text,Append}`
left behind by 1f67a3cba9. A follow-up
will remove them.

Differential Revision: https://reviews.llvm.org/D101650
2021-04-30 11:00:03 -07:00
Alan Baker
21427b8eb8 libclc: Add clspv target to libclc
Add clspv as a new target for libclc. clspv is an open-source compiler that compiles OpenCL C to Vulkan SPIR-V. Compiles for the spir target.

The clspv target differs from the the spirv target in the following ways:
* fma is modified to use uint2 instead of ulong for mantissas. This results in lower performance fma, but provides a implementation that can be used on more Vulkan devices where 64-bit integer support is less common.
* Use of a software implementation of nextafter because the generic implementation depends on nextafter being a defined builtin function for which clspv has no definition.
* Full optimization of the library (-O3) and no conversion to SPIR-V

This library is close to what would be produced by running opt -O3 < builtins.opt.spirv-mesa3d-.bc > builtins.opt.clspv--.bc and continuing the build from that point.

Reviewer: jvesely

Differential Revision: https://reviews.llvm.org/D94013
2021-03-04 00:19:10 -05:00
Aaron Puchert
1c1a810558 libclc: Use find_package to find Python 3 and require it
The script's shebang wants Python 3, so we use FindPython3. The
original code didn't work when an unversioned python was not available.
This is explicitly allowed in PEP 394. ("Distributors may choose to set
the behavior of the python command as follows: python2, python3, not
provide python command, allow python to be configurable by an end user
or a system administrator.")

Also I think it's actually required, so let the configuration fail if we
can't find it.

Lastly remove the shebang, since the script is only run via interpreter
and doesn't have the executable bit set anyway.

Reviewed By: jvesely

Differential Revision: https://reviews.llvm.org/D88366
2020-10-01 22:31:33 +02:00
Daniel Stone
291bfff5db libclc: Add a __builtin to let SPIRV targets select between SW and HW FMA
Reviewer: jenatali jvesely
Differential Revision: https://reviews.llvm.org/D85910
2020-09-16 01:37:22 -04:00
Jan Vesely
16ba78ee62 libclc/spirv: Add missing files from D85911
Fixes: 060c8e083d
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
2020-09-10 23:41:38 -04:00
Daniel Stone
060c8e083d libclc/spirv: Add various functions
Adds fma,fmod,ldexp.

Reviewer: jenatali jvesely

Differential Revision: https://reviews.llvm.org/D85911
2020-09-10 01:59:10 -04:00
Dave Airlie
c37145cab1 libclc: Add Mesa/SPIR-V target
Add targets to emit SPIR-V targeted to Mesa's OpenCL support, using
SPIR-V 1.1.

Substantially based on Dave Airlie's earlier work.

libclc: spirv: remove step/smoothstep apis not defined for SPIR-V

libclc: disable inlines for SPIR-V builds

Reviewed By: jvesely, tstellar, jenatali

Differential Revision: https://reviews.llvm.org/D77589
2020-08-17 14:01:46 -07:00
Daniel Stone
3d21fa56f5 libclc: Make all built-ins overloadable
The SPIR spec states that all OpenCL built-in functions should be
overloadable and mangled, to ensure consistency.

Add the overload attribute to functions which were missing them:
work dimensions, memory barriers and fences, and events.

Reviewed By: tstellar, jenatali

Differential Revision: https://reviews.llvm.org/D82078
2020-08-17 13:55:48 -07:00
Boris Brezillon
3a7051d9c2 libclc: Fix FP_ILOGBNAN definition
Fix FP_ILOGBNAN definition to match the opencl-c-base.h one and
guarantee that FP_ILOGBNAN and FP_ILOGB0 are different. Doing that
implies fixing ilogb() implementation to return the right value.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>

Reviewed By: jvesely

Differential Revision: https://reviews.llvm.org/D83473
2020-08-17 13:45:43 -07:00
Louis Dionne
afa1afd410 [CMake] Bump CMake minimum version to 3.13.4
This upgrade should be friction-less because we've already been ensuring
that CMake >= 3.13.4 is used.

This is part of the effort discussed on llvm-dev here:

  http://lists.llvm.org/pipermail/llvm-dev/2020-April/140578.html

Differential Revision: https://reviews.llvm.org/D78648
2020-07-22 14:25:07 -04:00
davidak
a3418631e8 libclc: update website url
old link is dead
2020-05-29 09:18:37 +02:00
Matt Arsenault
cf4d4e366a libclc: Compile with -nostdlib
This fixes a build error when compiling for amdgcn-amd-amdhsa, which
defaults to trying to link bitcode libraries.
2020-05-28 10:41:31 -04:00
Tom Stellard
174c41defc libclc: Pass system libraries to the linker after llvm libraries
Summary:
The llvm libraries depend on the symbols in the system libaries, so
the system libraries need to be added after.

Reviewers: jvesely

Reviewed By: jvesely

Subscribers: mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78535
2020-04-29 15:34:54 -07:00
Daniel Stone
24fad7278a libclc: Use temporary files rather than a pipe
This is required for using the Ninja backend on Windows, as it passes
commands directly to CreateProcess, and does not allow the shell to
interpret them: https://ninja-build.org/manual.html#ref_rule_command

Using the Visual Studio backend is not possible as attempting to create
a static library target comprised entirely of novel languages not known
to the Visual Studio backend built in to CMake's C++ source will
generate nothing at all.

reviewer: jvesely
Differential Revision: https://reviews.llvm.org/D77165
2020-04-14 10:03:27 -04:00
Daniel Stone
cccdd0579b libclc: Don't pass linker flags to CLC/LLAsm
We don't want the regular linker flags for these invocations, since
we're not compiling to the target machine anyway. This fixes things like
'/machine:x64' being unknown when invoked under Windows.

reviewer: jvesely
Differential Revision: https://reviews.llvm.org/D77164
2020-04-14 10:03:27 -04:00