Checking SSE Runtime Support

I would like to check if SSE4 or AVX is supported at run time, so that my program can use the instructions specific to the processor without creating a binary file for each processor.

If I could define it at runtime, I could use the interface and switch between different sets of instructions.

+4
source share
2 answers

GCC has a way to do this, which starts with a call __builtin_cpu_init, then calls __builtin_cpu_isand __builtin_cpu_supportsto test the functions. https://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/X86-Built-in-Functions.html

x86, ++, GCC multiversioning, , , , GCC , , , https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Function-Multiversioning.html

+6

MSVC extern int __isa_available MSVC.

MSVC 2013, , .

+2

All Articles