Box2D Forums

It is currently Sat May 25, 2013 3:50 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2, 3
Author Message
PostPosted: Fri Jan 14, 2011 6:42 am 
Offline

Joined: Mon Jun 08, 2009 12:21 pm
Posts: 353
Ahah!!! i'll have to try this out, I've been getting the weirdest results on the vertical stack test, where some of the stacks just fall over while the others stay still, and I couldn't figure out what in the world was causing it.

Edit: I'm also seeing very different ccd results between mac and windows


Top
 Profile  
 
PostPosted: Sun Jan 23, 2011 7:11 pm 
Offline

Joined: Mon Jun 08, 2009 12:21 pm
Posts: 353
The 2.1.2 update is fully implemented and working!!! I'm going through and inlining the hot spots of the engine, but everything *should* work just fine.


Top
 Profile  
 
PostPosted: Wed Apr 13, 2011 6:05 pm 
Offline

Joined: Wed Apr 13, 2011 5:58 pm
Posts: 3
ewjordan wrote:
MJW wrote:
Could inconsistent JIT optimization be the culprit? Twenty minutes' Googling was unable to produce for me any better answer than... maybe.

Possibly, but I'm not sure. The weird thing is, the inconsistencies persist even once JIT compilations stop (you can watch them with -XX:+PrintCompilation), so whatever non-determinism is happening, it's happening within the same compiled code, at least I think it is (unless the JVM is switching between compiled versions of code? I dunno...). Also have not been able to find much info on this online.

Quote:
It does sound like the strictfp keyword could indeed somewhat easily be used to quash the problem, anyway... though in that case one would need two whole versions of one's program. :(

Apparently this is the case: http://zetsgames.com/deterministic-physics/ seems to have tried that, and it worked.

Sucks that strictfp has to be added as a modifier, there's no way to turn it on and off for a whole codebase with a single flag, at least without adding a preprocessing step.

However, at least this tells us that it's not something wrong with the way the engine is coded, it's actually just an issue with the way floating point is handled in Java. And if strictfp works, that should actually give cross-platform consistency in Java, which is vastly more difficult to obtain in any other language, including C++. This could actually be the "killer feature" of the Java port if we were to add strictfp, though I'd want to measure the performance hit before going for it...



I think you're mistaken about the nondeterminism you're seeing on a single machine. Java is "deterministic", even without strictfp.

I suspect you're seeing the effects of these unseeded calls to Random() in jbox2d:
randomFloat() in MathUtils.java
new Random() in DynamicTree.java

By default, "new Random()" is seeded with the time, which will cause two runs of jbox2d to differ. I added a static seed to the random() calls (e.g., new Random(5)) and now every run is the same.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group