Intel® MPI Library
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.

Intel MPI wrappers new-dtags

LorisErcole
초급자
1,373 조회수

Hello, I'm using Intel MPI 2021.10, and I noticed that the MPI wrappers like mpiicpc always set --enable-new-dtags

if [ "$no_rpath" = "yes" ]; then
    rpath_opt="-Xlinker --enable-new-dtags"
else
    rpath_opt="-Xlinker --enable-new-dtags -Xlinker -rpath -Xlinker \"${libdir}${MPILIBDIR}\" -Xlinker -rpath -Xlinker \"${libdir}\""
fi

which can have the unintended  consequence of using RUNPATH instead of RPATH when linking to other libraries.

What is the reason for doing so? And would there be any side effect if we were to use --disable-new-dtags instead?

Thank you.

-Loris

레이블 (1)
  • MPI

0 포인트
2 응답
LorisErcole
초급자
1,201 조회수

I understand that --enable-new-dtags ensures the linker uses RUNPATH instead of RPATH, which allows LD_LIBRARY_PATH to take precedence at runtime.

However, I am in a scenario where I would like to use RPATH to ensure reproducibility in an environment where different versions of the same library may be installed. I found that if I use --disable-new-dtags flag, the MPI wrapper overrides it.
Here is a simple reproducer:

$ mpiicpx -Xlinker --disable-new-dtags -Wall -Wextra -Wl,-rpath,$MKLROOT/lib/intel64 -o matrix_mult_mpi matrix_mult_mpi.cpp -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl

results in an executable with RUNPATH:

$ readelf -d matrix_mult_mpi
Dynamic section at offset 0x53d20 contains 34 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libmkl_intel_ilp64.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libmkl_sequential.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libmkl_core.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libmpicxx.so.12]
 0x0000000000000001 (NEEDED)             Shared library: [libmpifort.so.12]
 0x0000000000000001 (NEEDED)             Shared library: [libmpi.so.12]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000001d (RUNPATH)            Library runpath: [/software/imkl/2023.2.0/mkl/2023.2.0/lib/intel64:/software/impi/2021.10.0-intel-compilers-2023.2.1/mpi/2021.10.0/lib/release:/software/impi/2021.10.0-intel-compilers-2023.2.1/mpi/2021.10.0/lib]
...

The reason being the way the mpiicpx command expands:

$ mpiicpx -Xlinker --disable-new-dtags -Wall -Wextra -Wl,-rpath,$MKLROOT/lib/intel64 -o matrix_mult_mpi matrix_mult_mpi.cpp -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl -show

icpx -Xlinker '--disable-new-dtags' '-Wall' '-Wextra' '-Wl,-rpath,/software/imkl/2023.2.0/mkl/2023.2.0/lib/intel64' -o 'matrix_mult_mpi' 'matrix_mult_mpi.cpp' '-lmkl_intel_ilp64' '-lmkl_sequential' '-lmkl_core' '-lpthread' '-lm' '-ldl' -I"/software/impi/2021.10.0-intel-compilers-2023.2.1/mpi/2021.10.0/include" -L"/software/impi/2021.10.0-intel-compilers-2023.2.1/mpi/2021.10.0/lib/release" -L"/software/impi/2021.10.0-intel-compilers-2023.2.1/mpi/2021.10.0/lib" -Xlinker --enable-new-dtags -Xlinker -rpath -Xlinker "/software/impi/2021.10.0-intel-compilers-2023.2.1/mpi/2021.10.0/lib/release" -Xlinker -rpath -Xlinker "/software/impi/2021.10.0-intel-compilers-2023.2.1/mpi/2021.10.0/lib" -lmpicxx -lmpifort -lmpi -ldl -lrt -lpthread

because -Xlinker --enable-new-dtags is appended to the original command, along with the flags for MPI libraries.

Is there a way to avoid this behavior and ensure that --enable-new-dtags is not introduced by the wrappers?

Thank you.

0 포인트
TobiasK
중재자
1,094 조회수

@LorisErcole 
the compiler wrappers are for convenience, you can just use the compiler directly and define your own linking and compiling options.

Most users are using LD_LIBRARY_PATH in an environment where multiple versions exists. 

0 포인트
응답