Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Cpu_flags_x86
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3, 4  Next  
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7053

PostPosted: Sun Feb 01, 2015 12:23 pm    Post subject: Reply with quote

mv wrote:
Speaking about perhaps wrong and outdated information which users might have: I am already getting completely new information here.
krinn wrote:
I know gcc is a bitch with mmx (i don't really know why).

What do you mean here? Does that mean that you do recommend to set CPU_FLAGS_X86="mmx" but nevertheless CFLAGS="-mno-mmx" on machines which do support mmx?

No i mean that:
Code:
case1: gcc -march=native -Q --help=target
  -mmmx                             [disabled]
  -msse                             [enabled]
  -msse2                            [enabled]
  -mno-sse4                         [disabled]
and
Code:
case2: gcc -march=native -msse2 -mno-sse -Q --help=target
  -mmmx                             [disabled]
  -msse                             [disabled]
  -msse2                            [disabled]
  -mno-sse4                         [enabled]

and
Code:
case3: LC_ALL=C gcc -march=native -mbuggyflag -Q --help=target
gcc: error: unrecognized command line option '-mbuggyflag'

So it mean that even the second time i ask gcc to handle sse2 (which is not really need but just to enforce the point), because sse2 depend on sse and sse is disable, sse2 is disable too.
But if we assume (as i really don't see any other reason), that gcc disable mmx usage with sse to promote using sse over mmx in case1.
When we met case2 where sse is disable, mmx is still not set enable.
So: for whatever reason, parsing output of gcc will never tell you your cpu can do mmx and mmx will always be disable except if you ask it.

So while parsing gcc output ease everything, as it will gave you error if the gcc version doesn't know a flag you pass to that version that might works with a newer/older gcc (case3) ; and it will also validate flags dependencies for you (like sse2 disable when sse is disable in case2 or look how gcc enable/disable itself the -mno-sse4) ; gcc will always tell you mmx is off.
(for the ref, my cpu is a corei7 but anyway, you don't need a big brain to know a cpu that could do sse is able to do mmx too)
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6279

PostPosted: Sun Feb 01, 2015 12:39 pm    Post subject: Reply with quote

krinn wrote:
Code:
case1: gcc -march=native -Q --help=target
  -mmmx                             [disabled]
  -msse                             [enabled]
  -msse2                            [enabled]
  -mno-sse4                         [disabled]
my cpu is a corei7

This seems to be a <gcc-4.9 issue. Running here on corei3, I get with gcc-4.9.2
Code:
» /usr/bin/gcc -march=native -Q --help=target|grep 'mmx\|sse. '
  -mmmx                                 [enabled]
  -mno-sse4                             [disabled]
  -msse                                 [enabled]
  -msse2                                [enabled]
  -msse3                                [enabled]
  -msse4                                [enabled]
  -msse5                     
  -mssse3                               [enabled]
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sun Feb 01, 2015 2:31 pm    Post subject: Reply with quote

What a mess thes instruction set extension are.

If you have both sse and sse2 you really don't want mmx.
mmx uses the FPU registers for SIMD integer operations.
sse adds eight new registers for SIMD single precision floating point operations.
sse2 adds integer arithmetic to the eight sse registers and some other goodies, effectively moving mmx out of the FPU.

Why don't you want mmx in CPU_FLAGS_X86=
It stalls the FPU, so you can't execute mmx and FPU instructions at the same time.
Anyway, the CPU_FLAGS_X86 has no effect on what gcc does, it affects the use, or not, of hand optimised code in a small number of multimedia packages.
Hopefully, anyone using mmx isn't doing it in an application that has a concurrent thread that uses normal FPU instructions.
Conversely, gcc should not use mmx if both sse and sse2 are available.

The python script that detects the content of /proc/cpuinfo fails for those AMD processers that can execute 3DNow! and 3DNowext but don't have the entries in /proc/cpuinfo.
Saying 'can execute' possibly means that the instructions work, but the speed up hardware is missing in these processors.
_________________
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
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Feb 01, 2015 3:34 pm    Post subject: Reply with quote

NeddySeagoon wrote:
If you have both sse and sse2 you really don't want mmx.

Neddy ... I assume the same is true for mmxext.

NeddySeagoon wrote:
Why don't you want mmx in CPU_FLAGS_X86= It stalls the FPU, so you can't execute mmx and FPU instructions at the same time.

Currently cpu_flags_x86_mmx is a REQUIRED_USE in the case of cpu_flags_x86_sse2 (media-video/ffmpeg):

Code:
The following REQUIRED_USE flag constraints are unsatisfied:
  cpu_flags_x86_sse2? ( cpu_flags_x86_mmx )

That may have been the case with USE="sse2 -mmx" I don't remember ... anyhow, we can keep rebuilding packages until we work it out ... that's "the true fun of Gentoo!"

best ... khay
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3830
Location: Dallas area

PostPosted: Sun Feb 01, 2015 4:04 pm    Post subject: Reply with quote

khayyam wrote:
Currently cpu_flags_x86_mmx is a REQUIRED_USE in the case of cpu_flags_x86_sse2 (media-video/ffmpeg):

Code:
The following REQUIRED_USE flag constraints are unsatisfied:
  cpu_flags_x86_sse2? ( cpu_flags_x86_mmx )



I'm not seeing that on ffmpeg,
but transcode has a requirement of mmx for sse2
and libvpx has a requirement of mmx for sse.

Sure am glad the devs know WTF they're doing :roll:
_________________
Asus m5a99fx, FX 8320 - nouveau, oss4, rx550 for qemu passthrough
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
5.0.13 zen kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 8.2.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6279

PostPosted: Sun Feb 01, 2015 4:19 pm    Post subject: Reply with quote

Anon-E-moose wrote:
but transcode has a requirement of mmx for sse2

This is harmless... what is worse (perhaps a bug to report?) is the libvpx ebuild:
Code:
REQUIRED_USE="
   cpu_flags_x86_sse? ( cpu_flags_x86_sse2 )
   cpu_flags_x86_sse2? ( cpu_flags_x86_mmx ) ...

Thus, if your processor supports sse but not sse2 (like athlon), you have to work with /etc/portage/package.use and unset cpu_flags_x86_sse to be able to build libvpx at all.
However, this behaviour existed already before CPU_FLAGS_X86 was introduced.

IMHO, this is a clear misuse of REQUIRED_USE which unfortunately can be see very often now since this REQUIRED_USE-misfeature was introduced: Instead of making a sane choice if unsual combinations are used, now the user is bugged to do unnecessary (since obvious) changes.
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3830
Location: Dallas area

PostPosted: Sun Feb 01, 2015 4:40 pm    Post subject: Reply with quote

It's harmless on the surface, but if both mmx and sse/sse2 are in the code I'm not sure which gets used at runtime and there is a performance difference.
And the only reason that I mentioned it is because of the earlier pronouncements that part of the reason for Cpu_flags_x86 was to fix errant packages and all it seems that they did is do a global name replace without any other thoughts.

And yeah, I noticed the REQUIRED_USE silliness.
_________________
Asus m5a99fx, FX 8320 - nouveau, oss4, rx550 for qemu passthrough
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
5.0.13 zen kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 8.2.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6279

PostPosted: Sun Feb 01, 2015 4:50 pm    Post subject: Reply with quote

Anon-E-moose wrote:
It's harmless on the surface, but if both mmx and sse/sse2 are in the code I'm not sure which gets used at runtime

I did not check, but I would be very surprised if it were not the upstream author who decided that --enable-sse implies --enable-mmx, so he should know what he is doing and why.
In general, every upstream which provides something like --enable-sse2 and --enable-mmx simultaneously should have a sane strategy what is done if both is enabled.
I would be very surprised (and would consider it as a bug) if enabling the latter overrides the former at runtime for any package.
Back to top
View user's profile Send private message
bandreabis
Advocate
Advocate


Joined: 18 Feb 2005
Posts: 2413
Location: イタリアのロディで

PostPosted: Sun Feb 01, 2015 5:00 pm    Post subject: Reply with quote

What do you want portage??? Explain it better.

Code:
!!! The ebuild selected to satisfy "media-video/transcode[dvd]" has unmet requirements.
- media-video/transcode-1.1.7-r3::gentoo USE="X a52 aac alsa dvd iconv jpeg lzo mp3 mpeg ogg sdl truetype vorbis x264 xml xvid (-altivec) -dv -imagemagick -mjpeg (-nuv) -oss (-pic) -postproc -quicktime -theora -v4l" ABI_X86="64" CPU_FLAGS_X86="3dnow sse2 -mmx -sse"

  The following REQUIRED_USE flag constraints are unsatisfied:
    cpu_flags_x86_sse2? ( cpu_flags_x86_mmx cpu_flags_x86_sse ) cpu_flags_x86_3dnow? ( cpu_flags_x86_mmx )

  The above constraints are a subset of the following complete expression:
    cpu_flags_x86_sse? ( cpu_flags_x86_mmx ) cpu_flags_x86_sse2? ( cpu_flags_x86_mmx cpu_flags_x86_sse ) cpu_flags_x86_3dnow? ( cpu_flags_x86_mmx ) nuv? ( lzo )

(dependency required by "app-cdr/k3b-2.0.2-r4[dvd,encode]" [installed])
(dependency required by "@selected" [set])
(dependency required by "@world" [argument])

_________________
Il numero di post non fa di me un esperto! Anzi!
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7053

PostPosted: Sun Feb 01, 2015 5:11 pm    Post subject: Reply with quote

mv wrote:
This seems to be a <gcc-4.9 issue. Running here on corei3, I get with gcc-4.9.2

Indeed, i always think it was a bug in gcc (mine is 4.7.1), it is even more funny when you force -march=pentium-mmx to see mmx are also disabled.

mv wrote:
upstream author who decided that --enable-sse implies --enable-mmx, so he should know what he is doing and why.

I don't think any cpu using sse exist without also supporting mmx.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Feb 01, 2015 5:15 pm    Post subject: Reply with quote

bandreabis wrote:
What do you want portage??? Explain it better.

bandreabis ... oh, the irony: "that's the major goal: making things more transparent".

bandreabis wrote:
Code:
  The following REQUIRED_USE flag constraints are unsatisfied:
    cpu_flags_x86_sse2? ( cpu_flags_x86_mmx cpu_flags_x86_sse ) cpu_flags_x86_3dnow? ( cpu_flags_x86_mmx )

Its saying that in order to have cpu_flags_x86_sse2 and cpu_flags_x86_3dnow you need to set cpu_flags_x86_mmx and cpu_flags_x86_sse.

best ... khay


Last edited by khayyam on Sun Feb 01, 2015 5:17 pm; edited 1 time in total
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6279

PostPosted: Sun Feb 01, 2015 5:16 pm    Post subject: Reply with quote

krinn wrote:
I don't think any cpu using sse exist without also supporting mmx.

If I understand correctly, mmx and sse go side by side: One is for integer, the other for floating point.
Only sse2 "contains" mmx in a certain sense. And there are several CPUs (Athlon probably being the most prominent) which support mmx but not sse2.
Back to top
View user's profile Send private message
bandreabis
Advocate
Advocate


Joined: 18 Feb 2005
Posts: 2413
Location: イタリアのロディで

PostPosted: Sun Feb 01, 2015 5:30 pm    Post subject: Reply with quote

So I MUST use mmx and sse beacuse I have sse2?
I have an Turion64 and my make.conf is:
Code:
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
CFLAGS="-march=native -fomit-frame-pointer -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"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
CPU_FLAGS_X86="3dnowext 3dnow mmxext ssse3 sse2"
USE="canna 3dnowext 3dnow mmxext custom-optimization bash-completion avi lm_sensors /
cjk ibus immqt-bc -immqt ssse3 userlocales lzma lzo qt5 samba sound xine xosd zsh-completion polkit"
FEATURES="parallel-fetch"
#CALLIGRA_FEATURES="braindump flow karbon kexi krita sheets stage words"
LIBREOFFICE_EXTENSIONS="nlpsolver pdfimport presenter-console presenter-minimizer"
MAKEOPTS="-j2"
ACCEPT_LICENSE="*"
VIDEO_CARDS="radeon"
INPUT_DEVICES="synaptics evdev"
ALSA_CARDS="atiixp"
LIBREOFFICE_EXTENSIONS="nlpsolver pdfimport presenter-console presenter-minimizer"
FEATURES="parallel-fetch"
PORTAGE_NICENESS="19"
LINGUAS="it ja"
# Set PORTDIR for backward compatibility with various tools:
#   gentoo-bashcomp - bug #478444
#   euse - bug #474574
#   euses and ufed - bug #478318
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage ${PORTDIR_OVERLAY}"



Do you think Its correct or useful?
_________________
Il numero di post non fa di me un esperto! Anzi!
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Feb 01, 2015 5:36 pm    Post subject: Reply with quote

bandreabis wrote:
So I MUST use mmx and sse beacuse I have sse2?

bandreabis ... not just sse2, for the above REQUIRED_USE cpu_flags_x86_sse2 requires sse and mmx, and cpu_flags_x86_3dnow requires mmx.

best ... khay
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6279

PostPosted: Sun Feb 01, 2015 5:36 pm    Post subject: Reply with quote

bandreabis wrote:
So I MUST use mmx and sse beacuse I have sse2?

/MUST/recommended to use/.
If in doubt, I would always use the flags which cpuinfo2cpuflags recommends: I would say that if this tool recommends suboptimal flags, then either the ebuild or the tool should be fixed.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sun Feb 01, 2015 5:37 pm    Post subject: Reply with quote

bandreabis,

Post your /proc/cpuinfo. Just for one core.
_________________
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
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Feb 01, 2015 5:40 pm    Post subject: Reply with quote

NeddySeagoon wrote:
Post your /proc/cpuinfo. Just for one core.

bandreabis ... that means the output of ...

Code:
% awk '/flags/{print ; exit}' /proc/cpuinfo

best ... khay
Back to top
View user's profile Send private message
bandreabis
Advocate
Advocate


Joined: 18 Feb 2005
Posts: 2413
Location: イタリアのロディで

PostPosted: Sun Feb 01, 2015 5:42 pm    Post subject: Reply with quote

Code:
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt lm 3dnowext 3dnow rep_good nopl pni lahf_lm


I suppose I can use them without any problem, isn't it?
_________________
Il numero di post non fa di me un esperto! Anzi!
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3830
Location: Dallas area

PostPosted: Sun Feb 01, 2015 5:56 pm    Post subject: Reply with quote

mv wrote:

Code:
REQUIRED_USE="
   cpu_flags_x86_sse? ( cpu_flags_x86_sse2 )
   cpu_flags_x86_sse2? ( cpu_flags_x86_mmx ) ...

Thus, if your processor supports sse but not sse2 (like athlon), you have to work with /etc/portage/package.use and unset cpu_flags_x86_sse to be able to build libvpx at all.
However, this behaviour existed already before CPU_FLAGS_X86 was introduced.


I looked at both libvpx and transcode configure scripts, since they both have "requirements" in the ebuild.
libvpx doesn't even care, and doesn't have a way to set or unset any cpu flags (it determines them in the configure script)
so the check in the ebuild is useless.

transcode does indeed need mmx set for sse/sse2/3dnow functionality, but it simply skips those in the configure script if mmx is disabled,
it doesn't check like libvpx.
_________________
Asus m5a99fx, FX 8320 - nouveau, oss4, rx550 for qemu passthrough
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
5.0.13 zen kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 8.2.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
229566
Tux's lil' helper
Tux's lil' helper


Joined: 16 Aug 2010
Posts: 127

PostPosted: Sun Feb 01, 2015 6:00 pm    Post subject: Reply with quote

mv wrote:
If in doubt, I would always use the flags which cpuinfo2cpuflags recommends: I would say that if this tool recommends suboptimal flags, then either the ebuild or the tool should be fixed.


Looking at the source, cpuinfo2cpuflags only looks at /proc/cpuinfo containing flags described in /usr/portage/profiles/desc/cpu_flags_x86.desc and then lists those that exist in both. For my AMD Phenom II X2, it lists:

Code:
CPU_FLAGS_X86="3dnow 3dnowext mmx mmxext popcnt sse sse2 sse3 sse4a"


Now admitting I don't know much about the implementation and function of these CPU features, does this mean cpuinfo2cpuflags is giving bad advice?
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6279

PostPosted: Sun Feb 01, 2015 6:16 pm    Post subject: Reply with quote

GrueXYZ wrote:
does this mean cpuinfo2cpuflags is giving bad advice?

Since it is written by mgorny with the aim to recommend you the setting, I think by definition it's advice should be correct for gentoo. As mentioned, otherwise I would say that either the script or the ebuild for which it gives wrong advice should be fixed (and I would suggest in such a case to report this as a bug).
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Feb 01, 2015 6:17 pm    Post subject: Reply with quote

GrueXYZ wrote:
Now admitting I don't know much about the implementation and function of these CPU features, does this mean cpuinfo2cpuflags is giving bad advice?

GrueXYZ ... yes, no, perhaps, maybe :) ... it's just not "complete (yes, expect more rebuilds!)".

best ... khay
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Feb 01, 2015 6:32 pm    Post subject: Reply with quote

bandreabis wrote:
Code:
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt lm 3dnowext 3dnow rep_good nopl pni lahf_lm

I suppose I can use them without any problem, isn't it?

bandreabis ... yes, the USE_REQUIRED mmx flag shouldn't be a problem in CPU_FLAGS_X86, but as NeddySeagoon suggests above mmx in conjuction with sse2 may not be a good idea in certain circumstances (dependent on the code, or how the build/runtime is using those features).

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


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

PostPosted: Sun Feb 01, 2015 6:50 pm    Post subject: Reply with quote

It should be harmless to set all the CPU_FLAGS_X86 that your CPU supports.
Then trust $UPSTREAM (not the gentoo devs) to deal with those cases where there is a choice, e.g. mmx or sse2.
Depending on the code design, one thread could use mmx and another sse2 concurrently as they use different register sets in th CPU.
If you are going to use only mmx or sse2, then sse2 is preferred but nothing stops you using both at the same time.
_________________
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
limn
l33t
l33t


Joined: 13 May 2005
Posts: 997

PostPosted: Sun Feb 01, 2015 8:12 pm    Post subject: Reply with quote

A garden gnome, really. Something you could tuck under your arm, easily.
And then a serious discussion. With verbs, and obfuscation, and everything.
Impressive.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
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