Why do Off-the-shelf applications work on both Intel and AMD processors?

One thing I lack understanding on is how can code compiled for an Intel CPU work on an AMD CPU.

My base understanding is that if you compile C code, for example, the compiler turns the source code into machine language which will have instructions for a particular processor. So, you need to compile with a compiler for whatever platform you want your application to use. Why don’t you require a compiler for AMD versus Intel, and have to buy software for a particular processor?

I know that AMD processors and Intel processors share some compatibility in the older x86 instructions; what I’d like to know is how do they do that? I mean, it’s not like AMD or Intel are calling each other up and telling each other their trade secrets, so how can they create instruction sets that are compatible?

Is all compatibility still based on the 386 instruction set, with a bunch of statements like “IF AMD CPU, do this ELSE IF INTEL do that”?

Intel TBB will work on AMD processors? [duplicate]

Possible Duplicate: AMD multi-core programming Is Intel TBB processor dependent? Will it work on amd or on ARM (under meeGo for example?)

Intel Vtune on amd processors

I installed Intel Vtune Analyzer 9 to get call-graph and counter-monitor data on a win32 application on a Windows 7 PC with AMD Turion X2 TL-58 processor. But it gives an error saying :The CPU archit

How do I support both intel cpu and amd gpu using opencl?

So, Intel SDK works with intel cpu, gpu, and xeon phi. AMD SDK works with AMD gpu and cpu. I would like to develop an application that targets intel cpu and AMD gpu. Can anyone suggest a development s

Intel’s HAXM equivalent for AMD on Windows OS

Is there any equivalent of Intel’s HAXM for AMD (Windows OS) or has anybody been able to hack HAXM to make it work on AMD processors (Windows OS)? Also, would Genymotion (http://www.genymotion.com) be

AMD APP OpenCL SDK on Intel

I have seen that AMD APP SDK samples work on a machine having only Intel CPU. How can this happen? How does the compiler target a different machine architecture? Do I not need Intel’s set of compilers

Do desktop processors support weakly ordered memory?

Are there any Intel/AMD desktop processors that support weakly ordered memory or this is a feature of a server setup with multiple processors?

OpenCL code to work with both AMD/Nvidia

Could someone tell if it’s possible to get an OpenCL code working with both AMD and Nvidia cards after compilation and what is the general procedure for that? Do I need to get both OpenCL SDKs (AMD/Nv

Chipset Information – AMD OR Intel

I want to get the chipset off multiple servers. Just testing the main line that will get this information. Some servers have Intel and others have AMD – when I use the below it really does not work –

Determine if a Processor is AMD64 or Intel64?

The Visual Studio C++ compiler provides the command line compiler options /favor:AMD64 and /favor:INTEL64 to optimize for AMD64 or Intel64 processors respectively. Now, the terms AMD64 and Intel64 are

OpenCV and AMD processors

I know that in the past OpenCV was based on IPP and was optimized to run on Intel CPUs. Is this still the case with OpenCV 2.0? Thanks, SW.

Answers

AMD and Intel x86 and x86-64 CPUs are almost entirely compatible. They both implement all of x86 and x86-64. They each have their own extensions (like MMX and 3DNow), but compilers don’t generally use them unless you tell them to. Nowadays, AMD and Intel both support almost all of each other’s extensions. The only time you may have to worry about the difference is when you are doing really low-level kernel stuff.

By the way, the instruction set isn’t really a “trade secret.” The implementation is. Both companies produce documentation on the instruction set, so each can copy it. The reason for this is probably that if more companies produce compatible chips, more software will be written for this instruction set, so more people will buy these chips. x86/x86-64 is basically the standard architecture for desktops, guaranteeing that people will continue to buy Intel and AMD chips. Intel and AMD have very different implementations, they just execute the same code.

Actually they do have a cross-licensing agreement. Information and innovation flowed from Intel to AMD back in the 90’s when AMD was a second source of 386 and 486 processors, and then from AMD to Intel when Intel adopted the x86-64 extensions.

Remember also that the instruction sets for these processors are publicly documented; typically one vendor will invent a new set of instructions, and a generation or two later the other vendor will implement compatible extensions. As such, rather than IF 386 …. you have something more along the lines of IF SSE4 IS SUPPORTED …, without regard to the specific vendor.

Both vendors implement the same instruction set, so when your compiled code gets turned into machine instructions, they will work on both chips. However, there are some special instruction sets such as SSE that can be specific to one vendor or another. If you want to improve performance for an application, you can make runtime checks to use these features when available.