<div class="gmail_quote">On Wed, Oct 5, 2011 at 12:38 PM, Peter Collingbourne <span dir="ltr"><<a href="mailto:peter@pcc.me.uk">peter@pcc.me.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Wed, Oct 05, 2011 at 12:18:39PM -0400, Justin Holewinski wrote:<br>
> Peter, one more question. Is the "opencl.kernels" metadata a permanent<br>
> thing, or is it a short-term hack? I ask because I'm working on how to<br>
> identify kernel vs. device functions in the PTX back-end. The way I see it,<br>
> I have two options:<br>
><br>
</div>> 1. Use a pass in the back-end to assign the proper calling convention to<br>
<div class="im">> each function, if the metadata is present.<br>
</div>> 2. Modify Clang (maybe through an extension of the CGOpenCLRuntime class)<br>
<div class="im">> to set the proper PTX calling convention when in OpenCL-mode.<br>
<br>
</div>I really don't like this metadata at all, and I'd prefer that we get<br>
rid of it, but I think that ARM's (non-open-source) GPU backend relies<br>
on it.<br>
<br>
I think that the best approach is to modify Clang to set the<br>
correct calling convention. Specifically, we can override the<br>
SetTargetAttributes function in PTXTargetCodeGenInfo to set the<br>
calling convention based on the presence of the attribute if we are<br>
in OpenCL mode.<br></blockquote><div><br></div><div>I agree, but I wasn't sure if the "opencl.kernels" metadata was the "proper" way to do it with Clang.</div><div><br></div><div>I just committed a patch for this. The only variation from what you suggested is an additional check to force device functions to be the default in PTXABIInfo. Otherwise, if kernels functions were the default (as could be the case, depending on triple), then some of the optimization logic was getting confused and replacing entire functions with llvm.trap calls due to calling convention mis-matches. I think the problem had to do with device functions being marked as kernel functions initially, then changed to device functions in SetTargetAttributes.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Thanks,<br>
<font color="#888888">--<br>
Peter<br>
</font></blockquote></div><br><br clear="all"><div><br></div>-- <br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div><br>