Hi,
OpenCL predefines many overloaded builtin functions (‘builtin’ in the sense of OpenCL spec) which are not defined in Clang. As such, to compile OpenCL kernels which call OpenCL ‘builtin’ functions, a header file declaring these functions is needed.
The khronos OpenCL header files can be found at these links:
https://github.com/KhronosGroup/SPIR/blob/spirv-1.0/lib/Headers/opencl-20.h
https://github.com/KhronosGroup/SPIR/blob/spirv-1.0/lib/Headers/opencl-12.h
I am wondering if upstreaming these header files to Clang trunk at clang/lib/Headers would save the OpenCL users the trouble of downloading these header files from different places.
Also with these header files upstreamed, we could make them implicitly included so that users do not need to include them explicitly.
Your feedback is welcome.
Thanks.
Sam
I see a benefit for the OpenCL users of open source Clang to be able to have the standard includes automatically or at least to have them in the same place as the compiler.
I am not sure if we might have some issue with their size though.
Each header is approximately 1MB large. It might be an issue not just for space but also parsing time. Using PCH would help to reduce compilation time but it seems PCHs have even larger size by a factor of 10.
For example:
opencl-12.h - 916K
opencl-12.h.pch - 1.9M
It is a bit surprising though since PCHs are stored using compressed bitstream as LLVM’s bitcode file format according to the documentation page. Has anyone looked at it before? Size is generally a problem for embedded devices.
Anastasia
but it seems PCHs have even larger size by a factor of 10.
To remove any confusion in my previous email, it’s actually factor of 2 (not 10!).
If there are no further comments to this, I think it makes sense to setup the review and continue with detailed discussions via cfe-commits.
I plan to address the PCH size issue in general as a separate thread.
Cheers,
Anastasia