Static linking with ta=multicore

Hi,

when I compile an openacc accelerated code with the following:
pgc++ -Bstatic_pgi -Bstatic -ta=multicore -lomp

the binary still contains a dynamic link to libomp.so.
How can I link this library statically?

Kind regards,
Robin

Hi Robin,

I’m assuming you mean without “-Bstatic”, since “-Bstatic” doesn’t include any shared objects.

% pgc++ -Bstatic -ta=multicore -mp test.cpp ; ldd a.out
        not a dynamic executable

For the KMPC OpenMP runtime (libomp), it looks like we either couldn’t include the static library or missed including it when -Bstatic_pgi is set.

Though, it looks correct in 19.10 when using our newer NVOpenMP runtime enabled via “-mp=nvomp”. NVOmp is beta in 19.10 but default as of 20.1.

% pgc++ -Bstatic_pgi -ta=multicore -mp test.cpp ; ldd a.out
        linux-vdso.so.1 (0x00007fff5abc1000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x000015401754d000)
        libomp.so => /proj/pgi/linux86-64-llvm/19.10/lib/libomp.so (0x000015401727c000)
        libstdc++.so.6 => /home/sw/thirdparty/gcc/gcc-9.2.0/linux86-64/lib64/libstdc++.so.6 (0x0000154016e99000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x0000154016c7a000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00001540168dc000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00001540164eb000)
        /lib64/ld-linux-x86-64.so.2 (0x0000154017751000)
        libgcc_s.so.1 => /home/sw/thirdparty/gcc/gcc-9.2.0/linux86-64/lib64/libgcc_s.so.1 (0x00001540162d4000)
% pgc++ -Bstatic_pgi -ta=multicore -mp=nvomp test.cpp ; ldd a.out
        linux-vdso.so.1 (0x00007ffd6917d000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x000014afe5f91000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x000014afe5d72000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x000014afe5b6a000)
        libstdc++.so.6 => /home/sw/thirdparty/gcc/gcc-9.2.0/linux86-64/lib64/libstdc++.so.6 (0x000014afe5787000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x000014afe53e9000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x000014afe4ff8000)
        /lib64/ld-linux-x86-64.so.2 (0x000014afe6195000)
        libgcc_s.so.1 => /home/sw/thirdparty/gcc/gcc-9.2.0/linux86-64/lib64/libgcc_s.so.1 (0x000014afe4de1000)

Please give NVOpenMP a try and let me know if it works for you.

-Mat

Hi Mat,

I am actually using 19.10. Passing “-mp=nvomp” to the linker successfully gets rid off the dynamic link.

Thanks a lot!

Kind regards,
Rob

Hi Mat,

Unfortunately I get some strange behavior when I use “-mp=novmp”. The program hangs randomly for an extended time (>20 s) and the results are also inconsistent.
Do you reckon this is fixed in newer versions (> 19.10)?

Kind regards,
Robin

Do you reckon this is fixed in newer versions (> 19.10)?

Possibly? But without understanding the issue or without a reproducer, I can’t tell for sure.

The NVIDIA HPC 20.5 Early Access SDK (https://developer.nvidia.com/hpc-sdk) (the successor to the PGI compiler) will be available here soon. I’d suggest signing up for the early access and see if that fixes the problem. If not, then let me know and we can arrange a way to get a reproducing example so we can investigate.

-Mat

I signed up for the early access. Since its not an urgent problem I will just test it with the next compiler version.

Regards,
Rob