Pages

Saturday, January 30, 2010

Compilers Can Make A Big Difference.

I wrote a certain C program that traditionally has taken 10 minutes to run.  Today I tried running it and after 45 minutes I crashed it thinking I must have introduced some bug causing it to not run correctly.  I started puting print statements everywhere and could not find a single place where the bug was.

Than, after an hour of playing with print statement, I noticed I was compiling with gcc when in the past I compiled with Intel's compiler icc.  I had no idea, but the types of rutines I wrote run literally ~7 times faster with icc than gcc.  This is not true about all C codes, but it is about this one.

Here's a new personal testimony Intel could use:
When I don't compile my codes with Intel compilers they run so slow comparitivley that one is almost convinced there must be major bugs in the code.

2 comments:

  1. It could simply be that your new compiler uses different default settings for optimizations. Take a close look at all the command line arguments and play around with them. The C compilers generate native code (vs. interpreted or byte code languages) and can be fine tuned to your particular hardware.

    The intel compiler running on intel hardware probably has default settings to optimize that combination. gcc runs on so many platforms they don't make those assumptions by default.

    Have you used a profiler? If you're worried about tuning for speed a profiler can be invaluable. Often times our human assumptions about bottlenecks are just wrong.

    ReplyDelete
  2. Stan,

    Thanks for the points, and you're probably right. This is a new Intel machine with new Intel compilers. Furthermore the version of gcc is years older than the hardware it's on.

    It probably is something to do with optimizations the Intel compiler is doing that gcc isn't/can't/

    ReplyDelete

To add a link to text:
<a href="URL">Text</a>