Multiple concurrent DynamicsWorlds

Post Reply
Sean20140722
Posts: 3
Joined: Tue Jul 22, 2014 2:05 pm

Multiple concurrent DynamicsWorlds

Post by Sean20140722 »

Hi Forum, I've got a very simple dynamic simulation working with JBullet. The simulation is a fitness test for a genetic algorithm so I typically run thousands-millions of simulations, devoting one thread per simulation. When I run the JBullet simulations with more than one thread, I get Exceptions typical of badly-synchronized Java code.

Before I put much more effort into my bug hunt, is it possible to execute many DynamicWorlds concurrently with Bullet? The only authoritative reference I can find is one from 2005 in which Erwin Coumans says
You can only run multiple dynamics world sequentially, not in parallel
http://www.bulletphysics.org/Bullet/php ... 373#p12982

Is it still the case that DynamicsWorlds can only be run sequentially? If there's no prospect of getting the tests to run concurrently, I'll run them sequentially and wait a bit longer.
Jonathan
Posts: 36
Joined: Sun Feb 10, 2013 6:52 pm

Re: Multiple concurrent DynamicsWorlds

Post by Jonathan »

This is probably what you're looking for:
http://bulletphysics.org/Bullet/phpBB3/ ... php?t=5588

I've been running simulation worlds in parallel (using the fix I linked) and haven't had any problems, but, that's not to say something might crop up in the future, because that's the nature of parallel problems. :roll:
Sean20140722
Posts: 3
Joined: Tue Jul 22, 2014 2:05 pm

Re: Multiple concurrent DynamicsWorlds

Post by Sean20140722 »

Jonathan wrote:This is probably what you're looking for:
http://bulletphysics.org/Bullet/phpBB3/ ... php?t=5588

I've been running simulation worlds in parallel (using the fix I linked) and haven't had any problems, but, that's not to say something might crop up in the future, because that's the nature of parallel problems. :roll:
"I've been running simulation worlds in parallel" was exactly what I was hoping to hear! Thanks for the tip - I'll try that today.

(edit 8:55 - maybe I won't try that. I'd mistakenly thought JBullet was a Java wrapper for Bullet, but it's a port. I'll try ... something similar)
Sean20140722
Posts: 3
Joined: Tue Jul 22, 2014 2:05 pm

Re: Multiple concurrent DynamicsWorlds (in JBullet!)

Post by Sean20140722 »

Removing ObjectPool from JBullet and changing all uses of ObjectPool to plain instantiations of new objects allows concurrent running with no exceptions so far. Replacing ObjectPool with a class with the same methods but synchronized for access by multiple concurrent threads also works, but not very much better than instantiating new objects. Could be my code's no good, could be JBullet is pooling the wrong objects.
Post Reply