-
Notifications
You must be signed in to change notification settings - Fork 59
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 option to use mpi imported targets #482
Conversation
cmake/thirdparty/SetupMPI.cmake
Outdated
LINK_FLAGS ${_mpi_link_flags} | ||
EXPORTABLE ${BLT_EXPORT_THIRDPARTY}) | ||
|
||
if(BLT_USE_MPI_IMPORTED_TARGETS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imported is a bit overloaded in this context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe "BLT_USE_CMAKE_MPI_TARGETS"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the other MPI options are all have the BLT_MPI
prefix, like BLT_MPI_COMPILE_FLAGS
how about:
BLT_MPI_USE_FINDMPI_CMAKE_TARGETS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works.. after this is proven to solve you problem, we should handle the overriding case where the user provides includes/link flags/etc.
Either by erroring out or overriding the target's properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or
BLT_MPI_USE_FIND_MPI_CMAKE_TARGETS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BLT_USE_FIND_MPI_TARGETS?
@white238 pushed docs, error checks and improvements. I also verified this does resolve the issue. |
# | ||
# TODO: should this be BLT_ENABLE_FIND_MPI? | ||
# | ||
if(ENABLE_FIND_MPI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove line 34 if you want to add this?
Yea this was a very early option. It should be prefixed but I've been hesitant to change it due to legacy. But honestly no one uses that I know anymore. The main use case was BGQ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed line 34 and the TODO
cmake/thirdparty/SetupMPI.cmake
Outdated
COMPILE_FLAGS ${_mpi_compile_flags} | ||
LINK_FLAGS ${_mpi_link_flags} | ||
EXPORTABLE ${BLT_EXPORT_THIRDPARTY}) | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line here please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -86,6 +86,11 @@ Test. ``test_2.cpp`` provides an example driver for MPI with GoogleTest. | |||
BLT also has the variable ``ENABLE_FIND_MPI`` which turns off all CMake's ``FindMPI`` | |||
logic and then uses the MPI wrapper directly when you provide them as the default | |||
compilers. | |||
|
|||
BLT also provides ``BLT_USE_FIND_MPI_TARGETS`` that will directly use the | |||
``MPI::MPI_C`` and ``MPI::MPI_CXX`` targets provided by CMake's ``FindMPI``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add that it those targets are able to be referenced under the unified name of mpi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two backticks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two backticks times two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @cyrush
Please also update the RELEASE_NOTES
cmake/thirdparty/SetupMPI.cmake
Outdated
@@ -33,6 +33,29 @@ set(_mpi_link_flags ) | |||
|
|||
message(STATUS "Enable FindMPI: ${ENABLE_FIND_MPI}") | |||
|
|||
# | |||
# TODO: should this be BLT_ENABLE_FIND_MPI? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: should this be
BLT_ENABLE_FIND_MPI
?
I agree that we should convert it to BLT_ENABLE_FIND_MPI
and deprecate ENABLE_FIND_MPI
, e.g. via a loud warning at first.
Perhaps we should do the same for many/most blt ENABLE_
variables at the same time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be a good time to do it since we just did the 0.4.0 release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added: #483 to track this name change, won't do in this PR
|
||
|
||
|
||
if(NOT ENABLE_FIND_MPI AND BLT_USE_FIND_MPI_TARGETS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we could handle this better by converting BLT_USE_FIND_MPI_TARGETS
to a cmake_dependent_option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried cmake_dependent_option
. It will just flip BLT_USE_FIND_MPI_TARGETS
to OFF, when ENABLE_FIND_MPI
is OFF. I think an explicit error is a better approach here -- better to error when things aren't consistent than to drive on to surprise town.
if (BLT_MPI_COMPILE_FLAGS) | ||
if(BLT_USE_FIND_MPI_TARGETS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please convert this to a foreach()
?
That way it is easier to see that it is the same logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each error case here provides a detailed unique error message. It's not just the var names that are different, so var indirection in a for loop won't get you the same result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the full section in the file -- the logic seems easy to parse. I feel a cmake for loop would not improve the readability. If you have an idea of how it could work, lets explore in a future PR.
Adds an option to use the modern imported targets provided by FindMPI.
This solves an issue with BLT related to transitive mpi deps and
-pthreads
vs cuda.The issue:
pthreads
and gives up.Using the targets imported by FindMPI solves this issue, b/c those targets expand to include the proper guards when FindMPI is called.
I don't know the exact point at where it changed, but pthreads is added by FindMPI in newer versions of CMake. It does not happen in CMake 3.14. We may eventually want to make this the default when newer CMake is used.
TODO: