[cfe-dev] Parsing CUDA file to AST

Eli Bendersky eliben at google.com
Wed Mar 5 13:21:37 PST 2014


On Wed, Mar 5, 2014 at 4:12 AM, jotas <julian.maciejewski at gmail.com> wrote:

> Hi,
> I ma building rewriter based on clang (based on some tutorial available on
> the internet).
> I am loading CUDA file and trying to traverse AST. I got a problem. It
> doesn't recognize CUDA directives like __global__ etc.
> I set:
> TheCompInst.getLangOpts().CUDA = 1;
> and source search patch to:
> /usr/include/linux
>
> Sould I do someting more?
>
> I get an error:
>
> :~/Documents/rewriter$ ./rewritersample bigfunc2.c
> bigfunc2.c:17:1: error: unknown type name '__global__'
> __global__ void foo22(int *a, int *b, int *c) {
> ^
> bigfunc2.c:17:12: error: expected identifier or '('
> __global__ void foo22(int *a, int *b, int *c) {
>            ^
> #include <cuda.h>
>
> #define N_WAVE          1024
> #define LOG2_N_WAVE     10
>

These are usually defined as preprocessor macros in the CUDA headers,
something like:

#define __device__ __attribute__((device))

You can take a peek at the public CUDA headers for more information.

Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140305/8893ba25/attachment.html>


More information about the cfe-dev mailing list