Vcpkg: Policy on /MP flag

Created on 8 Dec 2016  路  7Comments  路  Source: microsoft/vcpkg

Would you consider passing along the compile flag /MP (Multi.Processor Compilation) to C/C++ projects? It can shorten compile times a lot. For CMake projects you just need to append " /MP" to "CMAKE_C[XX]_FLAGS".

vcpkg-feature

Most helpful comment

We throw the MSBuild /m switch which builds projects in parallel, but we don't throw cl.exe's /MP switch which builds files _within_ a project in parallel. An unfortunate situation with MSBuild's C++ support today is that these two switches don't talk to each other: on an N processor machine, throwing both will potentially spawn N^2 processes. On quad core machines, this doesn't regress throughput _too_ badly (it just eats a bunch more RAM), but on higher core servers it can really start to cause problems.

Switching to Ninja for desktop builds solves this issue most soundly because Ninja looks inside each project build and will schedule down to the file level. Therefore, I think it's probably best to channel effort towards that move instead of tweaking combinations of /MPn and /m.

All 7 comments

You can also specify max n processes with /MPn.

I thought we already did this. Long term I think people want to switch to using ninja to build if possible.

We throw the MSBuild /m switch which builds projects in parallel, but we don't throw cl.exe's /MP switch which builds files _within_ a project in parallel. An unfortunate situation with MSBuild's C++ support today is that these two switches don't talk to each other: on an N processor machine, throwing both will potentially spawn N^2 processes. On quad core machines, this doesn't regress throughput _too_ badly (it just eats a bunch more RAM), but on higher core servers it can really start to cause problems.

Switching to Ninja for desktop builds solves this issue most soundly because Ninja looks inside each project build and will schedule down to the file level. Therefore, I think it's probably best to channel effort towards that move instead of tweaking combinations of /MPn and /m.

While we're at compiler flags, wouldn't it be beneficial to use /GL switch in release builds?

Is this information about MSBuild /m up to date? My builds seem to be strictly sequential. Some projects utilize all cores, while some are strictly single threaded. GDAL, for instance, takes 48 minutes to build on a powerful build machine - not counting dependencies. It would speed things up a lot to throw in /MP there.

Is this information about MSBuild /m up to date? My builds seem to be strictly sequential. Some projects utilize all cores, while some are strictly single threaded. GDAL, for instance, takes 48 minutes to build on a powerful build machine - not counting dependencies. It would speed things up a lot to throw in /MP there.

Looking at this line it seems that the info is up-to-date.

However, the compilation with VS is still really slow. It took me almost 5 hours to compile OpenCV with QT and CUDA feature (QT and CUDA were already installed).

This issue hasn鈥檛 been updated in two year, if it is still an issue, please reopen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pkeir picture pkeir  路  3Comments

madkoala picture madkoala  路  3Comments

jasjuang picture jasjuang  路  3Comments

invy picture invy  路  3Comments

jack17529 picture jack17529  路  3Comments