Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-threading #26

Open
JoergRambau opened this issue Apr 25, 2020 · 2 comments
Open

Multi-threading #26

JoergRambau opened this issue Apr 25, 2020 · 2 comments

Comments

@JoergRambau
Copy link

Dear qsopt_ex team,

I am Jörg Rambau from the university of Bayreuth. I am writing this as the author of TOPCOM. I have successfully built an interface to qsopt_ex for regularity checks of triangulations of point configurations, usable as an alternative to cddlib (Fukuda). However, using separate instances of the exact solver in multiple threads crashes the program in random places. It seems at first sight that the gmp memory management is global in qsopt_ex and not thread-safe.

My question is: is qsopt_ex expected to be thread-safe and I have made a mistake somewhere, or is it clear that several instances of the exact solver running in parallel threads will not work?

For my purpose, it would be the best if I could enforce the call of completely separate instances of the exact solver running lock-free, e.g., by thread-local storage for the global data. I have experimented with this myself, but it seems that "__thread", while making builtin types like "int" thread-local, fails to make mpq-structures from gmp thread-local. I also tried to compile qsopt_ex with c++ using "thread_local", but all the untyped preprocessor magic does not go through in c++.

I am developing mostly in Apple clang version 11.0.3 (clang-1103.0.32.59) and in various versions of gcc on ubuntu Linux, standard c++11.

Thanks a lot for clarifying!
Jörg

@jonls
Copy link
Owner

jonls commented Jun 14, 2020

Hi Jörg, I believe qsopt_ex is probably not thread-safe although I have not been involved in the original development of qsopt_ex and it's been a while since I looked at the code (as mentioned in the README I've simply forked the original qsopt_ex release to make some small improvements). The GMP docs mention that certain functions are not thread-safe and it appears some of these at least are used in the qsopt_ex code: https://gmplib.org/manual/Reentrancy. If you're interested in making some changes to improve multithreading compatibility, I'd be interested in merging those though I don't have a whole lot of time to get involved in improving stuff myself right now.

@JoergRambau
Copy link
Author

JoergRambau commented Jun 16, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants