Discussion:
Turn on parallel compilation in cmake builds?
Cantor, Scott
2017-08-21 13:55:50 UTC
Permalink
Primarily a Windows thing, my colleague doing testing says he doesn't think the default build currently spawns muiltiple threads inside the VS builds unless he turns that on. Is there a reason not to turn it on by default in the CMakeFile.txt file?

-- Scott


B�KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKCB��[��X��ܚX�KK[XZ[��Y]�][��X��ܚX�P\��\˘\X�K�ܙ�B��܈Y][ۘ[��[X[��K[
r***@codelibre.net
2017-08-21 14:38:05 UTC
Permalink
Post by Cantor, Scott
Primarily a Windows thing, my colleague doing testing says he doesn't
think the default build currently spawns muiltiple threads inside the
VS builds unless he turns that on. Is there a reason not to turn it on
by default in the CMakeFile.txt file?
What type of change is your colleague proposing to turn it on?

Have they read
https://blog.kitware.com/cmake-building-with-all-your-cores/ ? There
are some caveats there which are worth noting (relating to /MP) which
make adding it by default potentially bad since in combination with
target-level parallelism it can greatly exceed the resources of the
machine and break the build. It's also quite possible that xerces is
already being built in parallel with other projects [we do this] so
enabling parallelisation at the lowest level can break the
parallelisation already in place at a much higher level. There are also
multiple ways to parallelise builds on Windows, so any change should not
compromise building with any of the other methods.

If there's a way of safely enabling it, that would be great, but it
appears the current recommendations are to configure this when running
cmake rather than hardcoding the behaviour.


Kind regards,
Roger


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-***@xerces.apache.org
For additional commands, e-mail: c-dev-***@xerces.apache.org
Cantor, Scott
2017-08-21 14:47:26 UTC
Permalink
Post by r***@codelibre.net
What type of change is your colleague proposing to turn it on?
He was proposing something like this:

if(WIN32)
set(CMAKE_CXX_FLAGS "\MP")
endif()

But neither of us know cmake, he's just trying to make it work the way the original builds did.
Post by r***@codelibre.net
Have they read
https://blog.kitware.com/cmake-building-with-all-your-cores/ ? There
are some caveats there which are worth noting (relating to /MP) which
make adding it by default potentially bad since in combination with
target-level parallelism it can greatly exceed the resources of the
machine and break the build.
I'll point him at it. If there's a reason, that's fine, we can always turn it on ourselves.
Post by r***@codelibre.net
It's also quite possible that xerces is
already being built in parallel with other projects [we do this] so
enabling parallelisation at the lowest level can break the
parallelisation already in place at a much higher level.
We don't do that (pretty much can't, the stack is close to vertical for us), so not familiar with the issues.
Post by r***@codelibre.net
If there's a way of safely enabling it, that would be great, but it
appears the current recommendations are to configure this when running
cmake rather than hardcoding the behaviour.
That's all I needed to know, thanks.

We're getting our testing done, so I probably will aim to call for a vote soon, sorry for the hold up.

-- Scott



---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-***@xerces.apache.org
For additional commands, e-mail: c-dev-***@xerces.apache.org
r***@codelibre.net
2017-08-21 15:08:47 UTC
Permalink
Post by Cantor, Scott
Post by r***@codelibre.net
What type of change is your colleague proposing to turn it on?
if(WIN32)
set(CMAKE_CXX_FLAGS "\MP")
endif()
But neither of us know cmake, he's just trying to make it work the way
the original builds did.
I think this is too general. WIN32 is set for all builds on Windows
platforms, so would break GCC or clang builds. MSVC is set when using
cl, but for all generators so would break with Ninja or nmake etc.

I think you probably want this:

if(CMAKE_GENERATOR MATCHES "Visual Studio")
string(APPEND CMAKE_CXX_FLAGS "\\MP")
endif()

so that it's specific to MSVC with the msbuild project/solution file
generator for Visual Studio. And it also appends to the flags already
set so it won't wipe them out. You can equally set CXXFLAGS when
running cmake for the same effect, i.e. cmake -G "Visual Studio..."
-DCMAKE_CXX_FLAGS=\MP ...


Regards,
Roger

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-***@xerces.apache.org
For additional commands, e-mail: c-dev-***@xerces.apache.org

Loading...