<div class="gmail_quote">On Mon, Oct 24, 2011 at 6:24 AM, Alberto Magni <span dir="ltr"><<a href="mailto:alberto.magni86@gmail.com">alberto.magni86@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi everybody,<br><br>I am trying to produce ptx code starting from OpenCL C.<br>I am experiencing a problem concerning pointer parameters.<br>Here follows an example:<br><br>kernel void function(__global float* parameter1) {}<br>
<br>NVIDIA NVCC Compiler:<br><br>.entry function(<br> .param .u32 <b style="color:rgb(255, 0, 0)">.ptr</b> .global .align 4 function_param_0<br>)<br>{<br> ret;<br>}<br><br>CLANG + LLVM PTX backend<br><br>// (skipping builtin functions definitions)<br>
<br>.entry function (.param .b32 __param_1) // @function<br>{<br><br>// BB#0: // %entry<br> exit;<br>}<br><br>As you can see the code generated by the LLVM backend lacks the kernel parameter attribute<br>
.ptr, required to identify pointers [1]. I can understand that the address space attribute (.global) <br>is not defined since there is no agreement on how to represent them in the IR.<br></blockquote><div><br></div><div>
This is actually a PTX version issue. The .ptr annotations were introduced in PTX in version 2.2, and the back-end defaults to version 2.0. The CUDA driver API does not really care about this, but the NVidia OpenCL run-time requires this pointer attribute.</div>
<div><br></div><div>Try adding -Xclang -target-feature -Xclang +ptx23 to your command line.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>The command I use to compile is:<br>
clang kernels/<a href="http://parameters.cl" target="_blank">parameters.cl</a> -include ocldef.h -include <a href="http://builtin_functions_ptx.cl" target="_blank">builtin_functions_ptx.cl</a> -ccc-host-triple ptx32 -S -o -<br>
<br>where ocldef.h contains the definitions of OpenCL vector data types,<br>
<a href="http://builtin_functions_ptx.cl" target="_blank">builtin_functions_ptx.cl</a> is the file provided by Justin in a previous message [2].<br></blockquote><div><br></div><div>You may want to look into libclc: <a href="http://www.pcc.me.uk/~peter/libclc/">http://www.pcc.me.uk/~peter/libclc/</a></div>
<div><br></div><div>It provides more functionality than the file I posted eariler, and will most likely be the "official" OpenCL run-time library for the PTX back-end.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>Is this a bug? Or the .ptr attribute is just not supported yet ?<br><br>Thank you<br>
<br>Alberto<br><br>-------------------------<br><br>[1] PTX: Parallel Thread Execution ISA Version 2.3, page 30<br>[2] <a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-October/017699.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-October/017699.html</a><br>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div><br>