This post will introduce and explain a new compiler feature in Visual Studio 2012, called auto-vectorization. (A previous post - what is vectorization? - provides background)
The Visual Studio 2012 auto-vectorizer tries to make loops in your code run faster by automatically vectorizing your code – that’s to say, using the SSE instructions available in all current mainline Intel and AMD chips. Auto-vectorization is on by-default. You don’t need to request this speedup. You don’t need to throw a compiler switch. You don’t need to set environment variables or registry entries. You don’t need to change your C++ code. You don’t need to insert #pragmas. The compiler just goes ahead and does it. It all comes for free.
So, in a sense, you don’t really need to know anything about auto-vectorization: simply recompile your program, using Visual Studio 2012. Of course, this is an optimization, so you need to choose a “release” configuration (/O2 for command-line junkies) rather than a “debug” configuration (/Od) to see the benefit. The compiler will analyze your loops and generate code that makes them run faster.
The following list gives you an idea of the kind of topics on auto-vectorization we will be covering in future blog posts:
- What is Vectorization?
- Overview (this post)
- How it works
- Rules for Loop Header
- Rules for Loop Body
- Did It work?
- Did It Work? - The Movie
- How Much Faster?
- The Cookbook
- Examples: real-world snippets
Stay tuned, and if you have suggestions for other topics, please feel free to comment below.