Author Topic: GCC Optimization  (Read 15629 times)

Offline nickrt

  • Single posting newcomer
  • *
  • Posts: 8
GCC Optimization
« on: March 28, 2009, 01:17:58 pm »
Hello - I hope this is the right place! Firstly I love Code:Blocks as a development environment!!
Quick question - does the included GCC compiler (in PC environment?) support (a) 64-bit code generation and (b) the -mtune=core2 (or even core4?!) optimizations? I have developed some very maths intensive code that needs to run as fast as jolly well possible!!

Thanks for any help/suggestions!!

Nick

Offline CBLaw

  • Single posting newcomer
  • *
  • Posts: 8
Re: GCC Optimization
« Reply #1 on: March 29, 2009, 03:19:53 am »
Hey nickrt, I'm no pro, but. if you right click your project and select 'build options' you can set up the GCC compiler. On my machine I'm seeing 'Intel Pentium 4 Nocona (MMX SSE SSE2, SSE3, 64-bit extensions) listed about 2/3 of the down the list of compiler flags.  Of course this is only one of many CPU's you can build for. Hope this helps...


Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: GCC Optimization
« Reply #2 on: March 29, 2009, 02:32:31 pm »
There is no difference between Core 2 and what you call "Core 4". The latter is Core 2 with two extra cores, other than that, quad-core and dual-core CPUs of the same generation are identical.

The Core 2 architecture is supported by MinGW/gcc versions 4.3 and up. The official MinGW branch does not support 64-bit code generation, however there is an inofficial MinGW64 project doing that.
Under Linux/BSD/whatever, gcc certainly supports 64-bit code generation, has been for years.

So, no and no.
« Last Edit: March 29, 2009, 02:35:25 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline nickrt

  • Single posting newcomer
  • *
  • Posts: 8
Re: GCC Optimization
« Reply #3 on: April 03, 2009, 10:19:27 am »
Hello

Thank you for the help!

Having looked, it seems that for scientific applications, where the speed of "heavy" maths functions is important, the Intel C compiler is the best (http://software.intel.com/en-us/intel-compilers/).  Does the Code:Blocks environment support this compiler - as I am thinking of investing and would like to stay within the same development environment?

With GCC, I have found that there is an entire "art" to optimization and choice of the command-line options.  For my specific needs I use:

-mtune=nocona
-fomit-frame-pointer
-ffast-math
-fstrict-aliasing
-pipe
-malign-double
-fno-exceptions
-funsafe-math-optimizations
-mfpmath=sse
-msse2

These are all set in the Project-Build-Options, under "other options" (I used them for Release). Along with the following ticked:

Optimize full for speed
i686
Expensive optimizations

There is much discussion on the web on how the different options interact and which produce "better" code!!

Anyones input on the Intel compilers (for Windows and Linux) would be appreciated  :lol:


Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: GCC Optimization
« Reply #4 on: April 03, 2009, 10:49:52 pm »
Code::Blocks supports Intel's compiler, so it would not be a problem.

About optimizations... that's something you would have to try for yourself. You may want to search for GCC vs Intel comparisons (one which compares recent versions of both). See if the results convince you.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: GCC Optimization
« Reply #5 on: April 04, 2009, 12:25:04 am »
Differences between compiler optimisations are a few percent at best.
Differences between proper and improper algorithms can be 100 fold, differences between proper and improper threading can be 5-10 fold.

I'd not worry so much about the compiler, to be honest.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline nickrt

  • Single posting newcomer
  • *
  • Posts: 8
Re: GCC Optimization
« Reply #6 on: April 04, 2009, 04:55:28 pm »
Hi

Well that is not quite true when it comes down to library maths functions supplied with the compiler.  A quick test shows that the standard GCC compiler call to say the exp() function, is some 7-10 times SLOWER than that implemented by Intel, running on the same hardware, with just a straight-forward benchmark loop and timer.  I agree that a properly coded algorithm will always make the largest benefit, however, if it is mostly calling a maths library that has been implemented by other coders - then much efficiency is down to them and not me.  As it happens my code is very tight.  I suspect that the libraries in the GCC need some more work in this area (reviewing various forums it seems that the maths libraries have known algorithmic problems)  Intel has an advantage, in that they only need to consider their own hardware and I assume therefore tightly code the maths library matching their own processors (e.g. see: http://software.intel.com/en-us/articles/just-link-in-to-intel-compilers-math-library-windows/).

I am already running on 16*4 core processors overnight (NP-hard problems...); so a significant speed-up in the maths library would make a BIG difference to me!

Fingers crossed!

Offline CBLaw

  • Single posting newcomer
  • *
  • Posts: 8
Re: GCC Optimization
« Reply #7 on: April 12, 2009, 02:33:23 pm »
For me, speed isn't the only thing I worry about. Intel's debugger is way better. I find the Intel compilers diagnostics, remarks, warnings, and errors to be helpful to me while  building my app. So, I say if you're on Linux, pick up you free copy, and enjoy building with the great debugger and compiler output. Also I find the Intel compiler much faster at building unoptimized debug builds, which is another big plus. Then when you're ready to release you can play with both of them to see which one likes your code more.
   Of course if you need any money for your app, then you can't release with the free Intel. But because it's so good for developing, I'm always gonna build on Linux with the free version. Every once in a while I'll run GCC over my code to make sure it's still happy.

Offline nickrt

  • Single posting newcomer
  • *
  • Posts: 8
Re: GCC Optimization
« Reply #8 on: April 12, 2009, 04:08:57 pm »
Hi

Good idea! Although I compile for both Windows and Linux.  Linux for my clusters!

I wondered if you could tell me how to get the Intel compiler working with Code:Blocks? I have the Windows compiler installed, and the command line is fine, but where are the standard .h files and libraries? It does not seem to come with stdio.h etc? I have not had time to go through documentation as I am mid-way through a project with tight deadlines and changing to Intel compiler may give me speed-up I need... can you help??

My application is research based - not commercial - so I have access to all of Intel's offerings!

Thanks again, :P




Offline CBLaw

  • Single posting newcomer
  • *
  • Posts: 8
Re: GCC Optimization
« Reply #9 on: April 12, 2009, 06:25:51 pm »
I can help ya get it working in Linux. I have no idea how to get it working on windows, I could never afford it!

Lemme know if ya need Linux help. There's just a few articles of minutia to take care of, and you're good ta go!