Jump to content
Tuts 4 You
Sign in to follow this  
CodeExplorer

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

Recommended Posts

kao
6 hours ago, CodeExplorer said:

Visual Studio without Service Pack

..and any good reason NOT to install the service pack?

Share this post


Link to post
CodeExplorer

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

int isAvxSupported()
{
int HasAVX = 0;

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

  mov eax, 1
  cpuid
  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

supported:
  mov HasAVX, 1

not_supported:
  mov HasAVX, 0
   }

return HasAVX;

}

I don't have AVX!
https://stackoverflow.com/questions/44144763/avx-feature-detection-using-sigill-versus-cpu-probing

 

Edited by CodeExplorer (see edit history)

Share this post


Link to post
Teddy Rogers
13 hours ago, CodeExplorer said:

I don't have AVX!

What CPU do you have?

Ted.

Share this post


Link to post
CodeExplorer
2 hours ago, Teddy Rogers said:

What CPU do you have?

Ted.

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.
 

Share this post


Link to post

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
Sign in to follow this  
×
×
  • Create New...