Particle System written in C and CUDA (however use some little c++ for cuda, but i tried to follow strictly the C style)
output.webm
Compile the program with:
$ cmake -B build/ -DCMAKE_BUILD_TYPE=Release -DENABLE_CUDA=TRUE
$ cmake --build build/
Run:
$ ./build/particle_system
Compile the program with:
$ cmake -B build/ -DCMAKE_BUILD_TYPE=Release -DENABLE_CUDA=FALSE
$ cmake --build build/
Run:
$ ./build/particle_system
All the classic variable used in particle systems are available as Global Constants at the top of the src/constants.cpp file If you change the number of particles, you may want to change the call to the CUDA function to use more threads and blocks.
I have tested both Cpu and CUDA version with 4096 particles:
- Cpu -> ~32 FPS
- CUDA -> ~63 FPS
So up to now the CUDA code is 2x faster, but both versions are far from being optimized. Is worth noticing that the CUDA code become faster with a lot of particles.
- Try to port the logic on the GPU
- Add sliders to modify "Constants" at run-time
- Find a new data structure to perform a research faster than O(N^2)