[cfe-dev] Ask for CUDA supports in Clang

Eli Bendersky eliben at google.com
Mon Oct 6 15:46:03 PDT 2014


On Mon, Oct 6, 2014 at 3:36 PM, Jingyue Wu <jingyue at google.com> wrote:

> Eli,
>
> Lacking of real support for threadIdx, blockIdx, etc. may be fine for
> Pengcheng (?) because he's doing CUDA->AST->CUDA transformation.
>
>
Yep, I think this is what I wrote below suggests. The linked header creates
fake declarations of these globals, which is good enough for Clang's
parsing.

Eli




> Jingyue
>
> On Mon Oct 06 2014 at 3:21:11 PM Eli Bendersky <eliben at google.com> wrote:
>
>> On Mon, Oct 6, 2014 at 11:25 AM, lipengcheng <pli at cs.rochester.edu>
>> wrote:
>>
>>> Thanks, Eli.
>>>
>>> May I know what your initial support is? Can you please open it to me?
>>> I don’t need too strong CUDA support, say generating CUDA code to LLVM
>>> IR. What I only need to do is to parse CUDA code to Clang AST, and then
>>> translate it back .
>>>
>>>
>> So this part should already work, if you're careful. The main missing
>> parts for just parsing the CUDA source into the AST are:
>>
>> 1. Real support for the threadIdx, blockIdx, etc. special globals
>> 2. Various header definitions for __global__ & friends, CUDA builtins,
>> etc.
>>
>> If all you need is to *parse*, then a simple header like
>> https://gist.github.com/eliben/b014ac17cbe5a452803f should do the trick.
>>
>> Then you can do:
>>
>> $ clang  -cc1 -ast-dump -x cuda  -include <path-to-header-file-in-gist>
>> cuda-input-file.cu
>>
>> And this should dump the AST. If you need to support more CUDA builtins
>> (and/or runtime functions), you should add them to the header, *or* try to
>> get Clang to parse the NVIDIA CUDA headers.
>>
>> Eli
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> Thanks,
>>> Pengcheng
>>>
>>> On Oct 6, 2014, at 12:34 PM, Eli Bendersky <eliben at google.com> wrote:
>>>
>>>
>>>
>>> On Mon, Oct 6, 2014 at 6:40 AM, lipengcheng <pli at cs.rochester.edu
>>> <https://urldefense.proofpoint.com/v1/url?u=http://mailto:pli%40cs.rochester.edu&k=p4Ly7qpEBiYPBVenR9G2iQ%3D%3D%0A&r=8jiWUOA7YNYuE%2FO4heswhF5KaS3dN4VEfeX8hooBpaw%3D%0A&m=Ndab2z%2B8lUH2UWs3LWtnM9Cai6wVRsOxorwsUutFIqM%3D%0A&s=b573ee104d18abf760999f0d33766404caaf2d891bf0bcb90fd60c8cadd7232b>
>>> > wrote:
>>>
>>>> > Hi there,
>>>> >
>>>> > May I ask what’s the status of supporting CUDA on Clang?
>>>> > Are there any incomplete patches to use for CUDA? I am doing
>>>> > a source-to-source translation work for CUDA based on Clang.
>>>> >
>>>> > Thanks,
>>>> > Pengcheng
>>>>
>>>>
>>> Hi Pengcheng,
>>>
>>> CUDA is still only partially supported. This has been discussed a few
>>> times this year:
>>>
>>> http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-September/038979.html
>>> <https://urldefense.proofpoint.com/v1/url?u=http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-September/038979.html&k=p4Ly7qpEBiYPBVenR9G2iQ%3D%3D%0A&r=8jiWUOA7YNYuE%2FO4heswhF5KaS3dN4VEfeX8hooBpaw%3D%0A&m=Ndab2z%2B8lUH2UWs3LWtnM9Cai6wVRsOxorwsUutFIqM%3D%0A&s=49732052e1fd12cadb980beea32db56ab3523a57d889cf839753864eed1a8b28>
>>> http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-March/035782.html
>>> <https://urldefense.proofpoint.com/v1/url?u=http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-March/035782.html&k=p4Ly7qpEBiYPBVenR9G2iQ%3D%3D%0A&r=8jiWUOA7YNYuE%2FO4heswhF5KaS3dN4VEfeX8hooBpaw%3D%0A&m=Ndab2z%2B8lUH2UWs3LWtnM9Cai6wVRsOxorwsUutFIqM%3D%0A&s=4e85032739b5ab7b3bc84963f894a88d40ccd6d71b27630a6b17221e44aec8ee>
>>>
>>> Things haven't changed significantly since then. Patches welcome!
>>> Eli
>>>
>>>
>>>
>>>
>>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141006/d888d8e8/attachment.html>


More information about the cfe-dev mailing list