4 ms·
Usually you compile for the lowest common denominator. For example, the version of GCC I use defaults to -march=x86-64, which is a common subset of instructions
by pkkm 4y ago
Usually you compile for the lowest common denominator. For example, the version of GCC I use defaults to -march=x86-64, which is a common subset of instructions that should be supported by a 64-bit x86 CPU. You can override this with an argument like -march=sandybridge or -march=native (the latter enables all instructions your current machine can handle).
In principle, you could distribute many different binaries optimized for different CPUs. However, the more common approach in high-performance software is to compile most of the program for a generic instruction set and write several versions of the hottest parts. Then you detect the supported CPU features at runtime and dispatch appropriately.