No subject


Tue Dec 20 00:28:44 EST 2011


"Under fp:precise, only safe optimizations are performed on floating-point =
code and, unlike /Op, intermediate computations are consistently performed =
at the highest practical precision."

Calogero

--_000_E4AB3DD44D22854B819908379DE4AD49390EDFFFSETHNWS023carme_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:st1=3D"urn:schemas-microsoft-com:office:smarttags" xmlns=3D"http://ww=
w.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" name=3D"Person=
Name"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:"Segoe UI";
	panose-1:2 11 5 2 4 2 4 2 2 3;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";
	color:black;}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:blue;
	text-decoration:underline;}
pre
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Courier New";
	color:black;}
span.EmailStyle20
	{mso-style-type:personal-reply;
	font-family:Arial;
	color:navy;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext=3D"edit">
  <o:idmap v:ext=3D"edit" data=3D"1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body bgcolor=3Dwhite lang=3DSV link=3Dblue vlink=3Dblue>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span lang=
=3DEN-US
style=3D'font-size:12.0pt;font-family:Arial;color:windowtext'>Here is an
interesting article:<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span lang=
=3DEN-US
style=3D'font-size:12.0pt;font-family:Arial;color:windowtext'><o:p>&nbsp;</=
o:p></span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span lang=
=3DEN-US
style=3D'font-size:12.0pt;font-family:Arial;color:windowtext'>David Monniau=
x.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span lang=
=3DEN-US
style=3D'font-size:12.0pt;font-family:Arial;color:windowtext'>The pitfalls =
of
verifying floating-point computations.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span lang=
=3DEN-US
style=3D'font-size:12.0pt;font-family:Arial;color:windowtext'>ACM Transacti=
ons on
Programming Languages and Systems 30, 3 (2008) 12.<o:p></o:p></span></font>=
</p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span lang=
=3DEN-US
style=3D'font-size:12.0pt;font-family:Arial;color:windowtext'><a
href=3D"http://hal.archives-ouvertes.fr/hal-00128124">http://hal.archives-o=
uvertes.fr/hal-00128124</a><o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span lang=
=3DEN-US
style=3D'font-size:12.0pt;font-family:Arial;color:windowtext'><o:p>&nbsp;</=
o:p></span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span lang=
=3DEN-US
style=3D'font-size:12.0pt;font-family:Arial;color:windowtext'>Best regards,=
<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span lang=
=3DEN-US
style=3D'font-size:12.0pt;font-family:Arial;color:windowtext'><o:p>&nbsp;</=
o:p></span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span style=
=3D'font-size:
12.0pt;font-family:Arial;color:windowtext'>Mikael Rittri<o:p></o:p></span><=
/font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span style=
=3D'font-size:
12.0pt;font-family:Arial;color:windowtext'>Carmenta<o:p></o:p></span></font=
></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span style=
=3D'font-size:
12.0pt;font-family:Arial;color:windowtext'>Sweden<o:p></o:p></span></font><=
/p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3DArial><span style=
=3D'font-size:
12.0pt;font-family:Arial;color:windowtext'>http://www.carmenta.com<o:p></o:=
p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span style=
=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=3DMsoNormal align=3Dcenter style=3D'text-align:center'><font siz=
e=3D3
color=3Dblack face=3D"Times New Roman"><span lang=3DEN-US style=3D'font-siz=
e:12.0pt;
color:windowtext'>

<hr size=3D2 width=3D"100%" align=3Dcenter tabindex=3D-1>

</span></font></div>

<p class=3DMsoNormal><b><font size=3D2 color=3Dblack face=3DTahoma><span la=
ng=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:windowtext;font-weight:b=
old'>From:</span></font></b><font
size=3D2 color=3Dblack face=3DTahoma><span lang=3DEN-US style=3D'font-size:=
10.0pt;
font-family:Tahoma;color:windowtext'> proj-bounces at lists.maptools.org
[mailto:proj-bounces at lists.maptools.org] <b><span style=3D'font-weight:bold=
'>On
Behalf Of </span></b>Calogero Mauceri<br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> Thursday, March 15, 20=
12
9:06 AM<br>
<b><span style=3D'font-weight:bold'>To:</span></b> <st1:PersonName w:st=3D"=
on">PROJ.4
 and general Projections Discussions</st1:PersonName><br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> Re: [Proj] Problems=
 with
/Op option used to compile proj in Microsoft Visual Studio</span></font><fo=
nt
color=3Dblack><span lang=3DEN-US style=3D'color:windowtext'><o:p></o:p></sp=
an></font></p>

</div>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3D"Times New Roman">=
<span
style=3D'font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3D"Times New Roman">=
<span
style=3D'font-size:12.0pt'>Hi Janne,<br>
<br>
<br>
<o:p></o:p></span></font></p>

<blockquote style=3D'margin-top:5.0pt;margin-bottom:5.0pt' type=3Dcite><pre=
 wrap=3D""><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'>Disabling that option, the result returned in the version of proj <o:p></=
o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'>compiled with Microsoft Visual C++ 2003 is more consistent.<o:p></o:p></s=
pan></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'>Is there any reason why the /Op option is used to compile the proj?<o:p><=
/o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'><o:p>&nbsp;</o:p></span></font></pre></blockquote>

<pre wrap=3D""><font size=3D2 color=3Dblack face=3D"Courier New"><span
style=3D'font-size:10.0pt'><o:p>&nbsp;</o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'>I think that the /Op option only works with the 2003 version and what it =
does is as follows<o:p></o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'>(text from MSDN):<o:p></o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'><o:p>&nbsp;</o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'><o:p>&nbsp;</o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'>&quot;This option improves the consistency of floating-point tests for eq=
uality and inequality by disabling optimizations that could change the prec=
ision of floating-point calculations.<o:p></o:p></span></font></pre><pre><f=
ont
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'><o:p>&nbsp;</o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'>By default, the compiler uses the coprocessor's 80-bit registers to hold =
the intermediate results of floating-point calculations. This increases pro=
gram speed and decreases program size. However, because the calculation inv=
olves floating-point data types that are represented in memory by less than=
 80 bits, carrying the extra bits of precision (80 bits minus the number of=
 bits in a smaller floating-point type) through a lengthy calculation can p=
roduce inconsistent results.&quot;<o:p></o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'><o:p>&nbsp;</o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'><a
href=3D"http://msdn.microsoft.com/en-us/library/aa984742(v=3Dvs.71).aspx">h=
ttp://msdn.microsoft.com/en-us/library/aa984742(v=3Dvs.71).aspx</a><o:p></o=
:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'><o:p>&nbsp;</o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'><o:p>&nbsp;</o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'>So it is rather obvious that MS compilers use the full 80 bit FPP registe=
rs in PC processors by default and in most cases and the reason for using t=
hat switch in the first place must be the idea to have similar performance =
with other ANSI compiler environments? I am not sure if this answered the q=
uestion?<o:p></o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'><o:p>&nbsp;</o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'>regards: Janne.<o:p></o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span style=3D'font-size:10.0pt=
'><o:p>&nbsp;</o:p></span></font></pre>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3D"Times New Roman">=
<span
style=3D'font-size:12.0pt'><br>
Ok, the /Op option seems to be used to produce consistent and repeatable
results.<br>
The problem is that the cost of that repeatability is that the intermidiate
results in computations *lose accuracy*.<br>
That explains the problem proj (compiled with Visual Studio 2003) is having=
 in
the conversion I stated before.<br>
<br>
<br>
It is well explained here (text from MSDN) <br>
<br>
<a href=3D"http://msdn.microsoft.com/en-us/library/aa289157%28v=3Dvs.71%29.=
aspx">http://msdn.microsoft.com/en-us/library/aa289157%28v=3Dvs.71%29.aspx<=
/a><br>
<br>
&quot;</span></font><font size=3D2 face=3D"Segoe UI"><span style=3D'font-si=
ze:10.0pt;
font-family:"Segoe UI"'><span style=3D'orphans: 2;widows: 2;float:none;
word-spacing:0px'>Many C++ compilers offer a &quot;consistency&quot;
floating-point model, (through a /Op or /fltconsistency switch) which enabl=
es a
developer to create programs compliant with strict floating-point semantics=
.
When engaged, this model prevents the compiler from using most optimization=
s on
floating-point computations [...]. The consistency model, however, has a
dark-side. In order to return predictable results on different FPU
architectures, nearly all implementations of /Op round intermediate express=
ions
to the user specified precision; for example, consider the following
expression:<br>
<br>
<br>
</span></font><o:p></o:p></p>

</span><pre style=3D'word-break:break-all'><font size=3D2 color=3Dblack
face=3DConsolas><span style=3D'font-size:10.0pt;font-family:Consolas'>float=
 a, b, c, d, e;<o:p></o:p></span></font></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'>. . .<o:p></o:p></span></fo=
nt></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'>a =3D b*c + d*e;<o:p></o:p>=
</span></font></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></f=
ont></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3D"Segoe U=
I"><span
style=3D'font-size:10.0pt;font-family:"Segoe UI"'><span style=3D'orphans: 2=
;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>In order to produce consistent and repeatable =
results under /Op, this expression gets evaluated as if it were implemented=
 as follows:</span></span></font><font
face=3DConsolas><span style=3D'font-family:Consolas'><o:p></o:p></span></fo=
nt></pre>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3D"Times New Roman">=
<span
style=3D'font-size:12.0pt'><br>
<br>
<o:p></o:p></span></font></p>

<pre style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DCon=
solas><span
style=3D'font-size:10.0pt;font-family:Consolas'>float x =3D b*c;<o:p></o:p>=
</span></font></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'>float y =3D d*e;<o:p></o:p>=
</span></font></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'>a =3D x+y;<o:p></o:p></span=
></font></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></f=
ont></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3D"Segoe U=
I"><span
style=3D'font-size:10.0pt;font-family:"Segoe UI"'><span style=3D'orphans: 2=
;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>The final result now suffers from single-preci=
sion rounding errors<span
class=3Dapple-converted-space>&nbsp;</span></span><i style=3D'orphans: 2;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'><span style=3D'font-style:italic'>at each step in evaluat=
ing the expression</span></i></span></font><span
style=3D'color:rgb(0, 0, 0&#13;&#10; );-family: &#34;Segoe UI&#34;, Verdana=
, Arial;
orphans: 2;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-wid=
th: 0px;
float:none;word-spacing:0px'><font face=3DConsolas><span style=3D'font-fami=
ly:Consolas'>. Although this interpretation doesn't strictly break any C++ =
semantics rules, it's almost never the best way to evaluate floating-point =
expressions. It is generally more desirable to</span></span></font><i
style=3D'orphans: 2;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-s=
troke-width: 0px;
word-spacing:0px'><font face=3D"Segoe UI"><span style=3D'font-family:"Segoe=
 UI";
font-style:italic'> compute the intermediate results in as high a s precis =
ion as is practical</span></font></i><span
style=3D'orphans: 2;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-s=
troke-width: 0px;
float:none;word-spacing:0px'><font face=3D"Segoe UI"><span style=3D'font-fa=
mily:
"Segoe UI"'>. For instance, it would be better to compute the expression a=
=3Db*c+d*e in a higher precision as in,</span></span></font><font
face=3DConsolas><span style=3D'font-family:Consolas'><o:p></o:p></span></fo=
nt></pre><pre
style=3D'word-break:break-all;word-wrap: break-word;overflow-x: auto;overfl=
ow-y: auto;
orphans: 2;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-wid=
th: 0px;
word-spacing:0px'><font size=3D2 color=3Dblack face=3DConsolas><span
style=3D'font-size:10.0pt;font-family:Consolas'>double x =3D b*c;<o:p></o:p=
></span></font></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'>double y =3D d*e;<o:p></o:p=
></span></font></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'>double z =3D x+y;<o:p></o:p=
></span></font></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'>a =3D (float)z;<o:p></o:p><=
/span></font></pre>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3D"Times New Roman">=
<span
style=3D'font-size:12.0pt'><br>
</span></font><font size=3D2 face=3D"Segoe UI"><span style=3D'font-size:10.=
0pt;
font-family:"Segoe UI"'><span style=3D'orphans: 2;widows: 2;float:none;
word-spacing:0px'>or better yet<br>
<br>
<br>
</span></font><o:p></o:p></p>

</span><pre style=3D'word-break:break-all'><font size=3D2 color=3Dblack
face=3DConsolas><span style=3D'font-size:10.0pt;font-family:Consolas'>long =
double x =3D b*c;<o:p></o:p></span></font></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'>long double y =3D d*e<o:p><=
/o:p></span></font></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'>long double z =3D x+y;<o:p>=
</o:p></span></font></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'>a =3D (float)z;<o:p></o:p><=
/span></font></pre><pre
style=3D'word-break:break-all'><font size=3D2 color=3Dblack face=3DConsolas=
><span
style=3D'font-size:10.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></f=
ont></pre>

<p class=3DMsoNormal><font size=3D2 color=3Dblack face=3D"Segoe UI"><span
style=3D'font-size:10.0pt;font-family:"Segoe UI"'><span style=3D'orphans: 2=
;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>When computing the intermediate results in a
higher precision, the final result is *significantly more accurate*.
Ironically, by adopting a consistency model, the likelihood of error is
increased precisely when the user is trying to reduce error by disabling un=
safe
optimizations. Thus the consistency model can seriously reduce efficiency w=
hile
simultaneously providing no guarantee of increased accuracy. To serious
numerical programmers, this doesn't seem like a very good tradeoff and is t=
he
primary reason that the model is not generally well received.</span></span>=
</font><br>
&quot;<br>
<br>


More information about the Proj mailing list