Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

General purpose physics engine

Is there any general purpose physics engine that allows huge simulations of rigid bodies? I'm using PhysX from Nvidia, but the focus of this engine is game development, soft bodies. I want to know if exists physics engine that runs on top of PS3 cell processors or CUDA cores allowing massive scientific physics simulations.

like image 295
Lucas Avatar asked Mar 01 '10 19:03

Lucas


1 Answers

There is no "universal" physics library. E.g. can you imagine a useful surgery soft tissue simulation that would take relativistic effects into account? You could imagine dozens more examples.

You talk about both scientific and rigid body simulation, so it's not clear how realistic you wanna be. Rigid body is an approximation: nothing is absolutely rigid. But if nothing deforms very much in your simulation, and you're fine with a bunch of unrealistic approximations to friction and fast motion (common to all videogames), and you want out-of-the-box solution, I suspect running Havok on modern CPU will give you the best performance.

PS/3 is currently last gen. While I enjoyed writing physics for it in my day a lot, I must admit that a modern i7 with 6 cores gives you more performance - both theoretically and in practice - than one Cell.

CUDA is currently unproven tech for physics. I didn't write anything from it, but I'm very interested reader :) The challenges of writing CUDA-based physics are quite non-trivial if you want to approach IPC (instruction per cycle ratio) of a modern CPU, and I don't know of anyone successfully accompishing that. And if you don't approach the IPC of CPU-based physics, there's no point in CUDA physics, as it takes more effort.

Just do the math: a $500 Kepler GPU has 1536 cores @1GHz = 1.5 petaflops. A $590 Sandy Bridge CPU has 6 cores / 12 hyperthreads AVX (8-wide) @3.8GHz = 0.36 petaflop. Now, if you are able to achieve 5-to-1 parity (use 5 GPU cycles on average for 1 CPU cycle), your theoretical CUDA physics will run at the same speed as the CPU physics. Now, using 12 hyperthreads and AVX (8-wide SIMD) efficiently is not really easy. But parallelizing physics tasks across 1536 (!) CUDA threads, which must be very coherent and use memory in much more controlled way is no small feat either. I'm not saying it's impossible (and I'd love to try it, but I have a day job and other pet projects:)) but it'll take some time before physics community comes up with something scalable across thousands of threads.

And in the end the speed improvement is just 5-fold or so...:)

Anyway, if you write the sim yourself, and you don't want a general rigid body simulation, then CUDA may be your friend. E.g. If you want to simulate the motion of all the stars in Milky Way, with relativism, but without supernova and other discrete effects... It's quite clear how to spread that across 1536 (and more) threads. But if you want to have a mountain of rigid bodies, simulated the same way games do it currently, you're out of luck

like image 136
Sergiy Migdalskiy Avatar answered Sep 23 '22 16:09

Sergiy Migdalskiy