Microsoft visual studio 2019官方示例:

https://learn.microsoft.com/en-us/cpp/intrinsics/cpuid-cpuidex?redirectedfrom=MSDN&view=msvc-160

// InstructionSet.cpp
// Compile by using: cl /EHsc /W4 InstructionSet.cpp
// processor: x86, x64
// Uses the __cpuid intrinsic to get information about
// CPU extended instruction set support.#include <iostream>
#include <vector>
#include <bitset>
#include <array>
#include <string>
#include <intrin.h>class InstructionSet
{// forward declarationsclass InstructionSet_Internal;public:// gettersstatic std::string Vendor(void) { return CPU_Rep.vendor_; }static std::string Brand(void) { return CPU_Rep.brand_; }static bool SSE3(void) { return CPU_Rep.f_1_ECX_[0]; }static bool PCLMULQDQ(void) { return CPU_Rep.f_1_ECX_[1]; }static bool MONITOR(void) { return CPU_Rep.f_1_ECX_[3]; }static bool SSSE3(void) { return CPU_Rep.f_1_ECX_[9]; }static bool FMA(void) { return CPU_Rep.f_1_ECX_[12]; }static bool CMPXCHG16B(void) { return CPU_Rep.f_1_ECX_[13]; }static bool SSE41(void) { return CPU_Rep.f_1_ECX_[19]; }static bool SSE42(void) { return CPU_Rep.f_1_ECX_[20]; }static bool MOVBE(void) { return CPU_Rep.f_1_ECX_[22]; }static bool POPCNT(void) { return CPU_Rep.f_1_ECX_[23]; }static bool AES(void) { return CPU_Rep.f_1_ECX_[25]; }static bool XSAVE(void) { return CPU_Rep.f_1_ECX_[26]; }static bool OSXSAVE(void) { return CPU_Rep.f_1_ECX_[27]; }static bool AVX(void) { return CPU_Rep.f_1_ECX_[28]; }static bool F16C(void) { return CPU_Rep.f_1_ECX_[29]; }static bool RDRAND(void) { return CPU_Rep.f_1_ECX_[30]; }static bool MSR(void) { return CPU_Rep.f_1_EDX_[5]; }static bool CX8(void) { return CPU_Rep.f_1_EDX_[8]; }static bool SEP(void) { return CPU_Rep.f_1_EDX_[11]; }static bool CMOV(void) { return CPU_Rep.f_1_EDX_[15]; }static bool CLFSH(void) { return CPU_Rep.f_1_EDX_[19]; }static bool MMX(void) { return CPU_Rep.f_1_EDX_[23]; }static bool FXSR(void) { return CPU_Rep.f_1_EDX_[24]; }static bool SSE(void) { return CPU_Rep.f_1_EDX_[25]; }static bool SSE2(void) { return CPU_Rep.f_1_EDX_[26]; }static bool FSGSBASE(void) { return CPU_Rep.f_7_EBX_[0]; }static bool BMI1(void) { return CPU_Rep.f_7_EBX_[3]; }static bool HLE(void) { return CPU_Rep.isIntel_ && CPU_Rep.f_7_EBX_[4]; }static bool AVX2(void) { return CPU_Rep.f_7_EBX_[5]; }static bool BMI2(void) { return CPU_Rep.f_7_EBX_[8]; }static bool ERMS(void) { return CPU_Rep.f_7_EBX_[9]; }static bool INVPCID(void) { return CPU_Rep.f_7_EBX_[10]; }static bool RTM(void) { return CPU_Rep.isIntel_ && CPU_Rep.f_7_EBX_[11]; }static bool AVX512F(void) { return CPU_Rep.f_7_EBX_[16]; }static bool RDSEED(void) { return CPU_Rep.f_7_EBX_[18]; }static bool ADX(void) { return CPU_Rep.f_7_EBX_[19]; }static bool AVX512PF(void) { return CPU_Rep.f_7_EBX_[26]; }static bool AVX512ER(void) { return CPU_Rep.f_7_EBX_[27]; }static bool AVX512CD(void) { return CPU_Rep.f_7_EBX_[28]; }static bool SHA(void) { return CPU_Rep.f_7_EBX_[29]; }static bool PREFETCHWT1(void) { return CPU_Rep.f_7_ECX_[0]; }static bool LAHF(void) { return CPU_Rep.f_81_ECX_[0]; }static bool LZCNT(void) { return CPU_Rep.isIntel_ && CPU_Rep.f_81_ECX_[5]; }static bool ABM(void) { return CPU_Rep.isAMD_ && CPU_Rep.f_81_ECX_[5]; }static bool SSE4a(void) { return CPU_Rep.isAMD_ && CPU_Rep.f_81_ECX_[6]; }static bool XOP(void) { return CPU_Rep.isAMD_ && CPU_Rep.f_81_ECX_[11]; }static bool TBM(void) { return CPU_Rep.isAMD_ && CPU_Rep.f_81_ECX_[21]; }static bool SYSCALL(void) { return CPU_Rep.isIntel_ && CPU_Rep.f_81_EDX_[11]; }static bool MMXEXT(void) { return CPU_Rep.isAMD_ && CPU_Rep.f_81_EDX_[22]; }static bool RDTSCP(void) { return CPU_Rep.isIntel_ && CPU_Rep.f_81_EDX_[27]; }static bool _3DNOWEXT(void) { return CPU_Rep.isAMD_ && CPU_Rep.f_81_EDX_[30]; }static bool _3DNOW(void) { return CPU_Rep.isAMD_ && CPU_Rep.f_81_EDX_[31]; }private:static const InstructionSet_Internal CPU_Rep;class InstructionSet_Internal{public:InstructionSet_Internal(): nIds_{ 0 },nExIds_{ 0 },isIntel_{ false },isAMD_{ false },f_1_ECX_{ 0 },f_1_EDX_{ 0 },f_7_EBX_{ 0 },f_7_ECX_{ 0 },f_81_ECX_{ 0 },f_81_EDX_{ 0 },data_{},extdata_{}{//int cpuInfo[4] = {-1};std::array<int, 4> cpui;// Calling __cpuid with 0x0 as the function_id argument// gets the number of the highest valid function ID.__cpuid(cpui.data(), 0);nIds_ = cpui[0];for (int i = 0; i <= nIds_; ++i){__cpuidex(cpui.data(), i, 0);data_.push_back(cpui);}// Capture vendor stringchar vendor[0x20];memset(vendor, 0, sizeof(vendor));*reinterpret_cast<int*>(vendor) = data_[0][1];*reinterpret_cast<int*>(vendor + 4) = data_[0][3];*reinterpret_cast<int*>(vendor + 8) = data_[0][2];vendor_ = vendor;if (vendor_ == "GenuineIntel"){isIntel_ = true;}else if (vendor_ == "AuthenticAMD"){isAMD_ = true;}// load bitset with flags for function 0x00000001if (nIds_ >= 1){f_1_ECX_ = data_[1][2];f_1_EDX_ = data_[1][3];}// load bitset with flags for function 0x00000007if (nIds_ >= 7){f_7_EBX_ = data_[7][1];f_7_ECX_ = data_[7][2];}// Calling __cpuid with 0x80000000 as the function_id argument// gets the number of the highest valid extended ID.__cpuid(cpui.data(), 0x80000000);nExIds_ = cpui[0];char brand[0x40];memset(brand, 0, sizeof(brand));for (int i = 0x80000000; i <= nExIds_; ++i){__cpuidex(cpui.data(), i, 0);extdata_.push_back(cpui);}// load bitset with flags for function 0x80000001if (nExIds_ >= 0x80000001){f_81_ECX_ = extdata_[1][2];f_81_EDX_ = extdata_[1][3];}// Interpret CPU brand string if reportedif (nExIds_ >= 0x80000004){memcpy(brand, extdata_[2].data(), sizeof(cpui));memcpy(brand + 16, extdata_[3].data(), sizeof(cpui));memcpy(brand + 32, extdata_[4].data(), sizeof(cpui));brand_ = brand;}};int nIds_;int nExIds_;std::string vendor_;std::string brand_;bool isIntel_;bool isAMD_;std::bitset<32> f_1_ECX_;std::bitset<32> f_1_EDX_;std::bitset<32> f_7_EBX_;std::bitset<32> f_7_ECX_;std::bitset<32> f_81_ECX_;std::bitset<32> f_81_EDX_;std::vector<std::array<int, 4>> data_;std::vector<std::array<int, 4>> extdata_;};
};// Initialize static member data
const InstructionSet::InstructionSet_Internal InstructionSet::CPU_Rep;// Print out supported instruction set extensions
int main()
{auto& outstream = std::cout;auto support_message = [&outstream](std::string isa_feature, bool is_supported) {outstream << isa_feature << (is_supported ? " supported" : " not supported") << std::endl;};std::cout << InstructionSet::Vendor() << std::endl;std::cout << InstructionSet::Brand() << std::endl;support_message("3DNOW",       InstructionSet::_3DNOW());support_message("3DNOWEXT",    InstructionSet::_3DNOWEXT());support_message("ABM",         InstructionSet::ABM());support_message("ADX",         InstructionSet::ADX());support_message("AES",         InstructionSet::AES());support_message("AVX",         InstructionSet::AVX());support_message("AVX2",        InstructionSet::AVX2());support_message("AVX512CD",    InstructionSet::AVX512CD());support_message("AVX512ER",    InstructionSet::AVX512ER());support_message("AVX512F",     InstructionSet::AVX512F());support_message("AVX512PF",    InstructionSet::AVX512PF());support_message("BMI1",        InstructionSet::BMI1());support_message("BMI2",        InstructionSet::BMI2());support_message("CLFSH",       InstructionSet::CLFSH());support_message("CMPXCHG16B",  InstructionSet::CMPXCHG16B());support_message("CX8",         InstructionSet::CX8());support_message("ERMS",        InstructionSet::ERMS());support_message("F16C",        InstructionSet::F16C());support_message("FMA",         InstructionSet::FMA());support_message("FSGSBASE",    InstructionSet::FSGSBASE());support_message("FXSR",        InstructionSet::FXSR());support_message("HLE",         InstructionSet::HLE());support_message("INVPCID",     InstructionSet::INVPCID());support_message("LAHF",        InstructionSet::LAHF());support_message("LZCNT",       InstructionSet::LZCNT());support_message("MMX",         InstructionSet::MMX());support_message("MMXEXT",      InstructionSet::MMXEXT());support_message("MONITOR",     InstructionSet::MONITOR());support_message("MOVBE",       InstructionSet::MOVBE());support_message("MSR",         InstructionSet::MSR());support_message("OSXSAVE",     InstructionSet::OSXSAVE());support_message("PCLMULQDQ",   InstructionSet::PCLMULQDQ());support_message("POPCNT",      InstructionSet::POPCNT());support_message("PREFETCHWT1", InstructionSet::PREFETCHWT1());support_message("RDRAND",      InstructionSet::RDRAND());support_message("RDSEED",      InstructionSet::RDSEED());support_message("RDTSCP",      InstructionSet::RDTSCP());support_message("RTM",         InstructionSet::RTM());support_message("SEP",         InstructionSet::SEP());support_message("SHA",         InstructionSet::SHA());support_message("SSE",         InstructionSet::SSE());support_message("SSE2",        InstructionSet::SSE2());support_message("SSE3",        InstructionSet::SSE3());support_message("SSE4.1",      InstructionSet::SSE41());support_message("SSE4.2",      InstructionSet::SSE42());support_message("SSE4a",       InstructionSet::SSE4a());support_message("SSSE3",       InstructionSet::SSSE3());support_message("SYSCALL",     InstructionSet::SYSCALL());support_message("TBM",         InstructionSet::TBM());support_message("XOP",         InstructionSet::XOP());support_message("XSAVE",       InstructionSet::XSAVE());
}

windows平台查看CPU支持的指令集 代码:__cpuid,__cpuidex相关推荐

  1. 【小工具】- Ubuntu如何查看cpu支持的指令集

    Ubuntu如何查看cpu支持的指令集 # 查看cpu支持的所有指令集 cat /proc/cpuinfo |grep -i 'flags'# 查看cpu是否支持SSE指令集 cat /proc/cp ...

  2. 【运维小工具】 - Mac OS 如何查看cpu支持的指令集?

    方法一 直接查看cpu支持的指令集 # macos查看cpu支持的指令集 sysctl -a | grep machdep.cpu.features# macos 查看cpu是否支持SSE 4.2 s ...

  3. Windows 技术篇 - 如何查看cpu支持的指令集、型号、属性等详细信息,使用cpu-z工具查看处理器、内存、显卡、主板、缓存、SPD信息方法

    好工具推荐!!! 由于最近在研究 cpu 的指令集和操作系统,所以发现了工具:CPU-Z 非常的好用,非常的专业!!! 获取方式: 小蓝枣的csdn资源仓库 工具目录如下: 使用效果图: 喜欢的点个赞 ...

  4. 关于dorisdb 本地搭建virtual_box虚拟机设置CPU支持AVX2指令集

    dorisdb安装文档要求 https://docs.dorisdb.com/zh-cn/main/quick_start/Deploy 解决办法 Intel VT-x和AMD-V是intel和amd ...

  5. windows平台下载编译好的webrtc代码vs2015

    windows平台下载编译好的webrtc代码vs2015 编译好的源码工程地址:  https://github.com/hujianhua888/webrtc_vs2015,工程目录如下,包含所有 ...

  6. 【HPC】Intel SIMD技术——如何用code检查你的CPU支持哪些指令集?

    本人就职于国际知名终端厂商,负责modem芯片研发. 在5G早期负责终端数据业务层.核心网相关的开发工作,目前牵头6G算力网络技术标准研究. 博客内容主要围绕:        5G协议讲解       ...

  7. windows平台查看python安装路径

    windows平台查看python安装路径 打开终端 win + r 输入 where python 如图:

  8. 查看cpu位数 linux,【转】linux好windows下查看CPU位数、核数、个数

    32 or 64 linux下查看操作CPU的运行位数: getconf LONG_BIT 如结果是32,表示当前CPU工作在32位模式下(即操作系统是32位的),但并不表示CPU一定是32位的(64 ...

  9. Windows WMIC查看CPU info

    WMIC扩展WMI(Windows Management Instrumentation,Windows管理工具) ,提供了从命令行接口和批处理脚本执行系统管理的支持.记录WMIC查看CPU的方法.也 ...

最新文章

  1. java增加final,Java8增加功能--Effectively final 功能
  2. poj 2411 Mondriaan#39;s Dream 【dp】
  3. SAP错误问题汇总(转)
  4. spray.json.JsonParser$ParsingException: Unexpected end-of-input at input index
  5. 软件项目周报模板_一份高质量的职场工作周报,要这样写
  6. ajax离开页面方法,如果用户在页面加载完成之前离开页面,则触发jQuery ajaxError()处理程序...
  7. 框架模式笔记:MVC 与MVP框架(完)
  8. 热点Key问题的发现与解决
  9. BFS POJ 3278 Catch That Cow
  10. 线性代数的本质(Essense Of Linear Algebra)[2]
  11. 螺旋测微器 flash_Flash 101-第5部分:螺旋式失控
  12. 无线电波的波段划分和应用
  13. 盘点:上海十处最具情调的小资地!(组图)
  14. 为什么电脑浏览器显示时钟快了_打开网站提示您的时钟快了_网页显示您的时钟慢了,解决方法...
  15. c语言考研复试一般考什么,考研复试考什么
  16. Educational Codeforces Round 87 (Rated for Div. 2) F. Summoning Minions
  17. Educational Codeforces Round 115 (Rated for Div. 2) A. Computer Game
  18. python开源web项目-最火的五大 python 开源项目
  19. 洛谷 P2715 约数和
  20. VS2010编译出来的程序不兼容Win7 再解

热门文章

  1. DataBase_数据库的行式存储与列式存储
  2. 类和对象的定义和关系
  3. 限流的方式,为什么要限流,怎么实现限流
  4. STM32笔记--SDIO(SD卡读取)
  5. Unity 环境搭建
  6. 【STC15单片机】动态数码管
  7. spring入门配置
  8. 安装Fedora(附镜像下载地址)
  9. 使用美国国立医学图书馆编辑的最新版Index Medicus中医学主题词表(MeSH)
  10. ROS2021开发者大会将于新奥尔良重启