MantisBT - CMake
View Issue Details
0015182CMakeCMakepublic2014-09-30 16:262015-05-04 09:05
Kelly Thompson 
Chuck Atkins 
normalmajoralways
closedfixed 
LinuxRed Hat Enterprise Linux6.5
CMake 3.0 
CMake 3.2CMake 3.2 
0015182: FindMPI.cmake fails to properly detect Intel MPI 5.0.1
The FindMPI.cmake module queries for include path and link libraries by attempting to use various options (e.g.: -showme:compile) of MPI_${lang}_COMPILER.

      # Check whether the -showme:compile option works. This indicates that we have either OpenMPI
      # or a newer version of LAM-MPI, and implies that -showme:link will also work.
      execute_process(
        COMMAND ${MPI_${lang}_COMPILER} -showme:compile
        OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE
        ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE
        RESULT_VARIABLE MPI_COMPILER_RETURN)

For Intel MPI, MPI_CXX_COMPILER has the value 'mpiicpc.' The command 'mpiicpc -showme:compile' fails, but returns a '0' error code:

% mpiicpc -showme:comple; echo $?
icpc: command line warning #10006: ignoring unknown option '-showme:comple'
/var/lib/perceus/vnfs/asc-fe/rootfs/usr/bin/../lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
0

I have contacted Intel support and they confirmed that this is by design. Unknown compiler options are considered to be warnings, not errors.

This issue can be fixed by adding more complex logic to test the error state of the 'mpiicpc -showme:compile' command. In my local install of CMake, I added the following logic:

  if( "${MPI_COMPILE_CMDLINE}" MATCHES "undefined reference")
    set( MPI_COMPILER_RETURN 255 )
  endif()

This appears to solve the problem of incorrect information being saved in MPI_LINK_CMDLINE, MPI_INCDIRS, and MPI_LIBDIRS.
Before running cmake, I needed to set these environment variables:

export CXX=`which mpiicpc`
export CC=`which mpiicc`
export MPIEXEC=`which srun`

So that FindMPI would query the correct MPI compile wrappers.

See bug description for more details.
I can reproduce this issue with Intel MPI 5.0.1 and Intel MPI 4.1.3 on two different systems (RHEL 6.4 and RHEL 6.5)
No tags attached.
related to 0014991closed Kitware Robot FindMPI doesn't pass compiler flags to $MPICC -show. Finds wrong libraries for Xeon Phi native mode. 
diff doublecheckerror.diff (3,882) 2014-12-04 13:51
https://public.kitware.com/Bug/file/5311/doublecheckerror.diff
diff usecompilerewrapper.diff (892) 2014-12-04 14:01
https://public.kitware.com/Bug/file/5312/usecompilerewrapper.diff
patch 0001-FindMPI-Factor-out-compiler-wrapper-execution-into-h.patch (3,787) 2014-12-04 14:17
https://public.kitware.com/Bug/file/5313/0001-FindMPI-Factor-out-compiler-wrapper-execution-into-h.patch
patch 0002-FindMPI-Workaround-Intel-MPI-5.0.1-exit-code-problem.patch (1,470) 2014-12-04 14:17
https://public.kitware.com/Bug/file/5314/0002-FindMPI-Workaround-Intel-MPI-5.0.1-exit-code-problem.patch
diff linkflags.diff (2,284) 2014-12-04 17:23
https://public.kitware.com/Bug/file/5315/linkflags.diff
Issue History
2014-09-30 16:26Kelly ThompsonNew Issue
2014-10-17 15:28Arch D. RobisonNote Added: 0037044
2014-10-20 09:31Brad KingNote Added: 0037054
2014-10-30 12:25Brad KingAssigned To => Chuck Atkins
2014-10-30 12:25Brad KingStatusnew => assigned
2014-10-30 12:26Brad KingNote Added: 0037108
2014-10-30 12:26Brad KingTarget Version => CMake 3.2
2014-12-04 08:41Brad KingNote Added: 0037374
2014-12-04 09:30RolandSchulzNote Added: 0037377
2014-12-04 11:06Alin M ElenaNote Added: 0037380
2014-12-04 11:22Brad KingNote Added: 0037381
2014-12-04 13:49Alin M ElenaNote Added: 0037383
2014-12-04 13:51Alin M ElenaFile Added: doublecheckerror.diff
2014-12-04 13:52Alin M ElenaNote Added: 0037384
2014-12-04 14:01Alin M ElenaNote Added: 0037385
2014-12-04 14:01Alin M ElenaFile Added: usecompilerewrapper.diff
2014-12-04 14:17Brad KingFile Added: 0001-FindMPI-Factor-out-compiler-wrapper-execution-into-h.patch
2014-12-04 14:17Brad KingFile Added: 0002-FindMPI-Workaround-Intel-MPI-5.0.1-exit-code-problem.patch
2014-12-04 14:18Brad KingNote Added: 0037386
2014-12-04 16:28Alin M ElenaNote Added: 0037391
2014-12-04 17:22Alin M ElenaNote Added: 0037392
2014-12-04 17:23Alin M ElenaFile Added: linkflags.diff
2014-12-05 09:20Brad KingNote Added: 0037394
2014-12-05 09:28Brad KingNote Added: 0037395
2014-12-05 13:18Brad KingRelationship addedrelated to 0014991
2014-12-08 09:01Brad KingNote Added: 0037403
2014-12-08 09:01Brad KingStatusassigned => resolved
2014-12-08 09:01Brad KingResolutionopen => fixed
2014-12-08 09:01Brad KingFixed in Version => CMake 3.2
2015-05-04 09:05Robert MaynardNote Added: 0038694
2015-05-04 09:05Robert MaynardStatusresolved => closed

Notes
(0037044)
Arch D. Robison   
2014-10-17 15:28   
I ran into this issue with Intel MPI 5.0.1 and RHEL 7.0.
(0037054)
Brad King   
2014-10-20 09:31   
Currently there is no maintainer for the FindMPI module:

 http://www.cmake.org/Wiki/CMake:Module_Maintainers [^]
(0037108)
Brad King   
2014-10-30 12:26   
For reference, here is a mailing list thread with Kelly's proposed patch:

 Proposed patch for FindMPI.cmake (Intel MPI)
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/11466 [^]
(0037374)
Brad King   
2014-12-04 08:41   
Another mailing list thread about this:

 FindMPI and Intel MPI
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/11823 [^]
(0037377)
RolandSchulz   
2014-12-04 09:30   
This has been fixed in Intel MPI 5.0.2
(0037380)
Alin M Elena   
2014-12-04 11:06   
Indeed 5.0.2 seems to have no issue in finding the correct c++ and c details... only fortran fails...

Maybe I shall open a separate bug?
(0037381)
Brad King   
2014-12-04 11:22   
Re 0015182:0037380: No separate issue needed. The FindMPI module may need a change for this issue regardless of to which language it applies.

Even if upstream Intel MPI is fixed it would be nice to support the broken versions if possible anyway. The thread linked in 0015182:0037108 has a patch and my review of it. That would be a good starting point for continuing work on a workaround.
(0037383)
Alin M Elena   
2014-12-04 13:49   
There are three issues I see

1. Failure to detect undefined reference. I attached patch based on KT and Brad suggestions.
2. Failure to use the wrapper as a compiler and skip the detection via interrogation.
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 gone, but I think we shall not rely on user.)
(0037384)
Alin M Elena   
2014-12-04 13:52   
the patch I have spoken above is doublecheckerror.diff
(0037385)
Alin M Elena   
2014-12-04 14:01   
patch for issue 2. usecompilerewrapper.diff
shall be applied after first patch.
(0037386)
Brad King   
2014-12-04 14:18   
Re 0015182:0037384: Thanks. I've factored the first patch out into:

 0001-FindMPI-Factor-out-compiler-wrapper-execution-into-h.patch
 0002-FindMPI-Workaround-Intel-MPI-5.0.1-exit-code-problem.patch

with some minor revisions. Please test these.
(0037391)
Alin M Elena   
2014-12-04 16:28   
Thanks Brad! Tested it seems to work, fixes issue 1.
now we are ready for issue 2.
and one more issue.

4. the linker information is not parsed, see below


-- 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
(0037392)
Alin M Elena   
2014-12-04 17:22   
patch for issue 4 (2 too) linkflags.diff
(0037394)
Brad King   
2014-12-05 09:20   
Re 0015182:0037391: Thanks for testing. I've integrated the first round of patches:

 FindMPI: Factor out compiler wrapper execution into helper
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f5ede300 [^]

 FindMPI: Workaround Intel MPI 5.0.1 exit code problem
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7626c8dc [^]
(0037395)
Brad King   
2014-12-05 09:28   
Re 0015182:0037392: Thanks. I think these other fixes may take a few iterations so let's move discussion back to the dev list. Please use Git to create a commit and "git format-patch" to construct a patch with author/date/message/etc. and send to the list.
(0037403)
Brad King   
2014-12-08 09:01   
I'm resolving this issue because the originally reported problem has been addressed. Alin, please bring remaining patches to the developer mailing list as requested in 0015182:0037395.
(0038694)
Robert Maynard   
2015-05-04 09:05   
Closing resolved issues that have not been updated in more than 4 months.