c compilation - gcc vs visual c

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kumarchi@gmail.com

    c compilation - gcc vs visual c

    hello:

    I recently compiled a numerically intensive c project under cygwin gcc
    3.4.4 and microsoft visual c. The platform is intel T2400 1.83 ghz
    dual core lap top.

    the numerical stuff is both floating point and integer intensive

    The gcc optimized (-O3) vs non optimized improved the performance 30 %

    visual c optimized (standard , check 'release; under visual c 2005)
    vs non optimized ('build') was a whopping 8x performance gain

    but the most surprising thing was visual c optimized was 2x
    performance over gcc optimized.

    is anybody else seeing the same thing. if this is true microsoft c
    compiler is in a different league altogether

    i was not successful so far compiling under mingw. will it make dent ?
    2x is hard to overcome
  • jacob navia

    #2
    Re: c compilation - gcc vs visual c

    kumarchi@gmail. com wrote:
    hello:
    >
    I recently compiled a numerically intensive c project under cygwin gcc
    3.4.4 and microsoft visual c. The platform is intel T2400 1.83 ghz
    dual core lap top.
    >
    the numerical stuff is both floating point and integer intensive
    >
    The gcc optimized (-O3) vs non optimized improved the performance 30 %
    >
    The more you go with higher optimizations, the slower
    it goes. Use -O2.

    visual c optimized (standard , check 'release; under visual c 2005)
    vs non optimized ('build') was a whopping 8x performance gain
    >
    This is because the non optimized version injects a lot of
    checking code to avoid bugs. It is slower than strictly necessary.
    For instance they check at function exit if there wasn't a stack overwrite.

    but the most surprising thing was visual c optimized was 2x
    performance over gcc optimized.
    >
    Intel compiler is even better than Microsoft. It is the best compiler
    for the intel architecture. Period.
    is anybody else seeing the same thing. if this is true microsoft c
    compiler is in a different league altogether
    >
    Obviously Microsoft leaves gcc far behind, and I have been seeing this
    since at least 8-9 years.
    i was not successful so far compiling under mingw. will it make dent ?
    2x is hard to overcome

    mingw is just gcc using Microsoft run time library. Do not expect
    anything better/worst.

    It is not surprising that gcc is slower than Microsoft since the
    people behind each project have vastly different objectives and
    budgets to implement them.

    Gcc is running in many platforms and architectures.
    Microsoft is running in one platform exclusively.

    Gcc implements standards like C99 (module small problems), Microsoft
    implements only Microsoft environments (.net, etc). Microsoft is
    still at C89 level.





    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique

    Comment

    • Ulrich Eckhardt

      #3
      Re: c compilation - gcc vs visual c

      jacob navia wrote:
      Microsoft is running in one platform exclusively.
      Sorry, but that's untrue. The platforms I know are IA32, Intel's and AMD's
      64 bit platforms, MIPS, ARM, SH and maybe some more. Note that the latter
      are used for MS' embedded platform.

      Uli

      Comment

      • micans@gmail.com

        #4
        Re: c compilation - gcc vs visual c


        kumar...@gmail. com wrote:
        hello:
        >
        I recently compiled a numerically intensive c project under cygwin gcc
        3.4.4 and microsoft visual c. The platform is intel T2400 1.83 ghz
        dual core lap top.
        >
        the numerical stuff is both floating point and integer intensive
        >
        The gcc optimized (-O3) vs non optimized improved the performance 30 %
        It's probably not going to help you, but as a point of interest I have
        sometimes found -Os
        to work better (optimize for size) with gcc.

        Stijn


        Comment

        • kumarchi@gmail.com

          #5
          Re: c compilation - gcc vs visual c

          On May 9, 4:20 pm, jacob navia <ja...@nospam.c omwrote:
          kumar...@gmail. com wrote:
          hello:
          >
          I recently compiled a numerically intensive c project under cygwin gcc
          3.4.4 and microsoft visual c. The platform is intel T2400 1.83 ghz
          dual core lap top.
          >
          the numerical stuff is both floating point and integer intensive
          >
          The gcc optimized (-O3) vs non optimized improved the performance 30 %
          >
          The more you go with higher optimizations, the slower
          it goes. Use -O2.
          >
          visual c optimized (standard , check 'release; under visual c 2005)
          vs non optimized ('build') was a whopping 8x performance gain
          >
          This is because the non optimized version injects a lot of
          checking code to avoid bugs. It is slower than strictly necessary.
          For instance they check at function exit if there wasn't a stack overwrite..
          >
          but the most surprising thing was visual c optimized was 2x
          performance over gcc optimized.
          >
          Intel compiler is even better than Microsoft. It is the best compiler
          for the intel architecture. Period.
          >
          is anybody else seeing the same thing. if this is true microsoft c
          compiler is in a different league altogether
          >
          Obviously Microsoft leaves gcc far behind, and I have been seeing this
          since at least 8-9 years.
          >
          i was not successful so far compiling under mingw. will it make dent ?
          2x is hard to overcome
          >
          mingw is just gcc using Microsoft run time library. Do not expect
          anything better/worst.
          >
          It is not surprising that gcc is slower than Microsoft since the
          people behind each project have vastly different objectives and
          budgets to implement them.
          >
          Gcc is running in many platforms and architectures.
          Microsoft is running in one platform exclusively.
          >
          Gcc implements standards like C99 (module small problems), Microsoft
          implements only Microsoft  environments (.net, etc). Microsoft is
          still at C89 level.
          >
          --
          jacob navia
          jacob at jacob point remcomp point fr
          logiciels/informatiquehtt p://www.cs.virginia .edu/~lcc-win32
          the problem is in my type of product i have to recommend windows
          platform because based on gcc performance an apple to apple linux
          platform will run 2x slower

          Comment

          • moi

            #6
            Re: c compilation - gcc vs visual c

            On Fri, 09 May 2008 14:03:14 -0700, kumarchi wrote:
            On May 9, 4:20 pm, jacob navia <ja...@nospam.c omwrote:
            >kumar...@gmail .com wrote:
            hello:
            >>
            I recently compiled a numerically intensive c project under cygwin
            gcc 3.4.4 and microsoft visual c. The platform is intel T2400 1.83
            ghz dual core lap top.
            >>
            the numerical stuff is both floating point and integer intensive
            >>
            The gcc optimized (-O3) vs non optimized improved the performance 30
            %
            >>
            >The more you go with higher optimizations, the slower it goes. Use -O2.
            >>
            visual c optimized (standard , check 'release; under visual c 2005)
            vs non optimized ('build') was a whopping 8x performance gain
            >>
            >This is because the non optimized version injects a lot of checking
            >code to avoid bugs. It is slower than strictly necessary. For instance
            >they check at function exit if there wasn't a stack overwrite.
            >>
            but the most surprising thing was visual c optimized was 2x
            performance over gcc optimized.
            >Obviously Microsoft leaves gcc far behind, and I have been seeing this
            >since at least 8-9 years.
            >>
            i was not successful so far compiling under mingw. will it make dent
            ? 2x is hard to overcome
            >>
            the problem is in my type of product i have to recommend windows
            platform because based on gcc performance an apple to apple linux
            platform will run 2x slower
            Did you enable the -march=cpu-type -msse[2] code generation option ?

            HTH,
            AvK

            Comment

            • Ian Collins

              #7
              Re: c compilation - gcc vs visual c

              kumarchi@gmail. com wrote:
              >
              the problem is in my type of product i have to recommend windows
              platform because based on gcc performance an apple to apple linux
              platform will run 2x slower
              Then try the Intel compiler, which is also cross platform.

              --
              Ian Collins.

              Comment

              • jacob navia

                #8
                Re: c compilation - gcc vs visual c

                kumarchi@gmail. com wrote:
                >
                the problem is in my type of product i have to recommend windows
                platform because based on gcc performance an apple to apple linux
                platform will run 2x slower
                You can use Intel compiler under linux. Your code will be
                faster than under windows/MSVC.

                Of course do not tell your customers about Intel/Windows.
                :-)


                --
                jacob navia
                jacob at jacob point remcomp point fr
                logiciels/informatique

                Comment

                • Niz

                  #9
                  Re: c compilation - gcc vs visual c

                  On 2008-05-09 22:03:14 +0100, kumarchi@gmail. com said:
                  the problem is in my type of product i have to recommend windows
                  platform because based on gcc performance an apple to apple linux
                  platform will run 2x slower
                  Your using a version of GCC which is 3 years old. Perhaps try with one
                  of the newer versions with all the relevant optimisations and then see
                  if the difference is so great. Macs have GCC 4.0.1 (soon to be 4.2.2)
                  as their base compiler under Leopard.

                  Although as others have said, the Intel compiler is king of the hill
                  for producing fast Intel x86 and x86_64 code.

                  Comment

                  • Antoninus Twink

                    #10
                    Re: c compilation - gcc vs visual c

                    On 9 May 2008 at 21:03, kumarchi@gmail. com wrote:
                    the problem is in my type of product i have to recommend windows
                    platform because based on gcc performance an apple to apple linux
                    platform will run 2x slower
                    If speed is that important to you, why don't you hand-optimize the
                    assembly?

                    Comment

                    • cr88192

                      #11
                      Re: c compilation - gcc vs visual c


                      <kumarchi@gmail .comwrote in message
                      news:4780a4b0-8034-4a20-9058-8d53c89bfdd4@j2 2g2000hsf.googl egroups.com...
                      hello:
                      >
                      I recently compiled a numerically intensive c project under cygwin gcc
                      3.4.4 and microsoft visual c. The platform is intel T2400 1.83 ghz
                      dual core lap top.
                      >
                      the numerical stuff is both floating point and integer intensive
                      >
                      The gcc optimized (-O3) vs non optimized improved the performance 30 %
                      >
                      visual c optimized (standard , check 'release; under visual c 2005)
                      vs non optimized ('build') was a whopping 8x performance gain
                      >
                      but the most surprising thing was visual c optimized was 2x
                      performance over gcc optimized.
                      >
                      likely reason:
                      MS focuses a lot more on specific optimizations, and tweaking performance
                      for specific targets;
                      gcc, however, targets many targets, and tends to use far more generic code
                      generation (they try more to leverage fancy general purpose optimizations,
                      rather than arch-specific tweaks for various special cases).

                      in any case, gcc tends to, fairly often, produce fairly silly code (even
                      with optimizations), and, sadly, even with a very braindead lower-compiler
                      design (a hacked over stack machine), and optimizations focusing more on
                      "common special cases", it is not too hard to match or somewhat exceed gcc's
                      performance...

                      IMO, the 'O' options may well be Obfuscate rather than Optimize...


                      actually, one of the better ways at optimizing, would be likely to implement
                      a kind of abstract combinatorial tester, which would basically search the
                      space of possible optimizations and look for the ones with the lowest
                      simulated cost. sadly though, this will not work so well in the face of
                      usage patterns, which require actually using the code (the general option
                      could treat a very common case like an uncommon case, ...).

                      in something like a VM, it could be possible to use a kind of genetic
                      evolver for adapting functions (initially, it compiles functions
                      generically, and any functions it detects are using a significant portion of
                      the time, it starts mutating in an attempt to improve the general
                      performance). later, if/when a "final" version is desired, it uses the
                      versions of the functions found to be most effective.

                      note that this would likely be confined to the realms of low-level
                      optimization, with what are typically the biggest time wasters (general
                      algorithmic issues), being beyond the scope of such a tool...


                      the simplest approach, however (and the one I currently use in my compiler),
                      is to basically just test the compiler, and any obvious issues in the output
                      (silly code), are ones I focus on fixing.

                      the compiler machinery itself in my case, as this level, is little more than
                      just a very large and elaborate mass of decision trees (no fancy transforms
                      or general optimizer machinery, more just operations dispatched through a
                      maze of function calls).

                      this approach seems to work good enough IME...

                      is anybody else seeing the same thing. if this is true microsoft c
                      compiler is in a different league altogether
                      >
                      that, or, most of us are not that concerned with raw performance (vs having
                      a compiler we are not obligated to pay for...).

                      none the less, MS has at least a decent compiler in these regards...

                      i was not successful so far compiling under mingw. will it make dent ?
                      2x is hard to overcome
                      well, with gcc, it is hard to do much better...

                      as noted, MSVC and Intel are good options...




                      Comment

                      • kumarchi@gmail.com

                        #12
                        Re: c compilation - gcc vs visual c

                        On May 9, 6:41 pm, "cr88192" <cr88...@NOSPAM .hotmail.comwro te:
                        <kumar...@gmail .comwrote in message
                        >
                        news:4780a4b0-8034-4a20-9058-8d53c89bfdd4@j2 2g2000hsf.googl egroups.com...
                        >
                        >
                        >
                        hello:
                        >
                        I recently compiled a numerically intensive c project under cygwin gcc
                        3.4.4 and microsoft visual c. The platform is intel T2400 1.83 ghz
                        dual core lap top.
                        >
                        the numerical stuff is both floating point and integer intensive
                        >
                        The gcc optimized (-O3) vs non optimized improved the performance 30 %
                        >
                        visual c optimized (standard , check 'release; under visual c 2005)
                        vs non optimized ('build') was a whopping 8x performance gain
                        >
                        but the most surprising thing was visual c optimized was 2x
                        performance over gcc optimized.
                        >
                        likely reason:
                        MS focuses a lot more on specific optimizations, and tweaking performance
                        for specific targets;
                        gcc, however, targets many targets, and tends to use far more generic code
                        generation (they try more to leverage fancy general purpose optimizations,
                        rather than arch-specific tweaks for various special cases).
                        >
                        in any case, gcc tends to, fairly often, produce fairly silly code (even
                        with optimizations), and, sadly, even with a very braindead lower-compiler
                        design (a hacked over stack machine), and optimizations focusing more on
                        "common special cases", it is not too hard to match or somewhat exceed gcc's
                        performance...
                        >
                        IMO, the 'O' options may well be Obfuscate rather than Optimize...
                        >
                        actually, one of the better ways at optimizing, would be likely to implement
                        a kind of abstract combinatorial tester, which would basically search the
                        space of possible optimizations and look for the ones with the lowest
                        simulated cost. sadly though, this will not work so well in the face of
                        usage patterns, which require actually using the code (the general option
                        could treat a very common case like an uncommon case, ...).
                        >
                        in something like a VM, it could be possible to use a kind of genetic
                        evolver for adapting functions (initially, it compiles functions
                        generically, and any functions it detects are using a significant portion of
                        the time, it starts mutating in an attempt to improve the general
                        performance). later, if/when a "final" version is desired, it uses the
                        versions of the functions found to be most effective.
                        >
                        note that this would likely be confined to the realms of low-level
                        optimization, with what are typically the biggest time wasters (general
                        algorithmic issues), being beyond the scope of such a tool...
                        >
                        the simplest approach, however (and the one I currently use in my compiler),
                        is to basically just test the compiler, and any obvious issues in the output
                        (silly code), are ones I focus on fixing.
                        >
                        the compiler machinery itself in my case, as this level, is little more than
                        just a very large and elaborate mass of decision trees (no fancy transforms
                        or general optimizer machinery, more just operations dispatched through a
                        maze of function calls).
                        >
                        this approach seems to work good enough IME...
                        >
                        is anybody else seeing the same thing. if this is true microsoft c
                        compiler is in a different league altogether
                        >
                        that, or, most of us are not that concerned with raw performance (vs having
                        a compiler we are not obligated to pay for...).
                        >
                        none the less, MS has at least a decent compiler in these regards...
                        >
                        i was not successful so far compiling under mingw. will it make dent ?
                        2x is hard to overcome
                        >
                        well, with gcc, it is hard to do much better...
                        >
                        as noted, MSVC and Intel are good options...
                        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). it simply does lots of
                        floating point array(mainly through fft) and normal integer
                        operations

                        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

                        in our type of situation the intel compiler is not an option.
                        primarily because we have a standaradized dll plug in architecture
                        and so (if windoz do msvc) applies.

                        Comment

                        • kumarchi@gmail.com

                          #13
                          Re: c compilation - gcc vs visual c

                          On May 9, 6:41 pm, "cr88192" <cr88...@NOSPAM .hotmail.comwro te:
                          <kumar...@gmail .comwrote in message
                          >
                          news:4780a4b0-8034-4a20-9058-8d53c89bfdd4@j2 2g2000hsf.googl egroups.com...
                          >
                          >
                          >
                          hello:
                          >
                          I recently compiled a numerically intensive c project under cygwin gcc
                          3.4.4 and microsoft visual c. The platform is intel T2400 1.83 ghz
                          dual core lap top.
                          >
                          the numerical stuff is both floating point and integer intensive
                          >
                          The gcc optimized (-O3) vs non optimized improved the performance 30 %
                          >
                          visual c optimized (standard , check 'release; under visual c 2005)
                          vs non optimized ('build') was a whopping 8x performance gain
                          >
                          but the most surprising thing was visual c optimized was 2x
                          performance over gcc optimized.
                          >
                          likely reason:
                          MS focuses a lot more on specific optimizations, and tweaking performance
                          for specific targets;
                          gcc, however, targets many targets, and tends to use far more generic code
                          generation (they try more to leverage fancy general purpose optimizations,
                          rather than arch-specific tweaks for various special cases).
                          >
                          in any case, gcc tends to, fairly often, produce fairly silly code (even
                          with optimizations), and, sadly, even with a very braindead lower-compiler
                          design (a hacked over stack machine), and optimizations focusing more on
                          "common special cases", it is not too hard to match or somewhat exceed gcc's
                          performance...
                          >
                          IMO, the 'O' options may well be Obfuscate rather than Optimize...
                          >
                          actually, one of the better ways at optimizing, would be likely to implement
                          a kind of abstract combinatorial tester, which would basically search the
                          space of possible optimizations and look for the ones with the lowest
                          simulated cost. sadly though, this will not work so well in the face of
                          usage patterns, which require actually using the code (the general option
                          could treat a very common case like an uncommon case, ...).
                          >
                          in something like a VM, it could be possible to use a kind of genetic
                          evolver for adapting functions (initially, it compiles functions
                          generically, and any functions it detects are using a significant portion of
                          the time, it starts mutating in an attempt to improve the general
                          performance). later, if/when a "final" version is desired, it uses the
                          versions of the functions found to be most effective.
                          >
                          note that this would likely be confined to the realms of low-level
                          optimization, with what are typically the biggest time wasters (general
                          algorithmic issues), being beyond the scope of such a tool...
                          >
                          the simplest approach, however (and the one I currently use in my compiler),
                          is to basically just test the compiler, and any obvious issues in the output
                          (silly code), are ones I focus on fixing.
                          >
                          the compiler machinery itself in my case, as this level, is little more than
                          just a very large and elaborate mass of decision trees (no fancy transforms
                          or general optimizer machinery, more just operations dispatched through a
                          maze of function calls).
                          >
                          this approach seems to work good enough IME...
                          >
                          the one silver lining in this affair s because my code is simple, it
                          shoudl be possible for a compiler guru to zero in on the fundamental
                          issues and fix gcc

                          msvc cannot have some voodoo magic on a simple code like that

                          pardon my layman type of understanding!!

                          is anybody else seeing the same thing. if this is true microsoft c
                          compiler is in a different league altogether
                          >
                          that, or, most of us are not that concerned with raw performance (vs having
                          a compiler we are not obligated to pay for...).
                          >
                          none the less, MS has at least a decent compiler in these regards...
                          >
                          i was not successful so far compiling under mingw. will it make dent ?
                          2x is hard to overcome
                          >
                          well, with gcc, it is hard to do much better...
                          >
                          as noted, MSVC and Intel are good options...

                          Comment

                          • cr88192

                            #14
                            Re: c compilation - gcc vs visual c


                            "Niz" <notarealemaila ddresswrote in message
                            news:2008050923 082616807-notarealemailad dress@news-europe.giganews .com...
                            On 2008-05-09 22:03:14 +0100, kumarchi@gmail. com said:
                            >the problem is in my type of product i have to recommend windows
                            >platform because based on gcc performance an apple to apple linux
                            >platform will run 2x slower
                            >
                            Your using a version of GCC which is 3 years old. Perhaps try with one of
                            the newer versions with all the relevant optimisations and then see if the
                            difference is so great. Macs have GCC 4.0.1 (soon to be 4.2.2) as their
                            base compiler under Leopard.
                            >
                            sadly, I don't expect gcc to be steadily and rapidly picking up efficiency.
                            this is by no means a new project, and so likely any performance improvement
                            is likely to be fairly minor.

                            Although as others have said, the Intel compiler is king of the hill for
                            producing fast Intel x86 and x86_64 code.
                            >
                            wonder why that is?...

                            I think:
                            they make CPUs, so they have more than a few good ideas for how to optimize
                            them;
                            they only have to worry about a select few archs (x86, x86-64, and IA64), of
                            which, they can likely get away using very optimized backends (namely: a
                            specialized backend for each arch);
                            they get good money for all this, and have plenty of funds to devote;
                            ....

                            so, it would be saying a lot if they did not have a compiler which produced
                            good output...


                            meanwhile, as for gcc:
                            it is written by people with apparently more than a few weird ideas WRT
                            processor efficiency;
                            it has to target many archs, and use most of the same machinery between a
                            variety of them;
                            a good portion of the developers are hobbyists (not that hobbyists can't be
                            motivated, but many of them likely have other concerns as well);
                            ....

                            none the less, they are doing pretty well, and gcc is still a fairly good
                            compiler...






                            Comment

                            • Willem

                              #15
                              Re: c compilation - gcc vs visual c

                              kumarchi@gmail. com wrote:
                              ) 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). it simply does lots of
                              ) floating point array(mainly through fft) and normal integer
                              ) operations
                              )
                              ) I used -O3 flag and in my case so far it seems to be better than O2.
                              ) msvc by default uses their own O2.

                              Have you tried gcc's -march=native setting, along with possibly
                              -msse2 and/or -mfpmath=sse, or some other i386-specific settings ?

                              Normally, gcc will compile a binary so that it will run on any i386,
                              not only the current machine.

                              ) I cannot believe such a blatant difference will go unnoticed for long
                              )
                              ) in our type of situation the intel compiler is not an option.
                              ) primarily because we have a standaradized dll plug in architecture
                              ) and so (if windoz do msvc) applies.

                              SaSW, Willem
                              --
                              Disclaimer: I am in no way responsible for any of the statements
                              made in the above text. For all I know I might be
                              drugged or something..
                              No I'm not paranoid. You all think I'm paranoid, don't you !
                              #EOT

                              Comment

                              Working...