How do programs utilize new CPU instructions (e.g. AVX-512, Intel Quick Sync Video) while still being able to run on older CPUs?

315 views

New instruction sets can improve performance but it is difficult to distribute your program if most people’s computers cannot run the program. When compiling an executable to distribute, it either has code that uses or doesn’t certain CPU instructions. The only way around it I can think of is compiling multiple libraries for every function that may use a new instruction set, one with the new instruction set and other without. Then you detect which CPU you have and dynamically load the proper library at runtime.

In: 2

3 Answers

Anonymous 0 Comments

You don’t need to do it at runtime. You do it when you compile the code for a target processor. The compiler will only use instructions that the target can execute. Any other instructions are replaced with functions that emulate it.

You are viewing 1 out of 3 answers, click here to view all answers.