Design

Testing OpenCL GPU Capabilities

You might be surprised with the processing power that most modern software is wasting

Gaston Hillar is an IT consultant and author of more than 40 books. He can be contacted at gastonhillar@hotmail.com.

If you have a poweful OpenCL GPU available in a system, it is a good idea to understand its capabilities. You can do so by running algorithms in their CPU and GPU versions, and comparing the results. You might be surprised with the processing power that most modern software is wasting when it runs on a computer with an OpenCL GPU.

A few months ago, I wrote an article about an interesting utility called GPU Caps Viewer v1.8.6 which returns detailed information about the graphics cards and the GPU (short for "Graphics Processing Units") installed in a computer.

If GPU Caps Viewer lists your GPU as one of the CL devices, it is interesting to compare the results of running a few OpenCL demos in their CPU and GPU versions. The CPU version creates many threads that take advantage of the multiple cores, and therefore tries to take advantage of multicore microprocessors. The GPU version uses the multiple compute units offered by the OpenCL GPU and tries to minimize the CPU usage. Both tests produce the same real-time visual output with different frame rates according to their diverse capabilities.

The results will depend on your CPU and the OpenCL GPU. However, here I present some interesting results that will let you see the power that most modern software is wasting on high-end laptops. In this case, I am not going to consider power consumption but you must take into account that it is another important variable to watch when running these tests.

First, I ran the CL CPU-Mesh Deformer OpenCL demo. You just have to select it in the dropdown list located below OpenGL and OpenCL demos in GPU Caps Viewer, then click on the Start button. This demo shows a surface deformed by an OpenCL kernel running on the CPU, and then rendered through OpenGL. A dialog box lets you set the desired width and height for the window size that will render the animated surface and a dropdown list to specify the desired MSAA (short for "MultiSample Anti-Aliasing"). I left the default values for the window size, 600 for both width and height, but I selected 8X in MSAA. Once you have selected the desired values for the parameters, you just have to click Go!.

The demo is capable of generating 29 or 30 FPS ("Frames Per Second") most of the time. The average CPU usage is 40%.

[Click image to view at full size]

Figure 1: An OpenCL kernel running on the eight logical cores offered by the CPU is deforming the surface. The OpenGL render generates 29 or 30 FPS.

[Click image to view at full size]

Figure 2: The average CPU usage is 40% when the OpenCL kernel runs on the eight logical cores.

Then I ran the CL GPU-Mesh Deformer OpenCL demo. Again, you just have to select its name in the dropdown list located at the right below OpenGL and OpenCL demos in GPU Caps Viewer and then click on the Start | button. This demo shows the same surface deformed by an OpenCL kernel running on the GPU instead of the CPU. The rendering process is performed by OpenGL as in the previous execution. It is necessary to choose the same values selected for the CL CPU-Mesh Deformer OpenCL demo. And then again, you just click Go!.

The demo is capable of generating 40 or 41 FPS most of the time. The average CPU usage is 7%. There is more code running on the GPU.

[Click image to view at full size]

Figure 3: The OpenCL kernel running on the GPU is deforming the surface. The OpenGL render generates 40 or 41 FPS.

[Click image to view at full size]

Figure 4: The average CPU usage is 7% when the OpenCL kernel runs on the GPU.

The demo generates the same results with a difference in the sustained FPS rate. When the demo runs the OpenCL kernel on the GPU, it leaves a lot of CPU power free, because it is deforming the surface by running general-purpose code in the GPU. This demo is an excellent example of the new possibilities offered by OpenCL.

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task.
However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Video

This month's Dr. Dobb's Journal

This month,
Dr. Dobb's Journal is devoted to mobile programming. We introduce you to Apple's new Swift programming language, discuss the perils of being the third-most-popular mobile platform, revisit SQLite on Android
, and much more!