From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 4141 invoked from network); 5 Mar 1999 22:12:42 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 5 Mar 1999 22:12:42 -0000 Received: from mail11.digital.com (mail11.digital.com [192.208.46.10]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id RAA03188 for ; Fri, 5 Mar 1999 17:08:01 -0500 Received: from perf.zko.dec.com (perf.zko.dec.com [16.31.144.83]) by mail11.digital.com (8.9.2/8.9.2/WV2.0e) with ESMTP id RAA01358 for ; Fri, 5 Mar 1999 17:08:59 -0500 (EST) Received: from localhost by perf.zko.dec.com (8.8.8/1.1.10.5/07Mar97-1056AM) id RAA0000030441; Fri, 5 Mar 1999 17:08:00 -0500 (EST) Date: Fri, 5 Mar 1999 17:08:00 -0500 (EST) From: Phillip Ezolt To: axp-list@redhat.com cc: henning@perf.zko.dec.com Subject: Re: SIGFPE error on exponential underflow in g77 In-Reply-To: <199903051624.LAA23271@adder.cs.Virginia.EDU> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 5 Mar 1999, Greg Lindahl wrote: > Someone needs to look at the source of just the glue routine, and > decide if it doing something useful and needs -mieee when compiled, > or if it is doing excess work and needs to get cut down. > > -- g > There may be something more tricky than simply compiling the glue routine with -mieee. I have found that GNU libm actually returns denormalized numbers (VERY VERY small numbers) when ffm and cpml actually round this to zero. Consider the following program: #include main() { double y; double x=-744.07568359375; y = exp(x); printf("%g\n", y); printf("%g\n", x); } [spec@csg150 cpml.0.1]$ gcc -o test_exp_libm test_exp.c -lm [spec@csg150 cpml.0.1]$ ./test_exp_libm 4.94066e-324 -744.076 [spec@csg150 cpml.0.1]$ gcc -o test_exp_libm_mieee test_exp.c -mieee -lm [spec@csg150 cpml.0.1]$ ./test_exp_libm_mieee 4.94066e-324 -744.076 [spec@csg150 cpml.0.1]$ gcc -o test_exp_ffm test_exp.c -lffm [spec@csg150 cpml.0.1]$ ./test_exp_ffm 0 -744.076 [spec@csg150 cpml.0.1]$ gcc -o test_exp_cpml test_exp.c -lcpml [spec@csg150 cpml.0.1]$ ./test_exp_cpml 0 -744.076 (libm is glibc-2.0.7-29 ) (cpml is cpml.0.1) (libffm is libffm.0.28 ) (gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release) ) Libm returns a very small number instead of zero. It does not matter whether or not -mieee is used. It returns a denormalized number which fits into a double, and the program will work, for a while. However, you will immediately get a Floating Point Exception and a core dump when you try to change this into a single precision number. What is deceiving about this whole process is that you can happly get a denormalized number, and then a hundreds of cycles later you get an FPE. If you are experiencing trouble with this, it would be in your best interest to link in either the CPML or the FFM. First, they are MUCH faster than (on some things) than libm, and they both seem to round to zero appropriately. I am not sure how to trick g77 to use libffm or libcpml instead of libm, but it is definately worth it to find out. --Phil Digital/Compaq: High Performance Servers/Benchmark Performance Engineering Phillip.Ezolt@compaq.com ezolt@perf.zko.dec.com