Re: compile choices changing results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Julie Stern wrote:
So, do my answers below point to the gcc compiler switches
-O3 -fomit-frame-pointer -funroll-loops

They are significant; trust me on this.

Right. I haven't used 2.95 for years; it's considered old and unsupported nowadays, as is RH 7.3. I'm reasonably sure that floating point code generation has changed since that version.

That said, more recent versions of GCC can definitely produce varying floating point results when optimisation is enabled/disabled on x86. It's an artefact of how x87 (yes, x87) floating point works in conjunction with the fact that optimisation can reorder operations and/or rearrange register usage.

Try removing the -O3 from the makefile and see if that brings the results in line with the 'cc' version.

I don't think -fomit-frame-pointer should be a problem, but I'm unsure on -funroll-loops. If other list members are willing to comment, I'd appreciate that :)

and should this really produces different results in the
number crunching?

No, but x86 floating point is 'special' in that regard. If you want to know more about finite precision floating point issues, these links:

http://gcc.gnu.org/PR323
http://grouper.ieee.org/groups/754/
http://www.validlab.com/goldberg/paper.ps (found on the IEEE page)
http://www.cs.berkeley.edu/~wkahan/Mindless.pdf

were useful to me when I encountered a similar problem.

Neil.

On Thu, 2 Feb 2006, Neil Ferguson wrote:

Hello -

We need more information:

- what version of which OS are you using?

          Linux and I was told gcc and cc are the same in linux.  But,
I do anticipate running on other operating systems where they won't
be the same.   So, the LINUX v. is RehHat Linux 7.3

- what version of GCC?

          2.95.3

- what hardware/CPU architecture are you running on?

          Gateway intel pentium III, i686

- is 'cc' actually an alias or symlink for 'gcc', or is it another compiler altogether? Even if 'cc' points to a different version of GCC, that can be significant.

        Yes, there was a symbolic link to gcc.

Semi-educated guess - are you compiling for x86?

i686
Neil.

Julie Stern wrote:

Hello,
  I'm running some code which came with a makefile
containing -O3 -fomit-frame-pointer -funroll-loops
and the program results were drastically different from
running with just cc. (yes, right now its an unfair
comparison, cc vs. gcc -O3 -fomit-frame-pointer -funroll-loops),
but I didn't expect the results to be different.
  Can anyone explain what the compiler options actually
do in this case?  I can read the man pages, but don't
understand what it exactly does.  Can anyone explain
why my results would be different  (2nd and 3rd decimal place
different in numbers that are in scientitific notation and
are e06 and e37, so the differences are huge)?  Anybody
have opinions on cc vs. gcc that can help me decide which
to use?

   Thanks so much for help and advice.

--Julie


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux