[ODE] Re: dRandInt & performance
Aras Pranckevicius
nearaz at gmail.com
Tue May 17 14:35:59 MST 2005
> > Even on x86, it's a bad idea, because double->int will typically
> > cause a very expensive pipeline stall, because of the way compilers
> > implement conformance with the standard C numerics library rules.
>
> I'm surprised no one mentionned the Mersenne Twister. It's faster than C
> rand(), as only uses integers and logical operations (or/and/xor etc,
> thus avoiding costy mult/div). On top of that it also provides better
> "randomness".
IMHO, nothing that advanced is needed in there (to reorder the
constraints in the solver).
A simple linear congruential generator like already used for dRand or
advised by Yordan is pretty good. Yes, Mersenne Twister is good and
fast; but hardly can beat A*B+C generator at speed :)
The reason ODE's one is slow is just because: a) it uses
int->double->int operations (on PS2 that's automatically bad; on x86
double->int also takes ~80 cycles), b) it's not inline, and used in
solver's inner loops.
Replacing it as Yordan suggested is easy and good.
--
Aras 'NeARAZ' Pranckevicius
http://nesnausk.org/nearaz | http://nearaz.blogspot.com
More information about the ODE
mailing list