Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
which GCC / CFLAGS to use for Haswell?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
lutel
Tux's lil' helper
Tux's lil' helper


Joined: 19 Oct 2003
Posts: 93
Location: Pomroczna

PostPosted: Sat Jun 14, 2014 11:55 am    Post subject: which GCC / CFLAGS to use for Haswell? Reply with quote

I see that in latest stable GCC (4.7.3), there is flag "core-avx-i", but no "core-avx2". Do you think its safe/worth to unmask GCC 4.9 for production or should I stick with core-avx-i and -mavx2 with older GCC?

One more question - if I compile kernel, can I enforce it to be compiled with these flags?
Back to top
View user's profile Send private message
djdunn
l33t
l33t


Joined: 26 Dec 2004
Posts: 780
Location: Arrakis

PostPosted: Sat Jun 14, 2014 3:54 pm    Post subject: Reply with quote

there is no core-avx or core-avx2 in gcc-4.9 there however is a Haswell

from gcc documentation for gcc-4.9

‘haswell’
Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA, BMI, BMI2 and F16C instruction set support.

from gcc documentation for gcc-4.7.4
core-avx-i
Intel Core CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AES, PCLMUL, FSGSBASE, RDRND and F16C instruction set support.

to answer your question a march= is just a set of instructions to make it easier to choose the correct sets of instructions

i looked through the gcc-docs and all the instructions for the Haswell set are included more or less in gcc-4.7.4

as long as your perfectly sure you have a haswell, its perfectly safe to include those flags

your question about the kernel, yes its possible to attempt to compile the kernel with some of these flags. however, it involves editing the kernels Makefile, and the changes may make it unable to compile completely, and if it does compile completely you may encounter random kernel panics, but it doesn't mean you can't try, though because of the harm this can cause i wont tell you how to do it, but ill point you to where such things are defined, which is again the kernel Makefile
_________________
A process cannot be understood by stopping it. Understanding must move with the flow of the process, must join it and flow with it.

-The First Law of Mentat
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7071

PostPosted: Sat Jun 14, 2014 3:59 pm    Post subject: Reply with quote

Just use native, so as long as your gcc version handle native, it will do its best with what it know from your cpu.

And you better not play with the kernel, why would you want to play with the thing that will make you lost all your work if it crash?
Back to top
View user's profile Send private message
lutel
Tux's lil' helper
Tux's lil' helper


Joined: 19 Oct 2003
Posts: 93
Location: Pomroczna

PostPosted: Sat Jun 14, 2014 4:22 pm    Post subject: Reply with quote

after playing a bit with GCC 4.7.2 i found out that best flag set is "-march=native -mtune=corei7-avx". I've specified mtune, as 4.7.2 doesn't properly recognize Haswell and falls back to mtune=generic, if you like you can check it with...

gcc -march=native -mtune=corei7-avx -Q --help=target
Back to top
View user's profile Send private message
nlsa8z6zoz7lyih3ap
Guru
Guru


Joined: 25 Sep 2007
Posts: 376
Location: Canada

PostPosted: Sat Jun 14, 2014 4:23 pm    Post subject: Reply with quote

Quote:
your question about the kernel, yes its possible to attempt to compile the kernel with some of these flags. however, it involves editing the kernels Makefile, and the changes may make it unable to compile completely, and if it does compile completely you may encounter random kernel panics, but it doesn't mean you can't try, though because of the harm this can cause i wont tell you how to do it, but ill point you to where such things are defined, which is again the kernel Makefile



There is an easy way to do this with
Code:
USE="experimental" emerge gentoo-sources

(at least with the 3.4.13 and 3.4.14 series)

in the configuration choose

Processor type and features --->
Processor family (Native optimizations autodetected by GCC) --->

Quote:
And you better not play with the kernel, why would you want to play with the thing that will make you lost all your work if it crash?


This is safe advice. However, for what its worth, I have never had any trouble using the setting mentioned above.
My cpu is a piledriver and I have been using either either the above or a kernel patched by hand for the pile driver for over a year now.

PS This feature is not in gentoo-sources-3.15.0-r1 (yet) but instructions for patching it by had are give in

https://forums.gentoo.org/viewtopic-t-992960-highlight-.html
Back to top
View user's profile Send private message
lutel
Tux's lil' helper
Tux's lil' helper


Joined: 19 Oct 2003
Posts: 93
Location: Pomroczna

PostPosted: Sat Jun 14, 2014 4:53 pm    Post subject: Reply with quote

nlsa8z6zoz7lyih3ap - thank you for pointing me to this, me however use hardened-sources, but I'll try with the patch, it's a pity that such patch is not included by default.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum