Nvidia seems to be dominating the HPC / GPGPU computing landscape with CUDA. If I want to write a scientific application using and AMD GPU, what is the preferred language these days? I believe it used to be OpenCL and then I was hearing a lot about OpenACC which could work on Nvidia chips too. Now I’m seeing something about ROCm? Feeling a bit confused here!


I can't speak to how you would best work with an AMD GPU.

However, of the languages you list CUDA could be considered the lowest level, highest-performance language for general applications. This is because it's a hardware-specific language developed by the vendor specifically for their hardware. It can and does offer options that won't translate directly to other GPUs. For this reason, using it can produce vendor lock-in.

However, CUDA can be difficult to program with as it requires a decent understanding of how GPUs work as well as writing your code in a CUDA-compatible fashion. If your goal is to accelerate easier problems quickly or move old code onto a GPU without having to rewrite thousands of lines, then CUDA is a poor choice.

Instead, you want OpenACC or OpenMP 4.5+. Both of these language extensions allow you to parallelize your code with a minimum of fuss and knowledge, e.g.:

#pragma acc parallel loop //Memory movement handled automagically
for(int i=0;i<10000000;i++)
  a[i] = std::sqrt(std::log(a[i])+1.0); //Tada! I'm on the GPU

OpenMP and OpenACC do essentially the same thing, but OpenMP is an "open standard" while OpenACC is essentially Nvidia's attempt to co-opt the idea of open standards to their advantage. OpenACC also came to market first as part of this strategy. Moving between the two is not especially difficult, yet.

The last time I checked only Nvidia's PGI compiler supported OpenACC fully and only IBM's XL compiler supported OpenMP's target directives fully. But you can expect support for both to expand.

Kokkos, Thrust, Tensorflow, and other such libraries provide alternative high-level ways to leverage the GPU.

I can't speak to what ROCm does, but it looks as though it provides a hardware-indepent runtime library for OpenCL as well as HIP (which looks like an open, platform independent CUDA-esque language).

| cite | improve this answer | |

I don't have enough reputation, so I (have to) post an answer instead of a comment.

An alternative is to use the HIP compiler with its own language. See here: https://github.com/ROCm-Developer-Tools/HIP

In addition to the GPU-agnostic language, this compiler seems to be able to transform CUDA code to be executed on AMD GPUs.

| cite | improve this answer | |
  • 1
    $\begingroup$ I would say this qualifies to be an alternative-type answer, being a bit more than a comment in my mind. So, I would not move it to comments if you don't insist. $\endgroup$ – Anton Menshov Jun 25 '19 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.