Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Safe Cflags AMD E350 / Thinkpad x120e
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
gentian
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2012
Posts: 113

PostPosted: Fri Apr 27, 2012 1:12 pm    Post subject: Safe Cflags AMD E350 / Thinkpad x120e Reply with quote

I'm currently using "-march=native" and I'd like to know which flags are needed for my e350 cpu. Here's what's on the gentoo wiki page for e350 cpus:
Code:
-march=amdfam10 -O2 -pipe -mno-3dnow -mcx16 -mpopcnt -msse3 -msse4a -mmmx

And this is what I get when I run: gcc -### -march=native -E /usr/include/stdlib.h 2>&1 | grep "/usr/libexec/gcc/.*cc1"
Code:
"/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.3/cc1" "-E" "-quiet" "/usr/include/stdlib.h" "-D_FORTIFY_SOURCE=2" "-march=amdfam10" "-mcx16" "-msahf" "-mpopcnt" "-mabm" "--param" "l1-cache-size=32" "--param" "l1-cache-line-size=64" "--param" "l2-cache-size=512" "-mtune=amdfam10"

Any suggestions?

Thanks!
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Fri Apr 27, 2012 1:22 pm    Post subject: Reply with quote

gcc translates -march=native into -march=amdfam10, which would be ok for the average case.
but e350 lacks the 3dnow instruction set, which is why it has been excluded in the cflags shown on the wiki.

In addition, e350 support some more instruction, which are not covered by -march=amdfam10, which is why -mcx16 -mpopcnt -msse3 -msse4a -mmmx have been added.

IIRC it does not matter, if you chose -march=native or -march=amdfam10 as long as you append -fno-3dnow, becuase otherwise the compiler will generate code, that cannot be interpreted by the cpu. the other options are just to make full use of the cpu.
and even 3dnow errors would only appear in multimedia applications (ffmpeg, mplayer, vlc, browsers to name a few).

HTH
V.
_________________
read the portage output!
If my answer is too concise, ask for an explanation.
Back to top
View user's profile Send private message
gentian
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2012
Posts: 113

PostPosted: Fri Apr 27, 2012 2:16 pm    Post subject: Reply with quote

Veldrin wrote:
gcc translates -march=native into -march=amdfam10, which would be ok for the average case.
but e350 lacks the 3dnow instruction set, which is why it has been excluded in the cflags shown on the wiki.

In addition, e350 support some more instruction, which are not covered by -march=amdfam10, which is why -mcx16 -mpopcnt -msse3 -msse4a -mmmx have been added.

IIRC it does not matter, if you chose -march=native or -march=amdfam10 as long as you append -fno-3dnow, becuase otherwise the compiler will generate code, that cannot be interpreted by the cpu. the other options are just to make full use of the cpu.
and even 3dnow errors would only appear in multimedia applications (ffmpeg, mplayer, vlc, browsers to name a few).

HTH
V.

Thanks for you reply but I'm still a bit confused by the information you provided. I've always used athlon cpus with -march=k8 in make.conf for my machines and it worked great. I'm not really sure which flags to use. Would -march=amdfam10 be sufficient?
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Fri Apr 27, 2012 5:22 pm    Post subject: Reply with quote

That is correct, that in the past you could just use the arch of your cpu, even if gcc did not completely know it.

The problem with E350 is that gcc does not know it, so it uses the next best arch it knows: amdfam10.

BUT, E350 got stripped of the 3dnow commands, and amdfam10 still uses them, therefore code built with amdfam10 will have 3dnow instructions in it, which an E350 does not know how to interpret.


There are 2 possibilies to solve this issue: take the least common cpu that provides all instruction sets, that are understood by the cpu (which would -mtune=generic, there is not -march=generic), or take the next realted cpu and disable those parts it does not like (-march=amdfam10 -fno-3dnow).

that is for the explicit -march declaration.


if you want to use march=native, you have to make sure, that gcc knows your cpu (gcc-4.5 does not!) as it choses the best -march available.
The problem here again is that gcc chooses -march=amdfam10 which causes the above mentioned problem, and IIRC can be solved in exactly the same way (-march=native -fno-3dnow).


gcc-4.7 (currently in hardmasked testing) does provide -march=btver1, which coves all cpu features, and then -march=native works again without any fiddling, as gcc choses the correct -march.


I hope that clarified my previous post.
V.

PS. I ignored on purposes the part about the additional commands/instructions, to focus on the core issue.
_________________
read the portage output!
If my answer is too concise, ask for an explanation.
Back to top
View user's profile Send private message
gentian
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2012
Posts: 113

PostPosted: Fri Apr 27, 2012 5:38 pm    Post subject: Reply with quote

Veldrin wrote:
That is correct, that in the past you could just use the arch of your cpu, even if gcc did not completely know it.

The problem with E350 is that gcc does not know it, so it uses the next best arch it knows: amdfam10.

BUT, E350 got stripped of the 3dnow commands, and amdfam10 still uses them, therefore code built with amdfam10 will have 3dnow instructions in it, which an E350 does not know how to interpret.


There are 2 possibilies to solve this issue: take the least common cpu that provides all instruction sets, that are understood by the cpu (which would -mtune=generic, there is not -march=generic), or take the next realted cpu and disable those parts it does not like (-march=amdfam10 -fno-3dnow).

that is for the explicit -march declaration.


if you want to use march=native, you have to make sure, that gcc knows your cpu (gcc-4.5 does not!) as it choses the best -march available.
The problem here again is that gcc chooses -march=amdfam10 which causes the above mentioned problem, and IIRC can be solved in exactly the same way (-march=native -fno-3dnow).


gcc-4.7 (currently in hardmasked testing) does provide -march=btver1, which coves all cpu features, and then -march=native works again without any fiddling, as gcc choses the correct -march.


I hope that clarified my previous post.
V.

PS. I ignored on purposes the part about the additional commands/instructions, to focus on the core issue.

I got this from another user that has the e-350 and has gcc 4.6 installed. I need to use distcc, so should I just use those flags that where output from -march =native using gcc 4.6?
Code:
CFLAGS="-O2 -pipe -march=amdfam10 -mcx16 -msahf -mpopcnt --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=1024 -mtune=amdfam10"
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Fri Apr 27, 2012 6:14 pm    Post subject: Reply with quote

you can try.

my prediction: It will work fine till you hit the first 3dnow instruction, which will be used by some kind of multimedia application (that includes media players, web browsers (or its plugins), image manipulation and maybe some more).

I tend to be more conservative, as I built a -march=core2 system, and tried to run it on a phenom II cpu. works fine till i started the first browser (chromium iirc).
core2 includes -mssse3 which is not supported by amdfam10 cpu (phenom II), and the browser would just segfault.


V.
_________________
read the portage output!
If my answer is too concise, ask for an explanation.
Back to top
View user's profile Send private message
_SerEga_
n00b
n00b


Joined: 13 Jun 2009
Posts: 30
Location: Gatchina, Russia

PostPosted: Fri Apr 27, 2012 6:19 pm    Post subject: Reply with quote

gentian
In case gcc-4.6 you can use -march=btver1 ....
But if you used -march=amdfam10 then you must add -fno-3dnow . Also you may add -mcx16 -mpopcnt -msse3 -msse4a -mmmx
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54300
Location: 56N 3W

PostPosted: Fri Apr 27, 2012 6:28 pm    Post subject: Reply with quote

gcc-4.6 won't build a working grub, which is why its still masked.
Other than that, gcc-4.6 seems fine. Use grub-static in place of grub if you want to use gcc-4.6 systemwide.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
gentian
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2012
Posts: 113

PostPosted: Fri Apr 27, 2012 6:30 pm    Post subject: Reply with quote

NeddySeagoon wrote:
gcc-4.6 won't build a working grub, which is why its still masked.
Other than that, gcc-4.6 seems fine. Use grub-static in place of grub if you want to use gcc-4.6 systemwide.

Hi Neddy, I basically copied the flags you posted on another thread. Would those flags work ok on my e-350 system?
Code:
CFLAGS="-O2 -pipe -march=amdfam10 -mcx16 -msahf -mpopcnt --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=1024 -mtune=amdfam10"

thanks.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54300
Location: 56N 3W

PostPosted: Fri Apr 27, 2012 6:49 pm    Post subject: Reply with quote

gentian,

My E350 media player uses
Code:
CFLAGS="-O2 -pipe -march=btver1"  # needs gcc-4.6 or later


As others have said, AMD dropped some multimedia instructions on the E350, so you must explicity tell gcc not to use them if you want to use
Code:
-march=amdfam10

Thats a long way of saying no.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
gentian
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2012
Posts: 113

PostPosted: Fri Apr 27, 2012 6:52 pm    Post subject: Reply with quote

NeddySeagoon wrote:
gentian,

My E350 media player uses
Code:
CFLAGS="-O2 -pipe -march=btver1"  # needs gcc-4.6 or later


As others have said, AMD dropped some multimedia instructions on the E350, so you must explicity tell gcc not to use them if you want to use
Code:
-march=amdfam10

Thats a long way of saying no.

Gosh.. I'm so confused. So march=native will work but the flags used for march=native won't? How can I use distcc? What would the problem be if I use these cflags posted on gentoo-wiki:
Code:
-march=amdfam10 -O2 -pipe -mno-3dnow -mcx16 -mpopcnt -msse3 -msse4a -mmmx
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54300
Location: 56N 3W

PostPosted: Fri Apr 27, 2012 7:50 pm    Post subject: Reply with quote

gentian,

-march=native is shorthand for look at the CPU I'm running on and use the CFLAGS for the CPU I found.
Thats ok under the following circumstances.
a) you only want to run thre code on the CPU that built it
b) gcc knows your CPU exactly.

a) is generally not true when disctcc is used. The helper CPUs may net even be AMD. They could be PPC, SPARC, ARM ....
b) when gcc does not know your CPU exactly, it uses the CPU familiy. That generally OK but not for an E350.

In case b) you must euther get a newer gcc that does know your cpu (gcc-4.6.2) or help older gcc to get the CFLAGS right.
Most of the amdfam10 CPUs have 3dnow, 3dnowext and so on. The E350 does not.

For the code out of distcc to work, all of the contributing verions of gcc must be *identical*
I don't think distcc is worth the trouble any more. If you have 4G RAM, use gcc-4.6.2 and put /var/tmp/portage into /dev/shm
Code:
# build in RAM
/dev/shm        /var/tmp/portage        tmpfs   noatime,nodev,nosuid    0 0
and build on the laptop.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
gentian
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2012
Posts: 113

PostPosted: Sun Apr 29, 2012 9:17 am    Post subject: Reply with quote

Would I need to use these USE flags as well? I got these settings from the x120e gentoo-wiki page
Code:
fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc extd_apicid aperfmperf pni monitor ssse3 cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch ibs skinit wdt npt lbrv svm_lock nrip_save pausefilter

Also, how can I update all packages on my system to reflect the changed make.conf settings?
Thanks.
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Sun Apr 29, 2012 9:23 am    Post subject: Reply with quote

no - because these are cpu flags, and not useflags.
OTOH, for some of them useflags exist: mmx sse sse2 sse3 ssse3 sse4a
Those you could add. or just add them per package basis.

Can you link the page on gentoo-wiki? It seems down ATM, and maybe there is a cached version on google somewhere...

V.
_________________
read the portage output!
If my answer is too concise, ask for an explanation.
Back to top
View user's profile Send private message
gentian
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2012
Posts: 113

PostPosted: Sun Apr 29, 2012 9:34 am    Post subject: Reply with quote

Veldrin wrote:
no - because these are cpu flags, and not useflags.
OTOH, for some of them useflags exist: mmx sse sse2 sse3 ssse3 sse4a
Those you could add. or just add them per package basis.

Can you link the page on gentoo-wiki? It seems down ATM, and maybe there is a cached version on google somewhere...

V.

http://webcache.googleusercontent.com/search?q=cache:ByY1TH18sf4J:en.gentoo-wiki.com/wiki/Safe_Cflags/AMD+&cd=1&hl=en&ct=clnk&gl=gr
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Sun Apr 29, 2012 9:50 am    Post subject: Reply with quote

that is the usual safe cflags page. It does not mention anything about useflags. All those are required, are mentioned already.
_________________
read the portage output!
If my answer is too concise, ask for an explanation.
Back to top
View user's profile Send private message
gentian
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2012
Posts: 113

PostPosted: Sun Apr 29, 2012 11:02 am    Post subject: Reply with quote

Veldrin wrote:
that is the usual safe cflags page. It does not mention anything about useflags. All those are required, are mentioned already.

Thanks, Is this the command I need to issue after altering my cflags?
Code:
emerge --update --deep --with-bdeps=y --newuse world
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Sun Apr 29, 2012 12:37 pm    Post subject: Reply with quote

gentian wrote:
Veldrin wrote:
that is the usual safe cflags page. It does not mention anything about useflags. All those are required, are mentioned already.

Thanks, Is this the command I need to issue after altering my cflags?
Code:
emerge --update --deep --with-bdeps=y --newuse world

No, that is for rebuilding packages with new USE-flags.

for changes cflags, the recommended procedure is
Code:
emerge -a1 linux-headers glibc gcc binutils
emerge -e world

OTOH, if you do not desperately need the new cflags, then just leave the system as it is, and let the upgrades take care of the new cflags.
be also aware that emerge -e world will rebuild every single package, therefore this might take some time.

V.
_________________
read the portage output!
If my answer is too concise, ask for an explanation.
Back to top
View user's profile Send private message
emc
Guru
Guru


Joined: 02 Jul 2004
Posts: 564
Location: Cracow, Poland

PostPosted: Thu May 17, 2012 2:48 pm    Post subject: Reply with quote

I will try on my E450.
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