One drawback of using /MP versus building projects parallel is that it only parallelizes the compiler and not the linker. If you build multiple projects parallel, they also link parallel (if they don't have dependencies on each other). If you have many small independent projects (ITK 3.12 with testing and examples has 410 projects), this could be significant.
You can combine both settings too, but you have to be careful not to spawn to many compiler processes, as each parallel project will spawn multiple compiler instances. You can limit the number with /MP x (e.g. /MP 3 will build 3 .cpp files in parallel). So on a quad core machine, you could set Tools/Options/Projects and Solutions/Build and Run to build two projects in parallel and then specify /MP 2 to build two cpp files in parallel per project. Would be interesting to make some measurements on which combination yields the optimal results. Jochen -----Ursprüngliche Nachricht----- Von: [email protected] [mailto:[email protected]] Im Auftrag von Bill Hoffman Gesendet: Freitag, 10. April 2009 21:26 An: cmake Betreff: [CMake] /MP flag an VS parallel builds Jeff Baumes at Kitware recently made this discovery: Some may already know this, but I found a flag that you can use in Visual Studio that enables file-level build parallelism within projects like gmake. By default, Visual Studio only allows project-level parallelism, which does not always use all your cores, for example if you are building a project with a relatively small number of large libraries (like VTK) with deeper dependency trees. To enable this, add the flag /MP to CMAKE_CXX_FLAGS. I (and others) noticed significant build time speedup for builds of CMake, ParaView, and VTK. This is available in Visual Studio 2008, although some online thread discussions state that this flag is also available as a "hidden feature" of Visual Studio 2005. But you should probably assume it is buggy or incomplete in that version. The only known possible caveat is that having both file and project parallelism on work independently, so having 8 cores with /MP on a project with lots of project parallelism could spawn as many as 64 build threads, which will be inefficient. A repository like VXL with 600 projects may fall into this category. You can also play with a global setting for all projects (in Options, Projects and Solutions, Build and Run) to limit the number of projects built at once if this is an issue, or in those cases you can just not use /MP. Jeff BTW, this seems to beat gmake -j N on my dual core laptop. CMake build went from 3m (gmake) to 2m30s VS IDE from the command line. -Bill _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
