[ODE] Re: Different simulation results with different versions of Visual C++?

Keith Johnston keithj_pinoli at yahoo.com
Sun Aug 14 09:00:16 MST 2005


Since I am supporting multiple platforms, it looks
like option 2 is my only choice:

2) Quantize/round/truncate all physical quantities to
a known resolution after each simulation step.

I am trying this now - however, I am still seeing
differences in the mac and PC simulations.  I am
quantizing all the physics properties to 2 decimal
places after each time step: position, velocity,
angular velocity, and orientation.

Couldn't optimizations in the compilers still cause
different results even with quantized values?  

This is the rounding function I am using - is there a
better one?

float Round(const float &number, const int num_digits)
{

	float doComplete5i, doComplete5(number * powf(10.0f,
(float) (num_digits + 1)));


	if(number < 0.0f)
		doComplete5 -= 5.0f;
	else
		doComplete5 += 5.0f;

	doComplete5 /= 10.0f;
	modff(doComplete5, &doComplete5i);

	return doComplete5i / powf(10.0f, (float)
num_digits);
}




--- "Jon Watte (ODE)" <hplus-ode at mindcontrol.org>
wrote:

> 
> > This makes game development in which simulations
> must repeat exactly 
> > from one run to the next very difficult - as you
> can't guarantee that 
> > the compiler on one platform will produce the same
> results as on another.
> >  
> > Have others found a way to work around this
> problem?  I need *exactly* 
> > the same results from one simulation to another.
> 
> Two solutions:
> 
> 1) make sure all developers use exactly the same
> compiler (this can be 
> done multi-platform by generating code for Windows
> out of Intel's C++ 
> compiler, or GCC).
> 
> 2) Quantize/round/truncate all physical quantities
> to a known resolution 
> after each simulation step.
> 
> 
> Also beware that various DLLs will likely change
> your preferred rounding 
> mode and internal CPU floating point precision. If
> that's not enough, 
> Athlon CPUs don't actually support the 80-bit
> internal floating point 
> format that Pentium CPUs do, so you'll have to set
> the pentium to 64-bit 
> internal mode, too. Throwing exceptions or catching
> signals will also 
> change your CPU FP environment bits (the FPU control
> register).
> 
> 
> Note that if this is a multi-player game, this isn't
> enough, because you 
> will see different objects with different latencies
> on different 
> machines, and thus the matrices that get solved by
> ODE are different, 
> and thus the simulation will diverge anyway.
> 
> 
> Cheers,
> 
> 			/ h+
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the ODE mailing list