Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how verify that operating system support avx2 instructions

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.

like image 955
Konstantin Isupov Avatar asked Sep 13 '14 05:09

Konstantin Isupov


People also ask

How do I know if my CPU supports AVX2?

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.

How do you check if AVX is enabled Windows?

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.

What is AVX2 instruction set support?

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.

Can I install AVX2?

AVX2 extension is not something you can download and install on your computer. This is entirely a property of the CPU of your computer.


1 Answers

If you want to check for the support to a particular set of registers you basically have 2 options:

  • assembly with CPUid extensions
  • builtin functions ( if ) provided by your compiler

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

like image 156
user2485710 Avatar answered Nov 15 '22 07:11

user2485710