Hi,
I know this problem is known and i know that apparently the libiomp5.a library is designed intentionally not to work in shared objects. The point is that i would need this behaviour and i would appreciate intel allowing this possibility.
I explain my problem: i am building a python extension in c and i am trying to use openmp and mkl_lapacke. They both rely on libiomp5.so and so my c-program initialize such lib at its first parallel region.
On the other hand at a higher level i use python and in particular i use the numpy module for several calculations. Now it happens that numpy is built using mkl and thus it also initialize libiomp5.so
This creates a wonderful runtime error of the type:
OMP: Error #15: Initializing libiomp5.so, but found libiomp5.so already initialized.
OMP: Hint: This may cause performance degradation and correctness issues. Set environment variable KMP_DUPLICATE_LIB_OK=TRUE to ignore this problem and force the program to continue anyway. Please note that the use of KMP_DUPLICATE_LIB_OK is unsupported and using it may cause undefined behavior. For more information, please see http://www.intel.com/software/products/support/
It took me a while to figure out this was the problem but now it is clear. Setting KMP_DUPLICATE_LIB_OK is not an option i am doing calculations and i have to be reasonably sure about the results. I could make my program work compiling with gcc that links to the gomp library and for the linear system solver i used openblas. In this way my program is not calling at all libiomp5, but only numpy is doing that. No double initialization occurs.
Now the point is that i would like to use mkl_lapacke and intel compiler for my program, instead. To do this i think a solution would be to link statically libiomp5.a inside my program so that numpy and my extension work on different copies of libiomp5 library and they do not try to double initialize the same one.
So, to conclude, why is libiomp5.a library designed to not work in shared objects? And what would be the way to avoid the double initialization otherwise?
As python is interpreted, every imported module loads its own shared libs and there is no way (as far as i know) that two python modules can know they are using the same shared library.
Thanks,
Regards,
Riccardo