检测 CPU 支持的指令集

15 篇文章 2 订阅
2 篇文章 0 订阅

看了很多的 C/C++ 代码,都感觉太复杂。而且有的只支持 X86,不支持 X64。所以自己找了一番。
费了九牛二虎之力,才发现 Delphi原生就支持。
哎,浪费了很多时间,还得多研究研究 Delphi源码!

{ 检测 CPU 支持的指令集 <Check CPU support instruction set> }
procedure CheckCPU(var bMMX, bSSE1, bSSE2, bSSE3, bSSEE3, bSSE41, bSSE42, bAES, bFMA, bAVX1, bAVX2, bAVX512: Boolean);
begin
  bMMX    := GetCPUID(1).EDX and (1 shl 23) = (1 shl 23);
  bSSE1   := GetCPUID(1).EDX and (1 shl 25) = (1 shl 25);
  bSSE2   := GetCPUID(1).EDX and (1 shl 26) = (1 shl 26);
  bSSE3   := GetCPUID(1).ECX and (1 shl 00) = (1 shl 00);
  bSSEE3  := GetCPUID(1).ECX and (1 shl 09) = (1 shl 09);
  bSSE41  := GetCPUID(1).ECX and (1 shl 19) = (1 shl 19);
  bSSE42  := GetCPUID(1).ECX and (1 shl 20) = (1 shl 20);
  bAES    := GetCPUID(1).ECX and (1 shl 25) = (1 shl 25);
  bAVX1   := GetCPUID(1).ECX and (1 shl 28) = (1 shl 28);
  bFMA    := GetCPUID(1).ECX and (1 shl 12) = (1 shl 12);
  bAVX2   := GetCPUID(7).EBX and (1 shl 05) = (1 shl 05);
  bAVX512 := GetCPUID(7).EBX and (1 shl 16) = (1 shl 16);
end;

GetCPUID 在System.pas 单元中,无需引用,直接使用。
基于 Delphi 10.4.2 。其它低版本有没有,我就不知道了。

源码地址:GitHub - dbyoung720/CheckCPU: Check CPU support instruction set

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值