Problems with multithreading

Hello everyone,

I have to integrate (link) my routines to commercial software which was compiled with Sun One Studio 9. I have a reference version compiled several months ago working just fine. After recent updates on our Sun Fire 15K StarCat (Solaris 9) managed by our administrators I tried to recompile my version and multithreading stopped working ?it runs with one thread whatever I do. During compilation I used the same script, the same functions, compiler etc. When I checked the library dependency through ldd command I found out that my newly created build depends on /usr/lib/64/libpthread.so.1 and lib/sparcv9/libmtsk.so.1 while my older, perfectly working, does not (both builds depend on libthread.so.1). That was the only discrepancy. Our administrators were not able to track the source of the problem. Could anyone explain me what might have happened and how I can get this fixed. I will very appreciate any feedback!

Kind regards,

Artem

[979 byte] By [artkul] at [2007-11-26 11:27:42]
# 1

When you buld a multithreaded application, every cc and CC command line must include the -mt option. That option will automatically cause the program to be liked with the threading library (except when building shared libraries, when you must explicitly list every library that is needed).

If the program includes any C++ code, use CC to perform the link step(s). If it contains only C code, use cc to perform the link step(s).

I f the application uses pthreads, add the option

-lpthread

to each link command.

If that doesn't fix the problem, please show the complete command line that builds any shared libraries that you create, and the final link command.

clamage45 at 2007-7-7 3:43:20 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

Thank you, Stephen,

These are the options supplied to the linker (in two pieces). As you might see 杕t option is enabled and 杔threads only is set. I used these options already to create a successfully working program run nicely in parallel.

flink3d="CC -V -v -mt -native -dalign -ftrap=%none \

-libmil -fsimple=0 -xO3 -xtarget=ultra -xarch=v9b \

-xopenmp -xcheck=stkovf \

-L/usr/lib/lwp/sparcv9 -R/usr/lib/lwp/sparcv9 \

-L$Cpath/$SYSDIR \

-L$OPENWINHOME/lib/sparcv9 -L/usr/lib/sparcv9 \

-L/usr/ucblib/sparcv9 -L/usr/dt/lib/sparcv9 \

-L$path/$SYSDIR -L/opt/SUNWspro/lib/v9 \

-L/opt/SUNWspro/lib/v9b"

lopns3d=" -lGL -lGLU -lXm -lXt -lX11 -lnsl -lsocket \

-L/opt/SUNWspro/lib/v9b -xlic_lib=sunperf \

-lintl -lrt -ldl -lmtsk -lsunmath -lfsu -lfai2 -lfui -lthread"

I wonder why the newly created build depends on pthreads although I do not explicitly state this and my old working build created with the very same settings is pthreads independent.

Additional info: the program I link to is provided with a set of precompiled libraries written in Fortran, C and Cpp. Pthreads are not used on Sun US-III according to developers but only on HP servers.

Between creating working and non-working build we installed Sun One Studio 11 and got through unsuccessful attempt to install Solaris 10 (we rolled back to Solaris 9).

printenv PATH:

/usr/local/app/forte9/SUNWspro/bin:/usr/ccs/bin:/usr/local/teTeX/bin/sparc-sun- solaris2.9:/usr/local/xmgr/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin :/usr/dt/bin:/usr/ucb:/opt/SUNWhpc/HPC6.0/bin:/usr/openwin/bin:/usr/local/app/tm a/bin:/usr/local/app/Acrobat4/bin:/opt/CTEact/bin:/usr/local/staroffice7:/opt/SU NWut/bin:/opt/SUNWut/sbin:/usr/sfw/bin:/usr/sfw/sbin:/usr/dapp/aplac/bin:/usr/lo cal/app/forte9/SUNWspro/bin:/stripe1/artkul/ansys10/v100/ansys/bin/usIII:/stripe 1/artkul/ansys10/v100/ansys/bin/

printenv LD_LIBRARY_PATH

/usr/local/app/forte9/SUNWspro/lib:/usr/ccs/lib:/usr/j2se/lib:/usr/lib:/lib:/us r/local/ssl/lib:/usr/dt/lib:/opt/SUNWhpc/HPC6.0/lib:/usr/openwin/lib:/usr/local/ app/tma/lib:/usr/sfw/lib:/usr/dapp/aplac/lib:/usr/local/lib/sparcv9:/stripe1/art kul/ansys10/v100/ansys/syslib/usIII/:/stripe1/artkul/ansys10/v100/ansys/lib/usII I/:/stripe1/artkul/ansys10/v100/commonfiles/Tcl/lib/usIII

output from ddl:

libansys.so=> /stripe1/artkul/ansys10/v100/ansys/lib/usIII//libansys.so

libansysb.so=> /stripe1/artkul/ansys10/v100/ansys/lib/usIII//libansysb.so

libansysx.so=> /stripe1/artkul/ansys10/v100/ansys/lib/usIII//libansysx.so

libmnf.so => /stripe1/artkul/ansys10/v100/ansys/lib/usIII//libmnf.so

libcadoe_core.so => /stripe1/artkul/ansys10/v100/ansys/lib/usIII//libcadoe_core.so

libcif.so => /stripe1/artkul/ansys10/v100/ansys/lib/usIII//libcif.so

libz.so=> /stripe1/artkul/ansys10/v100/commonfiles/Tcl/lib/usIII/libz.so

libpng.so => /stripe1/artkul/ansys10/v100/commonfiles/Tcl/lib/usIII/libpng.so

libtiff.so=> /stripe1/artkul/ansys10/v100/commonfiles/Tcl/lib/usIII/libtiff.so

libjpeg.so=> /stripe1/artkul/ansys10/v100/commonfiles/Tcl/lib/usIII/libjpeg.so

libGL.so.1=> /lib/sparcv9/libGL.so.1

libGLU.so.1=> /lib/sparcv9/libGLU.so.1

libXm.so.4=> /lib/sparcv9/libXm.so.4

libXt.so.4=> /lib/sparcv9/libXt.so.4

libX11.so.4=> /lib/sparcv9/libX11.so.4

libnsl.so.1=> /lib/sparcv9/libnsl.so.1

libsocket.so.1=> /lib/sparcv9/libsocket.so.1

libsunperf.so.5=> /stripe1/artkul/ansys10/v100/ansys/syslib/usIII//libsunperf.so.5

libfui.so.1=> /stripe1/artkul/ansys10/v100/ansys/syslib/usIII//libfui.so.1

libfai.so.2=> /stripe1/artkul/ansys10/v100/ansys/syslib/usIII//libfai.so.2

libfsu.so.1=> /stripe1/artkul/ansys10/v100/ansys/syslib/usIII//libfsu.so.1

libmtsk.so.1=> /lib/sparcv9/libmtsk.so.1 (*)

libsunmath.so.1=> /stripe1/artkul/ansys10/v100/ansys/syslib/usIII//libsunmath.so.1

libintl.so.1=> /lib/sparcv9/libintl.so.1

librt.so.1=> /lib/sparcv9/librt.so.1

libdl.so.1=> /lib/sparcv9/libdl.so.1

libfai2.so.2=> /stripe1/artkul/ansys10/v100/ansys/syslib/usIII//libfai2.so.2

libthread.so.1=> /usr/lib/lwp/sparcv9/libthread.so.1

libCstd.so.1=> /lib/sparcv9/libCstd.so.1

libCrun.so.1=> /lib/sparcv9/libCrun.so.1

libm.so.1 => /lib/sparcv9/libm.so.1

libc.so.1 => /lib/sparcv9/libc.so.1

libw.so.1 => /lib/sparcv9/libw.so.1

libf77compat.so.1 => /stripe1/artkul/ansys10/v100/ansys/syslib/usIII//libf77compat.so.1

libXmu.so.4=> /usr/openwin/lib/sparcv9/libXmu.so.4

libXext.so.0=> /usr/openwin/lib/sparcv9/libXext.so.0

libdga.so.1=> /usr/openwin/lib/sparcv9/libdga.so.1

libSM.so.6=> /usr/openwin/lib/sparcv9/libSM.so.6

libICE.so.6=> /usr/openwin/lib/sparcv9/libICE.so.6

libmp.so.2=> /usr/lib/64/libmp.so.2

libpthread.so.1=> /usr/lib/64/libpthread.so.1 (*)

libaio.so.1=> /usr/lib/64/libaio.so.1

libmd5.so.1=> /usr/lib/64/libmd5.so.1

/usr/platform/SUNW,Sun-Fire-15000/lib/sparcv9/libc_psr.so.1

/usr/platform/SUNW,Sun-Fire-15000/lib/sparcv9/libmd5_psr.so.1

(*) - does not present in the old working version

Thank you again!

Kind regards,

Artem

artkul at 2007-7-7 3:43:20 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3
Hi,I think that libmtsk.so (microtask library) is used by openmp and depends on pthread. If it is possible, try to test it without openmp to be sure that its problem.
Olda79 at 2007-7-7 3:43:20 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4
Olda, thank you! It did solve the problem! To be precise I removed -L/usr/lib/lwp/sparcv9 and -lmtsk and everything got back to normal!
artkul at 2007-7-7 3:43:20 > top of Java-index,Development Tools,Solaris and Linux Development Tools...