CodeExplorer Posted September 6, 2019 Share Posted September 6, 2019 Detecting Advanced Vector Extensions (AVX) support in Visual Studio??? https://insufficientlycomplicated.wordpress.com/2011/11/07/detecting-intel-advanced-vector-extensions-avx-in-visual-studio/ The problem is that I have Visual Studio without Service Pack so _xgetbv method can't be used! Any other ways to detect if a CPU hash AVX? Link to comment
Teddy Rogers Posted September 6, 2019 Share Posted September 6, 2019 Have you tried GetEnabledXStateFeatures? There is an example in the AVX Support Portal on how to use it. Alternatively a more simpler approach is IsProcessorFeaturePresent. Or in assembler calling CPUID... Ted. Link to comment
kao Posted September 6, 2019 Share Posted September 6, 2019 6 hours ago, CodeExplorer said: Visual Studio without Service Pack ..and any good reason NOT to install the service pack? Link to comment
CodeExplorer Posted September 6, 2019 Author Share Posted September 6, 2019 (edited) 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 September 6, 2019 by CodeExplorer Link to comment
Teddy Rogers Posted September 7, 2019 Share Posted September 7, 2019 13 hours ago, CodeExplorer said: I don't have AVX! What CPU do you have? Ted. Link to comment
CodeExplorer Posted September 7, 2019 Author Share Posted September 7, 2019 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. Link to comment
Extreme Coders Posted September 7, 2019 Share Posted September 7, 2019 Intel Software Emulator can be used for running AVX apps on a non-AVX cpu. It emulates the unsupported instructions, so its quite slow than a native run, but better than not being able to run at all. https://software.intel.com/en-us/articles/intel-software-development-emulator Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now