[Libclc-dev] Difference between libclc and clover

Aaron Watry awatry at gmail.com
Mon Jan 6 12:02:14 PST 2014


Not sure about documentation, but here's my take on it:

Mesa: provides the state trackers for each API (in drivers that
support gallium), and the drivers for the various cards (e.g.
r600/radeonsi).
Clover: Is the state tracker that ships with Mesa to provide the OpenCL runtime.
libclc: Provides many of the built-in functions that are defined in
the OpenCL specification.  All functions are compiled to LLVM bitcode
(.bc files).

When running an OpenCL program on a Radeon SI-based card the program
lifecycle works like this:

1) Program links against -lOpenCL
    libOpenCL.so is either an instance of ocl-icd
(https://forge.imag.fr/projects/ocl-icd/), or something else that can
aid in CL platform/device discovery.  Mesa also supports building
clover's CL API and linking it directly as libOpenCL.so*. In this
case, clover directly provides the OpenCL runtime.

2) Program uses OpenCL API to discover platforms/devices that are
available.  One of them may be Mesa/clover.
3) If clover is used, the program will get a device and attempt to
compile its kernels.
4) When compiling kernels, clover uses clang to parse/compile kernels
(to LLVM IR I think). The libclc headers are used to provide the
declarations for any CL built-in functions that are needed by the
kernels
5) At some point in this process, we've generated LLVM IR from the
source kernels.
6) Now it's time to convert from IR to arch-specific binary code. In
the case of r600/radeonsi, we let LLVM do the job for us using the
R600 back-end in LLVM.
7) Lastly, we have to link the binary program together. In either step
6 or 7, we use libclc to provide pre-compiled implementations of the
OpenCL built-in functions (e.g. vstore/mad/clamp/etc)...
..
Note: There's some hand-wavy bits in there, and stuff that might be
less than perfectly accurate :)  That being said, hopefully it gives a
short general overview.  My knowledge of clover is partial, and while
I've looked at most of the code which mesa uses to convert CL source
into GPU executables, it's mostly just been scanning the code when
looking for specifics.

--Aaron


On Mon, Jan 6, 2014 at 12:36 PM, Dorrington, Albert
<albert.dorrington at lmco.com> wrote:
> I have been trying to get up to speed on llvm, clang, libclc, mesa and
> clover, for openCL development.
>
> I am a bit unclear on how libclc and mesa/clover fit together. Could anyone
> clarify, or poin tme in the direction of the appropriate documentation?
>
> (I have so far struck out in my google searches...)
>
>
>
> Thanks!
>
> -Al
>
>
>
>
>
>
>
>
> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at pcc.me.uk
> http://www.pcc.me.uk/cgi-bin/mailman/listinfo/libclc-dev
>




More information about the Libclc-dev mailing list