CUDA programming is difficult

Why you should bother with CUDA, OpenCL, and OpenGL.

What is CUDA? What about OpenCL and OpenGL and why should we bother with them? The answers to these questions are difficult to define, but we will try to find a clear explanation in language that is easy to understand.

There comes a time in the life of a video editor when he inevitably ponders the basic questions: “Is that all the speed that is realizable? Are there no other options? Like searching for the meaning of life or some great unified theory, this simple thought takes you into an endless and infinitely deep abyss of contemplation and research until you inevitably come across a question to which you simply cannot get a real answer.

We can't help you with a great unified theory, but we can say that the wall of information you will ultimately hit in your quest for the speed of video processing will ultimately be due to, “What is CUDA? What is OpenCL and why should I deal with it? "

In order to be able to understand CUDA and OpenGL, you also have to deal intensively with OpenCL. "

You can access many definitions on the internet wikis, read topic-related forums, and visit the sites that maintain these standards, but you will still be confused. In this article we would like to shed light on the darkness with a language that is as understandable as possible, but as already mentioned above, you can only understand CUDA and OpenGL if you are also familiar with OpenCL.

What is CUDA?

CUDA was developed by the graphics card manufacturer Nvidia and enables your programs to use the intelligence of your graphics card as a sub-CPU. Your CPU forwards certain tasks to the CUDA-enabled card. The graphics card specializes in processing things like lighting, movement and interaction as quickly as possible and even sending them across multiple lanes at once - as if you had four tills in the supermarket for a shopping cart. The results of this work are then passed back to the CPU, which has since come to bigger and better results.

The advantages.

It is relatively easy for programmers to integrate. Since it is software-based, a large part of the system has to be programmed into the program code so that its function can be varied or adapted. Since the main functionality of CUDA is the calculation, data generation and image manipulation, the processing, rendering and export times of your effects can be shortened considerably, especially when scaling up or down. Image analysis can also be improved, as can simulations such as fluid dynamics and predictive processes such as weather patterns. CUDA is also great for light sources and ray tracing. All of this means that features like rendering effects, video encoding and conversion will be much faster.

The disadvantage.

This means that not everyone can use CUDA immediately. This only works with "CUDA-capable" graphics cards. Since CUDA is owned by Nvidia, you will need a graphics card made by that company. For example, if you have a Mac Pro PC, this is simply not an option for you as these only come with AMD graphics cards. There are third-party options here, but Apple only ships AMD in their packages. You will also find that fewer programs support CUDA than its alternative, so let's talk about this other option.

What is OpenCL?

OpenCL is a relatively new system and can be seen as an alternative to CUDA for our discussion. However, it is an open standard - this means that everyone can use their functionality in their hardware and software without paying for proprietary technologies or licenses. While CUDA uses the graphics card for a co-processor, OpenCL passes the information in full and uses the graphics card as a separate universal peer processor. It's a small philosophical distinction, but in the end there is a quantifiable difference. It is a little more difficult for the programmer to program. As a user, you are not tied to a single vendor, and support is so widespread that most programs don't even mention its use.

What is OpenGL

OpenGL really is the beginning of the story. It's not about using the graphics card as a universal processor. Instead, it's simply a matter of drawing pixels or corner points on the screen. It's the system that allows your graphics card to create 2D and 3D displays for yours much faster than your CPU. Just as CUDA and OpenCL are alternatives to each other, OpenGL is an alternative to systems like DirectX on Windows. Put simply, OpenGL draws everything to your screen very quickly, OpenCL and CUDA do the calculations necessary when your videos interact with your effects and other media. OpenGL can place your video in the editing surface and have it play, but when you apply color correction to it, CUDA or OpenCL does the calculations to properly change every pixel of the video.

OpenGL can be implemented at the hardware level, i.e. programmers don't have to include the code in their program, they just have to call it. In addition, hardware manufacturers have the option of adding extensions to the core functionality, which means that some hardware could do better than others at certain tasks. This allows for very specific customization.

Where the user will see the benefits of OpenGL is in the operational capabilities of the software. Previews are displayed particularly quickly. In many programs it is also used for accelerated interfaces and overlays such as timelines, footage, windows, grids, guides, rulers and bounding boxes.

Ultimately, OpenGL is not an issue for the user, since both OpenCL and CUDA can and want to use the OpenGL system. What you need to understand here is that if you have a graphics card with the latest OpenGL support, you will always work faster than you would on a computer with a CPU and integrated graphics.

In a nutshell.

What does all of this mean for you and your workplace? Which is better - CUDA or OpenCL? We'll assume you've taken the first step, checked your software, and whatever you're using supports both options. If you have an Nvidia card then use CUDA. It is mostly considered faster than OpenCL. Also note that Nvidia cards support OpenCL. The general consensus is that they aren't as good at it as AMD cards, but they are getting closer and closer to them. Is it worth buying an Nvidia card just for CUDA support? This would depend on too many specific case factors that we could not consider here. You need to specify your needs and do your research. Not only what kind of work your company does, but also down to the individual machine as well as its workload and function. Before buying, you should also plan an intensive test phase.

Adobe, for example, explains on the company's website that, with a few exceptions, everything that CUDA does for Premiere Pro can also be done by OpenGL. It is also stated that it does not use either of these two methods of encoding or decoding. However, they can be used for rendering previews and final exports. The majority of those who have compared the two seem interested that CUDA is faster with Adobe products. CUDA has the advantage of being self-contained, which can result in faster performance due to better optimization.

Personal experiences.

We would also like to take the opportunity to communicate our personal experiences in this article. Please note, however, that we did not conduct any specific tests. We speak only for ourselves. Our experience is that CUDA, when available, works excellently and can really noticeably increase the working speed. However, we also need to point out a few crashes or glitches while rendering, transcoding, and exporting. Also, on a few rare occasions, we ran out of options and turned off CUDA, which eventually led to a successful outcome. We have never had to do the opposite. We have to add that our working hours with CUDA were also severely limited. We have experienced these problems when using more than one program, so it could possibly be due to an outdated version of CUDA. I just found it important enough to mention that things like that should be looked out for. Therefore, we do not want to recommend one or the other option here.

If you're able to figure out if your graphics card, or your entire system, is slowing down your workflow, then chances are that upgrading to a new card can make a huge improvement over what you're currently using. A good understanding of these technologies will help you understand where to start to make your workplaces as effective as possible. Investing in a card that supports the use of the graphics processor to supplement or relieve the CPU will greatly speed up your workflow.

Thanks for your visit.