How to recompile software with hardware optimization?

This may be useful for compiling local applications that you want to run faster.

Try this on your computer:
$ echo "" | gcc -march=native -v -E - 2>&1 | grep cc1
On my computer it has returned:
 /usr/libexec/gcc/x86_64-redhat-linux/4.6.1/cc1 -E -quiet -v - -march=corei7-avx -mcx16 -msahf -mno-movbe -maes -mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mavx -msse4.2 -msse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=4096 -mtune=corei7-avx
This command probes the local computer for optimization flags. To use it:
$ CFLAGS="[blue string from above]" ./configure
You may consider adding the "-O3" flag. The -O3 flag enables levels 1, 2 and 3 of compile time optimization. There are more information about -O3 on gcc man page. For doing it, instead of previous line, use:
$ CFLAGS="-O3 [blue string from above]" ./configure



Unknown said…
The returned string is in fact NOT the best way to optimize your code; it returns "the kitchen sink", every possible supported optimization, many of which conflict with each other. I ran the string returned on my dual corei5 acer ultra through a simple mandelbrot generator which uses opengl and some heavy math, of course, and it took 5 more seconds to run than when I used my usual optimizations of "-Os -march=corei7-avx". Do not use this string "as is."
interval said…
The string returned by this grep is probably not the right thing, many options conflict with each other. I ran the returned string through a simple mandelbrot generator program and it ran 5 seconds longer than with my usual options of "-Os -march=corei7-avx". These options are your kitchen sink and many conflict with each other.

Popular posts from this blog

Fedora: Booting Fedora LIVE to RAM

Benchmark: Core 2 Duo T7200 vs. Core i7 2620M

Five steps to create Fedora chroot jail using yum