View previous topic :: View next topic |
Author |
Message |
mrsaccess n00b
Joined: 03 Sep 2005 Posts: 30 Location: Greece
|
Posted: Mon Jun 04, 2012 3:32 pm Post subject: compiling for machines with different CPU features |
|
|
I have two systems and both are running Gentoo. I want to compile my programs once for both machines.
The problem is that despite both machines having a Core 2 Duo processor, one is a Penryn version with SSE 4.1 instructions and the other a Merom version without SSE 4.1.
So the question is: How can I set my make.conf so that GCC will create code that will take advantage of SSE 4.1 if it is available but work even if it isn't present?
Maybe it is simple but I haven't find an answer googling around for some time now.
PS. Also a thing about setiing -march=core2 is that it doesn't enable SSE4.1 according to GCC's manual. _________________ Hardware: The parts of your pc you can kick. |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21607
|
Posted: Tue Jun 05, 2012 1:22 am Post subject: |
|
|
As far as I know, what you want is not supported via a simple command line switch. The point of the new instructions is to perform certain operations quickly. If the CPU does not support the operation, then the code must either jump to an alternate block that does the same work without hardware assistance or it must execute the unsupported opcode, take a CPU fault, and hope that the kernel can emulate the requested operation. The former increases code size and may have negative impact on cache prediction. The latter is extremely expensive when it works at all, and requires kernel support. I am not aware of any kernel support for emulating SSE instructions.
With regard to -march=core2, that seems correct given your earlier statement that some Core 2 Duo processors do not understand SSE4.1 instructions. |
|
Back to top |
|
|
Genone Retired Dev
Joined: 14 Mar 2003 Posts: 9523 Location: beyond the rim
|
|
Back to top |
|
|
mrsaccess n00b
Joined: 03 Sep 2005 Posts: 30 Location: Greece
|
Posted: Tue Jun 05, 2012 11:03 am Post subject: |
|
|
Thanks!
I knew that SSE 4.1 doesn't help most applications. I was wondering for those few task intensive applications that can take advantage of it.
After a bit more search, it seems almost none uses SSE 4.1 and those who need it, should be set up by their developers (I guess asm blocks in the code, instructions in the makefile) to be able to detect it at runtime.
What initially confused me was that many binaries compiled for my Penryn machine, wouldn't run on my Merom machine, even Xorg or awk. I guess when SSE 4.1 gets enabled (with march=native for example), GCC will use it for much more programs than those that actually can take advantage of it.
Will stay with march=core2 mtune=native for now, since I want my apps to run as good as they can on my main machine, yet still be compatible with the second one. _________________ Hardware: The parts of your pc you can kick. |
|
Back to top |
|
|
|