GPU Programming, CUDA or OpenCL?

CudaGpgpuGpu

Cuda Problem Overview


I am a newbie to GPU programming. I have a laptop with NVIDIA GeForce GT 640 card. I am faced with 2 dilemmas, suggestions are most welcome.

  1. If I go for CUDA -- Ubuntu or Windows Clearly CUDA is more suitable to windows while it can be a severe issue to install on Ubuntu. I have seen some blogposts which claim to have installed CUDA 5 on Ubuntu 11.10 and Ubuntu 12.04. However, I have not been able to get them to work. Also, standard CUDA textbooks prefer to work in the windows domain and are more or less silent in concern with Unix/Ubuntu installation and working.

  2. CUDA or OpenCL -- Now this is probably more trickier than my first question ! I have mostly come across GPGPU projects using CUDA/Nvidia but OpenCL is probably is the next best option in open source and installing in Ubuntu probably will not be an issue, though some suggestions here will be most useful. Am I sacrificing any functionality if I go for OpenCL and NOT CUDA ?

Any help or suggestions ?

Cuda Solutions


Solution 1 - Cuda

  1. If you use OpenCL, you can easily use it both on Windows and Linux because having display drivers is enough to run OpenCL programs and for programming you would simply need to install the SDK. CUDA has more requirements on specific GCC versions etc. But it is not much more difficult to install on Linux also.

  2. In Linux CUDA has strange requirements such as using GCC 4.6 or 4.7. If you use a different version of GCC, you won't be able to compile your program anymore. If you use OpenCL, you can use any compiler because you would just need to link with the common OpenCL library. So OpenCL is easier to setup, use and compile for. Once you compile an OpenCL program it can be run on any hardware (as long as it is coded to do so) even if it was compiled using another brand's OpenCL SDK.

You can write OpenCL programs which will function on Nvidia, AMD, and Intel hardware, on GPUs, CPUs, and Accelerators. Even more, Altera is working on supporting OpenCL on FPGAs! If you use CUDA, you will have to use Nvidia GPUs only and re-write your code again in OpenCL or other language for other platforms. A serious limitation of using CUDA and cause of serious waste of time in the long run.

I see that somebody posted some old references between CUDA and OpenCL, but they are old! When those documents were out, only AMD properly supported OpenCL. Since 2013, OpenCL is supported by ARM, Altera, Intel etc. and became an industry standard.

The only downside is that since OpenCL is so flexible, you are faced with more options and ways to code memory allocations, transfers etc. in your program. Therefore it may feel more complicated perhaps.

Solution 2 - Cuda

I think it is not very difficult to set up cuda environment on ubuntu, you can give it a try.

As a computing architecture student, I think you need to learn both of OpenCL and CUDA. And you should learn cuda first because CUDA exposes more hardware and runtime info, hardware awareness is very important when you want to optimize your GPU codes.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionArkapravoView Question on Stackoverflow
Solution 1 - CudaEvren YurtesenView Answer on Stackoverflow
Solution 2 - CudaXiaolong XieView Answer on Stackoverflow