2 martie 2012 05:22
This site mentions these features but has no details about how to optimize your program for them. I doubt that the auto-vectorizer will be useful in my program, but the auto-parallelizer has some serious potential to speed things up while keeping backwards compatibility for me. (Windows, but I've got to keep it compatible back to Windows 98 for a bit longer.)
Does anyone have any pointers on the auto-parallelizer?
2 martie 2012 07:32Proprietar
Both features aim to make some of your loops go faster, without you having to rewrite the loops. Measure the performance of your loops with and without VS 11 to see if the automatic benefit applied in your cases.
Sorry that there is no more information beyond what you found on that MSDN page - we aim to address that in the coming months...
2 martie 2012 21:15
The auto-vectorizer is on by-default in VS11. It will examine your loops, and use SSE instructions where it can. You don't need to annotate your code, or tell us which loops are safe to vectorize - the compiler works it all out.
Some patterns of writing loops will be "friendly" to the vectorizer. We are working on a "cookbook" that advises on such patterns. And it will change, going forward, as we build more "smarts" into the analysis engine. But, for the moment, just re-compile your code, and measure the perf difference.
The auto-parallelizer is *not* on by-default in VS11. To request it within the IDE, go to project properties, code generation, and select "Enable Parallel Code Generation". If you build from the command-line, specify /Qpar
The auto-parallelizer is very conservative. In most cases, you will need to provide a hint, before each loop, that you want us to parallelize, using
where N denotes the number of cores you want to parallelize over. (Don't worry about asking to parallelize a loop that cannot be parallelized, due to data dependencies. The compiler will detect these, and issue a warning).
Hope this helps. We will also be recording a Channel9 session on this in the next week or two.
3 martie 2012 04:31
Awesome Jim, thanks. I am looking look forward to the channel 9 show. What I'm doing isn't heavy math for the most part, so I don't expect the auto-vectorizer to help much, although if it handles integers, I may be able to do some restructuring in a few spots to take advantage of the extra registers.
I'm more interested in the auto-parallelizer. I tried turning it on and it didn't appear to help any. Unfortunately, I'm getting errors when I try to run the Concurrency Visualizer, so I can't tell if it's making any difference. At least I now know the syntax of that pragma and that will let me play with it some more. If it will give me reasonable error messages about which variables it has issues with, that will be a huge help.
I know some of the difficulties in analyzing a C++ program, and I consider this to be like a dancing bear, it's not how graceful it is, I'm amazed you can make it dance at all!