[libclc] [libclc] Declare workitem built-ins in clc, move ptx-nvidiacl workitem built-ins into clc (PR #144333)

Wenju He via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 2 20:09:24 PDT 2025


wenju-he 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 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();
}
```


https://github.com/llvm/llvm-project/pull/144333


More information about the cfe-commits mailing list