Wednesday, November 9, 2011

Wrapping OpenCL™ in Vala℠

soda straw wrapper

Because of the recent stirs regarding OpenCL in our FLOSS ecosystem (think about clover, pocl, libclc and there is one I am missing ...) and some demand on my side, I tried to use OpenCL (in form of Intel's OCL SDK - as clover and pocl require some bleeding edge clang/llvm) from Vala - my favorite language in the ecological niche of GNOME.

My first attempt was a straight binding of the cl.h without modeling the intended OO structures. Modeling the intended structure is possible, but there are more things to do, like run-time checks (ever heard of ErrorCode?) ..
Yesterday I ended in writing a small set of wrapper classes in vala (so effectively a GLib wrapper around the low-level OpenCL C API), calling the native C functions via the created low-level API.
Today I got first basic kernel running, that's nice progress (I just tested in on a CPU, GPUto go ...)
This wrapper removes a lot of the boilerplate (and checks) needed to get OpenCL and a kernel running.

There is still much room for improvement in the wrapper, much can be cleaned up and VAPI can be restructured to incorporate the OO structure of OpenCL.
This could lead to a simpler wrapper.

Well, it's start - like the projects mentioned in the first paragraph ...
Dig into it at gitorious.

No comments:

Post a Comment