[cfe-dev] OpenCL/CUDA Interop with PTX Back-End

Peter Collingbourne peter at pcc.me.uk
Wed Oct 5 09:38:40 PDT 2011

On Wed, Oct 05, 2011 at 12:18:39PM -0400, Justin Holewinski wrote:
> Peter, one more question.  Is the "opencl.kernels" metadata a permanent
> thing, or is it a short-term hack?  I ask because I'm working on how to
> identify kernel vs. device functions in the PTX back-end.  The way I see it,
> I have two options:
>    1. Use a pass in the back-end to assign the proper calling convention to
>    each function, if the metadata is present.
>    2. Modify Clang (maybe through an extension of the CGOpenCLRuntime class)
>    to set the proper PTX calling convention when in OpenCL-mode.

I really don't like this metadata at all, and I'd prefer that we get
rid of it, but I think that ARM's (non-open-source) GPU backend relies
on it.

I think that the best approach is to modify Clang to set the
correct calling convention.  Specifically, we can override the
SetTargetAttributes function in PTXTargetCodeGenInfo to set the
calling convention based on the presence of the attribute if we are
in OpenCL mode.


More information about the cfe-dev mailing list