Please find below a proposed patch that addresses this bug: 
http://public.kitware.com/Bug/view.php?id=15182 (FindMPI.cmake fails to 
properly detect Intel MPI 5.0.1).  Because the return code is unreliable for 
the Intel MPI compile wrappers (e.g.: 'mpiicpc -showme:compile'), the output 
text must be interrogated for possible issues.  My choice of "undefined 
reference" may not be the best choice, but it works for all of my test cases.

I have tested this patch with OpenMPI, MPICH2 and Intel MPI on RHEL 6.4 and 
RHEL 6.4.  I have also tested it on Win7 with VS2013 using Microsoft HPC Pack 
2008 R2 MPI.

Would anyone like to provide feedback or test this modification?  What do I 
need to do to get this into release code?

-kt
Kelly Thompson


======================================================================================
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -226,6 +226,13 @@ function (interrogate_mpi_compiler lang try_libs)
         ERROR_VARIABLE   MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE
         RESULT_VARIABLE  MPI_COMPILER_RETURN)
+      # Intel MPI will return a zero return code even when the
+      # argument to the MPI compiler wrapper is unknown.  Attempt to
+      # catch this case.
+      if( "${MPI_COMPILE_CMDLINE}" MATCHES "undefined reference" )
+        set( MPI_COMPILER_RETURN 255 )
+      endif()
+
       if (MPI_COMPILER_RETURN EQUAL 0)
         # If we appear to have -showme:compile, then we should
         # also have -showme:link. Try it.
@@ -264,7 +271,15 @@ function (interrogate_mpi_compiler lang try_libs)
           RESULT_VARIABLE  MPI_COMPILER_RETURN)
       endif()
+      # Intel MPI will return a zero return code even when the
+      # argument to the MPI compiler wrapper is unknown.  Attempt to
+      # catch this case.
+      if( "${MPI_COMPILE_CMDLINE}" MATCHES "undefined reference" )
+        set( MPI_COMPILER_RETURN 255 )
+      endif()
+
       # MVAPICH uses -compile-info and -link-info.  Try them.
+      # Intel and Cray MPICH2 flavors will likely follow this path.
       if (NOT MPI_COMPILER_RETURN EQUAL 0)
         execute_process(
           COMMAND ${MPI_${lang}_COMPILER} -compile-info
@@ -378,7 +393,6 @@ function (interrogate_mpi_compiler lang try_libs)
         # Extract the set of libraries to link against from the link command
         # line
         string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES 
"${MPI_LINK_CMDLINE}")
-
         # add the compiler implicit directories because some compilers
         # such as the intel compiler have libraries that show up
         # in the showme list that can only be found in the implicit
@@ -588,6 +602,7 @@ foreach (lang C CXX Fortran)
       HINTS  ${_MPI_BASE_DIR}/bin
       PATHS  ${_MPI_PREFIX_PATH}
       )
+
     interrogate_mpi_compiler(${lang} ${try_libs})
     mark_as_advanced(MPI_${lang}_COMPILER)



-- 

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