Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MSVC_MP CMake option to adjust number of parallel build jobs #2705

Merged

Conversation

SunBlack
Copy link
Contributor

No description provided.

@SunBlack SunBlack force-pushed the extended_MP_option branch 3 times, most recently from 4ab09d7 to 6bb7369 Compare December 11, 2018 17:47
Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two Three comments here:

  • The logic is a little convoluted
  • I'm on a long term effort to stop us from writing on CMAKE_*_FLAGS
  • Are you sure you can remove that version check on MSVC?

Here's my suggestion

if(USE_MSVC_MP EQUAL 0)
  # USE_MSVC_MP is 0 in case the information cannot be determined by ProcessorCount => fallback
  add_compile_options("/MP")
elseif(USE_MSVC_MP GREATER 1)
  add_compile_options("/MP${USE_MSVC_MP}")
endif()

Assuming I'm not mistaken, this code should be equivalent.

@SunBlack
Copy link
Contributor Author

Are you sure you can remove that version check on MSVC

See #2690 (comment). Since C++14 is now necessary we require at least VS 2015 (MSVC_VERSION 1900) now.

I will check you suggestion. Looks indeed better :).

@SunBlack
Copy link
Contributor Author

Tested it: And it works :).

Side node: MSVC seems to ignore passed process count and only differ between with and without /MP. But I'm not sure if it is a UI error of VS or not. But documentation says we can pass processor count...

@SergioRAgostinho
Copy link
Member

After reading the documentation I noticed that one can pass /MP1 which makes the elseif() useless.

Also I'm questioning if USE_MSVC_MP is the best name to use here, since it gives the idea that is a binary var from the name. Maybe remove the prefix USE_?

Finally, our CI might blow-up out of memory if we don't tweak the number of compilations processes running, but we can tweak that later.

@SunBlack
Copy link
Contributor Author

SunBlack commented Dec 11, 2018

After reading the documentation I noticed that one can pass /MP1 which makes the elseif() useless.

I was thinking about it, too. But I there was a decision: Add a useless flag (MP1) or add two more CMake lines and prevent useless flag ;). And I didn't tried what happens in case someone enters -1 (if it will be ignored then or cause a compiler issue)

Also I'm questioning if USE_MSVC_MP is the best name to use here, since it gives the idea that is a binary var from the name. Maybe remove the prefix USE_?

I added USE_ before so it is in same group like USE_PROJECT_FOLDERS. But we could also start a group MSVC.

Finally, our CI might blow-up out of memory if we don't tweak the number of compilations processes running, but we can tweak that later.

I didn't changed behavior to the state of pre-PR.

@SergioRAgostinho
Copy link
Member

SergioRAgostinho commented Dec 12, 2018

I was thinking about it, too. But I there was a decision: Add a useless flag (MP1) or add two more CMake lines and prevent useless flag ;). And I didn't tried what happens in case someone enters -1 (if it will be ignored then or cause a compiler issue)

Makes sense. With the current logic, it will be ignored. Edit: if the elseif() was not there it would throw a compiler error.

I added USE_ before so it is in same group like USE_PROJECT_FOLDERS. But we could also start a group MSVC.

In this case better go with the MSVC group. USE_blah should be binary in my opinion.

I didn't changed behavior to the state of pre-PR.

From the logic it seems that by default it will always try to use the number if gets from ProcessorCount(). Everything went ok, so it is not a problem.

@SunBlack
Copy link
Contributor Author

I added USE_ before so it is in same group like USE_PROJECT_FOLDERS. But we could also start a group MSVC.

In this case better go with the MSVC group. USE_blah should be binary in my opinion.

What do you prefer as new name MSVC_MP, MSVC_simultaneously_compilers or whatever?

From the logic it seems that by default it will always try to use the number if gets from ProcessorCount(). Everything went ok, so it is not a problem.

As before ;)

@SergioRAgostinho
Copy link
Member

MSVC_MP works for me. The docstring is pretty clear.

As before ;)

Oh, true.

@taketwo
Copy link
Member

taketwo commented Dec 12, 2018

LGTM, but I'm not a MSVC user.

@taketwo taketwo requested a review from UnaNancyOwen December 12, 2018 11:03
Copy link
Member

@UnaNancyOwen UnaNancyOwen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@taketwo taketwo changed the title User can now adjust number of used simultaneous compilers (MSVC). Add MSVC_MP CMake option to adjust number of parallel build jobs Dec 12, 2018
@SergioRAgostinho SergioRAgostinho merged commit 9e05c4e into PointCloudLibrary:master Dec 12, 2018
@SunBlack SunBlack deleted the extended_MP_option branch December 15, 2018 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants