MPI: use library list provided by mpic++ instead of guessing (wrong)

Create issue
Issue #1308 closed
Frank Löffler created an issue

At the moment, ExternalLibraries/MPI guesses that the library list for openmpi is just 'mpi mpi_cxx'. This is wrong in my case (even for the built library; I need additional libraries. The OpenMPI FAQ mentions this: "NOTE: It is absolutely not sufficient to simply add "-lmpi" to your link line and assume that you will obtain a valid Open MPI executable."

They do recommend to use the compiler wrappers. I didn't try that, leaving a patch to a minimum. I would also not be sure how to replace to actual compilers using a thorn while it is supposedly being compiled - after the Cactus configure state (cannot do it before since the wrappers might not be build yet). Thus, I go the second way - also shown in the FAQ: I use mpic++ to get hold of the flags that are needed when linking against the library. This is very similar to what happens for some of the other ExternalLibraries as well (but a bit simpler since they also provide options to just get a list of the libraries, not including the flags themselves - which is what Cactus expects).

In my case, this uses the libraries 'mpi_cxx mpi nsl util m m nsl util m dl openmp'. Especially the missing 'util' in the current list prevented me from linking. Adding it hard to the list however might be wrong on systems where this is not needed or that library might not even exist. (and this isn't the only missing library)

I would like this to be included in the next release, as this would otherwise prevent people from building on at least some of the major Linux distros out of the box (Debian wheezy here) - or we would have to specify the library list by hand for these systems. Given the central part MPI plays I set this to 'major'. If we see problems with this approach we can still guess the missing libraries and try that, until after the release.

OpenMPI FAQ: http://www.open-mpi.org/faq/?category=mpi-apps

Keyword:

Comments (10)

  1. Erik Schnetter
    • changed status to open
    • removed comment

    I just realise that this auto-detection will be executed for all MPI implementations, not just for OpenMPI. These may not support these command line options, although an executable mpic++ will exist. Therefore, instead of checking whether mpic++ is executable, we need to check the return code of calling mpic++ with these options, and/or check whether the result is empty or an error message.

  2. Erik Schnetter
    • removed comment

    The redirection should be

    >/dev/null 2>&1
    

    because otherwise stderr will go to a copy of stdout, which will not be redirected. Try

    cc 2>&1 >/dev/null
    

    to see the effect.

  3. Log in to comment