我正在使用CMake(版本3.20.1)构建ScaLAPACK(提交7e4e07070a489686287c36ab473d21cf29a54bdd
)。find_package
实用程序在CMakeLists.txt
中用于定义使用MPI编译所需的库、包含目录和标志。ScaLAPACK库使用别名MPI::MPI_C
与MPI链接:
target_link_libraries( scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_C)
字符串
我正在构建一个共享库,因此根据CMake default behavior,生成的DSO在其RPATH
中不应该有任何条目。但是,已安装的库DSO在其RUNPATH
中维护以下条目:
$ readelf -d ~/opt/scalapack/lib/libscalapack.so | grep RUNPATH
0x000000000000001d (RUNPATH) Library runpath: [/opt/apps/resif/aion/2020b/epyc/software/UCX/1.9.0-GCCcore-10.2.0/lib64:/usr/lib64:/opt/apps/resif/aion/2020b/epyc/software/OpenMPI/4.0.5-GCC-10.2.0/lib]
型
如果使用find_package
实用程序定义的库变量MPI_C_LIBRARIES
将库与链接,
target_link_libraries( scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MPI_C_LIBRARIES})
型
则在已安装的DSO中没有RUNPATH
条目。
进一步查看CMake生成的Makefile,我注意到以下差异:
- 别名为
MPI::MPI_C
:
# File: <build directory>/CMakeFiles/scalapack.dir/DependInfo.cmake
...
set(CMAKE_Fortran_TARGET_INCLUDE_PATH
"/mnt/irisgpfs/apps/resif/aion/2020b/epyc/software/OpenMPI/4.0.5-GCC-10.2.0/include"
"/opt/apps/resif/aion/2020b/epyc/software/OpenMPI/4.0.5-GCC-10.2.0/include"
)
...
# File: <build directory>/CMakeFiles/scalapack.dir/Dflags.make
...
C_INCLUDES = -isystem /opt/apps/resif/aion/2020b/epyc/software/OpenMPI/4.0.5-GCC-10.2.0/include
C_FLAGS = -O3 -DNDEBUG -fPIC -fexceptions
Fortran_DEFINES = -DAdd_ -Dscalapack_EXPORTS
Fortran_INCLUDES = -I/mnt/irisgpfs/apps/resif/aion/2020b/epyc/software/OpenMPI/4.0.5-GCC-10.2.0/include -I/opt/apps/resif/aion/2020b/epyc/software/OpenMPI/4.0.5-GCC-10.2.0/include
Fortran_FLAGS = -fallow-argument-mismatch -O2 -DNDEBUG -O2 -fPIC -fexceptions
...
# File: <build directory>/CMakeFiles/scalapack.dir/link.txt
/opt/apps/resif/aion/2020b/epyc/software/GCCcore/10.2.0/bin/gfortran -fPIC -fallow-argument-mismatch -O2 -DNDEBUG -O2 -Wl,-rpath -Wl,/opt/apps/resif/aion/2020b/epyc/software/UCX/1.9.0-GCCcore-10.2.0/lib64 -Wl,-rpath -Wl,/usr/lib64 -Wl,-rpath -Wl,/opt/apps/resif/aion/2020b/epyc/software/OpenMPI/4.0.5-GCC-10.2.0/lib -Wl,--enable-new-dtags -L/mnt/irisgpfs/apps/resif/aion/2020b/epyc/software/UCX/1.9.0-GCCcore-10.2.0/lib -L/usr/lib64 -L/mnt/irisgpfs/apps/resif/aion/2020b/epyc/software/OpenMPI/4.0.5-GCC-10.2.0/lib -shared -Wl,-soname,libscalapack.so.2.2 -o lib/libscalapack.so.2.2.1 @CMakeFiles/scalapack.dir/objects1.rsp -Wl,-rpath,/home/users/gkafanas/opt/openblas/lib64: /home/users/gkafanas/opt/openblas/lib64/libopenblas.so -lpthread -lm -ldl /home/users/gkafanas/opt/openblas/lib64/libopenblas.so -lpthread -lm -ldl /opt/apps/resif/aion/2020b/epyc/software/OpenMPI/4.0.5-GCC-10.2.0/lib/libmpi.so
型
- 使用变量
MPI_C_LIBRARIES
:
# File: <build directory>/CMakeFiles/scalapack.dir/DependInfo.cmake
...
set(CMAKE_Fortran_TARGET_INCLUDE_PATH
)
...
# File: <build directory>/CMakeFiles/scalapack.dir/Dflags.make
...
C_INCLUDES =
C_FLAGS = -O3 -DNDEBUG -fPIC
Fortran_DEFINES = -DAdd_ -Dscalapack_EXPORTS
Fortran_INCLUDES =
Fortran_FLAGS = -fallow-argument-mismatch -O2 -DNDEBUG -O2 -fPIC
...
# File: <build directory>/CMakeFiles/scalapack.dir/link.txt
/opt/apps/resif/aion/2020b/epyc/software/GCCcore/10.2.0/bin/gfortran -fPIC -fallow-argument-mismatch -O2 -DNDEBUG -O2 -shared -Wl,-soname,libscalapack.so.2.2 -o lib/libscalapack.so.2.2.1 @CMakeFiles/scalapack.dir/objects1.rsp -Wl,-rpath,/home/users/gkafanas/opt/openblas/lib64: /home/users/gkafanas/opt/openblas/lib64/libopenblas.so -lpthread -lm -ldl /home/users/gkafanas/opt/openblas/lib64/libopenblas.so /opt/apps/resif/aion/2020b/epyc/software/OpenMPI/4.0.5-GCC-10.2.0/lib/libmpi.so -lpthread -lm -ldl /opt/apps/resif/aion/2020b/epyc/software/OpenMPI/4.0.5-GCC-10.2.0/lib/libmpi.so
型
所以看起来别名设置了一些不必要的系统选项。
我有两个问题:
1.别名MPI::MPI_C
是什么以及如何使用它。
1.为什么别名如此设置参数,而有人可能期望它只设置用于将ScaLAPACK DSO与MPI链接的变量。
1条答案
按热度按时间jgovgodb1#
我将间接地回答你的问题。由于CMake的标准化程度很低,我不知道
MPI::MPI_C
是什么,也不知道它是否可以工作。下面是我使用的:字符串
这是一个单一的源文件,但它可以适应自己的用途。