Jump to content
Tuts 4 You

Detecting Advanced Vector Extensions (AVX) support in Visual Studio???


Recommended Posts

Thanks Ted for the good direction!
Here is the working code:

int isAvxSupported()
int HasAVX = 0;

xor eax, eax
  cmp eax, 1           // does CPUID support eax = 1?
  jb not_supported

  mov eax, 1
  and ecx, 402653184  // check 27 bit (OS uses XSAVE/XRSTOR)  018000000h
  cmp ecx, 402653184  // and 28       (AVX supported by CPU)  018000000h
  jne not_supported

  xor ecx, ecx         // XFEATURE_ENABLED_MASK/XCR0 register number = 0
  xgetbv               // XFEATURE_ENABLED_MASK register is in edx:eax
  and eax, 6        // 110b
  cmp eax, 6        // check the AVX registers restore at context switch
  jne not_supported

  mov HasAVX, 1

  mov HasAVX, 0

return HasAVX;


I don't have AVX!


Edited by CodeExplorer
Link to comment
2 hours ago, Teddy Rogers said:

What CPU do you have?


AMD Athlon(tm) II X2 245
I know it is an very old CPU; I bought it 7 years ago!
I've thought to buy new motherboard/CPU/RAM.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...