[libclc] [libclc] Declare workitem built-ins in clc, move ptx-nvidiacl workitem built-ins into clc (PR #144333)
Fraser Cormack via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 3 02:26:19 PDT 2025
frasercrmck wrote:
> > I am seeing unresolved CLC functions in `nvptx--.bc` and `nvptx64--.bc`. I think it's because we're now building things like `get_num_groups` for `nvptx`/`nvptx64`, whereas previously they were not being built for those targets. We're also not building `__clc_get_num_groups` because we're (correctly) not including `ptx-nvidiacl` sources.
>
> thanks @frasercrmck for the careful review. `nvptx--.bc` and `nvptx64--.bc` issue is fixed in [b1397a4](https://github.com/llvm/llvm-project/commit/b1397a4c0ba63a2fd2392aa064bfa351ce014a7d)
>
> Please let me know if I should revert following style change and follow existing tyle.
>
> 1. add #ifndef __CLC_OPENCL_WORKITEM_* guard in opencl header file and include needed #include <clc/internal/clc.h>. E.g. libclc/opencl/include/clc/opencl/workitem/get_global_id.h.
>
> 2. include only needed headers in OpenCL lib files, e.g. in libclc/opencl/lib/ptx-nvidiacl/workitem/get_local_linear_id.cl
>
>
> ```
> #include <clc/opencl/workitem/get_local_linear_id.h>
> #include <clc/workitem/clc_get_local_linear_id.h>
>
> _CLC_OVERLOAD _CLC_DEF size_t get_local_linear_id() {
> return __clc_get_local_linear_id();
> }
> ```
I think that's a good approach, thanks. We generally include far too much stuff in the OpenCL layer.
One comment is that I had initially intended for `clc/internal` to only be used by the CLC builtins. I realise it's already being used by some `fma.cl`s but we might want to nip it in the bud. Perhaps we need a stripped down OpenCL header, like `clc/opencl/opencl-base.h` which includes just the types and macro defs?
https://github.com/llvm/llvm-project/pull/144333
More information about the cfe-commits
mailing list