Disabling AVX

Disabling AVX

Hi all,

Is there a way (under Windows 7) to disable the support of AVX.
I wan't to make sure that on a pre-SB machine I don't get "Illegal Instruction exception".
Currently I have to use another machine and it's a bit annoying.

I don't use the /QaXXX flags because the code is already taking very long to compile (so it's taken care of manually) and I want it to work on Microsoft compiler too (even if performances would be degraded of course ;) ).

So if there is some global flag to change to disable it (even if i need to reboot the computer), the information would be more than welcomed.

Thanks in advance !

18 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

If you want your .exe to run on an earlier architecture than the one you build on, and don't need AVX, you should simply build with an appropriate value for /arch, e.g. /arch:SSE4.1  Microsoft gives you only the option /arch:SSE2 (default for X64 and also, for Intel, for 32-bit mode), even though all CPUs made in the last 10 years would support /arch:SSE3.

Running on Windows 7 without the AVX service pack doesn't guarantee to show problems with AVX instructions.

VS 2013 supports AVX  with /arch:AVX  option.

Hi guys,

So i think i was not clear.

I have an exe (we don't care what produced it). It has AVX code path and SSE4 code path and it's not supposed to run any AVX code when it's not supported.
I want to fully test my exe on my Ivy bridge, so I need to find a way to disable AVX (in the OS ? in the BIOS ?) so I'm sure in the SSE4 code path, there is only SSE4 code as expected.

Off-topic answers make all this thread confusing and reduce the probability that I eventually get an answer, if you don't understand the point of what I am doing, no one is forcing you to answer.

Best Regards

Quote:

iliyapolak wrote:

VS 2013 supports AVX  with /arch:AVX  option.

As does VS2012.  I meant the only non-AVX option would be SSE2.

I don't believe that it is possible to disable AVX support in the processor.  

To test your non-AVX code path on a machine that supports AVX, you will need to patch the run-time checks so that AVX *appears* to be unsupported.   Based on earlier experience with patching binaries, I think there is a good chance that all of the checks for AVX support will be identical code fragments, so it should be possible to build a script to patch your binary.  

This has been done before with checks for "Genuine Intel" in the string returned by the CPUID instruction, so it should be possible.  All you need to do is reverse the sense of the conditional branch instruction following the CPUID check for AVX support, which should be a simple overwrite of some bits with no change to the file size.   The project may or may not be easy, depending on whether the compiler inserts the check once or many times, and whether the checks are identical in every occurrence.

John D. McCalpin, PhD "Dr. Bandwidth"

I already have what you describe (i use an env variable next to my cpuid wrapper)
Actually what i want exactly is to make sure that there is no AVX at all in the "non AVX" code path.
Some poor optimisation or symbol conflicts can lead to these issue and i need to track them.

In the meantime, i will use an "old" Xeon without AVX to make sure this hybrid binary works like a charm on a simple SSE4.2 machine :)

Thanks for the answer

Apparently the right way is to launch as admin:

bcdedit /set xsavedisable 1

Then reboot of course

I hope this thread will help ...

Quote:

Tim Prince wrote:

Quote:

iliyapolak wrote:

VS 2013 supports AVX  with /arch:AVX  option.

 

As does VS2012.  I meant the only non-AVX option would be SSE2.

I misunderstood your post:)

For patching you can use IDA freeware version which will recompile the patched exe.

 

 

Beside reversing conditional statement you can also insert unconditional jump to non AVX code target.

I think you could use SDE (http://software.intel.com/en-us/articles/intel-software-development-emul...) to lower capabilities of your CPU. I haven't tried it though.

@iliyapolak: offtopic ... again

@andysem: Good idea, I will give it a try
In the future it might be a much better and finer solution than bcdedit that, in my understanding, would disable every AVX instruction set.

>>>@iliyapolak: offtopic ... again>>>

Why do you think so?

Are not you trying to disable AVX code path execution in that exe?

>>>I have an exe (we don't care what produced it). It has AVX code path and SSE4 code path and it's not supposed to run any AVX code when it's not supported>>>

Quote:

iliyapolak wrote:

>>>@iliyapolak: offtopic ... again>>>

Why do you think so?

Are not you trying to disable AVX code path execution in that exe?

>>>I have an exe (we don't care what produced it). It has AVX code path and SSE4 code path and it's not supposed to run any AVX code when it's not supported>>>

Because i'm trying to make sure that my exe works perfectly on a SSE4 machine even if there is an AVX code path into it. If i alter the exe, there is nothing to test. I need to deploy the same binary for 2 generation of machines.

SDE was exactly what i was looking for actually.

@emmanuel

Next time please express your intention more clearly.Btw , I thought that patching or reversing some cmp jmp instruction will suite your needs.

I'm sorry if i wasn't clear.
Thank you for spending time answering anyway.

Kind regards

It's ok.

You are welcome.

Leave a Comment

Please sign in to add a comment. Not a member? Join today