Skip to content

[libclc] Reorganize OpenCL builtins #140557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 20, 2025
Merged

Conversation

frasercrmck
Copy link
Contributor

@frasercrmck frasercrmck commented May 19, 2025

This commits moves all OpenCL builtins under a top-level 'opencl' directory, akin to how the CLC builtins are organized. This new structure aims to better convey the separation of the two layers and that 'CLC' is not a subset of OpenCL or a libclc target.

In doing so this commit moves the location of the 'lib' directory to match CLC: libclc/generic/lib/ becomes libclc/opencl/lib/generic/. This allows us to remove some special casing in CMake and ensure a common directory structure.

It also tries to better communicate that the OpenCL headers are libclc-specific OpenCL headers and should not be confused with or used as standard OpenCL headers. It does so by ensuring includes are of the form <clc/opencl/*>. It might be that we don't specifically need the libclc OpenCL headers and we simply could use clang's built-in declarations, but we can revisit that later.

Aside from the code move, there is some code formatting and updating a couple of OpenCL builtin includes to use the readily available gentype helpers. This allows us to remove some '.inc' files.

This commits moves all OpenCL builtins under a top-level 'opencl'
directory, akin to how the CLC builtins are organized. This new
structure aims to better convey the separation of the two layers and
that 'CLC' is not a subset of OpenCL or a libclc target.

In doing so this commit moves the location of the 'lib' directory to
match CLC: libclc/generic/lib/ becomes libclc/opencl/lib/generic/. This
allows us to remove some special casing in CMake and ensure a common
directory structure.

It also tries to better communicate that the OpenCL headers are
libclc-specific OpenCL headers and should not be confused with or used
as standard OpenCL headers. It does so by ensuring includes are of the
form <clc/opencl/*>. It might be that we don't specifically need the
libclc OpenCL headers and we simply could use clang's built-in
declarations, but we can revisit that later.
@frasercrmck frasercrmck requested a review from arsenm May 19, 2025 15:03
@frasercrmck frasercrmck added the libclc libclc OpenCL library label May 19, 2025
Copy link

github-actions bot commented May 19, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link

github-actions bot commented May 19, 2025

✅ With the latest revision this PR passed the undef deprecator.

Copy link

github-actions bot commented May 19, 2025

✅ With the latest revision this PR passed the Python code formatter.

@frasercrmck frasercrmck merged commit 32cf55a into llvm:main May 20, 2025
9 checks passed
@frasercrmck frasercrmck deleted the libclc-move-opencl branch May 20, 2025 08:51
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 20, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building libclc at step 6 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/32280

Here is the relevant piece of the build log for the reference
Step 6 (build-unified-tree) failure: build (failure)
...
44.748 [4379/58/9684] Linking CXX static library lib/libHLFIRDialect.a
44.966 [4378/58/9685] Generating obj.libclc.dir/clspv64--/clc/lib/generic/integer/clc_rotate.cl.bc
44.971 [4377/58/9686] Generating obj.libclc.dir/clspv64--/clc/lib/generic/math/clc_fdim.cl.bc
44.976 [4376/58/9687] Linking CXX executable bin/mlir-translate
44.983 [4375/58/9688] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/math/clc_maxmag.cl.bc
44.991 [4374/58/9689] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/math/clc_exp.cl.bc
44.994 [4373/58/9690] Linking CXX executable bin/clang-repl
44.996 [4372/58/9691] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/math/clc_ldexp.cl.bc
45.016 [4371/58/9692] Generating obj.libclc.dir/clspv--/clc/lib/generic/math/clc_atanh.cl.bc
45.029 [4370/58/9693] Generating obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc
FAILED: tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc 
cd /build/buildbot/premerge-monolithic-linux/build/tools/libclc && /build/buildbot/premerge-monolithic-linux/build/bin/clang-21 -target r600-- -c -fno-builtin -nostdlib -cl-std=CL3.0 -DCLC_R600 -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/clc/include -mcpu=cedar -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/math -MD -MF /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc.d -MT /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc -cl-no-stdinc -emit-llvm -o /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc -x cl /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/math/ldexp.cl && /etc/cmake/bin/cmake -E cmake_transform_depfile Ninja gccdepfile /build/buildbot/premerge-monolithic-linux/llvm-project/llvm /build/buildbot/premerge-monolithic-linux/llvm-project/libclc /build/buildbot/premerge-monolithic-linux/build /build/buildbot/premerge-monolithic-linux/build/tools/libclc /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc.d /build/buildbot/premerge-monolithic-linux/build/CMakeFiles/d/15e419e5cf412e6112f9fcaec7c9a4899fec59af938d680467007d631db4569e.d
In file included from /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/math/ldexp.cl:11:
In file included from /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include/clc/opencl/clc.h:215:
/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include/clc/opencl/synchronization/barrier.h:9:38: error: unknown type name 'cl_mem_fence_flags'
    9 | _CLC_DECL _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags);
      |                                      ^
1 error generated.
45.037 [4370/57/9694] Generating obj.libclc.dir/clspv64--/clc/lib/generic/integer/clc_sub_sat.cl.bc
45.041 [4370/56/9695] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/integer/clc_mad24.cl.bc
45.051 [4370/55/9696] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/integer/clc_popcount.cl.bc
45.055 [4370/54/9697] Generating obj.libclc.dir/clspv--/clc/lib/generic/math/clc_asinpi.cl.bc
45.066 [4370/53/9698] Generating obj.libclc.dir/clspv--/clc/lib/generic/math/clc_cbrt.cl.bc
45.068 [4370/52/9699] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/math/clc_lgamma.cl.bc
45.070 [4370/51/9700] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/integer/clc_hadd.cl.bc
45.076 [4370/50/9701] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/math/clc_minmag.cl.bc
45.077 [4370/49/9702] Generating obj.libclc.dir/clspv--/clc/lib/generic/math/clc_atan.cl.bc
45.080 [4370/48/9703] Generating obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/minmag.cl.bc
FAILED: tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/minmag.cl.bc /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/minmag.cl.bc 
cd /build/buildbot/premerge-monolithic-linux/build/tools/libclc && /build/buildbot/premerge-monolithic-linux/build/bin/clang-21 -target r600-- -c -fno-builtin -nostdlib -cl-std=CL3.0 -DCLC_R600 -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/clc/include -mcpu=cedar -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/math -MD -MF /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/minmag.cl.bc.d -MT /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/minmag.cl.bc -cl-no-stdinc -emit-llvm -o /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/minmag.cl.bc -x cl /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/math/minmag.cl && /etc/cmake/bin/cmake -E cmake_transform_depfile Ninja gccdepfile /build/buildbot/premerge-monolithic-linux/llvm-project/llvm /build/buildbot/premerge-monolithic-linux/llvm-project/libclc /build/buildbot/premerge-monolithic-linux/build /build/buildbot/premerge-monolithic-linux/build/tools/libclc /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/minmag.cl.bc.d /build/buildbot/premerge-monolithic-linux/build/CMakeFiles/d/5127a63075fb24681fa20c53788e0d6689d668be9040efce3ddc7a42bd08471e.d
In file included from /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/math/minmag.cl:10:
In file included from /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include/clc/opencl/clc.h:215:
/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include/clc/opencl/synchronization/barrier.h:9:38: error: unknown type name 'cl_mem_fence_flags'
    9 | _CLC_DECL _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags);
      |                                      ^
1 error generated.
45.097 [4370/47/9704] Generating obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/half_tan.cl.bc
FAILED: tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/half_tan.cl.bc /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/half_tan.cl.bc 
cd /build/buildbot/premerge-monolithic-linux/build/tools/libclc && /build/buildbot/premerge-monolithic-linux/build/bin/clang-21 -target r600-- -c -fno-builtin -nostdlib -cl-std=CL3.0 -DCLC_R600 -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/clc/include -mcpu=cedar -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/math -MD -MF /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/half_tan.cl.bc.d -MT /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/half_tan.cl.bc -cl-no-stdinc -emit-llvm -o /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/half_tan.cl.bc -x cl /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/math/half_tan.cl && /etc/cmake/bin/cmake -E cmake_transform_depfile Ninja gccdepfile /build/buildbot/premerge-monolithic-linux/llvm-project/llvm /build/buildbot/premerge-monolithic-linux/llvm-project/libclc /build/buildbot/premerge-monolithic-linux/build /build/buildbot/premerge-monolithic-linux/build/tools/libclc /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/half_tan.cl.bc.d /build/buildbot/premerge-monolithic-linux/build/CMakeFiles/d/76cabe15064b53a444f6fc61157bf210ca85c37cf5255488400574276325a19b.d
In file included from /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/math/half_tan.cl:10:
In file included from /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include/clc/opencl/clc.h:215:
/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include/clc/opencl/synchronization/barrier.h:9:38: error: unknown type name 'cl_mem_fence_flags'
    9 | _CLC_DECL _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags);
      |                                      ^
1 error generated.
45.099 [4370/46/9705] Generating obj.libclc.dir/tahiti-amdgcn--/opencl/lib/generic/atomic/atom_xchg.cl.bc
FAILED: tools/libclc/obj.libclc.dir/tahiti-amdgcn--/opencl/lib/generic/atomic/atom_xchg.cl.bc /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/tahiti-amdgcn--/opencl/lib/generic/atomic/atom_xchg.cl.bc 
cd /build/buildbot/premerge-monolithic-linux/build/tools/libclc && /build/buildbot/premerge-monolithic-linux/build/bin/clang-21 -target amdgcn-- -c -fno-builtin -nostdlib -cl-std=CL3.0 -DCLC_AMDGCN -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/clc/include -mcpu=tahiti -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/atomic -MD -MF /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/tahiti-amdgcn--/opencl/lib/generic/atomic/atom_xchg.cl.bc.d -MT /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/tahiti-amdgcn--/opencl/lib/generic/atomic/atom_xchg.cl.bc -cl-no-stdinc -emit-llvm -o /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/tahiti-amdgcn--/opencl/lib/generic/atomic/atom_xchg.cl.bc -x cl /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/atomic/atom_xchg.cl && /etc/cmake/bin/cmake -E cmake_transform_depfile Ninja gccdepfile /build/buildbot/premerge-monolithic-linux/llvm-project/llvm /build/buildbot/premerge-monolithic-linux/llvm-project/libclc /build/buildbot/premerge-monolithic-linux/build /build/buildbot/premerge-monolithic-linux/build/tools/libclc /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/tahiti-amdgcn--/opencl/lib/generic/atomic/atom_xchg.cl.bc.d /build/buildbot/premerge-monolithic-linux/build/CMakeFiles/d/da21d9216a34cd4979312c6fba697d84c646a1e4c8edb93f5a3fa7cf466e9c0a.d
In file included from /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/atomic/atom_xchg.cl:14:

@llvm-ci
Copy link
Collaborator

llvm-ci commented May 20, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-windows running on premerge-windows-1 while building libclc at step 5 "clean-build-dir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/35/builds/10231

Here is the relevant piece of the build log for the reference
Step 5 (clean-build-dir) failure: Delete failed. (failure)
Step 7 (build-unified-tree) failure: build (failure)
...
[9368/13730] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/amdgcn/math/clc_fmin.cl.bc
[9369/13730] Generating obj.libclc.dir/nvptx--nvidiacl/clc/lib/generic/math/clc_half_rsqrt.cl.bc
[9370/13730] Generating obj.libclc.dir/tahiti-amdgcn-mesa-mesa3d/clc/lib/generic/integer/clc_rotate.cl.bc
[9371/13730] Generating obj.libclc.dir/barts-r600--/clc/lib/generic/math/clc_log10.cl.bc
[9372/13730] Generating obj.libclc.dir/nvptx--/opencl/lib/generic/atomic/atom_cmpxchg.cl.bc
[9373/13730] Generating obj.libclc.dir/nvptx--/opencl/lib/generic/atomic/atom_dec.cl.bc
[9374/13730] Generating obj.libclc.dir/nvptx--/opencl/lib/generic/atomic/atom_inc.cl.bc
[9375/13730] Generating obj.libclc.dir/nvptx--/clc/lib/generic/math/clc_acos.cl.bc
[9376/13730] Generating obj.libclc.dir/clspv--/clc/lib/generic/math/clc_cosh.cl.bc
[9377/13730] Generating obj.libclc.dir/cypress-r600--/opencl/lib/generic/math/atanpi.cl.bc
FAILED: tools/libclc/obj.libclc.dir/cypress-r600--/opencl/lib/generic/math/atanpi.cl.bc 
cmd.exe /C "cd /D C:\ws\buildbot\premerge-monolithic-windows\build\tools\libclc && C:\ws\buildbot\premerge-monolithic-windows\build\bin\clang.exe -target r600-- -c -fno-builtin -nostdlib -cl-std=CL3.0 -DCLC_R600 -IC:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/clc/include -mcpu=cypress -IC:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/include -IC:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/lib/generic/math -MD -MF C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc/obj.libclc.dir/cypress-r600--/opencl/lib/generic/math/atanpi.cl.bc.d -MT C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc/obj.libclc.dir/cypress-r600--/opencl/lib/generic/math/atanpi.cl.bc -cl-no-stdinc -emit-llvm -o C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc/obj.libclc.dir/cypress-r600--/opencl/lib/generic/math/atanpi.cl.bc -x cl C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/lib/generic/math/atanpi.cl && C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe -E cmake_transform_depfile Ninja gccdepfile C:/ws/buildbot/premerge-monolithic-windows/llvm-project/llvm C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc C:/ws/buildbot/premerge-monolithic-windows/build C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc/obj.libclc.dir/cypress-r600--/opencl/lib/generic/math/atanpi.cl.bc.d C:/ws/buildbot/premerge-monolithic-windows/build/CMakeFiles/d/816d9449643377a2e306bcdb978c39a064a7a94dab0108f97679da0f47eb5586.d"
In file included from C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/lib/generic/math/atanpi.cl:10:
In file included from C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/include\clc/opencl/clc.h:215:
C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/include\clc/opencl/synchronization/barrier.h:9:38: error: unknown type name 'cl_mem_fence_flags'

    9 | _CLC_DECL _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags);

      |                                      ^

1 error generated.

[9378/13730] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/math/clc_atan2.cl.bc
[9379/13730] Generating obj.libclc.dir/nvptx64--/opencl/lib/generic/math/native_log.cl.bc
FAILED: tools/libclc/obj.libclc.dir/nvptx64--/opencl/lib/generic/math/native_log.cl.bc 
cmd.exe /C "cd /D C:\ws\buildbot\premerge-monolithic-windows\build\tools\libclc && C:\ws\buildbot\premerge-monolithic-windows\build\bin\clang.exe -target nvptx64-- -c -fno-builtin -nostdlib -cl-std=CL3.0 -DCLC_NVPTX64 -IC:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/clc/include -IC:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/include -fapprox-func -IC:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/lib/generic/math -MD -MF C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc/obj.libclc.dir/nvptx64--/opencl/lib/generic/math/native_log.cl.bc.d -MT C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc/obj.libclc.dir/nvptx64--/opencl/lib/generic/math/native_log.cl.bc -cl-no-stdinc -emit-llvm -o C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc/obj.libclc.dir/nvptx64--/opencl/lib/generic/math/native_log.cl.bc -x cl C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/lib/generic/math/native_log.cl && C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe -E cmake_transform_depfile Ninja gccdepfile C:/ws/buildbot/premerge-monolithic-windows/llvm-project/llvm C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc C:/ws/buildbot/premerge-monolithic-windows/build C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc/obj.libclc.dir/nvptx64--/opencl/lib/generic/math/native_log.cl.bc.d C:/ws/buildbot/premerge-monolithic-windows/build/CMakeFiles/d/a605fe704e455e2b625306ff40ba202ef9fba54cc8350cb8c03997fce314b48f.d"
In file included from C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/lib/generic/math/native_log.cl:10:
In file included from C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/include\clc/opencl/clc.h:215:
C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/include\clc/opencl/synchronization/barrier.h:9:38: error: unknown type name 'cl_mem_fence_flags'

    9 | _CLC_DECL _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags);

      |                                      ^

1 error generated.

[9380/13730] Generating obj.libclc.dir/nvptx--/opencl/lib/generic/atomic/atom_add.cl.bc
FAILED: tools/libclc/obj.libclc.dir/nvptx--/opencl/lib/generic/atomic/atom_add.cl.bc 
cmd.exe /C "cd /D C:\ws\buildbot\premerge-monolithic-windows\build\tools\libclc && C:\ws\buildbot\premerge-monolithic-windows\build\bin\clang.exe -target nvptx-- -c -fno-builtin -nostdlib -cl-std=CL3.0 -DCLC_NVPTX -IC:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/clc/include -IC:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/include -IC:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/lib/generic/atomic -MD -MF C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc/obj.libclc.dir/nvptx--/opencl/lib/generic/atomic/atom_add.cl.bc.d -MT C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc/obj.libclc.dir/nvptx--/opencl/lib/generic/atomic/atom_add.cl.bc -cl-no-stdinc -emit-llvm -o C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc/obj.libclc.dir/nvptx--/opencl/lib/generic/atomic/atom_add.cl.bc -x cl C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/lib/generic/atomic/atom_add.cl && C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe -E cmake_transform_depfile Ninja gccdepfile C:/ws/buildbot/premerge-monolithic-windows/llvm-project/llvm C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc C:/ws/buildbot/premerge-monolithic-windows/build C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc C:/ws/buildbot/premerge-monolithic-windows/build/tools/libclc/obj.libclc.dir/nvptx--/opencl/lib/generic/atomic/atom_add.cl.bc.d C:/ws/buildbot/premerge-monolithic-windows/build/CMakeFiles/d/834bfe0e6051255ff329f5640681ec3220dc5815895d82af6d04c6ab489765c8.d"
In file included from C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/lib/generic/atomic/atom_add.cl:14:
In file included from C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/lib/generic/atomic\atom_int32_binary.inc:9:
In file included from C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/include\clc/opencl/clc.h:215:
C:/ws/buildbot/premerge-monolithic-windows/llvm-project/libclc/opencl/include\clc/opencl/synchronization/barrier.h:9:38: error: unknown type name 'cl_mem_fence_flags'
    9 | _CLC_DECL _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags);
      |                                      ^

1 error generated.

[9381/13730] Generating obj.libclc.dir/tahiti-amdgcn-mesa-mesa3d/opencl/lib/amdgcn/workitem/get_group_id.cl.bc

sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
This commits moves all OpenCL builtins under a top-level 'opencl'
directory, akin to how the CLC builtins are organized. This new
structure aims to better convey the separation of the two layers and
that 'CLC' is not a subset of OpenCL or a libclc target.

In doing so this commit moves the location of the 'lib' directory to
match CLC: libclc/generic/lib/ becomes libclc/opencl/lib/generic/. This
allows us to remove some special casing in CMake and ensure a common
directory structure.

It also tries to better communicate that the OpenCL headers are
libclc-specific OpenCL headers and should not be confused with or used
as standard OpenCL headers. It does so by ensuring includes are of the
form <clc/opencl/*>. It might be that we don't specifically need the
libclc OpenCL headers and we simply could use clang's built-in
declarations, but we can revisit that later.

Aside from the code move, there is some code formatting and updating a
couple of OpenCL builtin includes to use the readily available gentype
helpers. This allows us to remove some '.inc' files.
ajaden-codes pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 6, 2025
This commits moves all OpenCL builtins under a top-level 'opencl'
directory, akin to how the CLC builtins are organized. This new
structure aims to better convey the separation of the two layers and
that 'CLC' is not a subset of OpenCL or a libclc target.

In doing so this commit moves the location of the 'lib' directory to
match CLC: libclc/generic/lib/ becomes libclc/opencl/lib/generic/. This
allows us to remove some special casing in CMake and ensure a common
directory structure.

It also tries to better communicate that the OpenCL headers are
libclc-specific OpenCL headers and should not be confused with or used
as standard OpenCL headers. It does so by ensuring includes are of the
form <clc/opencl/*>. It might be that we don't specifically need the
libclc OpenCL headers and we simply could use clang's built-in
declarations, but we can revisit that later.

Aside from the code move, there is some code formatting and updating a
couple of OpenCL builtin includes to use the readily available gentype
helpers. This allows us to remove some '.inc' files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libclc libclc OpenCL library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants