Jump to content
Nytro

How to recompile software with hardware optimizations

Recommended Posts

Posted

How to recompile software with hardware optimizations

Ovidiu / 02/11/2011

I don’t like to recompile software. I also laugh my ass off when some Gentoo “god” tells me how much faster their system became after they tweaked their compile flags. But (because there’s always a “but”) once in a while I do compile software. And in some of those cases, I really want the best optimization possible.

One of these cases was when I wanted to run a CPU miner for Litecoin on my i7. I wanted to squeeze the most out the CPU, so I turned to the Gentoo wiki, where I found this page (seems down when I wrote this).

You can find out the hardware flags for GCC running this simple commannd:

$ echo "" | gcc -march=native -v -E - 2>&1 | grep cc1

The result looks something like this:

/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/cc1 -E -quiet -v - -D_FORTIFY_SOURCE=2 [COLOR="Blue"]-march=core2 -mcx16 -msahf -mpopcnt -msse4.2 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=6144 -mtune=core2[/COLOR] -fstack-protector

The part in blue is the interesting part and it should be used as part of the CFLAGS. Adding a -O3 there can’t hurt, either:

$ CFLAGS="-O3 -Wall <blue-string-from-above>" ./configure

A ‘make’ will then build whatever program you’re compiling with the best optimizations for your hardware.

I hope it’s useful! Enjoy!

Autor: Ovidiu

Sursa: http://blog.mybox.ro/2011/11/02/how-to-recompile-software-with-hardware-optimizations/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...