1

Can I get a single executable file, by using ICC(Intel C++ Compiler), that contains multiple versions of the compiled code for different architectures with different SSE1-4/AVX (but only x86_64, without x86_32) from different manufacturers AMD / Intel and the automatic choice in run-time required for the current processor architecture?

Alex
  • 12,578
  • 15
  • 99
  • 195
  • Last time I checked, ICC doesn't generate code that runs on AMD machines without "trickery". – Mats Petersson Sep 09 '13 at 17:25
  • @Mats Petersson And what is the "trickery" for example? Without this "trickery", code will not work on AMD? – Alex Sep 10 '13 at 08:17
  • 1
    It's been a while, but the code would check CPUID and bail out if it wasn't an Intel processor. Two ways to fix that: A) patch the library code that does the checking or B) install a virtual machine monitor that traps CPUID and returns the "GenuineIntel" rather than "AuthenticAMD" (or whatever it is the tags say). It may be that they have stopped that - it's been a couple o few years since I last tried ICC> – Mats Petersson Sep 10 '13 at 10:36

1 Answers1

2

Yes you can.

Just as you specify -xARCH (like -xAVX, -xHost) you can specify -axARCH to compile for two architectures

Example:

icc -xHost -axSSE2 ...

Will compile a default executable for the host architecture and optional code for SSE2 in case it's used on an older processor. Sadly only one additional architecture may be used. At runtime the most advanced code will be used.

In my icc 12.0.2 the valid options are: SSE2, SSE3, SSE4.1, SSE4.2, AVX, Host (-xHost only)

Modern AMD machines support SSE3 in all modern CPUs. SSE2 is by the way the standard lowest common denominator and is the default option if no -x option is specified. You can not make icc generate AMD 3DNow! code.

Sergey L.
  • 21,822
  • 5
  • 49
  • 75