Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[gentoo-user] CFlags for CPU

218 views
Skip to first unread message

Alokat

unread,
Jul 26, 2011, 2:50:02 PM7/26/11
to
Hi folks,

I'm wondering what kind of cpu-type I should use?

cat /proc/cpuinfo
..............

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Core(TM)2 Duo CPU     L7100  @ 1.20GHz
stepping        : 11
cpu MHz         : 1197.065
cache size      : 4096 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm ida dts tpr_shadow vnmi flexpriority
bogomips        : 2394.01
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

..............

After a short research on this website:
http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options

I guess core2 is the right one?
Is that true?

Regards,
alokat

Mark Knecht

unread,
Jul 26, 2011, 3:10:02 PM7/26/11
to

Or let gcc figure it out using

-march=native

which is what I eventually did:

# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
CFLAGS="-O2 -march=native -pipe"
#Safe CFlags for the Core-i7 (web info) saved for reference
#CFLAGS="-march=core2 -msse4 -mcx16 -msahf -O2 -pipe"
CXXFLAGS="${CFLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"


HTH,
Mark

Paul Hartman

unread,
Jul 26, 2011, 3:10:02 PM7/26/11
to
On Tue, Jul 26, 2011 at 3:36 PM, Alokat <mai...@alokat.org> wrote:
> I'm wondering what kind of cpu-type I should use?

Hi,

I think, in your case, core2 is the correct one.

If you run this command:
gcc -Q --help=target -march=native

gcc will tell you what it thinks are the best options for your CPU.

Alan McKinnon

unread,
Jul 26, 2011, 3:10:02 PM7/26/11
to
On Tuesday 26 July 2011 20:36:14 Alokat did opine thusly:
> I guess *core2* is the right one?
> Is that true?

native?

--
alan dot mckinnon at gmail dot com

Michael Mol

unread,
Jul 26, 2011, 3:10:03 PM7/26/11
to
On Tue, Jul 26, 2011 at 4:36 PM, Alokat <mai...@alokat.org> wrote:
> Hi folks,
>
> I'm wondering what kind of cpu-type I should use?
>
> cat /proc/cpuinfo
[snip]

> model name      : Intel(R) Core(TM)2 Duo CPU     L7100  @ 1.20GHz

[snip]


> ..............
>
> After a short research on this website:
> http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options
>
> I guess core2 is the right one?
> Is that true?

That should work fine. Or 'native', if you don't plan on playing with distcc.

--
:wq

pk

unread,
Jul 26, 2011, 4:40:02 PM7/26/11
to
On 2011-07-26 22:36, Alokat wrote:

> model name : Intel(R) Core(TM)2 Duo CPU L7100 @ 1.20GHz

<snip>

> I guess *core2* is the right one?

Yes, acc. to:
http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel#Core_2_Duo.2FQuad.2C_Xeon_51xx.2F53xx.2F54xx.2F3360.2C_Pentium_Dual-Core_T23xx.2B.2FExxxx.2C_Celeron_Dual-Core

HTH

Best regards

Peter K

Mick

unread,
Jul 26, 2011, 6:10:01 PM7/26/11
to

Thanks for this - I better make a note of it! ;-)

Does this mean that I did not need to have all these flags specified, because
they're already included?

CFLAGS="-march=core2 -msse4 -mcx16 -msahf -O2 -pipe"

-msse4 -mcx16 -msahf seem to be already enabled:
====================================================
$ gcc -Q --help=target -march=native
The following options are target specific:
-m128bit-long-double [disabled]
-m32 [disabled]
-m3dnow [disabled]
-m3dnowa [disabled]
-m64 [enabled]
-m80387 [enabled]
-m96bit-long-double [enabled]
-mabm [disabled]
-maccumulate-outgoing-args [disabled]
-maes [disabled]
-malign-double [disabled]
-malign-functions=
-malign-jumps=
-malign-loops=
-malign-stringops [enabled]
-march= core2
-masm=
-mavx [disabled]
-mbranch-cost=
-mcld [disabled]
-mcmodel=
-mcx16 [enabled]
-mfancy-math-387 [enabled]
-mfma [disabled]
-mforce-drap [disabled]
-mfp-ret-in-387 [enabled]
-mfpmath=
-mfused-madd [enabled]
-mglibc [enabled]
-mhard-float [enabled]
-mieee-fp [enabled]
-mincoming-stack-boundary=
-minline-all-stringops [disabled]
-minline-stringops-dynamically [disabled]
-mintel-syntax [disabled]
-mlarge-data-threshold=
-mmmx [disabled]
-mms-bitfields [disabled]
-mno-align-stringops [disabled]
-mno-fancy-math-387 [disabled]
-mno-fused-madd [disabled]
-mno-push-args [disabled]
-mno-red-zone [disabled]
-mno-sse4 [disabled]
-momit-leaf-frame-pointer [disabled]
-mpc
-mpclmul [disabled]
-mpopcnt [enabled]
-mpreferred-stack-boundary=
-mpush-args [enabled]
-mrecip [disabled]
-mred-zone [enabled]
-mregparm=
-mrtd [disabled]
-msahf [enabled]
-msoft-float [disabled]
-msse [enabled]
-msse2 [enabled]
-msse2avx [disabled]
-msse3 [enabled]
-msse4 [enabled]
-msse4.1 [enabled]
-msse4.2 [enabled]
-msse4a [disabled]
-msse5 [disabled]
-msseregparm [disabled]
-mssse3 [enabled]
-mstack-arg-probe [disabled]
-mstackrealign [enabled]
-mstringop-strategy=
-mtls-dialect=
-mtls-direct-seg-refs [enabled]
-mtune= core2
-muclibc [disabled]
-mveclibabi=
====================================================
--
Regards,
Mick

signature.asc

Paul Hartman

unread,
Jul 26, 2011, 6:20:01 PM7/26/11
to
On Tue, Jul 26, 2011 at 5:01 PM, Mick <michael...@gmail.com> wrote:
> On Tuesday 26 Jul 2011 20:02:05 Paul Hartman wrote:
>> On Tue, Jul 26, 2011 at 3:36 PM, Alokat <mai...@alokat.org> wrote:
>> > I'm wondering what kind of cpu-type I should use?
>>
>> Hi,
>>
>> I think, in your case, core2 is the correct one.
>>
>> If you run this command:
>> gcc -Q --help=target  -march=native
>>
>> gcc will tell you what it thinks are the best options for your CPU.
>
> Thanks for this - I better make a note of it!  ;-)
>
> Does this mean that I did not need to have all these flags specified, because
> they're already included?

Not quite; that command specifically shows you the options that would
be used if you were using -march=native. Since you're not using
native, change it to:

gcc -Q --help=target -march=core2

And that will show the defaults when you're using core2 as the arch.
(On my own system, a side-by-side comparison of native vs core2 shows
a lot of differences)

If native shows something as "enabled" but core2 doesn't, it should be
safe to add that option to your cflags because it's likely your CPU
can handle it just fine.

Bill Kenworthy

unread,
Jul 26, 2011, 9:10:01 PM7/26/11
to

moriah tuxonice-2.6.39 # gcc -Q --help=target -march=core2 >a
moriah tuxonice-2.6.39 # gcc -Q --help=target -march=native >b
moriah tuxonice-2.6.39 # diff a b
23c23
< -mcx16 [disabled]
---
> -mcx16 [enabled]
56c56
< -msahf [disabled]
---
> -msahf [enabled]
74c74
< -mtune=
---
> -mtune= core2
moriah tuxonice-2.6.39 #

I am now using core2 as I was having some really odd problems after
mixing flags after multiple hardware changes along with native. Core2
is recommended for this processor, and I cant see the two flags changed
via native making a difference, but the previous processors is no longer
available to check.

Perhaps someone could do the above and send me the result (the full "gcc
-Q --help=target -march=native", using gcc-4.5) for an intel E4600?
(the list probably wont be interested!)

BillK


Nikos Chantziaras

unread,
Jul 26, 2011, 11:20:02 PM7/26/11
to
On 07/27/2011 03:58 AM, Bill Kenworthy wrote:
>
> I am now using core2 as I was having some really odd problems after
> mixing flags after multiple hardware changes along with native. Core2
> is recommended for this processor, and I cant see the two flags changed
> via native making a difference, but the previous processors is no longer
> available to check.

Different Core 2 CPUs support different features. There are, for
example, Core 2 CPUs that support SSE4 and other Core 2's don't. If you
have "native" on one that supports it and then try to run it on another
that doesn't, chances are it will crash, even if both CPUs are "Core 2".

Andy Wilkinson

unread,
Jul 27, 2011, 10:30:02 AM7/27/11
to
Another good trick I've found on the forums is to run:

$ gcc -### -e -v -march=native /usr/include/stdlib.h

The last line of output will include the various CFLAGS that -march=native picks.  In my case (Phenom II 955):

 "/usr/libexec/gcc/x86_64-pc-linux-gnu/4.4.5/cc1" "-quiet" "/usr/include/stdlib.h" "-D_FORTIFY_SOURCE=2" "-march=amdfam10" "-mcx16" "-msahf" "-mpopcnt" "--param" "l1-cache-size=64" "--param" "l1-cache-line-size=64" "--param" "l2-cache-size=512" "-mtune=amdfam10" "-quiet" "-dumpbase" "stdlib.h" "-auxbase" "stdlib" "-o" "/tmp/ccR1PlNZ.s" "--output-pch=/usr/include/stdlib.h.gch"

I typically use -march=native when I don't need to worry about distcc, or the options from that output that start with "-m".

-Andy

Kfir Lavi

unread,
Jul 27, 2011, 10:40:02 AM7/27/11
to
I must stay, this is brilliant !
Thank you very much.

Kfir

Pandu Poluan

unread,
Jul 27, 2011, 11:00:02 AM7/27/11
to
-original message-
Subject: Re: [gentoo-user] CFlags for CPU
From: Andy Wilkinson <druk...@gmail.com>
Date: 2011-07-27 21:09

>Another good trick I've found on the forums is to run:
>
>$ gcc -### -e -v -march=native /usr/include/stdlib.h
>
>The last line of output will include the various CFLAGS that
>-march=native picks. In my case (Phenom II 955):
>
> "/usr/libexec/gcc/x86_64-pc-linux-gnu/4.4.5/cc1" "-quiet"

>"/usr/include/stdlib.h" "-D_FORTIFY_SOURCE=2" *"-march=amdfam10"
>"-mcx16" "-msahf" "-mpopcnt"* "--param" "l1-cache-size=64" "--param"


>"l1-cache-line-size=64" "--param" "l2-cache-size=512" "-mtune=amdfam10"
>"-quiet" "-dumpbase" "stdlib.h" "-auxbase" "stdlib" "-o"
>"/tmp/ccR1PlNZ.s" "--output-pch=/usr/include/stdlib.h.gch"
>
>I typically use -march=native when I don't need to worry about distcc,
>or the options from that output that start with "-m".

Hey, that's a nice trick! Thanks for re-sharing :)

That said, I usually *can't* use -march=native because all my Gentoo systems are virtualized servers, running on top of XenServer, which itself runs on heterogenous server boxes (all Intel).

So, I purposefully limit myself to "-march=nocona".

(I did raise an explicit point about -march parameter in my Gentoo-Wiki article)

Rgds,
--
FdS Pandu E Poluan
~ IT Optimizer ~

Sent from Nokia E72-1

Kfir Lavi

unread,
Jul 27, 2011, 12:30:25 PM7/27/11
to
Just shared this trick in my blog.
http://gentoo-what-did-you-say.blogspot.com/2011/07/finding-cpu-flags-using-gcc.html
I added a link to this thread in the post.

Kfir

Mick

unread,
Jul 27, 2011, 2:40:02 PM7/27/11
to
On Wednesday 27 Jul 2011 17:13:21 Kfir Lavi wrote:
> On Wed, Jul 27, 2011 at 5:34 PM, Kfir Lavi <lavi...@gmail.com> wrote:
> > On Wed, Jul 27, 2011 at 5:09 PM, Andy Wilkinson
> >>
> >> Another good trick I've found on the forums is to run:
> >> $ gcc -### -e -v -march=native /usr/include/stdlib.h
> >>
> >> The last line of output will include the various CFLAGS that
> >> -march=native
> >>
> >> picks. In my case (Phenom II 955):
> >> "/usr/libexec/gcc/x86_64-pc-linux-gnu/4.4.5/cc1" "-quiet"
> >>
> >> "/usr/include/stdlib.h" "-D_FORTIFY_SOURCE=2" *"-march=amdfam10"
> >> "-mcx16" "-msahf" "-mpopcnt"* "--param" "l1-cache-size=64" "--param"

> >> "l1-cache-line-size=64" "--param" "l2-cache-size=512" "-mtune=amdfam10"
> >> "-quiet" "-dumpbase" "stdlib.h" "-auxbase" "stdlib" "-o"
> >> "/tmp/ccR1PlNZ.s" "--output-pch=/usr/include/stdlib.h.gch"
> >>
> >> I typically use -march=native when I don't need to worry about distcc,
> >> or the options from that output that start with "-m".

> Just shared this trick in my blog.
> http://gentoo-what-did-you-say.blogspot.com/2011/07/finding-cpu-flags-using
> -gcc.html I added a link to this thread in the post.

It seems that on my early i7, the -march=core2 does not have all the -msse*
flags enabled, while native does:

$ diff -y --suppress-common-lines core2.txt native.txt
-mcx16 [disabled] | -mcx16 [enabled]
-mno-sse4 [enabled] | -mno-sse4 [disabled]
-mpopcnt [disabled] | -mpopcnt [enabled]
-msahf [disabled] | -msahf [enabled]
-msse [disabled] | -msse [enabled]
-msse2 [disabled] | -msse2 [enabled]
-msse3 [disabled] | -msse3 [enabled]
-msse4 [disabled] | -msse4 [enabled]
-msse4.1 [disabled] | -msse4.1 [enabled]
-msse4.2 [disabled] | -msse4.2 [enabled]
-mssse3 [disabled] | -mssse3 [enabled]
-mtune= | -mtune= core2


I wonder if I should just set it to "-march=native -O2 -pipe" and forget about
it ... native it seems to have more stuff switched on and it would probably be
a-good-thing® (although my understanding of what each flag does is rather
cursory).
--
Regards,
Mick

signature.asc

Mark Knecht

unread,
Jul 27, 2011, 4:30:02 PM7/27/11
to
Just curious if that's consistent with /proc/cpuinfo in the flags
section? MAybe gcc is wrong in it's enable/disable choices, or maybe
they know something specific.

This is from an i7-980 Extreme from about 1 year ago:

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe

syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts
rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64
monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 popcnt
aes lahf_lm ida arat dts tpr_shadow vnmi flexpriority ept vpid

- Mark

Mick

unread,
Jul 27, 2011, 5:00:02 PM7/27/11
to
On Wednesday 27 Jul 2011 21:24:33 Mark Knecht wrote:
> On Wed, Jul 27, 2011 at 11:32 AM, Mick <michael...@gmail.com> wrote:
> > On Wednesday 27 Jul 2011 17:13:21 Kfir Lavi wrote:
> >> On Wed, Jul 27, 2011 at 5:34 PM, Kfir Lavi <lavi...@gmail.com> wrote:
> >> > On Wed, Jul 27, 2011 at 5:09 PM, Andy Wilkinson
> >> >
> >> >> Another good trick I've found on the forums is to run:
> >> >> $ gcc -### -e -v -march=native /usr/include/stdlib.h
> >> >>
> >> >> The last line of output will include the various CFLAGS that
> >> >> -march=native
> >> >>
> >> >> picks. In my case (Phenom II 955):
> >> >> "/usr/libexec/gcc/x86_64-pc-linux-gnu/4.4.5/cc1" "-quiet"
> >> >>
> >> >> "/usr/include/stdlib.h" "-D_FORTIFY_SOURCE=2" *"-march=amdfam10"
> >> >> "-mcx16" "-msahf" "-mpopcnt"* "--param" "l1-cache-size=64" "--param"
> >> >> "l1-cache-line-size=64" "--param" "l2-cache-size=512"
> >> >> "-mtune=amdfam10" "-quiet" "-dumpbase" "stdlib.h" "-auxbase"
> >> >> "stdlib" "-o"
> >> >> "/tmp/ccR1PlNZ.s" "--output-pch=/usr/include/stdlib.h.gch"
> >> >>
> >> >> I typically use -march=native when I don't need to worry about
> >> >> distcc, or the options from that output that start with "-m".
> >>
> >> Just shared this trick in my blog.
> >> http://gentoo-what-did-you-say.blogspot.com/2011/07/finding-cpu-flags-us
> >> ing -gcc.html I added a link to this thread in the post.

Same here:

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov

pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm

constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc

aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm
sse4_1 sse4_2 popcnt lahf_lm ida dts tpr_shadow vnmi flexpriority ept vpid

--
Regards,
Mick

signature.asc

pk

unread,
Jul 27, 2011, 5:20:02 PM7/27/11
to
On 2011-07-27 20:32, Mick wrote:

> It seems that on my early i7, the -march=core2 does not have all the -msse*
> flags enabled, while native does:

Acc. to this there is a flag for i7, BUT... I'm not sure if current
stable version accepts it:
http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html

> I wonder if I should just set it to "-march=native -O2 -pipe" and forget about
> it ... native it seems to have more stuff switched on and it would probably be
> a-good-thing® (although my understanding of what each flag does is rather
> cursory).

I assume "native" would do fine...

Best regards

Peter K

Helmut Jarausch

unread,
Jul 28, 2011, 5:50:02 AM7/28/11
to
On 07/28/2011 11:40:40 AM, Kfir Lavi wrote:
> My guess is that -msse4.2 imply also -msse1..4.1
> Can someone confirm this?

I don't think so. It's part of the war Intel <-> AMD

Helmut.

Kfir Lavi

unread,
Jul 28, 2011, 5:50:03 AM7/28/11
to
My guess is that -msse4.2 imply also -msse1..4.1
Can someone confirm this?

Regards,
Kfir

Kfir Lavi

unread,
Jul 28, 2011, 6:00:03 AM7/28/11
to
Can you elaborate more?

Kfir

Helmut Jarausch

unread,
Jul 28, 2011, 6:10:02 AM7/28/11
to

Sorry, I mixed it up with SSE4a, see

http://en.wikipedia.org/wiki/SSE4

Helmut.

0 new messages