Using OpenCL with Qt

Qt SoftwareRecently we have been experimenting with OpenCL and Qt, to see what Qt needs to make it easier to use OpenCL and to see what Qt could use it for internally.  In this post we are going to give an introduction to OpenCL, the QtOpenCL wrapper library, show how to write your first QtOpenCL program, and tell you where to get more information on the project.

What is OpenCL anyway? – For those new to it, OpenCL is an open, royalty-free standard for parallel programming in a heterogeneous computing environment. The most common use you’ve probably heard of is to run arbitrary C code on your system’s GPU. These days GPU’s are more powerful than CPU’s, having been designed to pump out hundreds of thousands of textured triangles per second in your favorite shoot-em-up video game.  To do this, the GPU has access to parallel vector processing that far exceeds the capability of x86/SSE or ARM/NEON instructions on your average CPU.

For years, shader languages like GLSL have made the vector capabilities of the GPU available for arbitrary shader effects in OpenGL, but you are basically limited to whatever parameters a “draw triangle” call takes.  It’s also quite typical for OpenGL implementations to cut corners by using fixed-point and lower precisions.  The shader source code may say “float”, but it could be as little as 8 bits of actual precision.  While great for pumping out triangles where you won’t notice an “off-by-0.001″ error, this isn’t very useful for supercomputing, common mathematical algorithms, and super-precise pixel blending.

Enter OpenCL.  It defines a new C-style language that is more precise as to mathematical precision, and which allows arbitrary arguments to be provided to an OpenCL function – known as a kernel – to do almost anything that C can do. Special vector types like “float4″ are provided as well as an extensive mathematical library.  But its most impressive feature is work sizes – it is very easy to split your task up into small chunks that the GPU can scatter across all of its compute units (compute units include whatever CPUs and GPUs OpenCL can find, OpenCL uses everything available).  Unlike regular C where you can spend a lot of time writing outer loops and launching worker threads for subparts of your problem, OpenCL does it for you. We’ll see how that works shortly. Continue reading.

Related Posts

Gnome and Mozilla Foundations to Join Forces The Gnome Foundation, which is responsible for the Gnome project, and the Mozilla Foundation, a non-profit organization responsible for overseeing the...
Samba 3.2 Released Samba, the open source file and print server for Windows clients, has been updated to version 3.2. The previous stable version was version 3.0.30, and...
Trolltech’s Qt to be licensed under the GPL v3 Trolltech ASA is licensing its Qt cross-platform development framework under the GNU General Public License version 3 (GPL v3), with immediate effect....
Theora 1.0 Released The Xiph.Org Foundation has announced the release of Theora 1.0. "Theora is a video codec with a small CPU footprint that offers easy portability and ...
OpenOffice.org 2.4 Released "The OpenOffice.org Community is pleased to announce the release of OpenOffice.org 2.4, the latest version of the leading open source office productiv...
View Your Mind VYM (View Your Mind) is a tool to generate and manipulate maps which show your thoughts. Such maps can help you to improve your creativity and effecti...

We Recommend These Vendors and Free Offers

ContainerizeThis 2016 is a free, 2-day conference for all things containers and big data. Featured, will be presentations and free, hands-on workshops. Learn more at ContainerizeThis.com

Launch an SSD VPS in Europe, USA, Asia & Australia on Vultr's KVM-based Cloud platform starting at $5:00/month (15 GB SSD, 768 MB of RAM).

Deploy an SSD Cloud server in 55 seconds on DigitalOcean. Built for developers and starting at $5:00/month (20 GB SSD, 512 MB of RAM).

Want to become an expert ethical hacker and penetration tester? Request your free video training course of Online Penetration Testing and Ethical Hacking

Whether you're new to Linux or are a Linux guru, you can learn a lot more about the Linux kernel by requesting your free ebook of Linux Kernel In A Nutshell.


Leave a Comment

Your email address will not be published. Required fields are marked *

*