2

Here is my objective: I want to code a ray tracing engine in C++ that can be run on any GPU. That means that it should work on NVIDIA GPUs, AMDs, or even Intel Graphics chipsets. The choice of C++ was made because the final program will be used by a third party user who will not be able to install anything on his machine, but only run my executable.

At this point in my research, it appeared to me that the best solution was to use SYCL. Theoretically, SYCL is supposed to work on any OpenCL device. In practice, from what I have experienced so far, it is a horror to run and compile.

All of them promise great compatibility with manufacturers, but from what I could try Intel only compiles for Intel chipsets, ComputeCpp only works with some AMD and Intel GPUs, and hipSYCL is only usable with some AMD GPUs. This information should be taken with a pinch of salt, but that's what it seemed to me during my tests.

I would be interested in an alternative solution that can run a single code on any GPU, or a method that explains how to cleanly compile a SYCL code to run it on any hardware. Unfortunately, I don't know if this is possible.

Balfar
  • 63
  • 5
  • 1
    I'd like to share that, at least in this field, "I want an X that works for every Y," (here X = portability framework and Y = GPU) you are sure to come upon trade-offs and surely cannot cover every possible Y (people even make their own GPUs: https://vortex.cc.gatech.edu/). Thus, clarifying your priorities, applications, and use cases are important. If 99% of users will be on NVIDIA GPUs for the next 10 years, you may be able to allow for rather poor performance on other architectures. If performance is less important than covering more possible Y's (GPUs), then prioritize portability. –  Jul 20 '22 at 23:27
  • Thanks a lot for this message, got it! – Balfar Jul 21 '22 at 08:11

2 Answers2

4

There are a number of C/C++ libraries that provide portability layers. Off the top of my head, there's Kokkos, OCCA, OpenMP, Raja, and OpenACC. Support for non-NVIDIA GPUs might not be there yet, but AMD and Intel support is being funded for most of them.

  • Kokkos is template-based, and has a fair bit of use and support.
  • OCCA is more object oriented, but isn't as popular.
  • OpenMP is directives based parallelism and has recently added off-loading to GPUs. It's a compiler standard, so support highly depends on your compiler.
  • Raja is also template-based, although I've not personally used it.
  • OpenACC is also directives based programming just for GPUs. But, it isn't as popular as OpenMP.

You might also want to look at what the graphics community uses since ray-tracing can be used in rendering. I know OpenGL and Vulkan are two such libraries, but I don't know much about them.

Neil Lindquist
  • 815
  • 6
  • 10
3

The Julia GPUCompiler.jl stack uses Julia code as the front end and LLVM's compilation to retarget it to various compute devices. It has kernel generators for:

KernelAbstractions.jl is then a system for helping generate hardware-independent compute kernels from Julia code (built on GPUCompiler.jl of course).

And note that these are generic Julia codes, they support things like automatic differentiation.

Chris Rackauckas
  • 12,320
  • 1
  • 42
  • 68
  • This is interesting, thanks. I've never used Julia before but these solutions look efficient. But I would prefer something that can be used with C++, only because I want to obtain an .exe at the end. The program is supposed to be used by another person that cannot install anything on his computer. – Balfar Jul 19 '22 at 07:44
  • 1
    Julia can generate executables with https://github.com/JuliaLang/PackageCompiler.jl. – Chris Rackauckas Jul 19 '22 at 10:36