[LLVMdev] Upstream PTX backend that uses target independent code generator if possible

Che-Liang Chiou clchiou at gmail.com
Mon Aug 9 17:01:07 PDT 2010

Hi David,

Thanks for asking.

On Mon, Aug 9, 2010 at 3:25 PM, David A. Greene <greened at obbligato.org> wrote:
> Che-Liang Chiou <clchiou at gmail.com> writes:
>> Hi there,
>> I have a working prototype of PTX backend, and I would like to
>> upstream it if possible.  This backend is implemented by LLVM's target
>> independent code generator framework; I think this will make it easier
>> to maintain.
> How does this relate, at all, to the backend here:
> http://sourceforge.net/projects/llvmptxbackend/
> If they are unrelated, can you do a comparison of the two?  Perhaps
> there are holes in each that can be filled by the other.  It would be
> a shame to have two completely different PTX backends.
I surfed their code, and it seems that they didn't use code generator.
That means there design should be similar to CBackend or CPPBackend.
So I guess it can't generate some machine instructions like MAD,
and there are some PTX instruction set features that are hard to exploit
if not using code generator.

But I didn't study their code thoroughly, so I might be wrong about this.

>> I have tested this backend to translate a work-efficient parallel scan
>> kernel ( http://http.developer.nvidia.com/GPUGems3/gpugems3_ch39.html
>> ) into PTX code.  The generated PTX code was then executed on real
>> hardware, and the result is correct.
> How much of the LLVM IR does this support?  What's missing?
Have to add some intrinsics, calling conventions, and address spaces.
I would say these are relatively small changes.

>> So far I have to hack clang to generate bitcode for this backend, but
>> I will try to patch clang to parse CUDA (or OpenCL) while I am
>> upstreaming this backend.
> I think it's a lot of work to do CUDA support for not much benefit.
> The OpenMP committee is working on accelerator directives and that's
> the better long-term approach, IMHO.  Clang/LLVM would be a great
> vehicle to generate/test ideas for such directives.
Thanks for suggestion.

> http://openmp.org/wp/
> http://www.pgroup.com/lit/articles/insider/v2n2a5.htm
>                         -Dave


More information about the llvm-dev mailing list