0

I am writing a server application which has a large amount of source code. Compiling the application on my Intel Atom z510 takes around 15-20 minutes, and about 2-3 minutes on my Intel i7.

I am very new to cross compiling, new as in I've never done it. I can't find any reference on how to cross compile to the Z510. I found a great SO article on optimization flags for the atom here. However, no description on how to use them on my Intel i7 pc for my Intel Atom CPU.

I am making the assumption that anything compiled on my i7 will be default to being optimized for my i7, causing performance drops on the Atom. Any advice/search terms/websites would be greatly appreciated.

As always, thank you so much ahead of time.

Edit: I am using gcc 4.4. Apologies. (The one that comes with Ubuntu 10.04)

Constantin

Community
  • 1
  • 1
Constantin
  • 16,812
  • 9
  • 34
  • 52
  • Mentioning which compiler(s) you use would be helpful... – ildjarn Mar 30 '12 at 18:27
  • How do you build your project? That determines where gcc options need to be passed. Eventually they need to end up on the gcc command line. With `make`, you'd usually adjust your `CFLAGS` variable. – Ben Voigt Mar 30 '12 at 21:17
  • Hey Ben, I am using scons ... not my choice. I understand, there's plenty of documentation on how to set compiler flags for scons, I just don't know what flags. – Constantin Mar 31 '12 at 15:21

2 Answers2

3

I think your assumption that code compiled on the Atom is automatically optimized for the Atom is faulty.

Even if you request that behavior via -march=native -mtune=native, gcc 4.4 doesn't know how to optimize for Atom.

And code optimized for the Core i7 would run more slowly than code compiled on the Atom only if you are passing those flags to get code optimized for the Core i7 (which I think also requires a later version of gcc). Getting rid of those flags would cause the compiler on the i7 to generate the same code as the one on the Atom.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • Okay thanks Ben, you and timday seem to be agreeing that there's no reason why I shouldn't just do a regular compile on my i7 and copy the binaries over. I think that's what I'll do for now, and later I'll take some time to read about -march. – Constantin Mar 31 '12 at 15:24
1

If you're on your i7 and want to compile binaries compatible with and optimised for your Atom, just use a -march=atom option to gcc. The binaries produced should work, on the condition you're running the same OS on both systems (this includes agreeing on 32/64 bit-ness), and any necessary run-time dependencies are present.

timday
  • 24,582
  • 12
  • 83
  • 135
  • Right, this isn't truly cross-compilation, because the architecture is the same. It's just different hints to the optimizer. Also note that the linked question indicates that `-march=atom` is new in gcc 4.5, so not available to Constantin – Ben Voigt Mar 30 '12 at 21:14
  • 1
    Sorry, didn't realize it was only a recent addition. To be honest, the effect of processor specific optimisations is overrated for most, "general" code; and it sounds like the biggest gain here is in saving minutes of compile time, not a few percent at runtime. So you might as well use -march=i686; binaries should still work on Atom even if they're not completely optimal (and if you really care about optimal execution, get onto 4.5). – timday Mar 30 '12 at 21:33
  • Great! Thank you for the advice Tim. You know what I just realized as well, my i7 is running 11.10 in my virtual box which has gcc 4.6. So I might be able to use that atom flag! However, my 11.10 is 64 bit, would I need another flag to force 32 bit compile? Thanks! – Constantin Mar 31 '12 at 15:27
  • 1
    Ah, at this point I'm out of my depth. If I was you I'd read up on "multiarch" which is something to do with mixing 32bit and 64bit on Debian systems (although even if you could build 32bit, it'd still be with 11.10's libc and not work on 10.04 unless you got into pbuilder wrangling maybe), or since you're using virtualbox anyway just run another virtualbox with a 32bit 10.04 on your i7 for your atom-compatible builds (loses the atom optimisation option but that's really not a big deal). – timday Mar 31 '12 at 16:46