SV: [ODE] Why is dVector3 defined as dReal[4] ???

Joakim Eriksson jme at snowcode.com
Thu Feb 13 03:26:27 2003


Well its not easy to just add SIMD as an after thought. Its always
better to
think ahead and plan for what you will do in the future.
In physics a SIMD optimization is something that will happen sooner
or later so better plan for it. Things you can run into
otherwise when using only 3 floats is that all your routines assume
thats the
case so you do a "pointer += 3" and other things like that. Now if you
later
would change that to 4 floats per vector you would have a very hard time
finding
all those cases where you move through the float arrays. Missing just
one
could cause you a world of strange problems.
However for SIMD optimizations there are a bunch of other things that
has
to be done (for maximum speed) like alligning all memory to 16 bytes
(I dont think thats done now) and other fun things. 

Also if I'm not misstaken so doesnt there exist any called functions for
all vector operations in ODE so optimizing it for SIMD would be a
nightmare. (That is everything is done component wise everywhere)

Regards
 Joakim E.

-----Ursprungligt meddelande-----
Från: Michal Bacik [mailto:michal@lonelycatgames.com]
Skickat: den 13 februari 2003 11:03
Till: ODE mailing list
Ämne: RE: [ODE] Why is dVector3 defined as dReal[4] ???


> > >     IMHO, it's for the sake of speed.
> > >     Take a look at how the FPU doing math you'll see.
> >
> > Can you explain how's FPU doing math? I've been working with FPU for
a
> > while, and I know it loads one float (or double) at a time, not 4
> > (except
> > when you're using SIMD or similar extensions, which ODE doesn't seem
to
> > use).
>
> When I asked the very same question as you do (why is "Why is dVector3
> defined as dReal[4]") the reply I got was "because of SIMD alignment".
>
> And even though ODE might not use it now, it may in the future.

Quite a strange reason, mainly when this 'extension' could be easily
added
when actual SIMD support was implemented.

I tried to change the array to [3] members, but it starts crashing -
apparently the fourth member of dVector3 is already now used in some
equations (or because the memory got written-to by some init-time
stuff?).

- mb

_______________________________________________
ODE mailing list
ODE@q12.org
http://q12.org/mailman/listinfo/ode