Floating-point models in VS2005 vs VS2003  
Author Message
Gunilla





PostPosted: Visual C++ Language, Floating-point models in VS2005 vs VS2003 Top

We have found out that a new floating point model has been introduced in VS2005 where the programmer has the option to choose any of the modes Precise, Strict or Fast. According to the document http://www.hide-link.com/ : "Microsoft has selected fp:precise as the default floating-point mode because it creates both fast and accurate programs."

In VS2003 we were using the VS project setting "Floating-Point Consistency" set to "Default".

After the transfer from VS2003 to VS2005, we can now see some differences in results for our floating-point calculations. Would the mode "Strict" be a closer map to what we had in VS2003

I also wonder if one could expect the rounding semantics for floating-point expressions under "Precise" in VS2005 to differ from the default setting for "Floating-Point Consistency" in VS2003

Thanks!



Visual C++1  
 
 
Bill Cumming





PostPosted: Visual C++ Language, Floating-point models in VS2005 vs VS2003 Top

I had a similar problem with my port from 2003 to 2005 with the change in floating point behavior (see my post at http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=219982&SiteID=1)

I reported this as a bug
http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx feedbackid=b0e1a8e3-edeb-44e9-a4ca-9afdd478854c

but Microsoft responded that they still thought this was the best default and that changing it now would cause more problems than it would solve.

Sigh.


 
 
Kang Su Gatlin





PostPosted: Visual C++ Language, Floating-point models in VS2005 vs VS2003 Top

The VS2005 floating point model fixes the lack of a defined floating point model in VS2003. What this means for you is that there is no real analog to VS2003 in VS2005. With VS2005 we tried to construct rules around FP behavior that you can expect, whereas in VS2003 it was a lot more like "we'll do what we can but no promises".

With that said the reason we moved to /fp:precise as the default is that in terms of performance the generated code performs about as well as the default for VS2003, but with the added benefit of some guarantees around what we will do and what we won't.

If you are getting different results between VS2003 and VS2005 then you are probably seeing the result of VS2005 not performing a certain type of optimization that loses some accuracy, but VS2003 was doing so. Also remember that spilling registers can affect your code since you only get 11-bits in the exponent when in memory.

While we'll probably never implement a "Do the same thing as VS2003 switch" we are open to suggestions in our FP model, and would love to hear them.

Hope that helps.



 
 
Adam Wagman





PostPosted: Visual C++ Language, Floating-point models in VS2005 vs VS2003 Top

I understand that there is no VS2005 fp model that provides exact compatibility with VS2003 floating-point behavior. However, it would be very helpful to know approximately what VS2003 did in terms of each of the sorts of behavior discussed in http://msdn.microsoft.com/library/default.asp url=/library/en-us/dv_vstechart/html/floapoint.asp, i.e. "rounding semantics", "algebraic transformations", "contractions", etc., as well as the use of intrinsics (which VS2005 /fp:precise disables).

The reason I ask this is that we have a large library of code that has been tested and released under VS2003, and we'd like to understand the level of risk we're taking (both in terms of mathematical correctness and in terms of compatibility with the versions of our library that were released in the past) in choosing between /fp:precise and /fp:fast.

Even though there is no exact answer, can you give a best estimate as to whether VS2003 overall was closer to VS2005 /fp:precise or /fp:fast

Thanks!


 
 
Kang Su Gatlin





PostPosted: Visual C++ Language, Floating-point models in VS2005 vs VS2003 Top

Unfortunately the VS2003 FP model was not well-specified, but I'll do some digging to see what I can find out.

What I can say is that in terms of mapping FP options from VS2003 to VS2005 we have the following:

VS2003 (default) is closest to VS2005 (/fp:fast).

VS2003 (/Op) is a cross between VS2005 (/fp:precise and /fp:strict).

The mapping isn't exact. Our goal with VS2005 was to try to do the FP model right, rather than to replicate the VS2003 model. I hope that helps.

Thanks,