optimad / bitpit

Open source library for scientific HPC
http://optimad.github.io/bitpit/
GNU Lesser General Public License v3.0
117 stars 33 forks source link

Can't build with ENABLE_MPI=ON #196

Closed PhMakowski closed 3 years ago

PhMakowski commented 3 years ago

Hi, I have openmpi-devel-4.1.0, petsc-openmpi-devel-3.14.4, gcc-11.1.1 but I can't build bitpit 1.7.1 with ENABLE_MPI ON.

The log is here : https://paste.centos.org/view/cc010a87

the first 2 errors are :

In file included from /home/philippe/github/bitpit/src/LA/system_matrix.hpp:31,
                 from /home/philippe/github/bitpit/src/LA/system_solvers_large.hpp:34,
                 from /home/philippe/github/bitpit/src/LA/system_solvers_large.cpp:31:
/usr/include/openmpi-x86_64/mpi.h:1710:53: error: macro "MPI_Pcontrol" passed 2 arguments, but takes just 1
 1710 | OMPI_DECLSPEC  int MPI_Pcontrol(const int level, ...);
      |                                                     ^
In file included from /home/philippe/github/bitpit/src/LA/system_matrix.hpp:31,
                 from /home/philippe/github/bitpit/src/LA/system_solvers_large.hpp:34,
                 from /home/philippe/github/bitpit/src/LA/system_solvers_large.cpp:31:
/usr/include/openmpi-x86_64/mpi.h:1953:37: error: macro "MPI_Wtick" passed 1 arguments, but takes just 0
 1953 | OMPI_DECLSPEC  double MPI_Wtick(void);
andrea-iob commented 3 years ago

It seems you are compiling bitpit with openmpi-devel-4.1.0, however PETSc is compiled with a different MPI version:

Which distribution are you using? Maybe you will be able to find matching PETSc/MPI packages in the official repositories of your distribution.

PhMakowski commented 3 years ago

Which distribution are you using? Maybe you will be able to find matching PETSc/MPI packages in the official repositories of your distribution. I'm using Fedora with petsc-openmpi-devel and openmpi-devel By the way, under Ubuntu 20, I don't find the correct way to use openmpi and petsc from the package and build bitpit with.

PETSc could not be found.  Be sure to set PETSC_DIR and PETSC_ARCH.
(missing: PETSC_INCLUDES PETSC_LIBRARIES PETSC_EXECUTABLE_RUNS)
PhMakowski commented 3 years ago

Ok, I found the solution under Fedora. you have to change variables to :

cmake -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_MPI=ON -DPETSC_LIBRARIES=/usr/lib64/openmpi/lib/ -DPETSC_INCLUDES=/usr/include/openmpi-x86_64/petsc -DLAPACKE_DIR=/usr/lib64 -DLAPACKE_INCLUDE_DIRS=/usr/include/lapacke -DPETSC_EXECUTABLE_RUNS=/usr/lib64/petsc -DCBLAS_INCLUDE_DIRS=/usr/include/cblas/  ..

instead of (without MPI) :

cmake -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_MPI=OFF -DPETSC_INCLUDES=/usr/include/petsc -DPETSC_LIBRARIES=/usr/lib64 -DPETSC_EXECUTABLE_RUNS=/usr/lib64/petsc -DLAPACKE_DIR=/usr/lib64 -DLAPACKE_INCLUDE_DIRS=/usr/include/lapacke -DCBLAS_INCLUDE_DIRS=/usr/include/cblas/ ..

Under Ubuntu20 with MPI :

 cmake -DENABLE_MPI=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=OFF -DPETSC_EXECUTABLE_RUNS=/usr/lib/petsc -DPETSC_INCLUDES=/usr/include/petsc -DPETSC_LIBRARIES=/usr/lib/petsc  ..

Without MPI :

 cmake -DENABLE_MPI=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=OFF -DPETSC_EXECUTABLE_RUNS=/usr/lib/petsc -DPETSC_INCLUDES=/usr/include/petsc -DPETSC_LIBRARIES=/usr/lib/petsc -DCMAKE_CXX_FLAGS=-isystem\ /usr/include/openmpi/

Yes, the build without MPI need mpi.h ! Strange.

You can close the bug, but maybe it can be put in some doc.

andrea-iob commented 3 years ago

I think the serial version still needs MPI because PETSc in Ubuntu20 seems compiled with MPI support (you are using the same PETSc version for both MPI and non-MPI code, so I think that the PETSc library under /usr/lib/petsc is compiled with MPI support). If you need a MPI-free version, you need to compile PETSc without MPI support (https://www.mcs.anl.gov/petsc/documentation/installation.html see paragraph "Installing without MPI"). Fedora seems to have two different versions of PETSc: /usr/lib64/petsc looks like the serial version, whereas /usr/lib64/openmpi/lib looks like the MPI version.

andrea-iob commented 3 years ago

I'm closing the issue. Feel free to reopen it if you still have problems