Comments, Code and Qt. Some words about the wonderful world of software engineering

7Apr/101

QtOpenCL tested on my old machine

Qt Labs posted today an interesting blog post about OpenCL and how Qt will help developers to make OpenCL easier for them.

OpenCL is an open standard and a framework developed by nVidia, Apple and ATI that let's programmer run a piece of code on the GPU (or in parallel simultaneously on the CPU too). The power of OpenCL comes from the fact that our GPUs are much more powerful than the normal CPUs and they are massively optimized to run code in parallel. By offloading the CPU from heavy calculations and by running the calculations in parallel on the GPU, we can achieve some very impressive performance boosts. I'll present the results on my machine below.

QtOpenCL is Qt's way to help us with OpenCL. It will, according to the blog post

The QtOpenCL library wraps the OpenCL 1.0 API in a Qt-style API.  It takes the pain out of OpenCL initialization, program compilation, and kernel execution.  It also provides convenience functions for interfacing to existing Qt facilities such as QImage and QtOpenGL.


I compiled the QtOpenCL module with Qt 4.7, and run the demos on my Ubuntu machine, which is already pretty dated.

processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 47
model name      : AMD Athlon(tm) 64 Processor 3000+
stepping        : 0
cpu MHz         : 1809.401
cache size      : 512 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt lm 3dnowext 3dnow up pni lahf_lm
bogomips        : 3618.80
clflush size    : 64
power management: ts fid vid ttp tm stc

On this machine I have an nVidia GeForce 8600 graphics card with 512MB of RAM sitting on a PCI Express 16X bus.

The most interesting demo is probably the Mandelbrot viewer that comes with the QtOpenCL source code . It will zoom in and out on a predefined path on the well-known figure and doing the calculations and drawing in real time.

I managed to get around 0.2 to 0.5 fps when running the demo using nothing but the CPU. Not very impressive, but quite expected from this old machine.

Mandelbrot viewer running only on the CPU, and getting 0.2 - 0.5 fps, topping at 1.2 fps in the beginning.

The power the OpenCL and parallel computing is evident when you run the same program but doing the calculations on the GPU. Here is the same application running on the same machine, but getting up to over 20 fps. Very impressive!

Mandelbrot viewer running on the GPU with OpenCL. Getting up to over 20 fps.

It is really a killer thing if Qt manages to abstract some of the complexity of OpenCL so that normal developers can take advantage of the GPU's power in their own applications. And not only that, but if they managed to integrate OpenCL as part of normal Qt operations to let the GPU do some of the operations in for example animation framework, image manipulation or use it in Qt Concurrency. The power of GPUs and DSPs is already evident when they are used in their special domains. But with OpenCL we can harness their awesome calculation power in more general application.

The future of computing is not in making program run faster sequentially, but in making them run well in parallel. OpenCL is the first step to this, and it is really nice to see Qt jumping on board so early on!

I must also say that Qt has made running OpenCL very easy to start with. The hardest part was actually to replace Ubuntu's stock nVidia driver with a fresh one that has OpenCL support (I got it from here: http://developer.nvidia.com/object/opencl-download.html#Linux). But after it was successfully installed, it was again just to follow the instructions (http://qt.nokia.com/doc/opencl-snapshot/building.html) and it worked on the first time. Although, I still wonder why the libraries are not installed to the system when using the .pro file currently in the repository?

So now it's for me just a matter of learning some OpenCL language based on C99 to write some kernels :-)

Technorati Tags: , , , ,

  • http://www.resumewritingservice.biz//home/premium-resume-writers/ resume writers

    The increase in performance using OpenCL is really impressive