[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Linux and floating point arithmetic



This is just a heads-up to the list about potential problems
with portability of floating-point code in NS to Intel Linux
systems.

We recently had a problem with two of the validation tests in
test-all-friendly in tcl/test, which were passing on machines
running FreeBSD and Solaris, but giving different results on Intel
Linux machines.  We have now fixed the portability problem with
these particular validation tests, but since it is likely to come
up again, I thought I would send a brief summary to the list.

My current understanding is that, because Intel Linux doesn't use
IEEE arithmetic, floating point operations can give different
results on Intel Linux machines than on other systems that do use
IEEE arithmetic.  Our fix for this portability problem with the
tfrc.cc code (tcp-friendly congestion control) in NS has been to
make liberal use of EPSILONs (or, in our case, SMALLFLOAT), and to
say
  if (oldrate_ + EPSILON < rate_)
instead of
  if (oldrate_ < rate_),
for example.

The best citation that we (i.e., Jitu) found for this problem is the
answer to Question 4, 

  "My program works on machine A (and/or B ...) but doesn't work on
  Intel Linux because Intel Linux doesn't use IEEE arithmetic",

on the FAQ at "http://www.linuxsupportline.com/~billm/faq.html" on
Frequently Asked Floating Point Questions.  From this experience,
my assumption is that, even with the liberal use of EPSILONs in
floating-point arithmetic, we will continue to have portability
problems for NS on Intel Linux machines.

(The troubleshooting to diagnose this problem was done by Jitendra
Padhye, not by me, with assistance from John Heidemann and Nader
Salehi...)

- Sally
--------------------------------
http://www.aciri.org/floyd/
--------------------------------