【发布时间】:2017-01-04 16:34:38
【问题描述】:
如果 CPU 具有 AVX1 或 AVX2,则以下代码返回 True。有人知道如何修改此代码以准确检测 AVX2 指令支持吗?
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;
【问题讨论】:
-
您是否阅读过有关此 CPUID / XGETBV 用法的文档?你看懂这段代码了吗?
-
我将尝试破解此代码 (delphitricks.com/source-code/systeminfo/…) 并添加对 AVX2 的检测。但是,如果 (_edx 和 $04000000) = $04000000,我无法弄清楚这是什么……这个 $04000000 的价值是多少?根据en.wikipedia.org/wiki/CPUID,我知道 AVX2 的值为 5
标签: delphi