OpenMP Mex files : static TLS problem
Mostra commenti meno recenti
Recent versions of Matlab have a problem with running out of DTV slots for shared libraries loaded at runtime with the "initial-exec" TLS option.
Unfortunately the omp libs (libgomp / libiomp) are all use initial-exec for performance reasons.
They may work, but often the "static TLS" error from Matlab results, eg if some commands like 'doc' or other modules are loaded before hand.
More information here:
http://stackoverflow.com/questions/19268293/matlab-error-cannot-open-with-static-tls http://www.mathworks.de/support/bugreports/961964 http://www.mathworks.com/support/bugreports/1003952
This is really a devastating regression for my work (there was no problem at all with versions R2012a and earlier) and I am desperately looking for any sort of workaround.
At the moment the only thing I can think to try is to build my own GCC toolchain with libgfortran, libgomp etc. with fPIC and libgomp without initial-exec... so I can link everything statically into my mex file. But I understand this could have serious performance consequences for the openmp code which sort of defeats the point.
Is there any way then to use OpenMP within mex files? (is there a way to link against Matlab's libiomp?
Risposta accettata
Più risposte (2)
Martijn
il 6 Giu 2017
1 voto
If you want to make use of OpenMP, please follow this workflow:
where you do not use libgomp at all and instead use libiomp which is included with MATLAB. This a) prevents static TLS issues with libgomp and b) provides better compatibility (e.g. a MEX-file linked against libiomp can be cleared whereas MEX-files linked against libgomp may cause a crash when cleared (this is a libgomp, not a MATLAB issue, libgomp was never designed to be unloaded from a process)).
1 Commento
David Rigie
il 6 Dic 2017
I am interested in the solution linked above, but the link appears to be broken now. Do you have another reference explaining the described workflow?
Sergio Duarte
il 3 Apr 2020
0 voti
If you want you can look this:
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!