We're porting an application from Windows to the Mac, and we have a
problem doing floating point calculations on the different Mac processors.
On the PC, the application sets the floating point precision to 24 bits.
We're looking for a way to remove precision to floating point
operations, because our application is networked, and the results
produced by various floating point operations have to be exactly the
same on every clients.
It seems that at some point the G4 and G5 might be producing floating
point numbers with different precisions, and this desynchronizes our
application. This problem also appears, although less often, on an iMac
G4 when connected to a G4, but it is more apparent when we connect a G4
and a G5.
We're looking for a way to produce results that will be exactly the same
on different PPC processors. Performance is an issue, but precision is
not really and issue, as long as the computers produce the same result.
We're using Metrowerks Codewarrior 8.3, and we have disabled the
'Relaxed IEEE Floating Point' option. We're building a Mach-O 32 bits
application and we are not using any approximation functions (frsqrte,
etc) or AltiVec. Any suggestions are welcome.
Thank you!
Paul Russell - 23 Jul 2004 15:21 GMT
> We're porting an application from Windows to the Mac, and we have a
> problem doing floating point calculations on the different Mac processors.
[quoted text clipped - 19 lines]
> application and we are not using any approximation functions (frsqrte,
> etc) or AltiVec. Any suggestions are welcome.
You will probably never make this work (you're paying the price for a
very bad design decision, unfortunately), but a couple of ideas anyway:
- turn off fused multiply/add on the PowerPC builds
- if that doesn't help then consider doing all floating point on all
clients in double precision and just round the final result to float. In
the majority of cases this will give you repoducible results on
different processors.
Good luck,
Paul
Brad Oliver - 24 Jul 2004 00:10 GMT
> It seems that at some point the G4 and G5 might be producing floating
> point numbers with different precisions, and this desynchronizes our
> application.
Can you give an example of where they produce different results given
the same input? I'm not aware of any cases on the G4 where two different
Mac will produce two different results for the same calculation, and I'd
be surprised if the G5 gives a different result as well.
I worked on a few RTS game ports for the Mac that used floating point
calculations and on Mac-Mac games never had a desync problem related to
that. It was always some other thing - like an uninitialized variable,
uninitialized memory blocks, a memory allocator that called malloc()
instead of calloc() for critical data, or a random number generator that
was giving different values in the frame on the networked Macs.

Signature
Brad Oliver
bradman@pobox.com.AM_SPAY