GCC optimization flags for Intel Atom [closed]

2019-01-13 03:06发布

问题:

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

What are the best gcc optimization flags for this CPU?

回答1:

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

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



回答2:

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.



回答3:

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:

  • http://virtualdub.org/blog/pivot/entry.php?id=286
  • http://virtualdub.org/blog/pivot/entry.php?id=287


回答4:

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:

From Intel, Getting Started with MID

When using GCC to compile, there are a few recommended flags to use:

  • -O2 or -O1: O2 flag optimizes for speed, while the -O1 flag optimizes for size
  • -msse3
  • -march=core2
  • -mfpmath=sse


回答6:

Just like for Pentium 4:

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


回答7:

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



回答8:

here's some cross-pollenation of blogs... what i was really hoping for was a firefox-compiled-for-atom benchmark...

Address : http :// ivoras.sharanet.org/blog/tree/2009-02-11.optimizing-for-atom.html

"As it turns out, gcc appears to do a very decent job with -mtune=native, and mtune=generic is more than acceptable. The biggest gains (in this math-heavy benchmark) come from using SSE for math, but even they are destroyed by tuning for pentium4.

"The difference between the fastest and the slowest optimization is 21%. The impact of using march instead of mtune is negligible (not enough difference to tell if it helps or not).

"(I've included k6 just for reference - I know Atom doesn't have 3dnow)

"Late update: Tuning for k8 (with SSE and O3) yields a slightly higher best score of 182."



回答9:

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