From: "Patrick Mitran" Newsgroups: comp.os.msdos.djgpp References: <200108140003 DOT UAA12330 AT delorie DOT com> <005601c12455$477bcb80$0200a8c0 AT lff> <001b01c1245f$81ea6600$0200a8c0 AT lff> <997774002 DOT 560704 AT queeg DOT ludd DOT luth DOT se> <004801c124d1$2763c7e0$0200a8c0 AT lff> <003e01c124e2$70258340$0200a8c0 AT lff> <9lbmog$c9n$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> Subject: Re: Problems with compilation Lines: 41 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: Date: Wed, 15 Aug 2001 13:54:18 GMT NNTP-Posting-Host: 132.206.69.38 X-Complaints-To: abuse AT mcgill DOT ca X-Trace: carnaval.risq.qc.ca 997883658 132.206.69.38 (Wed, 15 Aug 2001 09:54:18 EDT) NNTP-Posting-Date: Wed, 15 Aug 2001 09:54:18 EDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com > > > 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