BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

How Visual Studio Improves C++ Performance

by Jeff Martin on Nov 01, 2012 |

Today at Build Jim Radigan and Don McCrady gave a presentation that discussed how the improved Visual Studio 2012 (VS2012) compiler can benefit developers programming in C++. Radigan began his talk, "Its all about performance: Using Visual C++ 2012 to Maximize Your Hardware", by giving a brief historical overview of the increases in computer power since the introduction of the original Pentium.

That first Pentium had 3.1 million transistors while the current generation Ivy Bridge CPUs have 1.4 billion transistors. As McCrady would later note, C++ AMP allows developers to utilize everything with one single langauge-- both the CPU, and the GPU that is increasingly present on CPU dies (in addition to the GPUs present in discrete expansion cards.)

While using code targeting C++ AMP can frequently provide the best performance versus generic code, Radigan continued by noting that the auto-vectorization and auto-parallelization optimizations present in VS2012 mean that in many cases recompiling existing C++ code can provide immediate benefits. As a result the optimizer present in VS2012 is double the size of previous versions.

Developers can mark sections of their code where they would like to ensure the compiler reviews for speed-up. Using the following pragma:

#pragma loop(hint_parallel(4))

… enables developers to provide a hint to the compiler that it is believed that the loop containing the pragma should be spread over multiple cores (in this snippet 4 cores). The compiler will still make a full anaylsis so that if the marked piece of code is not appropriately parallelizable the compiler will not implement any optimizations.

The demonstration of a raytracer by Radigan exhibited a 16X performance increase simply by recompile the source under VS2012. Radigan emphasized that the improved compiler performance of VS2012 notwithstanding, there is no “magic bullet” available to automatically produce faster code. That said, the compiler team is contninously seeking to innovate as Windows 8, SQL Server, and Office are all C++ applications.

Radigan indicated that while nothing is available right now, he would like to add native C# support to AMP. (At present C# developers can make use of AMP via P/Invoke.) Finally, the C++ AMP specification is an open standard, but there is currently not an implementation on Apple's platform (iOS or Mac OS X) but in theory it is possible for one to be made.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT