dotnut.c
is an ascii-art from a1k0n which can be originated back to 2006.
However, the author did a lot to optimize the code length and performance, making the code less readable. So I rewrote the code without optmization and added annotation.
Recently, I started to get interested in CUDA programming. Then I realized the donut on GPU with CUDA.
donut_nocuda.cpp is the normal donut code, but more readable.
donut_cuda.cu is the CUDA accelerated version. metal, here is the xcode project for Metal accelerated donut
#macOS
no-coda % clang++ donut_nocuda.cpp -o donut
no-coda % ./donut
#Windows with mingw
no-cuda> gcc donut_nocuda.cpp -o donut
no-cuda> ./donut.exe
CUDA acceleration requires compatible Nvidia GPU and CUDA runtime.
#Windows
cuda> nvcc ./donut_cuda.cu -o donut
cuda> ./donut.exe
Apple Metal accelerated donut, tested on Apple silicon devices.
Build the project with xcode or use the release here for macOS 14 and higher.
Because there's little optimization in the code, parameters, including the illuminance, camera and display, can be adjusted.
Enjoy the donut!