BOIDS Flocking Simulation using CUDA

Implemented a Flocking Simulation based on the Reynolds Boids algorithm, along with two levels of optimization: a uniform grid, and a uniform grid with semi-coherent memory access using CUDA.

Find the Github Repo here for further details about the algorithms used, performance analysis and Q&A.

Coherent grid - 500,000 Boids, Blocksize : 128

Coherent grid - 100,000 Boids, Blocksize : 128

Algorithm :

In the Boids flocking simulation, particles representing birds or fish (boids) move around the simulation space according to three rules:

  1. Cohesion - boids move towards the perceived center of mass of their neighbors

  2. Separation - boids avoid getting to close to their neighbors

  3. Alignment - boids generally try to move with the same direction and speed as their neighbors

These three rules specify a boid's velocity change in a timestep. At every timestep, a boid thus has to look at each of its neighboring boids and compute the velocity change contribution from each of the three rules.

Optimization :

We can use a uniform grid and a semi coherent uniform grid to cull the number of neighbor checks and improve the performance of the algorithm. Check the Github Repo to see the performance analysis for different methods.