[mvapich-discuss] --enable-threads=single causes mpicc to miss -lpthread, breaking ptmalloc at link-time

Jeff Hammond jeff.science at gmail.com
Thu Oct 24 14:11:33 EDT 2013


It seems that ptmalloc depends upon pthreads unconditionally but
configuring MVAPICH to support only single-threaded usage removes
-lpthread from mpicc, hence one cannot link an MPI program using
mpicc.  Manually inserting -lpthread at the end of the link line
resolves the problem and suggests the trivial solution in MVAPICH.

As a temporary solution, I will rebuild MVAPICH with
--enable-threads=runtime, but I prefer to avoid any runtime overhead
if possible.

My "fast" build options work just fine with MPICH right now so this is
an MVAPICH bug, which makes sense since MPICH does not use ptmalloc
internally.

Thanks,

Jeff

[jhammond at login1 oshmpi]$ mpichversion MVAPICH2 Version:     	2.0a
MVAPICH2 Release date:	Fri Aug 23 13:38:52 EDT 2013
MVAPICH2 Device:      	ch3:mrail
MVAPICH2 configure:   	CC=gcc CXX=g++ --enable-fc FC=gfortran
--enable-f77 F77=gfortran --with-pm=hydra --enable-mcast
--prefix=/soft/libraries/mpi/mvapich/3.0.a/gcc-fast --enable-static
--enable-fast=O3,nochkmsg,notiming,ndebug,nompit
--disable-weak-symbols --enable-threads=single
MVAPICH2 CC:  	gcc    -DNDEBUG -DNVALGRIND -O3
MVAPICH2 CXX: 	g++   -DNDEBUG -DNVALGRIND -O3
MVAPICH2 F77: 	gfortran   -O3
MVAPICH2 FC:  	gfortran   -O3

[jhammond at login1 oshmpi]$ mpicc -show
gcc -I/soft/libraries/mpi/mvapich/3.0.a/gcc-fast/include
-L/soft/libraries/mpi/mvapich/3.0.a/gcc-fast/lib -lpmpich -lmpich
-lopa -lmpl -libmad -lrdmacm -libumad -libverbs -lrt -lhwloc -lhwloc

[jhammond at login1 oshmpi]$ mpicc -g -O3 -std=c99 -Wall -I.
-DSHMEM_DEBUG=3     test_start.c -g -O3 -std=c99 -Wall -I.
-DSHMEM_DEBUG=3  libshmem.a -lpthread -o test_start.x
/soft/libraries/mpi/mvapich/3.0.a/gcc-fast/lib/libmpich.a(mvapich_malloc.o):
In function `ptmalloc_init.part.5':
mvapich_malloc.c:(.text+0xd74): undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status

[jhammond at login1 oshmpi]$ gcc  -g -O3 -std=c99 -Wall -I.
-DSHMEM_DEBUG=3     test_start.c -g -O3 -std=c99 -Wall -I.
-DSHMEM_DEBUG=3  libshmem.a
-I/soft/libraries/mpi/mvapich/3.0.a/gcc-fast/include
-L/soft/libraries/mpi/mvapich/3.0.a/gcc-fast/lib -lpmpich -lmpich
-lopa -lmpl -libmad -lrdmacm -libumad -libverbs -lpthread -lrt -lhwloc
 -o test_start.x



-- 
Jeff Hammond
jeff.science at gmail.com


More information about the mvapich-discuss mailing list