summaryrefslogtreecommitdiffstats
path: root/Modules/FindMPI.cmake
diff options
context:
space:
mode:
authorAxel Huebl <axel.huebl@plasma.ninja>2021-06-24 21:44:21 (GMT)
committerBrad King <brad.king@kitware.com>2021-07-13 13:47:51 (GMT)
commitd9fcbb06f2e39b5290f22ebc0e2c5076ae026ccd (patch)
tree4e403692f3f16f670c6b211b5bd18a61c2d4a135 /Modules/FindMPI.cmake
parent460e812369db398da34e14c9d40c3ecec06afaf1 (diff)
downloadCMake-d9fcbb06f2e39b5290f22ebc0e2c5076ae026ccd.zip
CMake-d9fcbb06f2e39b5290f22ebc0e2c5076ae026ccd.tar.gz
CMake-d9fcbb06f2e39b5290f22ebc0e2c5076ae026ccd.tar.bz2
FindMPI: Interrogate Cray compiler
Cray traditionally does not ship mpicc/mpic++ compiler wrappers. Due to that, the traditional CMake logic to find MPI is to *only* support MPI on Cray systems if either 1. Cray Wrappers are used for compiling, or 2. an auxiliary MPI executable is found. On many new Exascale prototypes, using the Cray wrappers for develop work is extremely painful. Vendors such as AMD and integrators such as HPE seem not to go well in lock-step in Cray programming envs, making offloading with Cray wrappers too challenging. On the other hand, using the working experimental Vendor compilers works well, as long as one does not need MPI. Extend the fallback MPI search logic by also interrogating the CC/cc/ftn binaries if found for their MPI flags. This does not change existing logic, i.e. using the Cray wrappers directly, but provides an additional way to get MPI programs compiled on Cray. Fixes: #22368
Diffstat (limited to 'Modules/FindMPI.cmake')
-rw-r--r--Modules/FindMPI.cmake50
1 files changed, 49 insertions, 1 deletions
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 0b0d2d3..f64c4b8 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -105,7 +105,7 @@ This module performs a four step search for an MPI implementation:
1. Search for ``MPIEXEC_EXECUTABLE`` and, if found, use its base directory.
2. Check if the compiler has MPI support built-in. This is the case if the user passed a
- compiler wrapper as ``CMAKE_<LANG>_COMPILER`` or if they're on a Cray system.
+ compiler wrapper as ``CMAKE_<LANG>_COMPILER`` or if they use Cray system compiler wrappers.
3. Attempt to find an MPI compiler wrapper and determine the compiler information from it.
4. Try to find an MPI implementation that does not ship such a wrapper by guessing settings.
Currently, only Microsoft MPI and MPICH2 on Windows are supported.
@@ -333,6 +333,11 @@ set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95
mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r
mpixlf mpixlf_r mpxlf mpxlf_r)
+# Cray Compiler names
+set(_MPI_Cray_C_COMPILER_NAMES cc)
+set(_MPI_Cray_CXX_COMPILER_NAMES CC)
+set(_MPI_Cray_Fortran_COMPILER_NAMES ftn)
+
# Prepend vendor-specific compiler wrappers to the list. If we don't know the compiler,
# attempt all of them.
# By attempting vendor-specific compiler names first, we should avoid situations where the compiler wrapper
@@ -488,6 +493,26 @@ function (_MPI_interrogate_compiler LANG)
endif()
endif()
+ # Cray compiler wrappers come usually without a separate mpicc/c++/ftn, but offer
+ # --cray-print-opts=...
+ if (NOT MPI_COMPILER_RETURN EQUAL 0)
+ _MPI_check_compiler(${LANG} "--cray-print-opts=cflags"
+ MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
+
+ if (MPI_COMPILER_RETURN EQUAL 0)
+ # Pass --no-as-needed so the mpi library is always linked. Otherwise, the
+ # Cray compiler wrapper puts an --as-needed flag around the mpi library,
+ # and it is not linked unless code directly refers to it.
+ _MPI_check_compiler(${LANG} "--no-as-needed;--cray-print-opts=libs"
+ MPI_LINK_CMDLINE MPI_COMPILER_RETURN)
+
+ if (NOT MPI_COMPILER_RETURN EQUAL 0)
+ unset(MPI_COMPILE_CMDLINE)
+ unset(MPI_LINK_CMDLINE)
+ endif()
+ endif()
+ endif()
+
# MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the
# -showme commands are more specialized.
if (NOT MPI_COMPILER_RETURN EQUAL 0)
@@ -1520,6 +1545,29 @@ foreach(LANG IN ITEMS C CXX Fortran)
endif()
endif()
+ # We are on a Cray, environment identfier: PE_ENV is set (CRAY), and
+ # have NOT found an mpic++-like compiler wrapper (previous block),
+ # and we do NOT use the Cray cc/CC compiler wrappers as CC/CXX CMake
+ # compiler.
+ # So as a last resort, we now interrogate cc/CC/ftn for MPI flags.
+ if(DEFINED ENV{PE_ENV} AND NOT "${MPI_${LANG}_COMPILER}")
+ set(MPI_PINNED_COMPILER TRUE)
+ find_program(MPI_${LANG}_COMPILER
+ NAMES ${_MPI_Cray_${LANG}_COMPILER_NAMES}
+ PATH_SUFFIXES bin sbin
+ DOC "MPI compiler for ${LANG}"
+ )
+
+ # If we haven't made the implicit compiler test yet, perform it now.
+ if(NOT MPI_${LANG}_TRIED_IMPLICIT)
+ _MPI_create_imported_target(${LANG})
+ _MPI_check_lang_works(${LANG} TRUE)
+ endif()
+
+ set(MPI_${LANG}_WORKS_IMPLICIT TRUE)
+ _MPI_interrogate_compiler(${LANG})
+ endif()
+
if(NOT MPI_PINNED_COMPILER AND NOT MPI_${LANG}_WRAPPER_FOUND)
# If MPI_PINNED_COMPILER wasn't given, and the MPI compiler we potentially found didn't work, we withdraw it.
set(MPI_${LANG}_COMPILER "MPI_${LANG}_COMPILER-NOTFOUND" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE)