[cfe-dev] OpenCl Built-in function declaration

Unai Lopez ulopez009 at ikasle.ehu.es
Wed Mar 7 02:20:28 PST 2012


Hi,

i just tried libclc and it contains several definitions that could be
useful for my goal,
although it doesn't contain the whole OpenCL spec. Maybe i will have to add
some functions but it works for me now.

Thanks.

2012/3/6 Peter Collingbourne <peter at pcc.me.uk>

> On Tue, Mar 06, 2012 at 06:17:37AM -0800, ulop9 wrote:
> > Hi,
> >
> > i'm trying to use Clang to generate the AST of an OpenCL kernel, to then
> > parse it and get some statistics about it (e.g. the number of floating
> > additions).
> >
> > I'm using Clang the following way: clang -cc1 -ast-dump -x cl "Kernel
> file"
> > > "Kernel ast"
> >
> > The point in here is that clang doesn't recognize OpenCl built-in
> functions,
> > functions such as "get_local_id()" give implicit declaration error. My
> > question is if there is any file where all these functions are defined.
> >
> > I've searched along the mailing list and the most similar solution to my
> > problem i've found is in:
> > http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-October/017800.html
> >
> > The ocldef.h file done by Speziale Ettore contains several definitions
> for
> > built-in functions
> > generated by TableGen as described in the post.
> > This file doesn't include all the functions in the OpenCl specification
> > Section 6, just some done by hand with TableGen, so i don't know if the
> only
> > solution is to complete this file or there is some
> > header file with all the declarations.
> >
> > Thanks in advice.
>
> You can also look at libclc, which is a project aimed to become a
> standard library implementation for OpenCL C.  libclc is nowhere
> near finished but it covers many commonly used functions, and you
> are welcome to contribute more.
>
> http://libclc.llvm.org/
>
> The compile-test.sh script in the root directory shows you how to
> compile a source file using libclc for the ptx32 target.  Since you
> are only collecting statistics it shouldn't matter much which target
> you use, so ptx32 should be fine.
>
> Thanks,
> --
> Peter
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120307/44fb3f85/attachment.html>


More information about the cfe-dev mailing list