Linux – How to check if libfftw3_threads.so.3.2.4 shared library was compiled for pthreads or for OpenMP

librarieslinux

There is FFTW library installed by an administrator system-wide, in /usr/lib64, and it includes /usr/lib64/libfftw3_threads.so.3.2.4.

When I compiled this library myself, before it was installed by sysadmin, I have noticed that you have to choose between OpenMP and pthreads version:

  • --enable-openmp: Like --enable-threads, but using OpenMP compiler directives in order to induce parallelism rather than spawning its own threads directly. Useful especially for programs already employing such directives, in order to minimize conflicts between different parallelization mechanisms. Use either --enable-openmp or --enable-threads, not both; in either case the multi-threaded FFTW interface/library (see Multi-threaded FFTW) is compiled (with different back ends).

The distribution is Gentoo, so theoretically either is possible.

How to check if said library was compiled with OpenMP support (which would be best), or with pthreads?

Best Answer

You can check whether the library is linked against pthread at least by using ldd. On Debian squeeze, my version is linked against pthread.

$ ii  libfftw3-3      3.2.2-1      library for computing Fast Fourier Transforms

$ ldd /usr/lib/libfftw3_threads.so.3.2.4
linux-gate.so.1 =>  (0xb77be000)
libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb776c000)
libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb7753000)   <---
libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb760c000)
/lib/ld-linux.so.2 (0xb77bf000)

Based on a quick net search, it looks like the program would have to link against the GCC OpenMP support library (GOMP) for OpenMP support, so you could use ldd to check for something with "libgomp" in it as well.