Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable only SIMD auto-vectorization optimization in Visual Studio 2015 (for C++)?

My question is simply how can I disable only the SIMD auto-vectorization optimization (keeping other optimizations of Release mode) in Visual Studio 2015 for:

1) the whole project being compiled;

2) for parts of the code.

In the first case, I would like to learn how to disable it for the whole project. For the second case, I would like to know whether it is also possible to do it for specific areas of the code, similarly to what is possible for all optimizations when using #pragma optimize("", off) and #pragma optimize("", on).

The purpose of this is performance comparison of some manually optimized code against the compiler's automatic SIMD vectorization.

like image 770
blipblop Avatar asked Jun 03 '26 05:06

blipblop


1 Answers

The Visual C++ auto-vectorizer is automatically enabled when building with /O2 or /Ox.

To see what it is doing, build with /Qvec-report:1 or /Qvec-report:2.

You can disable it for specific loops by using #pragma loop(no_vector)

See MSDN

There's no documented way to disable the auto-vectorizer globally while keeping standard optimizations enabled.

For more information, see this blog series, this video, and the Auto-Vectorization Cookbook

like image 58
Chuck Walbourn Avatar answered Jun 06 '26 07:06

Chuck Walbourn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!