[petsc-dev] --known-mpi-shared-library and --with-batch annoyance

Lisandro Dalcin dalcinl at gmail.com
Thu Apr 21 11:51:44 CDT 2016

On 20 April 2016 at 22:09, Barry Smith <bsmith at mcs.anl.gov> wrote:
>    When running with --batch one must provide the flag --known-mpi-shared-library this is annoying since no one will know this
>    I am trying to understand the purpose of this flag. It is used in MPI.py in the code
>   def checkSharedLibrary(self):
>     '''Sets flag indicating if MPI libraries are shared or not and
>     determines if MPI libraries CANNOT be used by shared libraries'''
>     self.executeTest(self.configureMPIEXEC)
>     try:
>       self.shared = self.libraries.checkShared('#include <mpi.h>\n','MPI_Init','MPI_Initialized','MPI_Finalize',checkLink = self.checkPackageLink,libraries = self.lib, defaultArg = 'known-mpi-shared-libraries', executor = self.mpiexec)
>     except RuntimeError, e:
>       if self.argDB['with-shared-libraries']:
>         raise RuntimeError('Shared libraries cannot be built using MPI provided.\nEither rebuild with --with-shared-libraries=0 or rebuild MPI with shared library support')
>       self.logPrint('MPI libraries cannot be used with shared libraries')
>       self.shared = 0
>     return
>    It looks to me like the code says that if MPI is not a shared library then you cannot build PETSc with a shared library.

I don't get what checkShared() is trying to do.

> 1) Is this true? What if MPI was built with PIC but static, won't it still be possible to use it with a PETSc shared library? i.e. is this even the right test?

If MPI is static but PIC, for sure you can build a shared PETSc.

> 2) Is there any way to get rid of this flag or will there be cases were configure goes through with success and accepts using shared libraries but then the build fails with unable to make the PETSc shared library?

To check if you can build a PETSc shared with an MPI static, you just
need to create a shared library with some routine calling eg.
MPI_Init()/Finalize(), not run any code (so the --batch flag is
irrelevant). If MPI is static but not PIC, and you attempt to build
any shared lib, most likely you will get a linker error, no need to
run any executable.

Lisandro Dalcin
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Extreme Computing Research Center (ECRC)
King Abdullah University of Science and Technology (KAUST)

4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 0109
Thuwal 23955-6900, Kingdom of Saudi Arabia

Office Phone: +966 12 808-0459

More information about the petsc-dev mailing list