[Vm-dev] cosine broken in all MacOSX squeak VM ???

David T. Lewis lewis at mail.msen.com
Thu Dec 20 00:48:30 UTC 2012


Ah, disregard that last request. I just tried your test on Linux with an
interpreter VM and get identical results. So whatever the issue may be,
it's not directly related either to Cog or to the OS X or Linux platform.

(1 to: 300) collect: [:i | (10.0 raisedTo: i) sin squared + (10.0
raisedTo: i) cos squared - 1 / Float epsilon]
==> #(0.0 -21.0 -216.0 1951.0 -825.0 164322.0 2.991826e6 -3.0252215e6 -1.80068624e8 2.452782e9 -1.3818168968e10 1.9409580542e10 -1.2061418157755e12 -1.37369133895955e13 2.20877965778384e14 1.832332075425868e15 -2.5599521483316e15 4.377391399315873e15 3.237602768736551e15 -7.53459233032038e14 -4.94951627959947e14 2.03784539975926e15 -3.557745036241023e15 -1.692141714222876e15 2.040197511584671e15 -2.8643848531433295e15 3.168462128503457e15 -2.0318519033994385e15 -7.560942910156825e14 -4.5028153136742195e15 -3.426854466503181e15 -1.418649792034695e15 8.7090371546003e14 -2.1774043366790325e15 1.941121311320685e15 -1.93867360212523e15 2.131382493442552e15 4.169413016402683e15 -4.5031507712845265e15 -7.356152265091465e14 3.920148320595575e15 2.179228447673421e15 -1.0114296447727515e15 1.330113557624607e15 -4.457353689995373e15 -1.880263356882716e15 -2.872128484832873e15 3.016349521732165e15 -4.480990106685961e15 3.19569314836586e15 -1.581753155166015e14 3.199137217136827e15 4.50294030862374e15 -3.0110707595282355e15 4.458723562494926e15 -4.2463330058425785e15 4.358209828797823e15 -4.2457867233600465e15 -2.960753766125356e15 -2.693256630942489e15 -1.520479177624157e15 2.641746915192578e15 -3.504897489257563e15 1.813503728796965e15 3.074336341560622e15 -5.97256624816351e14 1.073587160791169e15 4.186160297827384e15 4.497924487691962e15 -4.3077727519627555e15 4.429359323852198e15 -3.096460592432071e15 1.213629110703813e15 -4.161260068997854e15 2.317233500602424e15 -3.666439778857136e15 1.500077499611301e15 -3.138572335525628e15 6.4307437511246e14 3.356554182435327e15 -9.75723563463801e14 -1.649811792182865e15 3.937104780070054e15 -1.4793341565261355e15 -4.047371900443106e15 7.72233190078856e14 1.169783992475737e15 -1.4909425057871e15 -4.382289013808437e15 1.213001364608066e15 -3.605749721551412e15 2.710191214563881e15 -4.336920566885188e15 -4.502476001131051e15 -2.8099965016454795e15 4.12072763870841e15 -5.57779455544862e14 4.475889529685573e15 -3.6259312235885265e15 3.954090609931557e15 -4.4605885222177955e15 -3.337325060937194e15 -4.346389540116783e15 3.74441907853345e15 -4.1620714461728665e15 -5.099591168717e13 2.553845510974175e15 2.258337988641594e15 3.063772801416911e15 -1.805306216687873e15 -2.497581493408027e15 3.622812746106223e15 -4.382972321261686e15 -4.45386365161558e15 3.276906407725093e15 3.007907600141098e15 4.480565699528916e15 -3.54237171966018e15 3.752925964701424e15 4.408827953182914e15 2.096953638910183e15 -4.393769968850945e15 4.500786006901271e15 -1.581083948193687e15 1.169700890197498e15 -3.3874423876010835e15 2.863605975835901e15 -4.2869063287986425e15 -5.205816478427625e14 -2.9271520163418955e15 -3.772013523087962e15 4.169508231337842e15 3.840404913096656e15 2.542504609299383e15 1.69759596250146e15 3.847114094203394e15 -4.298101092829687e15 -1.0688625329157705e15 4.159796717481765e15 3.935073402807537e15 -1.6148451540436265e15 4.411499075105951e15 -2.843580812815678e15 -1.9120971398940355e15 4.503580883646485e15 -1.9701218709110135e15 -3.861853682856212e15 -4.2949392958536265e15 -2.9463550589098935e15 4.481960892530399e15 -3.343134871845262e15 1.080541361606581e15 -3.3897729409139165e15 -2.387446311031581e15 4.350276056636718e15 9.91733467069509e14 4.365264863690028e15 -3.741569355623088e15 -4.452740608168755e15 -3.15795803371365e15 -2.7489975805340635e15 3.199757133012006e15 -2.158387880932815e14 4.503103400356738e15 1.902116993445407e15 -4.502767849574766e15 -4.420675025510159e15 -3.223226339968156e15 -2.559865744060854e15 1.649168558137839e15 2.850118510476247e15 3.517590666072354e15 1.802154909276189e15 4.493146416373382e15 -3.459477990680043e15 -3.034707961323239e15 2.463491610289795e15 3.96225269950269e15 -4.50321162302445e15 -4.4985402478942355e15 -2.600111591420496e15 -2.63379448972398e14 -4.402124390477173e15 3.471044948848867e15 3.761818810241779e15 -4.0317541267624685e15 -2.135763668820118e15 1.539240019973895e15 -4.46292534488687e15 1.776571765309554e15 -4.231815862554569e15 -2.029425957359673e15 3.346969658562429e15 -4.1552319487404745e15 3.08072007301731e15 -1.05385255167594e14 -3.36593032831183e14 -4.4503463253214815e15 -4.50340241642147e15 -2.46314493017907e15 -1.032199154466155e15 4.420631567387747e15 1.252497471827995e15 -1.177046891800808e15 -4.4828195495085715e15 -2.579193863898077e15 4.483614772073998e15 1.528186600511539e15 1.33068021763956e14 -3.619170177727435e15 -4.484844709986238e15 -3.1233805913819345e15 8.51473165031089e14 -4.2249796981738845e15 3.987313390889281e15 2.849245764750216e15 3.799724040841556e15 1.528738816833949e15 1.634669847942142e15 4.34645405199183e15 4.269009964738385e15 -4.224106096617089e15 4.148169882858513e15 -1.6172990348645805e15 -4.2302765421664915e15 -4.470711005054515e15 -4.361309411749411e15 7.394365819882e14 4.489206349173658e15 -2.832536890249609e15 4.250200329110311e15 -2.667412190878914e15 -1.065229023882611e15 -3.283914290036329e15 -1.4063676692377625e15 -4.4978404106484755e15 -4.145387639318946e15 -6.14800486101632e14 2.504869599305481e15 -4.009339130716005e15 -2.4142611864176575e15 -4.5032556381749205e15 3.110018031872503e15 -9.250322908223325e14 -2.526855208740467e15 1.361009393734174e15 -4.492078228338737e15 2.912796328667893e15 4.09409700647427e15 2.791182421499453e15 4.145855096023572e15 2.43040793385622e15 5.69191792761865e14 3.230977716001856e15 -2.9156673712326025e15 -4.500315066014458e15 -3.622060279824399e15 4.50187604747962e15 4.402111723301732e15 2.308615113605639e15 2.270043265059346e15 -4.166117025382883e15 -4.4230716712644485e15 4.59149914296794e14 2.352070243581489e15 3.175772801017858e15 -2.1137624128327245e15 -2.9709660863318915e15 8.4657520765974e13 -4.82977178055096e14 2.144523075525596e15 -2.847870167559574e15 4.262219269613884e15 -3.725415013149388e15 1.042138635454828e15 -4.4384845263756075e15 -3.368303525860634e15 -1.8883292510848475e15 -3.874000107001921e15 3.477173429804369e15 3.985588071626476e15 -3.982487383817216e15 -1.331581238569595e15 -2.459049619054066e15 3.936765068849963e15 2.987744457852479e15 -3.5257803395067445e15 -1.425643549941399e15 -2.3131435190658035e15 -2.882921051391532e15 -2.721485989774561e15 3.819278401307263e15 3.08302823611501e14 3.487372405115793e15 4.502145069517247e15 -3.005640633293714e15 2.34262276841865e15 1.32465795728589e14 1.287776278854855e15 -2.991758532877996e15)

Dave


On Wed, Dec 19, 2012 at 07:11:02PM -0500, David T. Lewis wrote:
> Nicholas,
> 
> If you have a chance, could you try this on an interpreter VM and see if
> you get the same results?
> 
>    http://squeakvm.org/unix/release/Squeak-4.10.2.2614-darwin10.8.0_i386.tar.gz
> 
> This does not sound like something that should be specific to Cog so I am
> expecting you would see the same issue on both VMs. If so, we can take
> a look at the plugin and see what is going on.
> 
> Dave
> 
> 
> On Wed, Dec 19, 2012 at 03:33:24PM -0800, Eliot Miranda wrote:
> >  
> > Hi Nicholas,
> > 
> >     I'll take a look as soon as time allows.  I'm debugging a Newspeak
> > issue right now.
> > 
> > 
> > On Wed, Dec 19, 2012 at 1:34 PM, Nicolas Cellier <
> > nicolas.cellier.aka.nice at gmail.com> wrote:
> > 
> > >
> > > I just tried this a latest cog:
> > >
> > > (1 to: 300) collect: [:i | (10.0 raisedTo: i) sin squared + (10.0
> > > raisedTo: i) cos squared - 1 / Float epsilon]
> > > -> #(1.0 -21.0 -215.0 1951.0 -825.0 164322.0 2.991826e6 ...
> > >
> > > It sounds like incredibly high errors so soon...
> > >
> > > The sine is OK:
> > > (1 to: 300) collect: [:i | (10.0 raisedTo: i) sin - ((10.0 raisedTo:
> > > i) asArbitraryPrecisionFloatNumBits: 53) sin asFloat / ((10.0
> > > raisedTo: i) asArbitraryPrecisionFloatNumBits: 53) sin asFloat ulp]
> > > ->  #(-1.0 0.0 1.0 0.0 0.0 0.0 ...
> > >
> > > This is due to cosine:
> > > (1 to: 300) collect: [:i | (10.0 raisedTo: i) cos - ((10.0 raisedTo:
> > > i) asArbitraryPrecisionFloatNumBits: 53) cos asFloat / ((10.0
> > > raisedTo: i) asArbitraryPrecisionFloatNumBits: 53) cos asFloat ulp]
> > > -> #(-1.0 -24.0 -383.0 -2049.0 825.0 175417.0 -3.297612e6 ...
> > >
> > > Though, MacOSX math library is very robust and accurate even for Float
> > > fmax, this one works well:
> > >
> > > #include <stdio.h>
> > > #include <math.h>
> > > int main()
> > > {
> > >     int i;
> > >     double d,y;
> > >     for(i=1;i<301;i++) {
> > >         d=pow(10.0,i);
> > >         y=(cos(d)*cos(d)+sin(d)*sin(d)-1)/ldexp(1.0,-52);
> > >         printf("i=%d y=%.17f\n",i,y);
> > >     }
> > >     return 0;
> > > }
> > >
> > > $ gcc --version
> > > i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
> > > Copyright (C) 2007 Free Software Foundation, Inc.
> > >
> > > It sounds like sin is taken from one accurate library while cos is
> > > taken from an inacurrate one !!!
> > > For example it sounds like cos might well be using broken x86 fcos
> > > How can it be so?
> > > Can someone explain ?
> > >
> > > Virtual Machine
> > > ---------------
> > > /Users/nicolas/Smalltalk/Squeak/Cog.app/Contents/MacOS/Croquet
> > > Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.238] Croquet
> > > Cog 4.0.2637
> > > Mac OS X built on Dec 17 2012 19:54:57 Compiler: 4.2.1 (Apple Inc.
> > > build 5666) (dot 3)
> > > platform sources revision VM: r2637
> > > http://www.squeakvm.org/svn/squeak/branches/Cog Plugins: r2545
> > > http://squeakvm.org/svn/squeak/trunk/platforms/Cross/plugins
> > > CoInterpreter VMMaker.oscog-eem.238 uuid:
> > > a3d10eab-6079-4c91-99f6-3dcf58d1446f Dec 17 2012
> > > StackToRegisterMappingCogit VMMaker.oscog-eem.234 uuid:
> > > 66acafd1-cad0-4f20-b786-ab8f48201d82 Dec 17 2012
> > >
> > > Loaded VM Modules
> > > -----------------
> > > B2DPlugin VMMaker.oscog-eem.235 (i)
> > > BitBltPlugin VMMaker.oscog-eem.235 (i)
> > > DropPlugin VMMaker.oscog-eem.235 (i)
> > > FilePlugin VMMaker.oscog-eem.235 (i)
> > > FloatArrayPlugin VMMaker.oscog-eem.235 (e)
> > > InternetConfigPlugin VMMaker.oscog-eem.235 (i)
> > > LargeIntegers v1.5 VMMaker.oscog-eem.235 (i)
> > > Matrix2x3Plugin VMMaker.oscog-eem.235 (i)
> > > MiscPrimitivePlugin VMMaker.oscog-eem.235 (i)
> > > SecurityPlugin VMMaker.oscog-eem.235 (i)
> > > SocketPlugin VMMaker.oscog-eem.235 (i)
> > > ZipPlugin VMMaker.oscog-eem.235 (i)
> > > Same results with old VM
> > >
> > >
> > > Same result with old 4.2.5 VM !!!
> > >
> > > Virtual Machine
> > > ---------------
> > > /Users/nicolas/Smalltalk/Squeak/Squeak
> > > 4.2.5beta1U.app/Contents/MacOS/Squeak VM Opt
> > > Squeak4.1 of 17 April 2010 [latest update: #9957] Squeak VM 4.2.5b1
> > > Mac Carbon 4.2.5b1 15-Jun-10 >85D9C693-2A2A-4C33-B05C-C20B2A63B166<
> > > VMMaker versionString 4.2.4
> > >
> > > Loaded VM Modules
> > > -----------------
> > > B2DPlugin 15 June 2010 (i)
> > > BitBltPlugin 15 June 2010 (i)
> > > DropPlugin 15 June 2010 (i)
> > > FilePlugin 15 June 2010 (i)
> > > FloatArrayPlugin 15 June 2010 (i)
> > > InternetConfigPlugin 15 June 2010 (i)
> > > LargeIntegers v1.5 15 June 2010 (i)
> > > Matrix2x3Plugin 15 June 2010 (i)
> > > MiscPrimitivePlugin 15 June 2010 (i)
> > > SecurityPlugin 15 June 2010 (i)
> > > SocketPlugin 15 June 2010 (i)
> > > ZipPlugin 15 June 2010 (i)
> > >
> > 
> > 
> > 
> > -- 
> > best,
> > Eliot


More information about the Vm-dev mailing list