How to explore the availability of Intel® Extended Vector Extensions?

How can I test using Delphi 2007 that the box has AVX capability.

My question is limited only to the support request in the CPU (It is assumed that the OS is OK / Windows 7 SP1).

A PDF document entitled Introduction to Intel® Enhanced Vector Extensions Chris Lomont explains how to do this and provides an example code implementation, but in C ++.

It is also available on this page.

+7
source share
1 answer

Here is the translation of the assembler code provided on the 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; 

This code will work on both 32 and 64-bit versions of Delphi.

Update : register save code added by @PhiS.

+12
source

All Articles