Karol Herbst
1e655b2f25
clc: rework optional subgroup feature
...
OpenCL 3.0 core requires __opencl_c_subgroups to be set, the OpenCL
cl_khr_subgroups extenions can only be enabled if and only if the driver
guarentees independent forward progress between subgroups.
See CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS for more information.
Signed-off-by: Karol Herbst <git@karolherbst.de >
Reviewed-by: Nora Allen <blackcatgames@protonmail.com >
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22893 >
2023-07-07 12:27:35 +00:00
Dave Airlie
fb5ecbb4fe
clc: llvm 17 requires opaque pointers.
...
You can't turn this off for llvm17+, this at least makes things
run against llvm git now instead of blowing up in clang.
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24000 >
2023-07-05 19:21:49 +00:00
Yonggang Luo
5be8f98f5a
compiler/clc: Switch to use nir_foreach_function_impl in function nir_lower_libclc
...
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23901 >
2023-07-03 19:16:48 +00:00
Alyssa Rosenzweig
815efcdf7e
nir: Use nir_builder_create
...
perl -p0e 's/nir_builder ([^;]*);\s*nir_builder_init\(&\1, /nir_builder \1 = nir_builder_create(/g' -i $(git grep -l nir_builder_init)
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23860 >
2023-06-27 18:13:02 +00:00
Yonggang Luo
5b29463746
nir: Add function nir_function_set_impl
...
This function is added for create strong relationship between
nir_function_impl and nir_function.
So that nir_function->impl->function == nir_function is always true when
(nir_function->impl != NULL && nir_function->impl != NIR_SERIALIZE_FUNC_HAS_IMPL)
And indeed this invariant is already done in functions validate_function and validate_function_impl
of nir_validate
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com >
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23820 >
2023-06-24 14:48:47 +00:00
Karol Herbst
570c263ea3
nir/load_libclc: run some opt passes for everybody
...
Cuts down serialized size from 2850288 to 1377780 bytes.
Reduces clinfo with Rusticl time by 40% for debug builds.
(Old data, but the point stands)
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com >
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15996 >
2023-06-22 21:02:57 +00:00
Caio Oliveira
cb588d5d6e
compiler/clc: Move related NIR passes to the common mesa clc
...
These were historically in the spirv+nir combo, but the common mesa clc
is a better home for them.
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Acked-by: Nora Allen <blackcatgames@protonmail.com >
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23667 >
2023-06-20 03:43:41 +00:00
Caio Oliveira
be3e4c8aaf
compiler/clc: Rename the internal library from libclc to libmesaclc
...
There is an actual external libclc and we do use it, so rename the
internal common library to avoid confusion.
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Acked-by: Nora Allen <blackcatgames@protonmail.com >
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23667 >
2023-06-20 03:43:41 +00:00
Karol Herbst
99a480ba9b
clc: allow passing custom validator options
...
Signed-off-by: Karol Herbst <git@karolherbst.de >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23700 >
2023-06-19 22:54:59 +00:00
Karol Herbst
8f7da6f052
clc: fix SPIRVMessageConsumer for NULL src
...
This happens if we pass our own validator options. It's nothing we can
control, SPIRV-Tools just passes NULL instead of "input".
Signed-off-by: Karol Herbst <git@karolherbst.de >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23700 >
2023-06-19 22:54:59 +00:00
Karol Herbst
8f9514fc63
clc: static assert that clc_optional_features has no padding
...
Signed-off-by: Karol Herbst <git@karolherbst.de >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23685 >
2023-06-15 23:31:27 +00:00
Karol Herbst
23cbe6b0d5
clc: add commment to clc_optional_features to ensure no padding exists
...
Hopefully this is good enough.
Signed-off-by: Karol Herbst <git@karolherbst.de >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23532 >
2023-06-15 19:30:36 +00:00
Karol Herbst
90b8666ff2
clc: relax spec constant validation
...
Multiple values can have multiple spec constants assigned and vtn handles
this just fine. So just drop that assert as we need it to run SyCL
kernels.
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9037
Fixes: a699844ffb ("microsoft/clc: Parse SPIR-V specialization consts into metadata")
Signed-off-by: Karol Herbst <git@karolherbst.de >
Acked-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23512 >
2023-06-08 17:22:47 +00:00
Dor Askayo
a28540a430
meson: add feature option for use of system Clang headers at runtime
...
Enabling or disabling the "microsoft-clc" option previously changed
shared logic for all compiler/clc users, which was surprising.
In addition, the option to avoid the use of system Clang headers at
runtime is useful outside the scope of Windows.
Separating the two concepts by making this a neutral feature option
addresses both matters.
Signed-off-by: Dor Askayo <dor.askayo@gmail.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23255 >
2023-05-31 14:21:25 +00:00
norablackcat
75555d0660
rusticl/clc add integer_dot_prod feature macros
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23011 >
2023-05-18 23:59:53 +00:00
Karol Herbst
fb7e9b1c36
clc: free kernel args in clc_free_kernels_info
...
Signed-off-by: Karol Herbst <git@karolherbst.de >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22776 >
2023-05-02 15:28:38 +00:00
Lone_Wolf
f53e5efad7
compiler/clc: Fix embedded clang headers (microsoft-clc) for LLVM 16+
...
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7742
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22741 >
2023-04-27 23:06:42 +00:00
Karol Herbst
8fcfc51dad
clc: add clc_validate_spirv
...
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22280 >
2023-04-13 02:54:21 +00:00
Jesse Natalie
b27d8ee2e9
clc: Include opencl-c-base.h with LLVM 15 (using builtins)
...
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21168 >
2023-02-11 05:24:08 +00:00
Karol Herbst
e22491c832
clc: fetch clang resource dir at runtime
...
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19617 >
2022-12-02 15:38:44 +00:00
Karol Herbst
cd2609b12c
clc: generate sources only with with_microsoft_clc
...
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19617 >
2022-12-02 15:38:44 +00:00
Italo Nicola
66b3df3c15
clc: add 32-bit target
...
Signed-off-by: Italo Nicola <italonicola@collabora.com >
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18985 >
2022-10-15 02:23:03 +00:00
Pierre-Eric Pelloux-Prayer
70891edd97
nir: add a nir_opt_if_options enum
...
And don't enable nir_opt_if_optimize_phi_true_false on radeonsi with
LLVM 14 because it crashes Blender.
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6976
Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Acked-by: Emma Anholt <emma@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17949 >
2022-08-10 12:55:39 +00:00
Karol Herbst
6637b1f41e
clc: undefine spirv defs to work around LLVMs headers
...
Clang unconditionally adds those definitions if using a spirv LLVM target.
That's not a problem on its own, but clang's internal OpenCL header enable
a bunch of OpenCL extensions if those are set.
Lucky for us, we can simply undefine them and spare us the trouble of
finding an upstream solution to this problem :)
This fixes the OpenCL CTS' compiler features_macro test.
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17334 >
2022-08-04 23:53:50 +00:00
Lionel Landwerlin
cf44282deb
clc: add new feature options for intel_clc
...
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17253 >
2022-06-27 15:31:49 +00:00
Vinson Lee
3e679219a1
clc: Fix build with llvm-15.
...
opencl_c_h is defined only for llvm < 15.
Fixes: bcc2df4890 ("clc: speed up compilation by not relying on opencl-c.h")
Signed-off-by: Vinson Lee <vlee@freedesktop.org >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16808 >
2022-06-04 22:27:55 -07:00
Karol Herbst
cd8c083ab5
clc: disable opaque pointers until they are supported
...
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16479 >
2022-05-21 12:26:37 +00:00
Karol Herbst
b6ed3c6ea2
clc: fix compiler features_macro CTS Test
...
Even with that alone we can't pass the test, as LLVM enables some
extensions based on the SPIR target we choose.
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16479 >
2022-05-21 12:26:37 +00:00
Karol Herbst
bcc2df4890
clc: speed up compilation by not relying on opencl-c.h
...
This depends on LLVM change: https://reviews.llvm.org/D125401
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16479 >
2022-05-21 12:26:37 +00:00
Karol Herbst
e5a052f75f
clc: drop parsingComplete check
...
This relies too much on the properties of the SPIRV-LLVM-Translator and is
required to load SPIR-Vs found in the OpenCL CTS.
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16479 >
2022-05-21 12:26:37 +00:00
Karol Herbst
c0cf7f578a
clc: parse localSize and localSizeHint
...
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16479 >
2022-05-21 12:26:37 +00:00
Jason Ekstrand
46d9b0e431
clc: Declare LLVMContexts on the stack
...
This prevents more use-after-free errors. Passing them around using
std::unique_ptr ensures that the LLVMContext gets destroyed but doesn't
ensure destruction order. Declaring it on the stack ensures that the
context doesn't get destroyed until right before the the function
returns which is after any other LLVM stuff is destroyed.
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Icecream95 <ixn@disroot.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937 >
2022-04-14 21:19:56 +00:00
Jason Ekstrand
6099e6ce9a
clc: Rework logging a bit
...
First, separate out the LLVM context logging to make it take a
clc_logger instead of passing in a string stream. Currently, the LLVM
context may outlive the string stream which we assign which may lead to
use-after-free errors. Second, use a separate string stream for clang
diagnosticl logging which we intentionally declare before the compiler
so the compiler can't outlive it.
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Icecream95 <ixn@disroot.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937 >
2022-04-14 21:19:56 +00:00
Jason Ekstrand
6e3b9b1b1d
clc: Only initialize LLVM once
...
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Icecream95 <ixn@disroot.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937 >
2022-04-14 21:19:56 +00:00
Dave Airlie
fdab872224
clc: initialise one more llvm stage
...
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Icecream95 <ixn@disroot.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937 >
2022-04-14 21:19:56 +00:00
Dave Airlie
b518020f64
clc: add simple llvm initialise API
...
This just calls some of the LLVM init functions in a common place
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Icecream95 <ixn@disroot.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937 >
2022-04-14 21:19:56 +00:00
Icecream95
f226222846
clc: Use stringstream for printing spirv errors
...
The type of the spv_position_t components can differ across platforms,
it's simpler to just let C++ overloading handle it.
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15437 >
2022-04-14 00:14:43 +00:00
Jesse Natalie
53d4dc7feb
clc: Use kernel_arg_type_qual string to add const type qualifier to arg metadata
...
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13759 >
2021-11-15 07:47:00 -08:00
Jesse Natalie
82c69c9a9d
compiler/clc: Preserve OCL kernel arg type metadata on LLVM13
...
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13177 >
2021-10-04 18:16:01 +00:00
Jesse Natalie
3a752256f5
compiler/clc: Null extensions should mean all supported, not all
...
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13177 >
2021-10-04 18:16:01 +00:00
Lionel Landwerlin
445996379b
clc: let user specify the targetted SPIRV version
...
This version is given to the LLVM-SPIRV translator. On the SPIRV-Tools
side of things, we want to use the highest available version to be
sure to be able to parse back what was generated.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13113 >
2021-10-03 19:32:54 +00:00
Lionel Landwerlin
72fd81d0ac
clc: print warnings/errors on their own line
...
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13113 >
2021-10-03 19:32:54 +00:00
Lionel Landwerlin
3c8c817ae7
clc: add allowed extension for compile parameter
...
The LLVM-SPIRV translator can include a bunch of capabilities into the
generated SPIRV which is not what you always want. That include
internal Intel specific capabilities from the translator.
v2: Rename options
Fixup checks (Jesse)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13113 >
2021-10-03 19:32:54 +00:00
Jason Ekstrand
d2264489ce
compiler/clc: grab opencl-c.h from the system path by default
...
By default we use the header installed opencl-c.h header. But in the
case Mesa is compiled for microsoft clon12 we keep the injected file.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Dylan Baker <dylan@pnwbakers.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156 >
2021-09-30 07:09:08 +00:00
Jason Ekstrand
8490766f53
compiler/clc: Clean ups
...
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Dylan Baker <dylan@pnwbakers.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156 >
2021-09-30 07:09:08 +00:00
Jason Ekstrand
1506ea2ecb
Move a bunch of the CLC stuff from src/microsoft to common code
...
The D3D12-specific stuff isn't useful to have in common code but all the
stuff to invoke clang really should be common.
v2: Rebase (Lionel)
v3: Define a new clc_libclc_new_dxil() entrypoint to create a clc
context with DXIL nir_options (Jesse)
v4: Fixup meson build (Lionel)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Dylan Baker <dylan@pnwbakers.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156 >
2021-09-30 07:09:08 +00:00