Is there Hope for Parallel Computing Version of Bullet?

michaelth
Posts: 21
Joined: Mon Oct 22, 2007 12:47 pm

Is there Hope for Parallel Computing Version of Bullet?

Post by michaelth »

I am doing some job for network communication on data-link layer now.
Last year I developped a game just like HalfLife withBullet.However,its running speed will be really bad when more than 10 players join this game .
Now I have 5 PCs,which make a LAN in my Lab,and I wanna use them to do Parallel Computing for Game.So Is there Hope for Parallel Computing Version of Bullet?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Is there Hope for Parallel Computing Version of Bullet?

Post by Erwin Coumans »

There are already parallel optimizations for Bullet. See Bullet/Extras/BulletMultiThreaded. Most of the collision detection and constraint solver can run in parallel, on multiple threads/tasks.

BulletMultiThreaded currently supports Cell SPUs and Win32 Threads.

Usually there are also many other optimizations possible before parallelizing. Did you do some profiling/tuning which parts take up most time?
Thanks,
Erwin
michaelth
Posts: 21
Joined: Mon Oct 22, 2007 12:47 pm

Re: Is there Hope for Parallel Computing Version of Bullet?

Post by michaelth »

But How can I run differnent threads on different CPUs? Or the Parallel Interface of Bullet is just for Cell Spus?
michaelth
Posts: 21
Joined: Mon Oct 22, 2007 12:47 pm

Re: Is there Hope for Parallel Computing Version of Bullet?

Post by michaelth »

And one PC just have only one cpu inside.So I wanna to use NetWork to coordinate different thread in different PC.Can ithis idea be put into practice?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Is there Hope for Parallel Computing Version of Bullet?

Post by Erwin Coumans »

michaelth wrote:And one PC just have only one cpu inside.So I wanna to use NetWork to coordinate different thread in different PC.Can ithis idea be put into practice?
Yes.

Please take a look at the Bullet/Extras/BulletMultiThreaded project. Two main parts are multi threaded: most of the narrowphase collision detection (including static concave 3d triangle meshes) and the constraint solver. I would start with the collision detection first.

One would need to implement a networked support implementation using the btThreadSupportInterface. Then implement a networked version of SpuFakeDMA, which takes care of the data transport. Originally it has been developed for Playstation 3 SPU with 256kb private local storate memory, so the DMA streams the data from main memory to LS (collision pairs, collision shapes, transforms come in, and contact points/manifolds go out).

Then, instead of using the btCollisionDispatcher, use the SpuGatheringCollisionDispatcher. Ignore the obsolete Spu prefix: it can be more generally deployed, also on Win32 Threads, due to the btThreadSupportInterface abstraction.

Please let us know if you are interested in implementing such networked support. It seems more useful for non-real simulation though, as the communication might be slower then the actual simulation time.
Erwin
michaelth
Posts: 21
Joined: Mon Oct 22, 2007 12:47 pm

Re: Is there Hope for Parallel Computing Version of Bullet?

Post by michaelth »

Dear Erwin Coumans:
Thanks very much for your professional and detailed reply about my implementing such networked support.
Yes, I am really interested in implementing such networked support and even I wana finish this plan in several weeks.
The communication time is always a problem that can not be avoided.But if I apply directly the Data-link layer Communication on 100M bit/s EtherNet other than Communication on Some NetWork protocol ,the time can reduce a lot.I think Communication in every Simulation Frame should be finished in less than 5/1000 seconds.
And Now,I have another idea about Networked version of Bullet.
Assume that there are 4 PCs:A,B,C,D in EtherNet. Then I divided the 3D Space,which contain every rigidbody that need to be Simulation, into 4 sub Spaces:A,B,C,D. Then I create a DynamicWorld and Simulation for every Space in a PC.
So,I create DynamicWorld A for Space A in PC A,DynamicWorld B for Space B in PC B,DynamicWorld C for Space C in PC C,DynamicWorld D for Space D in PC D.
And After every Simulation,I will get the Orgin of every RigidBody from btTransform of it so that I can decide which DynamicWorld this
RigidBody should go to in the Next Simulation.For example,A RigidBody named RB,firstly in DynamicWorld A,if its origin changed to be in Space B after 1 Simulation,should be put in DynamicWorld B
in the next Simulation after romoved from DynamicWorld A.
But I feel that a long time will be needed for addRigidBody/ romoveRigidBody function's running.
So How about this idea?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Is there Hope for Parallel Computing Version of Bullet?

Post by Erwin Coumans »

michaelth wrote: And Now,I have another idea about Networked version of Bullet.
Assume that there are 4 PCs:A,B,C,D in EtherNet. Then I divided the 3D Space,which contain every rigidbody that need to be Simulation, into 4 sub Spaces:A,B,C,D. Then I create a DynamicWorld and Simulation for every Space in a PC.
So,I create DynamicWorld A for Space A in PC A,DynamicWorld B for Space B in PC B,DynamicWorld C for Space C in PC C,DynamicWorld D for Space D in PC D.
[...]
So How about this idea?
I would recommend to use my suggestion instead. Bullet/Extras/BulletMultiThreaded is designed to be distributed, and it deals with synchonization. So it can deal with one huge pile of objects that are all (in)directly touching. Please consider implementing a NetworkedSupport derived from btThreadSupportInterface, and modify add network support for FakeDMA. This would be great. BulletMultiThreaded also reduces memory/network bandwidth by only transfering the data that is needed.

The idea is to have one central PC with the entire simulation world. Then the collision dispatcher and constraint solver can distribute the workload across several other machines, who perform the calculations all in parallel, and return the results to the main machine. You could upload/cache large datastructures like triangle meshes locally on each machine, to avoid unnecessary network traffic.

How does your idea deal with boundaries between the various subspaces? If you have one big pile of objects, you cannot simply cut them, and simulate them independently, because you miss the interaction between objects that are shared between multiple subspaces. This is one of the problems that BulletMultiThreaded solves.

Do you plan to use public networking libraries?
Hope this helps,
Erwin
michaelth
Posts: 21
Joined: Mon Oct 22, 2007 12:47 pm

Re: Is there Hope for Parallel Computing Version of Bullet?

Post by michaelth »

How does your idea deal with boundaries between the various subspaces? If you have one big pile of objects, you cannot simply cut them, and simulate them independently, because you miss the interaction between objects that are shared between multiple subspaces. This is one of the problems that BulletMultiThreaded solves
/////////////////////////////////////////////
Thanks very much for your reply.
Yes,I have thought for this problem.At the beginning,I even wanna limit the rigidbody's size to minimize the probability that this rigidbody interaction with another rigidbodys from other subspace at the same moment.But now it seems a bad idea.
However,I firstly wanna apply this idea because I don't even take into account Changing the source code of Bullet.
Do you have any detailed suggestion of implementing a NetworkedSupport ?Now I wanna consider implementing it ,I want to use a Data-Link layer Packet Processing Library to finish it directly.