Skip to content

lmarzocchetti/c_particle_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Particle System in CUDA (and C)

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

Building for CUDA

Compile the program with:

$ cmake -B build/ -DCMAKE_BUILD_TYPE=Release -DENABLE_CUDA=TRUE
$ cmake --build build/

Run:

$ ./build/particle_system

Building for Cpu

Compile the program with:

$ cmake -B build/ -DCMAKE_BUILD_TYPE=Release -DENABLE_CUDA=FALSE
$ cmake --build build/

Run:

$ ./build/particle_system

Variables

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.

Performance

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.

TODOs

  • 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)

About

Particle System in CUDA and C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published