GPU Physics ! CUDA and You Pllliiphiparallelizing Physics

GPU Physics ! CUDA and You Pllliiphiparallelizing Physics

Phys ica l Simu la tion on GPUs Jim Van Ver th OpenGL Software Engineer NVIDIA [email protected] www.nvidia.com www.essentialmath.com Phys ics on GPU ! Topics of discussion ! Ways of parallelizing physics ! Examples of GPU physics ! CUDA and you PllliiPhiParallelizing Physics ! What we’ve talked about so far CPU GPU Display Game Logic, Graphics AI, Physics Awfully busy… improve performance? PllliiPhiParallelizing Physics ! Solution 1: Multicore CPU CPU GPU Display Game Logic, Physics Graphics AI PllliiPhiParallelizing Physics ! Solution 2a: Cell processor Game Logic, Display AI CPU GPU Graphics SPU SPU SPU SPU SPU SPU Physics PllliiPhiParallelizing Physics ! Solution 2b: AGEIA processor Game Logic, Display AI CPU GPU Graphics PPU Physics PllliiPhiParallelizing Physics ! Solution 3: Programmable GPU CPU GPU Display Game Logic, Graphics, AI Physics PllliiPhiParallelizing Physics ! Solution 3b: SLI GPU Display CPU Graphics Game Logic, GPU AI Physics GPU Compu ting ! Modern GPU has many independent processors: ! GeForce 8800 GTX: 128 SPs ! GeForce 8800 GT: 112 SPs ! Mostly processing power, not cache: ! GeForce 8800 GTX: 300-400 Gflops ! Ge Force 8800 GT: 500 Gflops ! A lot of parallel power for physics! GPU Phys ics Examp le ! From GPU Gems 3 ! Takahiro Harada, “Real-time Riggyid Body Simulation on GPUs” ! Simple physics engine, all running on GPU GPU Phys ics Examp le ! Idea: GPU is good at: ! Many similar computations ! Simple data ! So: ! Particles for collision representation ! Grid for collision detection ! Simp le co llis ion response Objec t Represen ta tion ! Global object data in texture pairs Position Orientation Linear Angular Momentum Momentum ! Alternate frame to frame Objec t Represen ta tion ! Collision rep: Solid (or shell) of particles ! Store as ! Fixed radius ! Displacement from center of mass Objec t Represen ta tion ! Smaller particles == better fit ! But more ppgrocessing Objec t Represen ta tion ! Particle data stored in texture and three rendertargets Displacement Position Velocity Force ! Update position, velocity each frame from global object data ! Update force from collisions Pipe line UdtUpdate Par tilticles Calculate Grid Compute Collisions Integrate UdtUpdate Par tilticles Update ! For each object do: Particles ! Iterate through all particles Calculate Grid ! Update particle position, velocity Compute Collisions Position Orientation Particle Position Displacement Integrate Linear Angular Momentum Momentum Particle Velocity GidRGrid Represen ta tion Update ! Stored as slabs within 2D rendertarget Particles Calculate Grid Compute Collisions ! Voxel stored as texel Integrate ! Four ppparticle indices per texel GidCGrid Crea tion Update ! For each particle do Particles ! Compute grid index Calculate Grid ! Write particle index to appropriate component at that location Compute Collisions Integrate Co llis ion Reso lu tion Update ! For each voxel do Particles ! For each particle in voxel do ! Compute force based on particles in Calculate Grid this and 27 neighboring voxels ! Regardless of collision! Compute ! Spring force Collisions ! Damping from relative vel. ! Tangential force Integrate ItIntegrati on Update ! Compute new linear and angular Particles momenta based on collision (and other) forces Calculate Grid ! Force/torque on rigid body is weighted sum of forces from each particle ! Compute new position and orientation Compute Collisions from momenta Integrate Demo Other approach es ! Simon Green’s particles ! Nyland, Harris and Prins: N-body sim. ! Parallelize one piece: ! Ex. Broad Phase (from GPU Gems 3) ! Do smaller problem ! Ex. Fluid dynamics (Hellfire: London) GPU Compu ting ! How to program? ! In the ppgast had to use Cg, GLSL, HLSL ! Problems: ! Requires specialized shader knowledge ! Data is often texture or rendertarget ! Can’t “scatter” data easily CUDA ! Solution is CUDA ! Stands for Compute Unified Device AhittArchitecture ! Extensions on C/C++ ! In teropera ble w ith D3D an d Open GL ! www.nvidia.com/cuda ! Use it! CUDA ! Updating our example: ! Instead of Cg, use standard C++ w/CUDA extensions ! Instead of textures or rendertargets, just use CUDA arrays ! Instead of vertex shader, use scatter operation RfReferences Takahiro Harada. “Real-Time Rigid Body Simulation on GPUs.” In GPU Gems 3, Hubert Nguyen, ed., Addison-Wesley, 2007. Lars Nyland, Mark Harris, Jan Prins. “Fast N-Body Simulation with CUDA.” In GPU Gems 3, Hubert Nguyen, ed., Addison-Wesley, 2007. Scott Le Grand. “Broad-Phase Collision Detection with CUDA.” In GPU Gems 3, Hubert Nguyen, ed., Addison-Wesley, 2007. Keenan Crane, Ignacio Llamas, Sarah Tariq. “Real-Time Simulation and Rendering of 3D Fluids.” In GPU Gems 3, Hubert Nguyen, ed., Addison-Wesley, 2007. Simon Green. “CUDA Particles” NVIDIA whitepaper, November, 2007. NVIDIA CUDA Compute Unified Device Architecture Programming Guide Version 1.1, November 2007..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    27 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us