Post #129,916
12/9/03 6:27:16 PM
|
Re: Hrm?
\n#include <stdio.h>\n#include <stdlib.h>\n\nvoid main(void)\n{\n printf ("%d\\n",sizeof(long double));\n}\n\n[voyager] drossl 4: ~> gcc -o junk junk.c\njunk.c: In function `main':\njunk.c:5: warning: return type of `main' is not `int'\n[voyager] drossl 5: ~> ./junk\n12\n[voyager] drossl 6: ~>\n\n In some cases emulation can be very fast, but I suspect what is happening is that the FPU is being used to full significand precision to sum an asymptotic expansion for the transcendental functions, done in assembler using a denormalized format. The IEEE 754/854 specifies a 128-bit type as well. Why is it 12? Could be something to do with FPUs on 64bit processors? As in the case with 53/80 for double, you would need extra bits to handle big exponents and gradual roundoff with denormalized numbers. Probably there are multitudinous compiler options for controlling the assumed format, but I never need anything beyond double so I've never bothered with it.
-drl
|
Post #130,062
12/10/03 1:59:06 PM
|
So what iron is that running on?
When I run that same program on my Wintel box, the program prints 10 As expected...
jb4 "There are two ways for you to have lower Prescription-drug costs. One is you could hire Rush Limbaugh's housekeeper ... or you can elect me President." John Kerry
|
Post #130,071
12/10/03 2:56:53 PM
|
Re: So what iron is that running on?
Intel of course - like I can afford a real machine :) It's gcc 3.3 with default options.
I'm sure the math is using a hybrid of FPU and emulation. The extra bytes must surely play the same role in 64/96 as they do in 53/80.
(You may already know this, but just in case - in numerical computing accuracy is worthless if you lose it all at once in a calculation due to over/underflow, so the thing to do is have a way of gradually underflowing so you can halt a calculation before it loses significance. The FPU has a "condition" or "status" register that indicates when a calculation has underflowed. However, the underflow can sometimes be handled by switching to a "denormalized" number format that is less accurate but can represent smaller numbers. So the math code can grind away just up to this point of "gradual underflow" and then stop with assurance of full precision.)
-drl
|
Post #130,095
12/10/03 5:01:56 PM
|
Also 12 on HPQ Presario 5831 (500 MHz Athlon)/gcc 2.95.4
|
Post #130,098
12/10/03 5:08:44 PM
|
Re: Also 12 on HPQ Presario 5831 (500 MHz Athlon)/gcc 2.95.4
OK, then, it's gcc (why am I not surprised?)
The 10 was reported by C++Builder, which uses the FPU natively.
jb4 "There are two ways for you to have lower Prescription-drug costs. One is you could hire Rush Limbaugh's housekeeper ... or you can elect me President." John Kerry
|
Post #130,106
12/10/03 6:02:45 PM
|
Re: Also 12 on HPQ Presario 5831 (500 MHz Athlon)/gcc 2.95.4
Come on jb, you know the gcc math library is using the FPU. It's just tracking round error internally to the library when needed: \n\n\n[voyager] drossl 1: ~> vi junk.c\n\n#include <math.h>\n\nvoid main(void)\n{\n float a, x = 1.0;\n double b, y = 1.0;\n long double c, z = 1.0;\n\n a = atan(x);\n b = atan(y);\n c = atan(z);\n\n c = (long double) a + (long double) b;\n}\n\n[voyager] drossl 2: ~> gcc -S -O0 junk.c\njunk.c: In function `main':\njunk.c:4: warning: return type of `main' is not `int'\n[voyager] drossl 3: ~> vi junk.s\n\n .file "junk.c"\n .text\n.globl main\n .type main, @function\nmain:\n\n; Set up\n\n pushl %ebp\n movl %esp, %ebp\n subl $88, %esp\n andl $-16, %esp\n movl $0, %eax\n subl %eax, %esp\n movl $0x3f800000, -16(%ebp)\n movl $0, -32(%ebp)\n movl $1072693248, -28(%ebp)\n movl $0, -72(%ebp)\n movl $-2147483648, -68(%ebp)\n movl $16383, -64(%ebp)\n\n; float call to atan\n\n subl $8, %esp\n flds -16(%ebp)\n leal -8(%esp), %esp\n fstpl (%esp)\n call atan\n\n; double call to atan\n\n addl $16, %esp\n fstps -12(%ebp)\n subl $8, %esp\n pushl -28(%ebp)\n pushl -32(%ebp)\n call atan\n\n; long double call to atan\n\n addl $16, %esp\n fstpl -24(%ebp)\n subl $8, %esp\n fldt -72(%ebp)\n fstpl -88(%ebp)\n movl -88(%ebp), %eax\n movl -84(%ebp), %edx\n pushl %edx\n pushl %eax\n call atan\n\n; long double arithmetic\n\n addl $16, %esp\n fstpt -56(%ebp)\n flds -12(%ebp)\n fldl -24(%ebp)\n faddp %st, %st(1)\n fstpt -56(%ebp)\n\n leave\n ret\n .size main, .-main\n .ident "GCC: (GNU) 3.3 20030226 (prerelease) (SuSE Linux)"\n\n\n
-drl
|
Post #130,111
12/10/03 6:42:47 PM
|
Sorry Ross: No Sale
Yer not gonna convince me using that garbage that passes for assembler that gcrapcrap spews! How the fuck do I know what an 'fstpl' or 'flds' or 'fstps' really maps to? The back-end could just as easily map it to an invalid instruction opcode that invokes the FPE (and quite probably does!).
Nope...show me real assembler code, and then I'll be convinced. I wanna know exactly what opcode causes the FPU to kick into (the heretofore undocumented) 128-bit mode....
jb4 "There are two ways for you to have lower Prescription-drug costs. One is you could hire Rush Limbaugh's housekeeper ... or you can elect me President." John Kerry
|
Post #130,134
12/10/03 8:43:13 PM
|
Re: Sorry Ross: No Sale
You're a hard man jb, to make me search a cvsweb on a phone line...
glibc-2.3.2 inverse cosine, single: [link|http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/i386/fpu/e_acosf.S?rev=1.1&content-type=text/x-cvsweb-markup&cvsroot=glibc|http://sources.redha...kup&cvsroot=glibc]
glibc-2.3.2 inverse cosine, long double: [link|http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/i386/fpu/e_acosl.c?rev=1.1&content-type=text/x-cvsweb-markup&cvsroot=glibc|http://sources.redha...kup&cvsroot=glibc]
The whole IEEE interface: [link|http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/i386/fpu/?cvsroot=glibc|http://sources.redha...pu/?cvsroot=glibc]
This is interesting: [link|http://www.ussg.iu.edu/hypermail/linux/kernel/0103.0/0453.html|http://www.ussg.iu.e.../0103.0/0453.html]
(drill down down down)
What Linux does presently on x86 is as right as right can be on this platform. Compare with what MS's compilers do (die when you run out of the fp stack slots, telling users to simplify the expressions in the source code) and be happy. The *BSD choice is valid by some lines of thought, but it also denies people the happy accident of computing with more precision and range than they thought they needed. Overall, computing with x86 double-extended is a good thing so long as you don't introduce multiple roundings. That's a compiler issue, not a kernel one. Historical note: According to one of the x87 designers, this all boils down to the simple fact that there's no time when a pair of collaborators in California and Israel can be both awake and lucid enough to explain things well over a noisy telephone line. Amazing that it really wasn't long ago. And if anyone's really interested, keep checking
[link|http://www.cs.berkeley.edu/~wkahan/|http://www.cs.berkeley.edu/~wkahan/]
as some of Dr. Kahan's older papers are slowly converted and added. They give a great deal of insight into the choices that eventually became the accepted IEEE 754 standard.
-drl
|
Post #130,508
12/12/03 6:14:33 PM
|
Please stand by...
...This is an acknowledgement of your outstanding work in tracking down those links. There is something...er, odd...about them, and I have to do a little looking up which I haven't got time to do now here at work.
Watch this space for an update soon...
jb4 "There are two ways for you to have lower Prescription-drug costs. One is you could hire Rush Limbaugh's housekeeper ... or you can elect me President." John Kerry
|
Post #130,545
12/13/03 1:35:08 AM
|
Doesn't compile here
peter@cordelia:~> gcc junk.c junk.c: In function `main': junk.c:4: warning: return type of `main' is not `int' /tmp/ccQ6VeMY.o(.text+0x4e): In function `main': : undefined reference to `atan' /tmp/ccQ6VeMY.o(.text+0x62): In function `main': : undefined reference to `atan' /tmp/ccQ6VeMY.o(.text+0x7e): In function `main': : undefined reference to `atan' collect2: ld returned 1 exit status peter@cordelia:~> gcc -v Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.1/specs Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --disable-checking --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit i586-suse-linux Thread model: posix gcc version 3.3.1 (SuSE Linux) peter@cordelia:~>
Peter [link|http://www.debian.org|Shill For Hire] [link|http://www.kuro5hin.org|There is no K5 Cabal] [link|http://guildenstern.dyndns.org|Blog]
|
Post #130,566
12/13/03 12:37:09 PM
|
Gotta add -lm for math library
-drl
|