Commit Graph

134 Commits

Author SHA1 Message Date
Tobias Ribizel
80d37167fe Find{Threads,MPI}: Add support for CUDA with Clang
Currently CMake passes `-Xcompiler -pthread` flags to CUDA compilers
irrespective of the actual CUDA compiler ID.  This makes sure the
additional `-Xcompiler` flag is only used with nvcc.
2020-05-25 11:17:52 -04:00
Brad King
faa0c62106 FindMPI: Normalize paths from MSMPI environment variables
Fixes: #20606
2020-04-20 13:39:06 -04:00
Brad King
adc58e9612 Merge topic 'FindMPI-pgi-spectrum-mpi-wrappers'
cd449c6175 FindMPI: Add the pgi compiler wrapper names used by IBM Spectrum MPI

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4598
2020-04-13 10:57:23 -04:00
Chuck Atkins
cd449c6175 FindMPI: Add the pgi compiler wrapper names used by IBM Spectrum MPI 2020-04-10 12:01:59 -04:00
Brad King
a63f1c5c03 Merge topic 'FindMPI-fix-rerun'
b4d5ea8233 FindMPI: Preserve order of include directories on re-runs of CMake
8261ee3a9c FindMPI: Restore re-construction of include directories

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4341
2020-02-11 08:17:45 -05:00
Brad King
b4d5ea8233 FindMPI: Preserve order of include directories on re-runs of CMake
The fix in commit 5861c6d450 (FindMPI: Preserve include order when
extracting component directories, 2019-12-19) only works on the first
run of CMake in which we find MPI.  Extend the fix to save the compiler
wrapper's entire include path in our cache without splitting anything
out.  That way we can preserve the order when CMake re-runs.

Fixes: #20338
2020-02-10 11:14:42 -05:00
Brad King
8261ee3a9c FindMPI: Restore re-construction of include directories
The fix in commit 5861c6d450 (FindMPI: Preserve include order when
extracting component directories, 2019-12-19) only works on the first
run of CMake in which we find MPI.  It preserves the include directories
on the first run but still splits them up and saves the pieces in the
cache.  On future runs the pieces are not re-assembled, and we do not
know the order anyway.

Restore the re-assembly step so that at least all the include dirs are
available.  Leave preservation of the original order to later work.

Issue: #20338
2020-02-10 11:10:29 -05:00
Brad King
7cc74a59f3 Merge topic 'findmpi-documentation'
95a501addb Help: Add more variable documentation to FindMPI

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4263
2020-01-23 10:01:57 -05:00
Kyle Edwards
95a501addb Help: Add more variable documentation to FindMPI 2020-01-22 14:46:09 -05:00
Brad King
fbd20759be Merge topic 'FindMPI-fix-return'
8217a26d29 FindMPI: Fix regression when compiling with MPI wrappers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4254
2020-01-22 09:30:53 -05:00
Brad King
8217a26d29 FindMPI: Fix regression when compiling with MPI wrappers
The change in commit 5861c6d450 (FindMPI: Preserve include order when
extracting component directories, 2019-12-19) converted a CMake-language
function to a macro.  However, it contains a `return()` call that now
applies in the caller's scope, which is in correct.  The `return()` is
meant to skip work when using a MPI compiler wrapper as the main
compiler.  Move that condition to the call site instead.

Fixes: #20234
2020-01-21 10:41:20 -05:00
Ben Boeckel
be4d1bdf9a FPHSA: acknowledge the name mismatches in CMake-owned modules 2020-01-14 17:25:49 -05:00
Chuck Atkins
5861c6d450 FindMPI: Preserve include order when extracting component directories
Fixes: #20098
2020-01-10 14:13:44 -05:00
Keith Ballard
e221039e11 FindMPI: Improve error when a component's language is not enabled
Previously, if a CMake project requests a component for a language that is
not enabled, it would simply give an error with the message

    Could NOT find MPI (missing: MPI_${LANG}_FOUND)

which is not indicative that the language was not enabled.  This change
provides an error message indicating that it failed to find the
particular MPI component because no compiler was available for the
language and the language might need to be enabled for the project.

Closes: #19996
2019-11-20 10:23:33 -05:00
Brad King
01c7c4236a Merge topic 'FindMPI-restore-flag-vars'
31b8b28fed FindMPI: Restore MPI_<LANG>_COMPILE_FLAGS and MPI_<LANG>_COMPILE_OPTIONS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3710
2019-08-21 10:28:33 -04:00
Robert Maynard
31b8b28fed FindMPI: Restore MPI_<LANG>_COMPILE_FLAGS and MPI_<LANG>_COMPILE_OPTIONS
In commit e374b9f1eb (FindMPI: Restore MPI_<LANG>_COMPILE_FLAGS as a
command-line string, 2018-09-10, v3.12.3~6^2) we tried to restore the
compile flags but accidentally inverted the arguments to `list(JOIN)`
causing both `MPI_<LANG>_COMPILE_FLAGS` and `MPI_<LANG>_COMPILE_OPTIONS`
to be empty.

Issue: #18349
2019-08-21 10:08:12 -04:00
Brad King
f54c9f6cc3 Merge topic 'FindMPI-link-flags'
cf04da7e70 FindMPI: make sure computed link flags are not de-duplicated

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: Ben Boeckel <ben.boeckel@kitware.com>
Tested-by: Robert Maynard <robert.maynard@kitware.com>
Acked-by: Axel Huebl <axel.huebl@plasma.ninja>
Merge-request: !3605
2019-07-26 07:12:08 -04:00
Robert Maynard
cf04da7e70 FindMPI: make sure computed link flags are not de-duplicated
In commit f7eaa342de (FindMPI: Store imported target link flags as a
list instead of a string, 2019-06-14, v3.15.0-rc2~2^2) we used
`separate_arguments` to parse the extracted link flags and add them to
`INTERFACE_LINK_LIBRARIES`.  That property is not meant for link flags
and CMake may de-duplicate them.  This is particularly problematic for
flags like `-Wl,-rpath -Wl,/path1 -Wl,-rpath -Wl,/path2`.

In commit 39c572c9c9 (FindMPI: Updated to use INTERFACE_LINK_OPTIONS,
2019-06-24) we moved the parsed flags over to `INTERFACE_LINK_OPTIONS`,
but that may still perform de-duplication.  Avoid the parsing and
de-duplication of flags by passing the original string via `SHELL:`
instead.

Fixes: #19516
2019-07-25 12:59:21 -04:00
Brian Carlson
5affe415a3 FindMPI: Add MPI_EXECUTABLE_SUFFIX to every item in lists
Add the `${MPI_EXECUTABLE_SUFFIX}` to each of the items in the
`_MPI_${id}_${LANG}_COMPILER_NAMES` and `_MPI_${LANG}_GENERIC_COMPILER_NAMES` rather
than just adding the suffix to the last item in each list.
2019-06-29 13:35:01 -04:00
Robert Maynard
39c572c9c9 FindMPI: Updated to use INTERFACE_LINK_OPTIONS 2019-06-24 16:45:44 -04:00
Robert Maynard
f7eaa342de FindMPI: Store imported target link flags as a list instead of a string
We already use the `separate_arguments` `NATIVE_COMMAND` mode to parse
command-line strings into lists in several other places.

Fixes: #18897
2019-06-19 07:25:05 -04:00
Christian Pfeiffer
521ea77fc0 FindMPI: Correct documentaiton for library version 2019-05-06 18:42:02 +02:00
Christian Pfeiffer
c672a6a4b9 FindMPI: Add error logging 2019-05-06 18:40:44 +02:00
Christian Pfeiffer
7db32efbab FindMPI: Don't retain libdirs for Win32
On Windows systems, the need to retain library directories should not
nomrally occur. This can only occur on Unix like systems where a shared
library is being linked that has a dependency on another library which
is not being found in the default directories (e.g. libgfortran on BSD)

This also works around an issue introduced by !1694 in that the Visual
Studio generator does not handle link flags passed in
`INTERFACE_LINK_LIBRARIES` correctly, causing problems when using that
generator with Intel MPI in certain circumstances.
2019-04-20 20:45:09 +02:00
Brad King
7033a77942 Merge topic 'FindMPI-pthread-cuda'
e2d54e5c40 FindMPI: Pass -pthread to CUDA compiler through -Xcompiler

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Merge-request: !2529
2018-10-26 09:21:46 -04:00
Brad King
e2d54e5c40 FindMPI: Pass -pthread to CUDA compiler through -Xcompiler
When adding this flag to imported targets, wrap it in a generator
expression to use `-Xcompiler` to pass the flag for CUDA.

Fixes: #17929
2018-10-25 10:41:19 -04:00
Kitware Robot
df4ed1e9ff Help: Convert remaining modules to block-style comments 2018-10-22 11:09:34 -04:00
Brad King
e374b9f1eb FindMPI: Restore MPI_<LANG>_COMPILE_FLAGS as a command-line string
Refactoring in commit v3.10.0-rc1~103^2~2 (FindMPI: Modernization from
ground up, 2017-04-25) accidentally left this variable set as a copy of
the `;`-list in `MPI_<LANG>_COMPILE_OPTIONS`, but the flags variable is
documented as a command-line string.  Restore it now.

Fixes: #18349
2018-09-10 14:33:29 -04:00
Chuck Atkins
bab4bc5f32 FindMPI: Fix libname regex to not match the compiler executable
When trying to match full path libraries on the mpicc link line, the
current regex is not strict enough and improperly matches a partial path
to the Xcode compiler path with homebrew mpich.  This adjusts the regex
to look for a space preceeding the library name to prevent the first
argument, i.e. the compiler invocation, from being matched, and require
either a space or end-pattern after the library to prevent mismatches with
arguments that contain the library suffix but don't actually end with it.
2018-04-12 15:07:16 -04:00
Christian Pfeiffer
0def36043f FindMPI: Discard IMPI boilerplate text
Intel MPI on Windows prefixes all outputs with some boilerplate
copyright text. By discarding it, we should prevent any potential
clashes with our regex parsing.
2018-01-31 17:43:30 +01:00
Christian Pfeiffer
9ecbec5e01 FindMPI: Support for IMPI's compiler check
Intel MPI has an optional feature to check compatibility with the
compiler, given by I_MPI_CHECK_COMPILER.
This commit adds support for executing that check.
2018-01-31 17:27:38 +01:00
Christian Pfeiffer
767553674e FindMPI: Set up environment variables for wrapper
For MPICH derivates and Intel MPI, we can improve the compiler wrapper
behavior and accuracy by defining certain environment variables if they
haven't been set otherwise.
2018-01-31 17:27:37 +01:00
Christian Pfeiffer
e7c0298d5c FindMPI: Retain unused link paths
If our ``find_library`` step hasn't used a particular link directory at
all, it's best to retain it in order to prevent issues from secondary
dependencies not being found.
2018-01-30 18:23:45 +01:00
Christian Pfeiffer
8cddc89926 FindMPI: Use more CMake variables
This replaces hardcoded expectations of flags like -l and -L with a
dynamical solution based on CMake platform variables.

Furthermore, the linker flag parsing is dynamified to support more forms
and given linker paths are now removed properly from the linker flags.
2018-01-30 18:23:45 +01:00
Christian Pfeiffer
8b79107add FindMPI: Improve link information parsing
The parsing of link information coming from the compiler wrapper has been improved:

- Support MSVC /link argument separation properly and add support for potential VC++ link flags
- Rely on the global import/static/shared library suffixes instead of hardcoded special values.
This should improve compatibility with Cygwin and MinGW should any MPI implementation there need this behavior.
- Don't use ``find_library`` if the full path of a library is known anyways.
2018-01-25 16:31:10 +01:00
Christian Pfeiffer
5e9512a358 FindMPI: Move MSMPI/MPICH2 mpiexec search
Move the logic to search mpiexec for MSMPI and MPICH2 guesses to their
respective guessing logic. This way, we can prevent mix ups between
their mpiexecs and other potential matches, for example from an Intel
MPI installation.
2018-01-10 18:20:49 +01:00
Brad King
a363c9356d Merge topic 'findmpi-builtin-fix'
d1d8719f FindMPI: Fix various legacy problems

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1569
2017-12-13 07:52:54 -05:00
Christian Pfeiffer
d1d8719f62 FindMPI: Fix various legacy problems
This MR fixes a number of bugs stemming from legacy variable handling,
partially introduced by commit v3.10.0-rc1~103^2 (FindMPI: Add support
for FreeBSD and SLES, 2017-08-09).

* `MPI_COMPILE_OPTIONS` and `MPI_COMPILE_DEFINITIONS` legacy hints were not passed correctly.
* Legacy variables could be parsed after they were set by `FindMPI` cause erroneous hinting on subsequent runs.
* In the case of the compiler supporting MPI implicitly:
	* not all consumption variables would be correctly reset.
	* `MPI_<LANG>_HEADER_DIR` would be set unintentionally.
	* `MPI_<LANG>_LIB_NAMES` appeared in cache despite being ignored.
	* on subsequent passes, `MPI_<LANG>_COMPILER` could be corrupted.
* the C-to-CXX copy logic would take place even if `MPI_SKIP_GUESSING` was turned on
* if only some language compilers were given, inconsistent search behavior could be observed

Issue: #17538
2017-12-12 14:20:02 +01:00
Brad King
22f440ae69 Merge topic 'findmpi-notfound-spam'
bde7513d FindMPI: Correct legacy variable handling

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1557
2017-12-06 08:00:46 -05:00
Brad King
b6dd3969e8 Merge topic 'findmpi-found-cond'
2047eb36 FindMPI: Fix multiple configure runs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1556
2017-12-06 08:00:07 -05:00
Brad King
0418e91f7d Merge branch 'findmpi-notfound-spam' into release-3.10
Merge-request: !1557
2017-12-05 08:37:10 -05:00
Christian Pfeiffer
2047eb360d FindMPI: Fix multiple configure runs
Due to a erroneous logical dependency on a temporary variable, FindMPI
would depend its FOUND status on the set of flags needed to support
compiler-implicit MPI support after the first configure run.

This behavior is especially causing a misreported NOT FOUND status after
the first run on MPI implementations without MPI compiler like MS-MPI or
MPICH2 on Windows.
2017-12-05 14:17:27 +01:00
Christian Pfeiffer
bde7513d2f FindMPI: Correct legacy variable handling
Due to a minor logic error, MPI_LIBRARY, MPI_EXTRA_LIBRARY and
MPI_<LANG>_LIBRARIES hints are currently not correctly handled and
discarded.

Additionally, if either C or CXX aren't enabled, there subsequent calls
to FindMPI will cause cache variables of the sort "MPI_MPI_EXTRA_LIBRARY-NOTFOUND"
to appear due to an error in the compatibility handling. (Doesn't affect
functionality)
2017-12-05 14:14:40 +01:00
Christian Pfeiffer
1615cdedf5 FindMPI: Treat 'command not found' as an error
If the compiler given in I_MPI_... could not be found, the Intel MPI
wrappers emit an error like "line 590: ifort: command not found".
The script should currently fail to match the output of this for
information, but we should generally treat such an output as invalid,
since the displayed configuration line can become a mixup between Intel
and GNU compiler settings.
2017-11-15 15:27:35 +01:00
Christian Pfeiffer
1610f757ac FindMPI: Use physical cores for MPIEXEC_MAX_NUMPROCS
Since commit v3.9.0-rc1~224^2~1 (FindMPI: MPIEXEC handling improvements,
2017-04-21) the `ProcessorCount` module is being used to initialize
`MPIEXEC_MAX_NUMPROCS`.  However, this leads to the logical cores being
counted rather than the physical ones, and some MPI implementations like
OpenMPI will error if mpiexec is called with that number.  Switch it to
the number of physical cores using `cmake_host_system_information`.

This ensures that if `MPIEXEC_MAX_NUMPROCS` is being used to set up MPI
tests with CTest or similar that the tests won't spuriously fail due to
OpenMPI refusing to start the application.
2017-10-24 10:41:02 -04:00
Christian Pfeiffer
bf1e606f60 FindMPI: Add support for FreeBSD and SLES
Fixes: #17117
2017-09-15 14:55:08 +02:00
Christian Pfeiffer
2f673da69f FindMPI: Support components for various languages 2017-09-15 14:55:08 +02:00
Christian Pfeiffer
9a58e69cc8 FindMPI: Modernization from ground up
This is a near-total rewrite of FindMPI implementing the following
features:

Environmental improvements:

- C++ settings can now be picked from C settings if no dedicated C++
  settings are found (some installs of IBM Platform MPI)
- Fortran settings can now be found on MPICH-1, MVAPICH-1, Microsoft
  MPI and MPICH-2 on Windows.

- Improved flag procession logic: Flags related to security enhancements
  of MPI itself, and unrelated to MPI usage (-fstack-protector-strong on
  e.g. RHEL 7 for MPICH and MVAPICH) will be filtered out properly now.
  -pthread is now being handled. -fno-strict-aliasing, which may be needed
  while compiling MVAPICH (e.g. RHEL 7's MVAPICH package) is also
  filtered.

Features added:

- MPI version can be determined for each language and is exposed as the
  package version
- MPI functionality is being tested to ensure the correctness of
  settings
- MPI-2 C++ bindings can be suppressed if desired by the project or
  user. For older MPIs, this often resolves issues and eliminated the
  infamous SEEK_SET trouble.
- MPI-2 C++ bindings are now being searched for and exposed by a
  variable if detected.
- Fortran support now does not make assumptions over the MPI present and
  works with ILP64 MPI implementations.
- Fortran now exposes which bindings (mpif.h, mpi/mpi_f08 modules) are
  available
- MPI detection can now work hybridly, which for example permits using the
  Fortran modules shipped with some compiler suites together with MPI
  (e.g. PGI on Windows shipping MSMPI modules)
- Ability to determine MPI library version (*requires* try_run, caution)
  upon request
- Ability to determine Fortran capabilities from MPI-3 for each of the
  bindings (subarrays, asynchronous attribute protecting entities) (also
  requires try_run)

Fine grained control over the search process:

- Possibility to selectively enable and disable steps like compiler
  wrapper search and guessing. Permits picking Microsoft MPI over Intel
  MPI if both are loaded (previously not possible without removing the
  IMPI compiler wrappers from the environment)
- Ability to pick MPICH2 over MSMPI (previously the first one located
  was taken)
- A user may now pass compiler flags to the compiler wrapper script,
  enabling much more flexibility. This permits for example linking the
  Intel MPI debug runtime, static linking, ILP64 with Fortran,
  linking tracing, ...
- A user may define a suffix for all MPI binaries that are being looked
  for (useful on Debian/Ubuntu where the alternative MPI installs are each
  appended with their name, e.g. mpicc.mpich and mpicc.lam)

Cache variable improvements

- Instead of the previous plural cache variables a list-of-variables
  approach is now in place. Permits correcting individual variables
  instead of having to wade through a list, also speeds up the search
  process and increases comfort by eliminating duplicate entries in
  LIBRARIES over languages
- MPIEXEC was corrected to MPIEXEC_EXECUTABLE in order to fix the
  grouping in the CMake GUI for the variable (previously ungrouped)
2017-09-15 14:55:08 +02:00
Christian Pfeiffer
28d8383797 separgs: Use NATIVE_COMMAND where appropriate 2017-04-26 20:34:23 +02:00
Christian Pfeiffer
ece4f64749 FindMPI: Modernize documentation 2017-04-21 20:02:20 +02:00