delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/12/15/06:11:29

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
Sender: rich AT phekda DOT freeserve DOT co DOT uk
Message-ID: <3C1B38A4.5675566D@phekda.freeserve.co.uk>
Date: Sat, 15 Dec 2001 11:48:52 +0000
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.19 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: libemu and profiling (LONG) [Was: Re: Building a profiled version of
libc]
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1011209140442 DOT 14529B-100000 AT is>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Eli Zaretskii wrote:
[snip]
> > Using the math co-pro (387 not set or set to y) gives a result of
> > 0.122385; using a patched emu387.dxe gives a result of 0.1. Shouldn't
> > the results be the same or at least a little closer?
> 
> They should be very close.  Does the same happen with other argument
> values to atan?  What about sin and cos?

Please find the new test program at the end of this mail. Below is what it
produces. My 2.03 install is in c:/djgpp. My CVS checkout is in
c:/develop/djgpp.rw. The libraries built against CVS have profiling turned
on. I compiled the test program with gcc 3.0.2 with the following lines
for against 2.03 and CVS respectively:

    gcc -Wall -g -o m m.c

    gcc -Wall -g -I/develop/djgpp.rw/include -L/develop/djgpp.rw/lib \
        -o m m.c

Built against 2.03, default environment (i.e. detects math co-pro in my
Athlon chip):

80387 detected.
atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.0996687, sin(0.1) = 0.0998334, cos(0.1) = 0.995004
atan(0.2) = 0.197396, sin(0.2) = 0.198669, cos(0.2) = 0.980067
atan(0.3) = 0.291457, sin(0.3) = 0.29552, cos(0.3) = 0.955336
atan(0.4) = 0.380506, sin(0.4) = 0.389418, cos(0.4) = 0.921061
atan(0.5) = 0.463648, sin(0.5) = 0.479426, cos(0.5) = 0.877583
atan(0.6) = 0.54042, sin(0.6) = 0.564642, cos(0.6) = 0.825336
atan(0.7) = 0.610726, sin(0.7) = 0.644218, cos(0.7) = 0.764842
atan(0.8) = 0.674741, sin(0.8) = 0.717356, cos(0.8) = 0.696707
atan(0.9) = 0.732815, sin(0.9) = 0.783327, cos(0.9) = 0.62161

Built against CVS, default environment (i.e. detects math co-pro in my
Athlon chip):

atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.0996687, sin(0.1) = 0.0998334, cos(0.1) = 0.995004
atan(0.2) = 0.197396, sin(0.2) = 0.198669, cos(0.2) = 0.980067
atan(0.3) = 0.291457, sin(0.3) = 0.29552, cos(0.3) = 0.955336
atan(0.4) = 0.380506, sin(0.4) = 0.389418, cos(0.4) = 0.921061
atan(0.5) = 0.463648, sin(0.5) = 0.479426, cos(0.5) = 0.877583
atan(0.6) = 0.54042, sin(0.6) = 0.564642, cos(0.6) = 0.825336
atan(0.7) = 0.610726, sin(0.7) = 0.644218, cos(0.7) = 0.764842
atan(0.8) = 0.674741, sin(0.8) = 0.717356, cos(0.8) = 0.696707
atan(0.9) = 0.732815, sin(0.9) = 0.783327, cos(0.9) = 0.62161

Built against 2.03, 387=n, EMU387=c:/djgpp/bin/emu387.dxe:

atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.0996687, sin(0.1) = 0.0998334, cos(0.1) = 0.995004
atan(0.2) = 0.197396, sin(0.2) = 0.198669, cos(0.2) = 0.980067
atan(0.3) = 0.291457, sin(0.3) = 0.29552, cos(0.3) = 0.955336
atan(0.4) = 0.380506, sin(0.4) = 0.389418, cos(0.4) = 0.921061
atan(0.5) = 0.463648, sin(0.5) = 0.479426, cos(0.5) = 0.877583
atan(0.6) = 0.54042, sin(0.6) = 0.564642, cos(0.6) = 0.825336
atan(0.7) = 0.610726, sin(0.7) = 0.644218, cos(0.7) = 0.764842
atan(0.8) = 0.674741, sin(0.8) = 0.717356, cos(0.8) = 0.696707
atan(0.9) = 0.732815, sin(0.9) = 0.783327, cos(0.9) = 0.62161

Built against CVS, 387=n, EMU387=c:/develop/djgpp.rw/bin/emu387.dxe:

atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.09, sin(0.1) = 0.09, cos(0.1) = 4e-06
atan(0.2) = 0.1, sin(0.2) = 0.1, cos(0.2) = 6e-05
atan(0.2) = 0.2, sin(0.2) = 0.2, cos(0.2) = 0.0003
atan(0.3) = 0.3, sin(0.3) = 0.3, cos(0.3) = 0.001
atan(0.4) = 0.4, sin(0.4) = 0.4, cos(0.4) = 0.002
atan(0.5) = 0.5, sin(0.5) = 0.5, cos(0.5) = 0.005
atan(0.6) = 0.6, sin(0.6) = 0.6, cos(0.6) = 0.009
atan(0.7) = 0.6, sin(0.7) = 0.7, cos(0.7) = 0.01
atan(0.8) = 0.7, sin(0.8) = 0.7, cos(0.8) = 0.02

Built against 2.03, 387=n, EMU387=c:/develop/djgpp.rw/bin/emu387.dxe:

atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.09, sin(0.1) = 0.09, cos(0.1) = 4e-06
atan(0.2) = 0.1, sin(0.2) = 0.1, cos(0.2) = 6e-05
atan(0.2) = 0.2, sin(0.2) = 0.2, cos(0.2) = 0.0003
atan(0.3) = 0.3, sin(0.3) = 0.3, cos(0.3) = 0.001
atan(0.4) = 0.4, sin(0.4) = 0.4, cos(0.4) = 0.002
atan(0.5) = 0.5, sin(0.5) = 0.5, cos(0.5) = 0.005
atan(0.6) = 0.6, sin(0.6) = 0.6, cos(0.6) = 0.009
atan(0.7) = 0.6, sin(0.7) = 0.7, cos(0.7) = 0.01
atan(0.8) = 0.7, sin(0.8) = 0.7, cos(0.8) = 0.02

Built against CVS, 387=n, EMU387=c:/djgpp/bin/emu387.dxe:

atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.0996687, sin(0.1) = 0.0998334, cos(0.1) = 0.995004
atan(0.2) = 0.197396, sin(0.2) = 0.198669, cos(0.2) = 0.980067
atan(0.3) = 0.291457, sin(0.3) = 0.29552, cos(0.3) = 0.955336
atan(0.4) = 0.380506, sin(0.4) = 0.389418, cos(0.4) = 0.921061
atan(0.5) = 0.463648, sin(0.5) = 0.479426, cos(0.5) = 0.877583
atan(0.6) = 0.54042, sin(0.6) = 0.564642, cos(0.6) = 0.825336
atan(0.7) = 0.610726, sin(0.7) = 0.644218, cos(0.7) = 0.764842
atan(0.8) = 0.674741, sin(0.8) = 0.717356, cos(0.8) = 0.696707
atan(0.9) = 0.732815, sin(0.9) = 0.783327, cos(0.9) = 0.62161

So I conclude that there's something very wrong with emu387.dxe built
against CVS.

I rebuilt without profiling, but the result was the same. I downgraded to
gcc 2.95.3 and it worked again:

atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.0996687, sin(0.1) = 0.0998334, cos(0.1) = 0.995004
atan(0.2) = 0.197396, sin(0.2) = 0.198669, cos(0.2) = 0.980067
atan(0.3) = 0.291457, sin(0.3) = 0.29552, cos(0.3) = 0.955336
atan(0.4) = 0.380506, sin(0.4) = 0.389418, cos(0.4) = 0.921061
atan(0.5) = 0.463648, sin(0.5) = 0.479426, cos(0.5) = 0.877583
atan(0.6) = 0.54042, sin(0.6) = 0.564642, cos(0.6) = 0.825336
atan(0.7) = 0.610726, sin(0.7) = 0.644218, cos(0.7) = 0.764842
atan(0.8) = 0.674741, sin(0.8) = 0.717356, cos(0.8) = 0.696707
atan(0.9) = 0.732815, sin(0.9) = 0.783327, cos(0.9) = 0.62161

So it looks like a code generation issue.

> Also, could you please try the same on plain DOS?  I don't trust the
> Windows DPMI server as far as FP emulation is considered.

If the above isn't enough to prove that gcc 3.0.x is the problem, then
I'll be happy to rerun on DOS. I only have Windows '98 SE, but presumably
its DOS mode would be OK.
 
BTW is emu387 documented anywhere? If not, I'll whip up a quick manual for
it, describing what it does, what effect the 387 & EMU387 environment
variables, etc.

Thanks, bye, Rich =]

-- 
Richard Dawe
http://www.phekda.freeserve.co.uk/richdawe/

---Start m.c---
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int
main (void)
{
  double l, d;

  for (l = 0; l < 0.9; l += 0.1)
    {
      d = atan(l);
      printf("atan(%g) = %g, ", l, d);
      d = sin(l);
      printf("sin(%g) = %g, ", l, d);
      d = cos(l);
      printf("cos(%g) = %g\n", l, d);
    }

  return(EXIT_SUCCESS);
}
---End m.c---

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019