The attached example program hangs after it finishes (0% CPU usage), but doesn't quit back to shell.
The critical part is that a call to "cblas_sgemm" is followed by a call to "system".
I'm new to using MKL, so perhaps I'm not linking correctly, or making some other stupid mistake.
I'm using GCC (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2 to compile and link this as follows:
gcc -static -I/home/t/local/intel_mkl/mkl/include -o mkl_hangs mkl_hangs.c -L/home/t/local/intel_mkl/composerxe-2011.4.191/mkl/lib/intel64 -L/home/t/local/intel_mkl/lib/intel64 -lmkl_intel_lp64 -Wl,--start-group -lmkl_intel_thread -lmkl_core -Wl,--end-group -liomp5 -fopenmp
(This is on Ubuntu 11.04, AMD64, and /home/t/local/intel_mkl is where I installed MKL)
Please let me know if you can or cannot reproduce this behavior, and thanks in advance for any suggestions!
[bash][mecej4@login2 LANG]$ . /opt/intel/Compiler/11.1/072/bin/iccvars.sh ia64 [mecej4@login2 LANG]$ icc -mkl hang.c [mecej4@login2 LANG]$ ./a.out 0.000000 F51 cmplx.cxx hang.c perfs.f90 test.bin MP correct hashtbl.f90 pptr.f90 tsc.f90 Makefile d2.F hola.f90 prob.f90 tst.f90 Pemb dpotrx.c hola.tgz psx.f90 vfe.f90 a.out dstx.c ibug.f90 pth.f90 wang.f90 allo.f90 dstxda.c kr.f90 rci.F zb.c archive.zip error makefile.moelle rci.F90 zb.f90 bend.f escribir.f90 moelle.f90 rndg.f90 zb1.f90 bob.f90 example.tar moelle.ftn side.f90 zd.f90 bugmod.f90 ffunc.f90 pc_checkcgsmks__genmod.f90 splt.f90 cmain.c gemm.cpp pc_makelowercase__genmod.f90 str.f90[/bash]
"/bin/ls" definitely exists. In fact it runs, and "system" returns. I suspect some kind of memory/stack corruption (possibly related to the threading libraries and static linking), which is why the program doesn't quit.
By the way, it seems that you compiled with ICC. I'm seeing this problem while I'm compiling with GCC.
I get exactly the same problem while doing dynamic linking, which is simpler:
gcc -I/home/t/local/intel_mkl/mkl/include -o mkl_hangs mkl_hangs.c -L/home/t/local/intel_mkl/composerxe-2011.4.191/mkl/lib/intel64 -L/home/t/local/intel_mkl/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -fopenmp -lm
Anyone with a 64-bit Linux care to try to reproduce this?
I can see several problems here but your example works OK on my Linux.
1) it's not good to link with both OpenMP libraries: -liomp5 -fopenmp
2) Link line should use groupping for MKL-libs (try Intel MKL Link Line Advisor)
3) For -fopenmp please also try -lmkl_gnu_thread instead of -lmkl_intel_thread
4) -static option will need static libpthread but some OSes do not have it
Please try something like as followsif you need static linking :
gcc-I/home/t/local/intel_mkl/mkl/include -o mkl_hangs mkl_hangs.c -L/home/t/local/intel_mkl/composerxe-2011.4.191/mkl/lib/intel64 -L/home/t/local/intel_mkl/lib/intel64 -Bstatic -Wl,--start-group -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group -liomp5 -Bdynamic -lpthread -lm
or for dynamic linking
gcc -I/home/t/local/intel_mkl/mkl/include -o mkl_hangs mkl_hangs.c -L/home/t/local/intel_mkl/composerxe-2011.4.191/mkl/lib/intel64 -L/home/t/local/intel_mkl/lib/intel64-Bdynamic -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm
It's strange however, that icc code fails. Please try intel-threads with icc.
I mean use icc in the case (2) above.
Also, it's interesting that cases (3) and (4) fail. I'll try to reproduce them.
As to your note (b) you could manually substitute correct path to the static libmkl_intel_lp64 library...