RenderKit / embree

Embree ray tracing kernels repository.
Apache License 2.0
2.32k stars 383 forks source link

rewrite embree using sycl with CPU version #458

Closed peiZhaoQiu closed 9 months ago

peiZhaoQiu commented 9 months ago

Hi, I'm currently attempting to implement a ray tracing algorithm using Embree as the backend. I've already created the C++ version and now I want to scale it to a homogeneous system using SYCL. I understand that there is a SYCL version of Embree that utilizes Intel architecture GPU hardware components, but I don't have an Intel GPU. My goal is to make my implementation vendor-neutral, as one of the main ideals of using SYCL is to break free from vendor lock-in.

Currently, I aim to transform my CPU-based Embree application into a SYCL-based one while using the non-SYCL version of Embree (the CPU implementation) as a third-party library. I believe this should be possible, as I've seen claims on the Internet of people using Embree in CUDA applications. I'd like to ask if this approach is feasible and, if not, how challenging the conversion process might be. I'm aware that the non-SYCL version of Embree isn't optimized for GPU acceleration, but for now, my primary goal is to make it work

I have now re-written the Embree ray intersection example with sycl which imports the Embree CPU version as a third-party library (https://github.com/ucglaedin/syclEmbreeRayIntersetction) The program compiled but gives the wrong result, can you give me some hints as what are goes wrong?

svenwoop commented 9 months ago

You can use Embree in SYCL only to run in Intel GPUs at the moment. Using Embree through SYCL on the CPU is not supported. What you can do to switch between CPU and GPU rendering is using some tbb::parallel_for for CPU rendering and some sycl::parallel_for for GPU rendering, with both kernels invoking the exact same render function. Also I cannot compile your example, it gives me an error of invalid implicit capture of this, and when fixing that problem of accessor<...>& cannot get used as kernel parameter. Nevertheless, the way the code is using Embree in SYCL currently is not going to work.

peiZhaoQiu commented 9 months ago

Thank you so much for replying, sorry for the error, it is an old error that I fixed but forgot to update with git. Can you please try to recompile with the current version? For me, it yields the following result.

image

Is that possible for you can explain to me why Embree is not compatible with Sycl or more generally what makes a third-party library Sycl compatible?

I am working on a scientific sycl simulation project involving ray tracing, I can implement my own ray tracing framework but I prefer to use Embree if possible.

svenwoop commented 9 months ago

Embree is not just using SYCL, but access ray tracing hardware which is vendor specific. For that reason we just support Intel GPUs for now. Thus with Embree you can just use Intel GPUs through SYCL, and for CPUs use a tbb::parallel_for or other parallization mechanism.