[LLVMdev] Function pointer parameters in PTX backend

Justin Holewinski justin.holewinski at gmail.com
Mon Oct 24 05:28:58 PDT 2011


On Mon, Oct 24, 2011 at 6:24 AM, Alberto Magni <alberto.magni86 at gmail.com>wrote:

> Hi everybody,
>
> I am trying to produce ptx code starting from OpenCL C.
> I am experiencing a problem concerning pointer parameters.
> Here follows an example:
>
> kernel void function(__global float* parameter1) {}
>
> NVIDIA NVCC Compiler:
>
> .entry function(
>  .param .u32 *.ptr* .global .align 4 function_param_0
> )
> {
>  ret;
> }
>
> CLANG + LLVM PTX backend
>
> // (skipping builtin functions definitions)
>
> .entry function (.param .b32 __param_1) // @function
> {
>
> // BB#0:                                // %entry
>  exit;
> }
>
> As you can see the code generated by the LLVM backend lacks the kernel
> parameter attribute
> .ptr, required to identify pointers [1]. I can understand that the address
> space attribute (.global)
> is not defined since there is no agreement on how to represent them in the
> IR.
>

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.

Try adding -Xclang -target-feature -Xclang +ptx23 to your command line.


>
> The command I use to compile is:
> clang kernels/parameters.cl -include ocldef.h -include
> builtin_functions_ptx.cl -ccc-host-triple ptx32 -S -o -
>
> where ocldef.h contains the definitions of OpenCL vector data types,
> builtin_functions_ptx.cl is the file provided by Justin in a previous
> message [2].
>

You may want to look into libclc: http://www.pcc.me.uk/~peter/libclc/

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.


>
> Is this a bug? Or the .ptr attribute is just not supported yet ?
>
> Thank you
>
> Alberto
>
> -------------------------
>
> [1] PTX: Parallel Thread Execution ISA Version 2.3, page 30
> [2] http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-October/017699.html
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>


-- 

Thanks,

Justin Holewinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111024/64e6ba4d/attachment.html>


More information about the llvm-dev mailing list