I have configuration: Intel(R) Core(TM) i7-4702MQ CPU (with Haswell architecture), Windows 8, Intel C++ Compiller XE 13.0. I want run my program with avx2 optimization and put compilation flags:
/QaxCORE-AVX2, /QxCORE-AVX2
But when I run the program I get error:
Fatal Error: This program was not built to run in your system. Please verify that both the operating system and the processor support Intel(R) AVX2, BMI, LZCNT, HLE, RTM, and FMA instructions.
I run avx2 cpu support test which is given on page: How to detect new instruction support in the 4th generation Intel Core processor family. Result:
This CPU supports ISA extensions introduced in Haswell.
How can I check that my operating system support avx2-extensions and what could be the cause of the error? For use avx2 extensions i need set both /QaxCORE-AVX2
and /QxCORE-AVX2
flags?
upd: if i set flag
/QxAVX
that program has been successfully launched.
On linux (or unix machines) the information about your cpu is in /proc/cpuinfo . You can extract information from there by hand, or with a grep command ( grep flags /proc/cpuinfo ). Also most compilers will automatically define __AVX2__ so you can check for that too.
To make sure that AVX is enabled, do the following: Open your Windows Power Shell in Admin mode. In the command line type: bcdedit /set xsavedisable 0 (do NOT set this value to a number other than zero!). You should get feedback that the operation was successfully completed.
Advanced Vector Extensions 2 (AVX2), also known as Haswell New Instructions, is an expansion of the AVX instruction set introduced in Intel's Haswell microarchitecture. AVX2 makes the following additions: expansion of most vector integer SSE and AVX instructions to 256 bits.
AVX2 extension is not something you can download and install on your computer. This is entirely a property of the CPU of your computer.
If you want to check for the support to a particular set of registers you basically have 2 options:
writing assembly that detects which sets of registers are supported is a tedious, long and potentially error-prone task, not to mention that assembly it's not portable across different OSs, different SoC and different ABIs, there is also the burden of CPUid instructions which are not always implemented with the same pattern in all CPUs, there are different ways to do the reach the same bit of information with different vendors or even different family of CPUs from the same vendor; but this has one big advantage, it's not limited by anything, if you really need to know anything about your CPU/SoC, assembly + CPUid related stuff is the way to go .
Now gcc and other compilers implement something for your basic needs when you have to investigate your cpu capabilities in the form of builtin functions, which means that this special functions will generate the equivalent code in assembly and give you the answer that you want.
Using gcc
, the check for AVX2 is as easy as writing
...
if(__builtin_cpu_supports("avx2"))
{
...
}
...
docs : http://gcc.gnu.org/onlinedocs/gcc/X86-Built-in-Functions.html
for Visual Studio / msvc there are intrinsics such as __cpuid
and __cpuidex
that you can use to retrieve the same informations, here it is a link with a complete and working example .
docs : http://msdn.microsoft.com/en-us/library/hskdteyh.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With