Both CUDA and OpenCL are well-known GPGPU-languages. Unfortunately there are some slight differences between the languages, which are shown below.
You might have heard of HiP, the language that AMD made to support both modern AMD Fiji GPUs and CUDA-devices. CUDA can be (mostly automatically) translated to HiP and from that moment your code also supports AMD high-end devices.
To give an overview how HiP compares to other APIs, Ben Sanders made an overview. Below you’ll find the table for CUDA, OpenCL and HiP, slightly altered to be more complete. The languages HC and C++AMP can be found in the original.
|Device||int deviceId||cl_device||int deviceId|
|Memory||void *||cl_mem||void *|
|Grid of threads||grid||NDRange||grid|
|Subgroup of threads||block||work-group||block|
|Scheduled execution||warp||sub-group (warp, wavefront, etc)||warp|
|Device Function||__device__||N/A. Implied in device compilation||__device__|
|Host Function||__host_ (default)||N/A. Implied in host compilation.||__host_ (default)|
|Host + Device Function||__host____device__||N/A.||__host____device__|
|Kernel Launch||<<< >>>||clEnqueueNDRangeKernel||hipLaunchKernel|
You see that HiP borrowed from CUDA.
The discussion is ofcourse if all alike APIs shouldn’t use the same wordings. A best thing would be to mix for the best, as CUDA’s “shared” is much more clearer than OpenCL’s “local”. OpenCL’s functions on locations and dimensions (get_global_id(0) and such) on the other had, are often more appreciated than what CUDA offers. CUDA’s “<<< >>>” breaks all C/C++ compilers, making it very hard to make a frontend of IDE-plugin.
I hope you found the above useful to better understand the differences between CUDA and OpenCL, but also to see how HiP comes into the picture.