I have a large Visual Studio 2010 solution file (.sln) that contains a large number of projects (~50). Each project consists of roughly 20 .cpp and .h files. Building the entire project takes roughly 2 hours on a fast Intel i7 machine with all the dependencies cached locally on a fast SSD.
I am attempting to replicate an existing experiment I found on this topic, and need some clarification on how to:
- Get the parallelization I'm seeking to work in Visual Studio (with the GUI/IDE).
- Get these changes also working with automated command-line builds via
MSBuild.exe.
First, are the /m and /maxcpucount options the same? I've read an article on the /m option, which seems to build more projects in parallel. This appears to be the same option I set via the following actions in the GUI:
- Tools
- Options
- Projects and Solutions
- Build and Run
Maximum number of parallel project builds
There is another option, /MP, which I can reach in the GUI via:
- Projects
- Properties
- Configuration Properties
- C/C++
- General
Multi-processor Compilation
Please correct me if I'm wrong on this, but this seems to suggest that the project will build multiple .cpp files in parallel, but there's no option to specify how many, unless I have to manually set it in the text box (ie: /MP 4 or /MP4.
It also seems that in order for /MP to work, I need to disable minimal rebuild (ie: Enabled Minimal Rebuild: No (/GM-)), and it also doesn't work with pre-compiled headers. I've worked around the pre-compiled headers issue by making the precompiled headers be a dedicated project that the solution builds first, before all other projects.
To the question: How can I implement these options for parallel project builds within the solution, and parallel file (.cpp) builds within the projects, using MSBuild via the command-line, and confirm that they are working as expected? Are my assumptions above also correct? My end goal is to test building the project with up to the total number of cores being uses, or possibly even overloading it if my build process is I/O bound rather than CPU bound. I can do this easily enough in Linux via:
NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
NUMJOBS="$(echo "$NUMCPUS*1.5" | bc)"
NUMJOBS="$(printf '%.0f' $NUMJOBS)"
alias pmake='time nice make -j$NUMJOBS'
This allows me to, on my 8-core PC, queue up 12 build tasks at once, and make automatically builds up to 12 .cpp files in parallel, handling implicit build rules/dependencies, etc. I'm trying to achieve the same thing in Visual Studio Professional and MSBuild. When my builds are I/O bound, this approach has been the best at keeping all cores at ~100% usage.
Thank you.
/mand/MPoptions are different, or are the same? I'm trying to configure the builds so it builds 4 projects in a solution at a time, and each project is trying to compile 4.cppfiles. This would be 16ci.exebuilds in parallel on an 8 core machine, but I'm assuming due to the I/O bound nature of the jobs, increasing the jobs should help keep more CPUs burning at 100%. - Cloud