Parallel builds in Visual C++ 2005

(via Herb Sutter's blog)

If you haven't upgraded to Visual Studio 2008 yet, or like me, discovered that the mighty Boost doesn't build with it yet, then you might be interested to know that one of its most useful new features for C++ developers is available, undocumented, in '2005.

If you've got SMP (which is pretty likely these days), you probably know that Visual C++ 2005 already offers parallel project builds, and that they're useless if your solution contains a single monolithic project, or a bunch of interdependent projects.

However, VC 2005 actually has the ability to parallelise compiles at the source file level, too. In your project's properties, go to C/C++ -> Command Line, and in the Additional options box, add "/MP". Now it'll build as many compilation units (i.e. .cpp files) in parallel as you have CPUs. I did a "dual core on a budget" upgrade last week, and /MP has actually halved my build times. Now I can stop rueing my liberal usage of slow-building C++ templates!

Caveat: The compiler output can look a little mixed up, but you get used to it.

Don't let this revelation stop you upgrading to 2008, but if you're stuck with 2005 for reasons financial, technical, or political then /MP might be the most productive three characters you could type.

Posted by pwr (site) at November 28, 2007, 6:31pm. Category: blog. semipermalink Tags: visual studio, development

1 comment

StumbleUpon Toolbar Share on Facebook

Post a comment

name:
email:
site:
All three fields are optional. Your email address will only be made available to the site owner.



Comments

Displaying comments 0-1 of 1 (most recent first)

The complete syntax of the /MP compilerswitch is "/MP[nProcesses]". It is a good idea to create twice as much processes than installed CPUs.

Posted by _stefan at June 19, 2008, 8:08am. Category: blog.

counter exotic polos have cursed this planet since August 2002. You appear to be browsing from country code US.
This site and all its contents (except where otherwise stated) are Copyright © 1996-2007 Paul Roberts.
Powered by clunkyblog release 3.00. clunkyblog is Copyright © 2003, 2004, 2007 Paul Roberts. Generated in 11791ms.
Valid CSS! Valid XHTML 1.1!