Problems with compilation

Problems with compilation

Post by Luis Filipe Fabian » Wed, 15 Aug 2001 09:08:40



Hi!

When I try to compile my C program on Red Hat 7 (with gcc -lm), I execute my
program and it works fine.
When I try to compile my program with DJGPP on windows ME, the source
compiles, but the program produces a result that is VERY different...

This program executes a lot of calculations (its a CFD (Computation Fluid
Dinamics))

I've attached two .txt files. The "residue - Right.txt" is the result of the
program compiled on Red Hat. The other one is the result of the program
compiled on windows.

Both programs are compiled with the -lm tag only...

What's going on?

Thank you

Luis Filipe Fabiani

 
 
 

Problems with compilation

Post by Luis Filipe Fabian » Wed, 15 Aug 2001 10:21:51


oops...
The files didn't post....
The output is on the form  Iteration ; Number

On the 11th iteration, the results begin to diverge...
It's the same file, only compiled with diferent gcc's : Right - Linux;
Wrong - DJGPP's gcc

Here they are:
Right            |  Wrong
0; 0.329133 | 0; 0.329133
1; 0.220333 | 1; 0.220333
2; 0.146741 | 2; 0.146741
3; 0.125026 | 3; 0.125026
4; 0.106024 | 4; 0.106024
5; 0.093153 | 5; 0.093153
6; 0.083088 | 6; 0.083088
7; 0.075116 | 7; 0.075116
8; 0.068662 | 8; 0.068662
9; 0.063431 | 9; 0.063431
10; 0.063296 | 10; 0.063296
11; 0.065674 | 11; 0.065673
12; 0.063461 | 12; 0.066310
13; 0.067236 | 13; 0.072322
14; 0.064131 | 14; 0.078448
15; 0.063704 | 15; 0.084744
16; 0.063850 | 16; 0.091271
17; 0.065451 | 17; 0.098079
18; 0.066698 | 18; 2.314107
19; 0.067066 | 19; 74590.910631
20; 0.067872 | 20; 124418055.579191
21; 0.065327 | 21; 142883321.212786
22; 0.063717 | 22; 7570885.623484
23; 0.064031 | 23; 25362702.508947
24; 0.063090 | 24; 22309838.861715
25; 0.063946 | 25; 20835205.956095
26; 0.061509 | 26; 19779109.964971
27; 0.058900 | 27; 23448905.095606
28; 0.056620 | 28; 47721078.397535
29; 0.054561 | 29; 97424595.922030
30; 0.051854 | 30; 215667118.942004
31; 0.047735 | 31; 362099809.016882
32; 0.044531 | 32; 236468185.999834
33; 0.041628 | 33; 66325025.613121
34; 0.038936 | 34; 31350644.743425
35; 0.036422 | 35; 15501626.230143
36; 0.034027 | 36; 13297585.111108
37; 0.031724 | 37; 10950479.385661
38; 0.029488 | 38; 9902540.237108
39; 0.027310 | 39; 21185592.664676
40; 0.025177 | 40; 45937320.893174
41; 0.023088 | 41; 105073647.941135
42; 0.021030 | 42; 275960064.961689
43; 0.018984 | 43; 592422551.289142
44; 0.016872 | 44; 483024722.683900
45; 0.012940 | 45; 284947246.762392
46; 0.017840 | 46; 53667929.755020
47; 0.012115 | 47; 20404174.448806
48; 0.022233 | 48; 6266806.773535
49; 0.013821 | 49; 3235923.508142
50; 0.028398 | 50; 2426480.057794
51; 0.015700 | 51; 1737723.504312
52; 0.030979 | 52; 2128216.590766
53; 0.014267 | 53; 3944701.380660
54; 0.031926 | 54; 9333217.969296
55; 0.012861 | 55; 27997996.131216
56; 0.031076 | 56; 73494030.907925
57; 0.008809 | 57; 75898314.086979
58; 0.027018 | 58; 56544142.654860
59; 0.011931 | 59; 48748296.536950
60; 0.022586 | 60; 39751467.278435
61; 0.013112 | 61; 35259831.747422
62; 0.020840 | 62; 29513432.369993
63; 0.014943 | 63; 29578606.923238
64; 0.022154 | 64; 46994047.872672

Thank you

Luis Filipe Fabiani

 
 
 

Problems with compilation

Post by Martin Str|mber » Wed, 15 Aug 2001 16:26:42



: oops...
: The files didn't post....
: The output is on the form  Iteration ; Number

: On the 11th iteration, the results begin to diverge...
: It's the same file, only compiled with diferent gcc's : Right - Linux;
: Wrong - DJGPP's gcc

: Here they are:
: Right            |  Wrong
: 0; 0.329133 | 0; 0.329133
: 1; 0.220333 | 1; 0.220333
: 2; 0.146741 | 2; 0.146741
: 3; 0.125026 | 3; 0.125026
: 4; 0.106024 | 4; 0.106024
: 5; 0.093153 | 5; 0.093153
: 6; 0.083088 | 6; 0.083088
: 7; 0.075116 | 7; 0.075116
: 8; 0.068662 | 8; 0.068662
: 9; 0.063431 | 9; 0.063431
: 10; 0.063296 | 10; 0.063296
: 11; 0.065674 | 11; 0.065673
: 12; 0.063461 | 12; 0.066310
: 13; 0.067236 | 13; 0.072322

First, do you use the same versions of gcc on both platforms?

Second, do you use the same switches to gcc?

Third, how do you deduce that one is right and the other is wrong?

Right,

                                                MartinS

 
 
 

Problems with compilation

Post by Eli Zaretski » Wed, 15 Aug 2001 18:18:54



> Date: Mon, 13 Aug 2001 21:08:40 -0300

> When I try to compile my C program on Red Hat 7 (with gcc -lm), I execute my
> program and it works fine.
> When I try to compile my program with DJGPP on windows ME, the source
> compiles, but the program produces a result that is VERY different...

> This program executes a lot of calculations (its a CFD (Computation Fluid
> Dinamics))

It's hard to tell, without more information about what the program
does (or, more accurately, HOW does it do that).  Here are a few ideas
to try:

  - Try linking the program without -lm.  It might fail (if it uses
    math functions that are only available in libm.a); if so, try
    putting "-lc -lm" (in that order!) at the end of the link command
    line.  This will cause the program to use a different version of
    some of the math function; perhaps that will help.

  - Use the matherr facility to see whether your program calls some
    math functions with invalid arguments.  (For details about this,
    type "info libc alpha matherr" from the shell prompt, and read
    there.)

As Martin suggested, checking the GCC versions and compilation
switches is also a good idea.

If none of the above helps, the only way to debug this is to run the
program under a de*, put a breakpoint on the spot where the
difference starts to show, and poke around to see what's going on.

 
 
 

Problems with compilation

Post by Luis Filipe Fabian » Wed, 15 Aug 2001 23:55:18


Hi!
----- Original Message -----

Newsgroups: comp.os.msdos.djgpp

Sent: Tuesday, August 14, 2001 4:26 AM
Subject: Re: Problems with compilation

> First, do you use the same versions of gcc on both platforms?
I don't know :( what's the current version of DJGPP's gcc?

> Second, do you use the same switches to gcc?
Yes, only -lm

> Third, how do you deduce that one is right and the other is wrong?

This is acctually a "translation" to C of a MatLab "program" (.m file). So I
can compare the results from there....

But as Eli sugested, I will try the "-lc -lm" tags

Thanks

Luis Filipe Fabiani

 
 
 

Problems with compilation

Post by Luis Filipe Fabian » Thu, 16 Aug 2001 01:59:03


Well, just tried the compilation with -lc -lm, but it didn't work out... (on
windows) t just worked on Red Hat 7

The gcc version of my Red Hat is 2.96, so I'm not compiling the source code
with the same version of gcc...

I've noticed that I can only produce correct results when the program is
compiled under Red Hat 7 (I've tried with another version of linux -
"Conectiva", and it didn't work out)

Is it possible that RedHat's gcc compile with a somewhat implicit option
that is not enabled on other versions?

The main strange thing is that, after the 11th iteration, both programs
produce equal results (until the last decimal) and after that, they start to
diverge...(as seen on a previous post)

Is someone willing to compile/run the program on other platforms?? it's VERY
small

Thank you

Luis Filipe Fabiani

----- Original Message -----


Sent: Tuesday, August 14, 2001 11:55 AM
Subject: Re: Problems with compilation

> Hi!
> ----- Original Message -----

> Newsgroups: comp.os.msdos.djgpp

> Sent: Tuesday, August 14, 2001 4:26 AM
> Subject: Re: Problems with compilation

> > First, do you use the same versions of gcc on both platforms?
> I don't know :( what's the current version of DJGPP's gcc?

> > Second, do you use the same switches to gcc?
> Yes, only -lm

> > Third, how do you deduce that one is right and the other is wrong?

> This is acctually a "translation" to C of a MatLab "program" (.m file). So
I
> can compare the results from there....

> But as Eli sugested, I will try the "-lc -lm" tags

> Thanks

> Luis Filipe Fabiani

 
 
 

Problems with compilation

Post by Eli Zaretski » Thu, 16 Aug 2001 01:59:34



> Date: Tue, 14 Aug 2001 11:55:18 -0300

> > First, do you use the same versions of gcc on both platforms?
> I don't know :( what's the current version of DJGPP's gcc?

You can see both versions by typing "gcc --version" on both systems.
 
 
 

Problems with compilation

Post by Hans-Bernhard Broeke » Thu, 16 Aug 2001 02:22:24



Quote:> Is it possible that RedHat's gcc compile with a somewhat implicit option
> that is not enabled on other versions?

*Everything* is possible. Even more so since you still didn't show
even a single line of source code yet. To see the options GCC actually
uses while compiling, add switches '-v' and '-Q' to the compiler
flags.

Quote:> The main strange thing is that, after the 11th iteration, both programs
> produce equal results (until the last decimal)

... not necessarily.  You can only compare those decimals you actually
printed (6, out of a total 16 or more, depending upon some flags).

--

Even if all the snow were burnt, ashes would remain.

 
 
 

Problems with compilation

Post by Eli Zaretski » Thu, 16 Aug 2001 02:03:07



> Date: Tue, 14 Aug 2001 11:55:18 -0300

> > Third, how do you deduce that one is right and the other is wrong?

> This is acctually a "translation" to C of a MatLab "program" (.m file). So I
> can compare the results from there....

Then I suspect some uninitialized storage, like an array that is not
zeroed out.  Most (all?) Unix systems return malloc'ed storage that is
zeroed out, while DJGPP does not (for performance reasons).  You can
use the _CRT0_FLAG_FILL_SBRK_MEMORY flag to get the Unix behavior.
 
 
 

Problems with compilation

Post by Lets Go Cane » Thu, 16 Aug 2001 03:09:29



[...]

Quote:> Is someone willing to compile/run the program on other platforms??
> it's VERY
> small

If it is small, you should post the source here so people can see the
program.  Then they can provide an accurate analysis.

=====
--------------
Lets Go Canes!

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

 
 
 

Problems with compilation

Post by Patrick Mitra » Thu, 16 Aug 2001 22:54:18


Quote:

> > Is it possible that RedHat's gcc compile with a somewhat implicit option
> > that is not enabled on other versions?

> *Everything* is possible. Even more so since you still didn't show
> even a single line of source code yet. To see the options GCC actually
> uses while compiling, add switches '-v' and '-Q' to the compiler
> flags.

> > The main strange thing is that, after the 11th iteration, both programs
> > produce equal results (until the last decimal)

I'm also running big iterative simulations with MATLAB and C code compiled
with DJGPP. I don't believe the compiler is at fault here. There are a few
numerical
issues to consider when using C code. For example, what kind of rounding are
you
using (this is one likely issue since iterative algorithms are particularly
suceptable
to this kind of issue). Do you use transcendental functions such as erfc or
other?
These are implemented in libm as curve fits that may differ on the last few
decimals
depending on which implementation of the library you link with. What kind on
arithmetic precision do you use? I've noticed in my case that after 100
iterations of
what I do the results are different depending on whether I use float, double
or long double precision. MATLAB uses double, so if you want to repeat that
behaviour, you should too. Do you use the -ffast-math and -ffloat-no-store
options? These will also change your numerical behaviour. Do you use random
numbers? There are many issues
with generating random numbers. A 32-bit random integer isn't necessarily a
good
choice to create a "random" double in the range [0-1] since you can't make
the
last 20 or so binary digits of the mantissa "random".

Cheers,
Patrick

 
 
 

Problems with compilation

Post by Luis Filipe Fabian » Fri, 17 Aug 2001 04:58:33


I've figured it out...

It's a bug on versions < 2.96

On versions 2.96 and above, it's not present...

Thank you VERY much for the help....

Luis Filipe Fabiani

 
 
 

1. Problem with compilation!

Hi
I am new to C++ world.
I am trying to compile a code using GCC. I am getting teh following message.
c:/djgpp/lang/cxx/iostream.h:31: streambuf.h: No such file or directory
(ENOENT)

Can someone help me as to what I need to do?

Thanks.
Goutam Dasgupta

2. Fixed!

3. Problems with compilation

4. Select and Update logjam

5. djgpp compilation problem (another new problem (sorry!))

6. Announcing the SHARE Technical Conference, July28 to Aug. 2nd. New Orleans LA

7. allegro 2.2 compilation problem

8. Any luck using Roadrunner on Win2000

9. djgpp compilation problem

10. Allegro Latest WIP compilation problems...

11. Compilation problem

12. Maths expression parser, compilation problems

13. Compilation problem