Slashdot Mirror


Intel Compiler Compared To gcc

Screaming Lunatic writes "Here are some benchmarks comparing Intel's compiler and gcc on Linux. Gcc holds it own in a lot of cases. But Intel, not surprisingly, excels on their own hardware. With Intel offering a free (as in beer) non-commercial license for their compiler, how many people are using Intel's compiler on a regular basis?"

51 of 101 comments (clear)

  1. Re:Huh? by Omega+Hacker · · Score: 5, Informative

    Both machines are running SMP kernels because Hyperthreading makes the single P4 processor look like two processors. If you don't run an SMP kernel, you don't get access to the second virtualized CPU.

    --
    GStreamer - The only way to stream!
  2. c++ programs by reaper20 · · Score: 4, Interesting

    So does this mean tha mozilla compiled with the intel compiler would run comparable to it's windows counterpart?

    I would like to see a test with real desktop applications and desktops, ie. gcc GNOME/KDE vs. icc GNOME/KDE. Would these projects see significant performance improvements from the Intel compiler?

    1. Re:c++ programs by swmccracken · · Score: 4, Interesting

      The Intel Compilers are not linux specific. They come in both Windows and Linux flavours - and there's nothing stopping you from compiling Moz for Windows using it, afaik.

      And, no, I supsect not really. Intel Compilers are designed for number-crunching work - eg: finite element alaysis, engineering simulations, that sort of thing. They perform optimizations designed to improve CPU bound processes. I suspect that interactive / IO bound processes wouldn't be so affected.

      Secondly, it depends where the bottleneck is - I could be the runtime linker, or the X-Window system itself or who knows.

      Those projects should see some level of improvement, but I wouldn't imagine it's twice as fast. (Things like a paint program might though - as the Intel compilers can take existing "normal" C code and generate SSE and MMX using code.)

    2. Re:c++ programs by zenyu · · Score: 4, Informative
      Unfortunately the C++ from the two compilers is not compatible, yet. I think they are working on it, perhaps with gcc3.3 and Intel 9.0. Also, the being a different compiler it won't just compile a program that you've got working with gcc 2.x, gcc 3.2, and Visual C++ 6.0, esp if you have a long compat.h to do it.

      I like icc, esp since I'm using a lot of floating point and gcc isn't too good with that on the PentiumIII & 4. But so far haven't had the time to unit test every component with my C++ project, and you can't just drop in icc compiled classes, it's all or nothin' (or lots of hacks and C code, but I'd rather put the work into a proper port at some point.) gcc 3.2 is also better than those benchmarks show, I've gotten a doubling in speed on some code compared to gcc 2.x. It's often a matter of trying different flags on each unit and rerunning your benchmark, I think the -Ox's aren't finely tuned yet on the gcc3.x series.

      There is a real problem with compilation speed on gcc3.2, I thought it hung when I ran a "-g3" compile and it was stuck on one short file for 10 mins, nope, just REALLY slow. I modified my makefiles to do a non-debug compile to check for errors before doing a "-g" Then I only "-g3" the files I need, when I need them. I mention it mostly because it may explain why the -Ox flags aren't optimal yet.

    3. Re:c++ programs by bunratty · · Score: 5, Informative
      So does this mean tha mozilla compiled with the intel compiler would run comparable to it's windows counterpart?
      The last I heard, the reason that Linux builds of Mozilla are slower than Windows builds is that Linux Mozilla builds use g++ 2.95 with -O optimization. When they can switch to g++ 3.2.1 with -O2 optimization, the speeds should be comparable.
      --
      What a fool believes, he sees, no wise man has the power to reason away.
    4. Re:c++ programs by halfnerd · · Score: 2, Interesting

      I'm running mozilla compiled with gcc 3.2.1 with no problems at all. Even got java working thanks to the excellent portage system in Gentoo. And I heard that flash 6 can be used with gcc3.2.1 compiled mozilla

  3. Integer performance? by crow · · Score: 3, Informative

    In looking at the selection of benchmarks, it seems like they're all based on scientific numeric problems. In other words, they're all very floating-point intensive. I'll admit that I didn't read it all that carefully, but it looked a bit like reporting SPECfp numbers without looking at SPECint.

    Also, the benchmarks used are probably much more loop-oriented than much of the real-world code, but that's typical of benchmarks.

    What I would find interesting would be to compile glibc, apache, and something like perl or mysql with both sets of compilers and see what difference you can get with some web server benchmarks. Or compile X and some game and see how the frame rate compares between the two compilers. Or compile X and Mozilla, and find some really complicated pages to see what gets rendered the fastest (possibly using some trick to get it to cycle between several such pages 1000 times).

  4. Could this replace gcc ? by zaqattack911 · · Score: 3, Insightful

    I'm a little ignorant when it comes to this... gcc and linux have always gone hand in hand in my mind.

    Could we see versions of linux distributed with intel compiler instead of gcc? Can the intel compiler compile the kernel?

    Clue me in!

    --noodles

    1. Re:Could this replace gcc ? by flockofseagulls · · Score: 2

      Try reading the article before posting.

      Intel does not support all gcc language extensions; while it has been used to compile the Linux kernel and other free software projects, it is not a drop-in replacement for gcc.

    2. Re:Could this replace gcc ? by swmccracken · · Score: 2, Interesting

      A while ago, no. Intel explicitly documented that their C compiler could not compile the Linux kernel because the Linux kernel used a significant amount of gcc-specific functionality. (Specifics of inline keywords, the inline assembly bits interfacing with the c written bits, for example.)

      I do not know if this is still true, but I imagine it is.

      The Kernel developers use gcc - I wouldn't entirely trust using a different compiler. Besides, there probably isn't a huge performance penality.

      I've looked at using the Intel compilers (the have a FORTRAN one) and their main advantage is in number-crunching applications. I suspect the differences aren't so important in interactive / non-crunching applications.

      -
      -

    3. Re:Could this replace gcc ? by Screaming+Lunatic · · Score: 2, Insightful
      Intel does not support all gcc language extensions; while it has been used to compile the Linux kernel and other free software projects, it is not a drop-in replacement for gcc.

      I'm somewhat dissappointed with kernel hackers (and other opensource developers) with respect to this issue. The issue is that the kernel is not ANSI-C compliant, not the fact that icc isn't compliant.

      It annoys me when MS does not support standards such OpenGL or with MSVC6 or with .doc files, etc.

      I'm not trying to troll here, but standards are a Good Thing(TM). But who am I to complain, Linus' tree is Linus' tree and he is allowed to do whatever he wants with it. Although, I'd like to see a hacker pick it up and port it to ANSI-C.

    4. Re:Could this replace gcc ? by T-Ranger · · Score: 5, Informative
      Unfortunatly the reality of the compiler world is that everything has there own unique extensions to ANSI-C. And for that matter, there own unique bugs related to there implementation of ANSI C as well.

      Any peice of software as large, complex, and critical, as a OS kernel is going to, at the very least, be tested agianst a specific compiler. Linux was developed primarly with free tools, ie GCC. So Linus and his cohorts have taken the test-on-gcc mindset one step further and used GCC extensions.

      So what? What do they loose? No functionality, they could implement things in ASM if need be, so convience. And convienent things are probabaly understandable things, and understandable things mean less buggy code.

      If people never used compiler extenstions, then you would never have to run ./configure :)

    5. Re:Could this replace gcc ? by Xner · · Score: 2, Informative
      ... because the Linux kernel used a significant amount of gcc-specific functionality.

      I have the impression that a significant point is the difference in assembler syntax. GCC uses the AT&T syntax, where the register you want to store into comes last, while the Intel compilers (and just about any other x86-native tool) uses the Intel syntax, where the distination register is the first one in the list. There are other differences as well, regardign the way type information and indirection is handled.

      My impression is that Intel does not want to implement an AT&T style assembler parser, and the GCC folks got bothered so much about Intel syntax by all the x86 newbies that they'd rather jump off a cliff.

      --
      Pathman, Free (as in GPL) 3D Pac Man
    6. Re:Could this replace gcc ? by Anonymous+Brave+Guy · · Score: 2
      So what? What do they loose?

      Portability. They are just as locked in as any other development team using a single proprietary compiler with its own custom extensions. As a result, they are stuck using a tool that, with all due respect, produces pretty mediocre output compared to the best in the field. That might not matter too much for an OS, since chances are it doesn't take much advantage of either the things the other compilers optimise better or the features GCC doesn't support properly. In general, though, it's a very serious point (said the guy who writes code that compiles on 15 different platforms every day).

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    7. Re:Could this replace gcc ? by Bert64 · · Score: 2

      gcc is as much of a standard as windows or msword, just because its commonly used doesnt make it a standard.

      --
      http://spamdecoy.net - free throwaway anonymous email - avoid spam!
  5. heh. by pb · · Score: 2

    I was just looking into this the other day--since Intel just supplies their own binaries, it wasn't thrilled about my Gentoo install. Sure, I had rpm, and I could use --nodeps to make it shut up during the install, but even then it didn't like my binaries. Maybe they're too new to be RedHat compatible? ...not to mention the silly license file I had to copy to get the thing to even attempt to install. Thanks, Intel, but no thanks. Until you open the source on this one, I see no need to test it out on my ATHLON. ;)

    --
    pb Reply or e-mail; don't vaguely moderate.
  6. An oldie but a goodie! (Intel joke) by pyman · · Score: 2, Funny

    I am Pentium of Borg. Division is futile. You will be approximated.

    --
    a ^= b; b ^= a; a ^= b;
  7. gcc and Intel compilers by flockofseagulls · · Score: 3, Insightful

    But Intel, not surprisingly, excels on their own hardware.

    Do you mean to imply that Intel knows something about the Pentium architecture or instruction set that the authors of gcc don't? Does the code emitted from the Intel compiler use undocumented instructions? Intel's compiler is newer than gcc and wasn't developed with the "many eyes" that have looked at gcc over the years. It looks like Intel's engineers wrote a better compiler, simple as that.

    These benchmarks give gcc a black eye, but I doubt Intel was using undocumented secrets of their chip to defeat gcc. Sometimes the open source community has to admit that not every open source project represents the state-of-the-art.

    1. Re:gcc and Intel compilers by Screaming+Lunatic · · Score: 4, Insightful
      I wasn't trying to imply anything that you are implying that I tried to imply. Intel writes an optimizing compiler. The compiler optimizes well for Intel hardware. I don't think that there are undocumented instructions or any other conspiracy theory. Intel would be stupid do that. It would give AMD more opportunity to whip them with programs compiled with msvc or gcc.

      I do believe that Intel engineers probably have a better understanding of branch prediction and cache misses on Intel hardware.

      I don't think these benchmarks give gcc a black eye at all. gcc aims to be a cross-platform compiler first, optimizing compiler second. icc aims to be an optimizing compiler first, cross-platform compiler second.

      And chill with the conspiracy theories.

    2. Re:gcc and Intel compilers by swmccracken · · Score: 2, Interesting

      Instruction selection isn't that simple - knowing what instructions there are isn't difficult, as that is documented.

      But, knowing which instruction would be the fastest in each particular situation, how to organise things to reduce the chance of a cache miss and that sort of thing. So, yes, Intel know more about their chips than anyone else does.

      (However, AMD know more about AMD chips than anyone else does...)

    3. Re:gcc and Intel compilers by JabberWokky · · Score: 2
      Amazingly enough, I excel at using my workstation. I don't use any software that is not unavailable elsewhere, but it's amazing how, since I put it together, I tend to know what's available on it and where the quickest place to find the icons to launch things are (and which apps don't have icons, since I habitually launch them from the command line).

      Am I using undocumented "KDE+Bash+Linux knowledge"? Hardly. Do I have a 'home turf advantage'? Yup.

      Who said that intel was doing anything nefarious? I'd say it's passibly *obvious* that the engineers that designed the chip would have an advantage at designing an optomizing compiler, even when things are completely documented. And so it is.

      --
      Evan

      --
      "$30 for the One True Ring. $10 each additional ring!" -- JRR "Bob" Tolkien
    4. Re:gcc and Intel compilers by MikeBabcock · · Score: 2

      There always have been (and always will be) undocumented instructions. However, Intel is probably just using better heuristics to decide what to do where.

      --
      - Michael T. Babcock (Yes, I blog)
    5. Re:gcc and Intel compilers by ameoba · · Score: 2

      I'm sure that it'd be REALLY easy to pick up on undocumented instructions.. just compile with a "compile only, do not assemble" option and look at the output.

      --
      my sig's at the bottom of the page.
    6. Re:gcc and Intel compilers by MikeBabcock · · Score: 3, Informative

      Or take a look at the info on x86.org.

      --
      - Michael T. Babcock (Yes, I blog)
    7. Re:gcc and Intel compilers by FuzzyDaddy · · Score: 2
      One tool that Intel has that no one else does is an accurate software model of their processor. They make one to validate the design before making silicon. This allows them to look at EXACTLY the code that is executing inside the processor - cache hits/misses, branch predictions, everything down to the last clock cycle.

      This tool alone probably gives them a huge edge in developing compilers.

      --
      It's not wasting time, I'm educating myself.
  8. Not my experience. by WasterDave · · Score: 4, Informative

    I've been writing some integer only video compression code, and these results don't really bear out what I've been seeing with GCC 3.1 and Intel C++ 6. I'm getting a consistent 15-20% more framerate under Intel, using an Athlon. An Athlon, god alone knows what we'd be looking at if I was daft enough to buy a P4. Admittedly there are some vectorizable loops in there (that are going to be replaced by primitives at some point), but even without those the performance improvement from C6 was consistent and noticeable.

    More relevant is how the performance of C7 is markedly worse on the P3 platform than C6. Very disappointing, makes me wonder what they've done.

    Dave

    --
    I write a blog now, you should be afraid.
    1. Re:Not my experience. by zenyu · · Score: 2
      More relevant is how the performance of C7 is markedly worse on the P3 platform than C6.

      C7 defaults to -mcpu=pentium4, I bet he'd get different results with -mcpu=pentiumpro

      These benchmarks aren't really for those that really need the fastest code, they will benchmark their own code. But, it is valid for what deciding what to compile all that other stuff. Though with gcc holding it's own on most of those benchmarks the ubiquity gcc gets through it's license is outweighs the small performance benefit, well in C surely. Hopefully someone will look at that wacky place in the C++ benchmarks where icc outperformed it by over 1000%, perhaps the fix for that could be pulled into -O3 or maybe -O6, like with pgcc... gcc 3.0 was mostly a standards release, 3.1 and 3.2 were mostly bug fixes, hopefully 3.3 will iron out the ABI interpretation differences between gcc and icc, then 3.4+ can be performance oriented.

    2. Re:Not my experience. by JKR · · Score: 2
      More relevant is how the performance of C7 is markedly worse on the P3 platform than C6. Very disappointing, makes me wonder what they've done.

      It's optimising for P4 by default, which is missing the barrel shifter the P3 uses to generate immediate operands. On P4 it uses a 3rd cut-down ALU to handle them. Hence P3 code will run slowly on P4 CPUs (on top of the fact that P4 only gets ~80% performance clock-for-clock compared to P3) and vice-versa.

      Jon.

  9. Gentoo supports icc by djohnsto · · Score: 2

    You still have to get the license file and install it where necessary, but try an `emerge icc`. It does work (by doing pretty much exactly what you did by hand...). What I really want is the ability to put USE='icc' in make.conf.

    --
    Dan
  10. some practical issues by blackcoot · · Score: 5, Informative

    i've been using icc on a realtime computer vision project that i'm working on. intel's compiler ended up giving me an approximately 30% boost over all --- a difference which is not to be sneezed at. in terms of empirical performance data for my application, icc wins hands down.

    that said, icc does a lot of things that really irritate me. for one, it's diagnostic messages with -Wall are, well, 90% crap. note to intel: i don't care about temporaries being used when initializing std::strings from constants --- the compiler should be smart enough to do constructor eliding and quit bothering me. the command line arguments are somewhat cryptic, as are the error messages you get when you don't get the command line just right. the inter procedural optimization is very *very* nice; however, be prepared for *huge* temporary files if you're doing ipo across files (4+mb for a 20k source file adds up very quickly).

    this all said, i don't think that i'm going to give up either compiler. gcc tends to be faster on the builds (especially with optimization turned on) and has diagnostics that are more meaningful to me. fortunately, my makefiles know how to deal with both ;-)

    1. Re:some practical issues by Random+Walk · · Score: 2
      In my experience, it is always a good idea to test both compilers for your specific application. I have seen cases where icc performs far worse than gcc, apparently because the compiled code causes much more page faults.

      On the other hand, icc supports OpenMP, which means that on an SMP machine you might be able to parallelize a loop by inserting just a single line of code, like:
      #pragma omp parallel ...

  11. Mail sent to author by guerby · · Score: 5, Informative
    I sent this on December 10th, no answer or update to the page:

    Hi, I just saw your posting on the GCC list and was surprised by your analysis about Scimark 2.0 "Overall, Intel produces code that is 15% faster". If you look at the detailed result, you'll find out that the Monte Carlo tests is an obvious problem for GCC since it produces code 3 times as slow as Intel whereas on other tests it is on par. This discrepency explains about all of the 15% difference in the composite difference (which is a simple arithmetic average), so "overall" is a bit strong :).

    Interested I took a look at the Monte Carlo test, and it turns out to be 20 lines of code that generate random numbers using integer arithmetic, ie not floating point intensive stuff at all which is quite at odd with your statement "I've found this benchmark reflects the performance I can expect in my own numerical applications".

    My conclusion is that GCC is probably missing one obvious integer optimisation that Intel compiler does, but I don't think we can generalize from this particular point.

    You can quote me on a public forum if you want to. I write numerical intensive code for a living at a big bank.

    Sincerely,

    1. Re:Mail sent to author by ChaoticCoyote · · Score: 2

      You need to re-read the article, which has changed. The "15%" senetence was an artifact that should have been deleted (and now is) from an earlier article.

      The text you found objectional is replaced by the following:

      On the Pentium III, gcc and Intel run very close together. The Pentium IV tests, however, show a trend that will continue throughout the rest of these tests: Intel produces faster code on almost all tests, and produces code that is 20% faster overall. Only on the Sparse Matrix Multiplication test did gcc generate the fastest code.

      Many "numerical applications" involve integer calculations; last time I looked, integers were numbers, too. ;)

    2. Re:Mail sent to author by guerby · · Score: 2

      If you remove the Monte Carlo test, the P4 composite result turns out to be 9.3% better for icc, quite a different figure than 20% (even if icc is of course still better on 3 out of 4 tests).

      Well you can obviously play with words. Why did SPEC dudes bother splitting between SPECint and SPECfp after all? :).

    3. Re:Mail sent to author by Daleks · · Score: 2

      Numbers don't lie, people do. Did you know that 99% of people under the age of 16 are unemployed?!

  12. Interesting... by Pathwalker · · Score: 3, Interesting

    I wonder why he didn't turn on -fforce-addr under GCC?

    Under the versions of GCC that I have used, I've always found that -fforce-addr -fforce-mem gives a slight speed boost when combined with -O3 -fomit-frame-pointer.

    Under GCC 3.2, it looks like -fforce-mem is turned on at optimization -O2 and above, but -fforce-addr does not appear to be turned on, and it seems like it may be of some help in pointer heavy code.

  13. A Practical Problem by ChaoticCoyote · · Score: 2

    I didn't use -fforce-addr because I didn't think of it! ;)

    Based on some work suggested by someone in e-mail, I'm going to see if it's possible to write a "test every option combination" script. Given the hundreds of potential options, we're looking at a REALLY BIG test... ;)

    In my view, gcc has far too many options and virtually no real documentation about how those options interact, or even what options go with what circumstances. Very messy, and very hard for people to figure out.

    ,

    I hope to alleviate that problem, given time and resources.

    1. Re:A Practical Problem by mbessey · · Score: 2

      I don't think you'll be able to test EVERY combination of options, simply because there are so many.

      On the version of GCC I normally use, there are 25 -f options for controlling optimization. There are also a couple of other options that will effect code efficiency as a side-effect.

      To test every combination of 25 options, you'd have to recompile and re-execute your tests 33,554,432 (2 to the 25th power) times, which will probably exceed your patience.

      With a little clever winnowing of options, you might be able to cut that down to a reasonable set of options. Presumably, some options will always be a win, in nearly every situation. If you take those as fixed, that'll cut down the set of permutations significantly.

      -Mark

  14. Everything is relative... by ChaoticCoyote · · Score: 2

    ...to specific applications and environments. I hope the tests bear that out -- in general, Intel and gcc are tied on Pentium III hardware, and Intel produces demonstrably faster code on Pentium 4 systems.

    My article is a guideline, not a pronouncement. Your mileage is guaranteed to vary.

  15. Head Start by ChaoticCoyote · · Score: 4, Interesting

    Historically, Intel has always been ahead of the competition in terms of code generation; I've used their Windows compiler for years as a replacement for Microsoft's less-than-stellar Visual C++.

    On the Pentium III, the gcc and Intel C++ run neck-and-neck for the most part, reflecting the maturity of knowledge about that chip. The Pentium 4 is newer territory, and Intel has a decided edge in know how to get the most out of their hardware.

    I have great faith in the gcc development team, and as my article clearly states:

    If anything, these tests prove that free software can produce products that rival -- and sometimes exceed -- the qualities of their commercial counterparts.

    This article is an ongoing effort; I assure you, I'll be updating and expanding the material in response to the comments of readers and further experience.

  16. A lost sentence! by ChaoticCoyote · · Score: 2

    Aarrrgggghhhhhh! I'd made that point in an earlier incarnation of the article, and it got lost when I rewrote the conclusions. Thanks for bringing this too my attention; I'll restore the lost text.

  17. More benchmarks... by ChaoticCoyote · · Score: 2

    ...are on their way, including soem very unusual ones. Stay tuned for new episodes in the continuing saga. ;)

  18. Re:Glibc 2.3 issues? by ChaoticCoyote · · Score: 3, Interesting

    I'm running Intel C++ and Fortran 95 with Debian "unstable" as my distro (though I provide my own kernel), and it's currently using glibc 2.3.1.

    Intel has stated on their web site forum that their compilers don't work with the glibc provided with Red Hat 8.0. I don't have an installation of Red Hat here, so I can't verify the problem.

  19. SPECint vs. SPECfp by yerricde · · Score: 2, Interesting

    Why did SPEC dudes bother splitting between SPECint and SPECfp after all?

    Because encryption and other heavy number theory doesn't use floating-point.

    Because analog modeling of physical systems such as circuits doesn't use integers except as loop counters and pointers.

    Because floating-point hardware draws a lot of power, forcing makers of handheld devices to omit the FPU.

    --
    Will I retire or break 10K?
  20. Re:Why temporaries matter by blackcoot · · Score: 4, Interesting

    My specific issue has to do with code that looks like this:

    class C {
    public:
    C(const string& s = "some string");
    };

    icc wants code that looks like this:

    class C {
    public:
    C(const string& s = string("some string"));
    };

    The only real difference I see between the two is the explicit creation of a temporary. Now, as to why GCC doesn't complain is another issue --- maybe its diagnostics for temporaries aren't turned on with -Wall (perhaps -pedantic fixes that); however, I have this feeling that GCC's constructor elision is the trick here. To be honest, I'm very curious to find out why this happens. As an interesting aside, Stroustrup tackles the issue of overloading operators in a "smart" way so as to avoid unecessary copies.

    Personally, I think Java (and whomever it "borrowed" these particular semantics from) got it right. Unfortunately, Java isn't exactly a good language for talking to hardware ;-)

  21. gcc may perform well on x86, but... by Bert64 · · Score: 2

    On other architectures, gcc lags WAY behind the native compiler from the hardware vendor, look at sun workshop, compaq alpha compiler or sgi mipspro..
    And the more code is made that only compiles with gcc, the more performance wastage on these architectures.

    --
    http://spamdecoy.net - free throwaway anonymous email - avoid spam!
    1. Re:gcc may perform well on x86, but... by Znork · · Score: 2

      Indeed. Those vendors would do well to improve gcc on their platforms for their own sake.

      Installing a commercial compiler takes several months in large corporations, assuming you get permission for the expense at all, and often that is not an acceptable option. So gcc is what you get (which has the added advantage of not needing to deal with a PITA license server).

      If that means the performance will suck on Solaris, Tru64, HP-UX or IRIX that just means we are more likely to migrate applications to x86 linux machines instead, not that we buy the compiler...

    2. Re:gcc may perform well on x86, but... by Bert64 · · Score: 2

      However, migrating to x86 is not an option in many cases, ESPECIALLY those which really require high performance....
      x86 is still really limited to 4gig address space, the scalability is poor and not all applications are appropriate for being clustered. Often a high end 64bit multiprocessor system is the only option, and in these cases a 10% speed increase could result in hours of time saved, or even more..

      --
      http://spamdecoy.net - free throwaway anonymous email - avoid spam!
    3. Re:gcc may perform well on x86, but... by Znork · · Score: 2

      Indeed. And if Sun and company feel fine with retreating up the scale until they eventually sell a few hundred systems per year that's ok.

      If, on the other hand, they're interested in remaing competetive in the low to midrange server end they'd do well to make sure that GCC has the best code generation possible for their platform because GCC is quite often the defacto compiler installed, despite it not being the best for the platform (even if the platform specific compilers were free gcc would remain immensly popular and probably remain the most common compiler on those systems merely because it works close to the same between platforms).

  22. Re:Why temporaries matter by e-Motion · · Score: 2, Informative

    My specific issue has to do with code that looks like this:

    class C {
    public:
    C(const string& s = "some string");
    };

    icc wants code that looks like this:

    class C {
    public:
    C(const string& s = string("some string"));
    };

    The only real difference I see between the two is the explicit creation of a temporary. Now, as to why GCC doesn't complain is another issue --- maybe its diagnostics for temporaries aren't turned on with -Wall (perhaps -pedantic fixes that); however, I have this feeling that GCC's constructor elision is the trick here. To be honest, I'm very curious to find out why this happens.


    Constructor elision trick? The code

    const std::string& s = "some string";

    implicitly constructs a temporary std::string and binds it to the reference s. I don't know how the compiler could eliminate the construction of the temporary each time the function is called, unless it compiled it to something like the following:

    // C.hpp
    #include <string>
    class C {
    static const std::string S_DEFAULT;
    public:
    C(const std::string& s = S_DEFAULT);
    };

    // C.cpp
    #include "C.hpp"
    #include <iostream>
    const std::string C::S_DEFAULT("some string");
    C::C(const std::string& s) {
    std::cout << "C::C() called with: " << s << std::endl;
    }

    You may wish to rewrite your code in this manner because it virtually guarantees that the std::string for the default parameter is constructed once and only once. It also provides an added benefit: if the value of the default changes (from, say, "some string" to "some other string"), then only the C class's translation unit needs to be recompiled.

  23. relativity on the brain. by 7-Vodka · · Score: 2

    You know, Einstein once said his biggest mistake was naming his theory 'special relativity'

    His theory is not that everything is 'relative', it is that if you specify all the variables, everything is precisely understood.

    Moreover, it does not apply to anything else. How is it that you use the postulates of the constancy of the speed of light and of simultaniety, can be applied to the speed of ICC over GCC???

    Quote from the article:
    "Like Einstein, I have to say the answer is relative."

    DOH!

    --

    Liberty.