Skip to content

guoci/sycl-examples

Repository files navigation

SYCL examples

Some simple SYCL code examples.

N-body Maxwell-Boltzmann distribution

Uses N-body simulation to approximate Maxwell-Boltzmann distribution.

Maxwell_Boltzmann_distribution.mp4
Notes

Another implementation written in PyTorch can be found here. I found an issue with that code. The total energy do not remain constant over time due to multiple collisions per particle at an iteration.

For my SYCL implementation, I resolved that with allowing only one collision per particle at an iteration.

Ripple

SYCL rewrite of CUDA code in the "CUDA By Example" book.

ripple.mp4
Notes The update_host member function can be very useful when we have a loop where a buffer is used repeatedly and we need the host data to update at each iteration. Since we cannot destroy a buffer in the loop, the only way of forcing the update is to use update_host.

Julia set

SYCL rewrite of CUDA code in the "CUDA By Example" book. Julia set

Ray tracing

SYCL rewrite of CUDA code in the "CUDA By Example" book. ray tracing

build and run

A SYCL compiler is required to compiler SYCL code. A normal C++ compiler would not work. See https://sycl.tech/ for more information.

This is built with the SYCL compiler from Intel.

cd into the directory of the example, then run the following in shell

cmake -DCMAKE_BUILD_TYPE=Release -S . -B ./cmake-build-release
cmake --build ./cmake-build-release --target <target_name> -j
cmake-build-release/<target_name>