判断cpu是不是支持SSE42指令集

来源:互联网 发布:php safe mode 编辑:程序博客网 时间:2024/06/05 12:52

VS编译64位C++程序,不支持嵌入式汇编,所以需要使用intrinsic函数判断cpu特性

bool isSupportSSE42(){const int BIT_C_SSE42 = 0x00100000;   // bit 20  int CPUInfo[4] = {0};//CPUInfo参数用于接收输出的eax, ebx, ecx, edx这四个寄存器.//这个函数的具体参考资料//https://msdn.microsoft.com/en-us/library/hskdteyh(v=vs.140).aspx__cpuid(CPUInfo,1);if ((CPUInfo[2] & BIT_C_SSE42) == 0){return false;}//这里假设操作系统支持SSE42特性return true;}


 

0 0