GithubHelp home page GithubHelp logo

agentlee / project1-cuda-flocking Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cis565-fall-2017/project1-cuda-flocking

0.0 1.0 0.0 245.46 MB

An introduction to CUDA programming by way of a Boids Flocking simulation

CMake 68.12% Makefile 0.39% GLSL 0.38% C++ 13.93% Cuda 17.19%

project1-cuda-flocking's Introduction

Flocking with CUDA

University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 1 - Flocking

  • Jonathan Lee
  • Tested on: Windows 7, i7-7700 @ 4.2GHz 16GB, GTX 1070 (Personal Machine)

Overview

Flocking

In this simulation, three types of steering were used to simulate flocking.

  1. Cohesion - boids move towards the perceived center of mass of their neighbors
  2. Separation - boids avoid getting too close to their neighbors
  3. Alignment - boids generally try to move with the same direction and speed as their neighbors

Searching

  1. Naive Search - Loops through all N boids to update position and velocity.
  2. Naive Uniform Grid - Rather than looping through all N boids in the simulation, we only loop through the boids that are in the 8 neighboring cells of the current boid being processed.
  3. Coherent Uniform Grid - This is similar to the Naive Uniform Grid however, this improves upon the Naive Uniform Grid in that we completely eliminate an extra fetch to obtain position and velocity. Because of this, there is a drastic improvement in performance.

Results

10,000 Boids

100,000 Boids

500,000 Boids

Performance Analysis

Number of Boids

With each of the three methods, the framerate eventually converges to 0 as the number of boids increases. I believe that this is due to the fact that each cell can contain more and more boids which requires an additional loop.

Block Size

Decreasing the block size did cause a dip in performance across all three searches. I didn't notice any alarming performance differences at 32, 64, and 256. I believe that this is due to the warp size being capped at 32 threads.

One thing that I noticed with changing the block size was that once I changed the blocksize to anything greater than 512, the simulation crashes with too many resources requested for launch. After researching the error, I found out that this meant that there weren't enough available registers on the multiprocessor to handle the block size.

Uniform vs. Coherent Grids

With fewer boids, the difference between the Uniform and Coherent Grids seems pretty insignificant. However, as you increase the number of boids, the difference becomes extremely noticable. Searching using the Uniform Grid requires an extra lookup through dev_particlesArrayIndices whereas searching using the Coherent Grid does not. A single index can provide the boid's position, velocity, and grid cell.

Neighbor Checking

Increasing the neighbor check from 8 to 27 neighboring cells caused a decrease in performance. In the chart below, we can see that the FPS decreases as more boids are added. Not only that, but the simulation crashed sooner for both Uniform and Coherent Grid Searches.

project1-cuda-flocking's People

Contributors

agentlee avatar likangning93 avatar ottaviohartman avatar trungtle avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.