GCC optimization flags for Intel Atom [closed]

2019-01-13 02:23发布

I'm developing a performance critical application for Intel Atom processor.

What are the best gcc optimization flags for this CPU?

9条回答
霸刀☆藐视天下
2楼-- · 2019-01-13 03:01

I don't know if GCC has any Atom-specific optimization flags yet, but the Atom core is supposed to be very similar to the original Pentium, with the very significant addition of the MMX/SSE/SSE2/SSE3/SSSE3 instruction sets. Of course, these only make a significant difference if your code is floating-point or DSP-heavy.

Perhaps you could try:

gcc -O2 -march=pentium -mmmx -msse -msse2 -msse3 -mssse3 -mfpmath=sse

查看更多
何必那么认真
3楼-- · 2019-01-13 03:03

GCC 4.5 will contain the -march=atom and -mtune=atom options.

Source: http://gcc.gnu.org/gcc-4.5/changes.html

查看更多
你好瞎i
4楼-- · 2019-01-13 03:04

Well, the Gentoo wiki states for the prescott:

http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel#Atom_N270

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"

CXXFLAGS="${CFLAGS}"

查看更多
何必那么认真
5楼-- · 2019-01-13 03:11

I've a script that auto selects the appropriate flags for your CPU and compiler combination. I've just updated it to support Intel Atom:

http://www.pixelbeat.org/scripts/gcccpuopt

Update: I previously specified -march=prescott for Atom, but looking more into it shows that Atom is merom ISA compliant, therefore -march=core2 is more appropriate. Note however that Atoms are in-order cores, the last of those being the original pentium. Therefore it's probably better to -mtune=pentium as well. Unfortunately I don't have an Atom to test. I would really appreciate if anyone could benchmark the diff between:

-march=core2 -mfpmath=sse -O3
-march=core2 -mtune=pentium -mfpmath=sse -O3

Update: Here are a couple of nice articles on low level optimization for Atom:

查看更多
老娘就宠你
6楼-- · 2019-01-13 03:14

There is a cool framework called Acovea (Analysis of Compiler Options via Evolutionary Algorithm), by Scott Rober Ladd, one of the GCC hackers. It's a genetic/evolutionary algorithm framework that tries to optimize GCC optimization flags for a specific piece of code via natural selection.

It works something like this: you write a little piece of benchmark code (it really has to be little, because it will be re-compiled and executed several thousand times) that represents the performance characteristics of the larger program you want to optimize. Then Acovea randomly constructs some dozens of different GCC commandlines and compiles and runs your benchmark with each of them. The best of these commandlines are then allowed to "mate" and "breed" new "children" which (hopefully) inherit the best "genes" from their "parents". This process is repeated for a couple dozen "generations", until a stable set of commandline flags emerges.

查看更多
爷的心禁止访问
7楼-- · 2019-01-13 03:20

i686 is closest. Don't go for core2.

GCC 4.1 -O3 -march=i686 GCC 4.3 -O3 -march=native

GCC 4.1 -O4 -ffast-math GCC 4.3 -O4 -ffast-math

http://macles.blogspot.com/2008/09/intel-cc-compiler-gcc-and-intel-atom.html

查看更多
登录 后发表回答