Results 1 to 5 of 5

Thread: LIBCLC: An OpenCL C Library Implementation

  1. #1
    Join Date
    Jan 2007
    Posts
    14,641

    Default LIBCLC: An OpenCL C Library Implementation

    Phoronix: LIBCLC: An OpenCL C Library Implementation

    It was just two days ago that the Portable OpenCL project was announced, but today there's another open-source OpenCL project that takes advantage of LLVM/Clang: libclc, an OpenCL C library implementation...

    http://www.phoronix.com/vr.php?view=MTAwMzI

  2. #2
    Join Date
    Jan 2009
    Posts
    1,656

    Default

    would it be possible for someone to explain how all these libraries interact with eachother or to put it better where do they fall in the stack????

    The only thing i think i have understood thus far is that Clover is the OpenCL state tracker that, as of now, works on G3D software and will need quite a few work to work on HW right??

    What about this and the other announced OpenCL projects


  3. #3
    Join Date
    Nov 2007
    Posts
    1,024

    Default

    Quote Originally Posted by 89c51 View Post
    would it be possible for someone to explain how all these libraries interact with eachother or to put it better where do they fall in the stack????

    The only thing i think i have understood thus far is that Clover is the OpenCL state tracker that, as of now, works on G3D software and will need quite a few work to work on HW right??

    What about this and the other announced OpenCL projects

    OpenCL is a standard that encompasses several different layers. What OpenCL specifies is a C API for compiling and executing programs written in a special language which is designed for massively parallel execution (and hence has various limitations compared to most programming languages but which offers incredible performance on the appropriate hardware). OpenCL also species the grammar and semantics of that language, also just called OpenCL. Finally, OpenCL specifies a standard library for that language, much like C or C++ specifies a standard library (a collection of types and functions and so on) which all conforming implementations must provide.

    All of the Open Source OpenCL implementation use Clang as the OpenCL compiler. That is, they have Clang convert from the raw text source code into an intermediate format (not the final executable format). Each Open Source implementation provides its own C API implementation, including the part that takes the compiler output (the IR) and converts into the actual executable form that the C API implementation is able to run on the target hardware. The standard library portions are at least partially implemented by each implementation, but there is no complete implementation.

    Clover's C API implementation compiles the Clang-generated IR into TGSI, which is then compiled by Gallium drivers into GPU machine code, allowing executing of OpenCL programs on your GPU (as they were intended to be).

    Portable OpenCL's C API implementation compiles the Clang-generated IR using LLVM (which is what Clang natively supports) allowing it to run on any LLVM-supported target. Right now that just means your host CPU and some highly specialized co-processors. Unlikely to ever support GPUs as doing so requires tight integration with the graphics driver, which means being integrated into Gallium (like Clover already is).

    libclc provides the standard library functions that OpenCL requires, which neither Clover nor Portable OpenCL offer in full. libclc only supports NVIDIA's proprietary stack right now, but should find its way into Portable OpenCL soon, and may find its way into Clover as well. It is likely being implemented on NVIDIA's stack first simply because that stack actually works while both Clover and Portable OpenCL are works in progress.

  4. #4
    Join Date
    Jan 2009
    Posts
    1,656

    Default

    thank you very much

  5. #5
    Join Date
    Mar 2011
    Posts
    13

    Default

    Hello,

    It's nice to see there is work going on for an open source OpenCL implementation. Here is my point of view.

    POCL is, for what I've seen in its source code, a C library that allows applications to compile OpenCL C code to LLVM IR. POCL also implements the functions needed to manage OpenCL buffers and other objects. It seems to be fairly complete. But OpenCL isn't only a C API, it's also a language. The language itself is nearly completely compiled by Clang, and works fairly well, but the OpenCL standard also comes with a bunch of functions one must provide in order to be compatible with OpenCL-using applications. They are things like cos(), tan2(), sqrt(), etc. There is a huge number of these functions, and every function must support float, float2, float3, float4, float8, float16 and even these same vector dimensions for uint, int, etc.

    Clover is equivalent to POCL. I have developed it during the summer, and this library is complete : it can handle all the OpenCL objects, and use Clang to compile OpenCL C to LLVM bitcode. Currently, Clover doesn't support TGSI and can only run the LLVM IR on the CPU, using the LLVM JIT, but it was engineered to be easily adaptable to produce TGSI.

    The problem of Clover and POCL is that there are many OpenCL C built-in functions to implement. Here comes libclc, a project that seems to aim to implement the OpenCL C functions, using LLVM intrinsics for example. This project is still very young though, and as I have seen, it only implements a small part of the functions requested by OpenCL.

    But there is a hope : Clover also implements some of these functions, and in a fairly efficient way. I'm currently working on these built-ins, the last thing missing before Clover is able to launch real OpenCL applications. You can follow my changes at http://cgit.freedesktop.org/~steckdenis/clover/log/ . Currently, I think that Clover is more advanced than the two other projects, but their developers may have more free time than me, and to they will move faster.

    I hope I've helped you to understand a bit more this story of OpenCL libraries. It is strange that two new OpenCL libraries are announced at only two or three days of interval, but it's good that people work on OpenCL under Linux.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •