An open compiler translates CUDA for x86 multi-core processors

Summary

At the end of 2009 the open source project Ocelot released a just-in-time compiler that runs CUDA programs not only on NVIDIA graphics cards but also on x86 processors with several cores. To do so, it translates the GPU instructions into LLVM's intermediate language and generates machine code for any LLVM target from it. It had been validated against over 100 CUDA applications and was licensed under the New BSD licence.

What Ocelot solved

CUDA is NVIDIA's programming model for computing on the graphics card. Anyone who wrote for it was tied to NVIDIA hardware. Ocelot took the PTX intermediate code that the CUDA compiler generates and translated it so that it also ran on normal processors. This made it possible to test the same code without a graphics card and to run it on computers without an NVIDIA card.

This was valuable for research: programs could be compared, analysed and debugged on different hardware without rewriting the source code.

Why it mattered

In 2009 OpenCL had just appeared as a vendor-independent standard. Ocelot showed another way: not rewriting the code but bringing the existing CUDA code to other hardware with a compiler. The idea of working with LLVM as a common intermediate layer has since become widely established in the compiler world.

What became of it

The lock-in to CUDA is still one of NVIDIA's strongest arguments today, especially for AI applications. Projects such as AMD's HIP, which translates CUDA-like code for AMD cards, carry Ocelot's idea forward. Red Fox, which accelerated database queries on GPUs in 2013, also came from the same research group at Georgia Tech.

Ideas

  • A just-in-time compiler can translate GPU code to other hardware at run time.
  • LLVM serves as a common intermediate layer for many target architectures.
  • Translating existing code instead of rewriting it reduces lock-in to one vendor.

Insights

  • Programming models often tie software to a vendor more strongly than the hardware itself.
  • Compiler intermediate languages are a powerful tool against dependencies.

Facts

  • Ocelot translated CUDA programs via LLVM to x86 multi-core processors.
  • The compiler had been validated against over 100 CUDA applications.
  • The code was licensed under the New BSD licence.

References

Remarks

  • Ocelot came from Georgia Tech; the project page was originally hosted on Google Code.

Recommendations

  • In GPU projects, check early how strongly you are tying yourself to one vendor.
  • Use portable layers such as HIP, SYCL or OpenCL if hardware independence matters.

Read the original article

Search the Web Archive

Found a mistake or have something to add? Get in touch.