2
$\begingroup$

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.

$\endgroup$
2
  • 1
    $\begingroup$ 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: 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. $\endgroup$
    – user20857
    Jul 20, 2022 at 23:27
  • $\begingroup$ Thanks a lot for this message, got it! $\endgroup$
    – Balfar
    Jul 21, 2022 at 8:11

2 Answers 2

4
$\begingroup$

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.

$\endgroup$
3
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ 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. $\endgroup$
    – Balfar
    Jul 19, 2022 at 7:44
  • 1
    $\begingroup$ Julia can generate executables with github.com/JuliaLang/PackageCompiler.jl. $\endgroup$ Jul 19, 2022 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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