Re: c compilation - gcc vs visual c



kumarchi@xxxxxxxxx wrote:
<snip>
thanx all of you for responding. I was totally unprepared for such a
vast performance difference (2x msvc vs gcc) and my code is not at all
special(no UI, complicated classes etc).

Those are not the types of things which cause modern compilers to stumble.
They seem complex abstractly, but to a compiler are fairly transparent.

it simply does lots of floating point array(mainly through fft) and normal
integer operations

These are things for which compilers are designed to be highly optimized,
and for which failure to enable a seemingly minor feature can cause huge
variance in performance, like you're seeing.

I used -O3 flag and in my case so far it seems to be better than O2.
msvc by default uses their own O2.

I cannot believe such a blatant difference will go unnoticed for long

It's not gone unnoticed, it's merely gone largely uncommented in this group
because this is the wrong group to ask. GCC is not that far behind MSVC. All
the number and graphs I've seen suggest that something else is involved
here.

Yes, you should try GCC 4.x, because GCC 4.x implemented a different
optimization framework. But this probably doesn't account for the 2x
difference.

It's highly likely that the difference you're seeing is a failure to tell
GCC how and which CPU feature sets to target. GCC depends on the build
system to dictate all the various platform-dependent optimizations; because
GCC is often used for cross-compiling, and for various other reasons, that
kind of logic--like CPU-specific optimizations (as opposed to mere
architecture)--is farmed out. It's likely that MSVC, or Visual Studio, is
turning knobs which in GCC must be done manually.

I recommend that you find another newsgroup, or web page, or other
documentation, to help you turn GCC's knobs. The suggestions here, like
-msse, etc, are a _start_, but by no means exhaustive, or even sufficient.
There are lots of flags to know about; for instance, only the very latest
version of GCC 4.x (4.3, I think) automatically vectorizes, but only if you
specify -msse and/or -mtune or something like that. Prior to 4.x, you need
to not only enable the instruction set, but enable vectorizing.

And there are probably tools/applications you can find which will help you
turn those knobs. I'm just not that familiar to give detailed advice. And
while many people are far more knowledgable in this group, you're apt to get
conflicting or confusing advice because this issue isn't the group's focus.
.



Relevant Pages

  • Re: c compilation - gcc vs visual c
    ... thanx all of you for responding. ... vast performance difference and my code is not at all ... msvc by default uses their own O2. ... Normally, gcc will compile a binary so that it will run on any i386, ...
    (comp.lang.c)
  • Re: compiler back-end development?
    ... with GCC and MSVC. ... I could try to use my own own compiler, but at this stage its Win64 support ... a lot more of my code needs proper tests, and a lot more of my code needs ...
    (comp.compilers)
  • Re: assigning a pointer the address of local variable
    ... In most of the compilers I use (GCC, MSVC++, lcc..) this program runs ... allright printing an address and the correct value 4. ...
    (comp.lang.c)
  • Re: 128 bit integers is on topic
    ... since the code doesn't run under gcc, it is specific to lcc-win etc. ... defines int128_t and uint128_t (at least for my compiler). ... it is worth noting that MSVC does not have this header. ... since my internal mental projections tend to be full 3D ...
    (comp.lang.c)
  • Re: gcc question
    ... > MSVC is likely to be slightly faster because it is ... > MSVC standard will be slower than Gcc because it doesn't do any ... > MSVC Std is fairly cheap. ... > Gcc and MSVC have good conformance. ...
    (microsoft.public.vc.language)