gpt4 book ai didi

delphi - 如何探测英特尔® 高级矢量扩展的可用性?

转载 作者:行者123 更新时间:2023-12-03 14:51:23 24 4
gpt4 key购买 nike

如何使用 Delphi 2007 检查盒子是否支持 AVX。

我的问题仅限于查询CPU的支持(假设操作系统正常/Windows 7 SP1)。

名为 Introduction to Intel® Advanced Vector Extensions 的 PDF 文档Chris Lomont 解释了如何做到这一点,并提供了一个使用 C++ 实现的示例代码。

也可在此 page 获取.

最佳答案

这是 Intel blog 上给出的汇编代码的翻译:

function isAvxSupported: Boolean;
asm
{$IFDEF CPUX86}
push ebx
{$ENDIF}
{$IFDEF CPUX64}
mov r10, rbx
{$ENDIF}
xor eax, eax
cpuid
cmp eax, 1
jb @not_supported
mov eax, 1
cpuid
and ecx, 018000000h
cmp ecx, 018000000h
jne @not_supported
xor ecx, ecx
db 0Fh, 01h, 0D0h //XGETBV
and eax, 110b
cmp eax, 110b
jne @not_supported
mov eax, 1
jmp @done
@not_supported:
xor eax, eax
@done:
{$IFDEF CPUX86}
pop ebx
{$ENDIF}
{$IFDEF CPUX64}
mov rbx, r10
{$ENDIF}
end;

此代码可在 32 位和 64 位版本的 Delphi 中运行。

更新:注册保存代码感谢 @PhiS 添加。

关于delphi - 如何探测英特尔® 高级矢量扩展的可用性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9942118/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com