Hi,<br><br>i just tried libclc and it contains several definitions that could be useful for my goal,<br>although it doesn't contain the whole OpenCL spec. Maybe i will have to add<br>some functions but it works for me now.<br>
<br>Thanks.<br><br><div class="gmail_quote">2012/3/6 Peter Collingbourne <span dir="ltr"><<a href="mailto:peter@pcc.me.uk">peter@pcc.me.uk</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tue, Mar 06, 2012 at 06:17:37AM -0800, ulop9 wrote:<br>
> Hi,<br>
><br>
> i'm trying to use Clang to generate the AST of an OpenCL kernel, to then<br>
> parse it and get some statistics about it (e.g. the number of floating<br>
> additions).<br>
><br>
> I'm using Clang the following way: clang -cc1 -ast-dump -x cl "Kernel file"<br>
> > "Kernel ast"<br>
><br>
> The point in here is that clang doesn't recognize OpenCl built-in functions,<br>
> functions such as "get_local_id()" give implicit declaration error. My<br>
> question is if there is any file where all these functions are defined.<br>
><br>
> I've searched along the mailing list and the most similar solution to my<br>
> problem i've found is in:<br>
> <a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-October/017800.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-October/017800.html</a><br>
><br>
> The ocldef.h file done by Speziale Ettore contains several definitions for<br>
> built-in functions<br>
> generated by TableGen as described in the post.<br>
> This file doesn't include all the functions in the OpenCl specification<br>
> Section 6, just some done by hand with TableGen, so i don't know if the only<br>
> solution is to complete this file or there is some<br>
> header file with all the declarations.<br>
><br>
> Thanks in advice.<br>
<br>
</div>You can also look at libclc, which is a project aimed to become a<br>
standard library implementation for OpenCL C.  libclc is nowhere<br>
near finished but it covers many commonly used functions, and you<br>
are welcome to contribute more.<br>
<br>
<a href="http://libclc.llvm.org/" target="_blank">http://libclc.llvm.org/</a><br>
<br>
The compile-test.sh script in the root directory shows you how to<br>
compile a source file using libclc for the ptx32 target.  Since you<br>
are only collecting statistics it shouldn't matter much which target<br>
you use, so ptx32 should be fine.<br>
<br>
Thanks,<br>
<span class="HOEnZb"><font color="#888888">--<br>
Peter<br>
</font></span></blockquote></div><br>