Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests fail to build: mpi library not linked #47

Closed
drew-parsons opened this issue Feb 16, 2022 · 3 comments
Closed

tests fail to build: mpi library not linked #47

drew-parsons opened this issue Feb 16, 2022 · 3 comments

Comments

@drew-parsons
Copy link
Contributor

For the new v2.2.0, the handling of the fortran compiler was changed in commit #61c60f5 to keep the identity of the fortran compiler (CMAKE_Fortran_COMPILER) separate from the MPI fortran compiler (MPI_Fortran_COMPILER). Previously the mpi wrapper was also used as the plain fortran compiler.

That change makes sense. The serial and mpi variants of the fortran compiler should be handled separately. But it has a consequence on the tests in TESTING. These tests link against -lscalapack, but libscalapack requires libmpi. It's not automatically pulled in, the -lmpi need to be added when compiling the tests.

The tests are currently configured to use the standard compiler (implicitly, CMAKE_Fortran_COMPILER). Before commit #61c60f5, the identification with MPI_Fortran_COMPILER meant that mpifort added the required -lmpi. Now that CMAKE_Fortran_COMPILER is kept separate, gfortran is used without -lmpi, so tests fail to link, giving errors like (in the case of xclu from TESTING/LIN)

/usr/bin/gfortran -Wl,-z,relro -Wl,--as-needed -g -O2 -ffile-prefix-map=/build/scalapack-2.2.0=. -fstack-protector-strong -std=legacy -std=legacy CMakeFiles/xclu.dir/pcludriver.f.o CMakeFiles/xclu.dir/pcluinfo.f.o CMakeFiles/xclu.dir/pcgetrrv.f.o CMakeFiles/xclu.dir/pcmatgen.f.o CMakeFiles/xclu.dir/pmatgeninc.f.o CMakeFiles/xclu.dir/pclaschk.f.o CMakeFiles/xclu.dir/pclafchk.f.o -o ../xclu  -Wl,-rpath,/build/scalapack-2.2.0/build-mpich/lib ../../lib/libscalapack-mpich.so.2.2.0 /usr/lib/x86_64-linux-gnu/liblapack.so /usr/lib/x86_64-linux-gnu/libblas.so /usr/lib/x86_64-linux-gnu/libblas.so 
/usr/bin/ld: ../../lib/libscalapack-mpich.so.2.2.0: undefined reference to `MPI_Barrier'
/usr/bin/ld: ../../lib/libscalapack-mpich.so.2.2.0: undefined reference to `MPI_Waitall'
/usr/bin/ld: ../../lib/libscalapack-mpich.so.2.2.0: undefined reference to `MPI_Send'
/usr/bin/ld: ../../lib/libscalapack-mpich.so.2.2.0: undefined reference to `MPI_Comm_dup'
/usr/bin/ld: ../../lib/libscalapack-mpich.so.2.2.0: undefined reference to `MPI_Irecv'
/usr/bin/ld: ../../lib/libscalapack-mpich.so.2.2.0: undefined reference to `MPI_Isend'
...
collect2: error: ld returned 1 exit status
make[4]: *** [TESTING/LIN/CMakeFiles/xclu.dir/build.make:193: TESTING/xclu] Error 1

I guess the test configuration should be updated so that the tests get compiled using MPI_Fortran_COMPILER

@drew-parsons
Copy link
Contributor Author

Worth noting that C compiler is reset to the MPI wrapper,

SET(CMAKE_C_COMPILER "${MPI_C_COMPILER}")

So commit #61c60f5 (i.e. PR #39 ) makes the handling of fortran discrepant to the handling of C.

@weslleyspereira
Copy link
Collaborator

Hi @drew-parsons. Let me ask on #39.

@ajaypanyala
Copy link
Contributor

Hi @weslleyspereira Sorry, I overlooked the C compiler line being reset to the MPI wrapper. That can be commented too to make it consistent with commit #61c60f5 and update the test configuration as @drew-parsons suggested. I think the fix here is to simply add ${MPI_Fortran_LIBRARIES} to each of the target_link_libraries line in TESTING/LIN/CMakeLists.txt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants