Implementation of OpenCL in clang

is there any implementation for OpenCL, like function qualifiers __kernel and the address space qualifiers (__global, __local, __constant, __private) in LLVM’s Clang ?

As far as I know clang currently does not support OpenCL. There are some efforts of patching clang to support OpenCL that I’ve heard of, but it’s not made it into mainstream clang yet and it seems to go rather slow…
I’d really like to see clang supporting OpenCL too. I’d be really helpful for my research.

For now, you can help yourself with a little hack. For example, you can always include a header file that defines the OpenCL keywords, as in

#define __kernel __attribute__((annotate("kernel")))
#define __global __attribute__((annotate("global")))

That’s what I’ve done anyway. It’s not very elegant but it works for me.


Thanks for the hint, I will use this. Hopefuly in the future an implementation for clang will be available from LLVM developers.

Have a nice weekend,

Also you might consider the following as a possible alternative for the address spaces
#define __global attribute((address_space(1)))
#define __local attribute((address_space(3)))
#define __constant attribute((address_space(2)))
#define __private attribute((address_space(4)))
Or some similar numeric bindings