Dear All,

recently I have run into some issues with FindMPI and intel mpi[1],
more intel mpi issue rather than cmake. The original issue reported
in[1] was solved. However in the process I made few points related
mainly to FindMPI, that I summarise in here:

1. the linker information is not parsed, see below
2. Failure to use the wrapper as a compiler.
3. Using wrong wrappers to interrogate for intel mpi and intel
compilers. eg. mpif90 instead of mpiifort (NB: If a user uses
I_MPI_F90=ifort, or c/c++ equivalents this issue is somehow
mittigated)

1. Linker issue
-- MPI_C_INCLUDE_PATH
/ichec/packages/intel/intel-cluster-studio-2015/impi_5.0.1/intel64/include
-- MPI_C_LINK_FLAGS
-- MPI_C_LIBRARIES
/ichec/packages/intel/intel-cluster-studio-2015/impi_5.0.1/intel64/lib/libmpifort.so;/ichec/packages/intel/intel-cluster-studio-2015/impi_5.0.1/intel64/lib/release/libmpi.so;/ichec/packages/intel/intel-cluster-studio-2015/impi_5.0.1/intel64/lib/libmpigi.a;/usr/lib64/libdl.so;/usr/lib64/librt.so;/usr/lib64/libpthread.so
-- Configuring done
-- Generating done
-- Build files have been written to: /ichec/home/staff/alin/findmpi/5.0.1
[alin@fionn2:~/findmpi/5.0.1]: mpicc -compile-info
gcc -I/ichec/packages/intel/intel-cluster-studio-2015/impi_5.0.1/intel64/include
-L/ichec/packages/intel/intel-cluster-studio-2015/impi_5.0.1/intel64/lib/release
-L/ichec/packages/intel/intel-cluster-studio-2015/impi_5.0.1/intel64/lib
-Xlinker --enable-new-dtags -Xlinker -rpath -Xlinker
/ichec/packages/intel/intel-cluster-studio-2015/impi_5.0.1/intel64/lib/release
-Xlinker -rpath -Xlinker
/ichec/packages/intel/intel-cluster-studio-2015/impi_5.0.1/intel64/lib
-Xlinker -rpath -Xlinker /opt/intel/mpi-rt/5.0/intel64/lib/release
-Xlinker -rpath -Xlinker /opt/intel/mpi-rt/5.0/intel64/lib -lmpifort
-lmpi -lmpigi -ldl -lrt -lpthread

Patch attached
0001-correctly-detect-MPI-linker-flags-for-Intel-MPI-mayb.patch


2. We first use whatever is provided in FC to detect the
libs/includes/linker flags. I think the correct order shall be first
check if what is provided in FC build mpi binaries, if fails go to
interrogation.

patch attached
0002-first-try-to-see-if-what-user-provided-produces-an-m.patch


3. This is a more complex issue and my understanding is that FindMPI
was designed with mpicc/mpicxx/mpif90 being the workhorse wrappers for
MPI. While I do not propose to change that I think that implementing
the change at 2. will somehow mitigate the case of multiple wrappers
and compilers.



[1] http://www.cmake.org/Bug/view.php?id=15182


Without Questions there are no Answers!
______________________________________________________________________
Dr. Alin Marin ELENA
http://alin.elenaworld.net/
______________________________________________________________________
From 4462ada3909c5ab023800b0f389038dcada9f91d Mon Sep 17 00:00:00 2001
From: Alin Marin Elena <alinm.el...@gmail.com>
Date: Tue, 9 Dec 2014 10:52:33 +0000
Subject: [PATCH 1/2] correctly detect MPI linker flags for Intel MPI maybe
 others too

---
 Modules/FindMPI.cmake | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 6f6dcf3..75f645f 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -373,6 +373,17 @@ function (interrogate_mpi_compiler lang try_libs)
           endif()
         endforeach()
 
+        # Extract linker flags from the link command line  Intel compilers.. others maybe
+        string(REGEX MATCHALL "(^| )-Xlinker ([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}")
+        set(MPI_LINK_FLAGS_WORK)
+        foreach(FLAG ${MPI_ALL_LINK_FLAGS})
+          if (MPI_LINK_FLAGS_WORK)
+            set(MPI_LINK_FLAGS_WORK "${MPI_LINK_FLAGS_WORK} ${FLAG}")
+          else()
+            set(MPI_LINK_FLAGS_WORK ${FLAG})
+          endif()
+        endforeach()
+
         # Extract the set of libraries to link against from the link command
         # line
         string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}")
-- 
2.2.0

From 08cd4aacf7fb7e26d4a0f39c0db4631afec87a4d Mon Sep 17 00:00:00 2001
From: Alin Marin Elena <alinm.el...@gmail.com>
Date: Tue, 9 Dec 2014 11:55:14 +0000
Subject: [PATCH 2/2] first try to see if what user provided produces an mpi
 binary

---
 Modules/FindMPI.cmake | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 75f645f..5f23c02 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -486,7 +486,7 @@ endfunction()
 
 
 # This function attempts to compile with the regular compiler, to see if MPI programs
-# work with it.  This is a last ditch attempt after we've tried interrogating mpicc and
+# work with it.  This is a first ditch attempt befre interrogating mpicc and
 # friends, and after we've tried to find generic libraries.  Works on machines like
 # Cray XE6, where the modules environment changes what MPI version cc, CC, and ftn use.
 function(try_regular_compiler lang success)
@@ -578,6 +578,12 @@ endforeach()
 # This loop finds the compilers and sends them off for interrogation.
 foreach (lang C CXX Fortran)
   if (CMAKE_${lang}_COMPILER_WORKS)
+    # first ditch try -- try our luck, just try running the regular compiler and
+    # see if we can create an MPI executable.
+    set(regular_compiler_worked 0)
+    if (NOT MPI_${lang}_LIBRARIES OR NOT MPI_${lang}_INCLUDE_PATH)
+      try_regular_compiler(${lang} regular_compiler_worked)
+    endif()
     # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler.
     if (MPI_${lang}_COMPILER)
       is_file_executable(MPI_${lang}_COMPILER MPI_COMPILER_IS_EXECUTABLE)
@@ -600,13 +606,6 @@ foreach (lang C CXX Fortran)
     interrogate_mpi_compiler(${lang} ${try_libs})
     mark_as_advanced(MPI_${lang}_COMPILER)
 
-    # last ditch try -- if nothing works so far, just try running the regular compiler and
-    # see if we can create an MPI executable.
-    set(regular_compiler_worked 0)
-    if (NOT MPI_${lang}_LIBRARIES OR NOT MPI_${lang}_INCLUDE_PATH)
-      try_regular_compiler(${lang} regular_compiler_worked)
-    endif()
-
     set(MPI_${lang}_FIND_QUIETLY ${MPI_FIND_QUIETLY})
     set(MPI_${lang}_FIND_REQUIRED ${MPI_FIND_REQUIRED})
     set(MPI_${lang}_FIND_VERSION ${MPI_FIND_VERSION})
-- 
2.2.0

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to