On Tue, Apr 29, 2014 at 5:53 AM, Alan Bromborsky <[email protected]> wrote: > On 04/29/2014 03:13 AM, Joachim Durchholz wrote: >> >> Am 25.04.2014 18:13, schrieb Alan Bromborsky: >>> >>> Has anyone had any experience in using parallel python with sympy. It >>> seems to me that there are probably a lot of loops that have independent >>> operations. >> >> >> I'm unsure whether it's possible. >> >> Multithreading becomes problematic as soon as you have shared updatable >> data structures. >> >> Parallelizing stuff within a SymPy computation would require explicitly >> forking off threads in the various algorithms; I do not think SymPy does >> that. >> I'm not sure whether SymPy's expression transformation algorithms do >> in-place updates or construct new trees. If it's the former, any attempt at >> parallelization will crash horribly. >> >> A potentially huge, potentially nonexistent problem are SymPy's value >> caches. SymPy creates considerable amounts of precalculated constants - Pi, >> a prime sieve, known integrals, that kind of stuff. Creation happens >> on-demand; I do not know what happens if two threads try to create the same >> constant at the same time. Possible outcomes: >> - Just duplicate effort, everything works. >> - Duplicate effort and constant is stored twice (some constants are large, >> so that's not so good but workable - this MIGHT break code that compares >> against these constants using == though). >> - Things crash horribly (but at least you know that it failed). >> - Silent errors, wrong results. >> > Would that be true for basic algebraic manipulation (the core?) > simplification, and calculating derivatives.
Parallelization is another area where CSymPy can make make a difference --- it's pure C++, so there are no issues with Python. So the underlying basic algebraic manipulation (the core) can be parallelized. If anybody is interesting in trying this out, send us PRs, or ask for help with this. I suspect some of the algorithms are memory bound, so there might not be much speedup, but I am sure there are many algorithms that can be parallelized easily. Ondrej > >> Since SymPy is CPU-bound, Python implementations that use the global >> interpreter lock might see a minimal speedup (thread A continues while >> thread B waits for a file operation) -> not worth it. >> Other Python implementations might work better. Still, the common caches >> are going to create lock contention between threads, at least initially >> while SymPy is still creating constants; later on, when the constants are >> read-only, this should become a nonissue, so use large-ish problems when >> benchmarking. >> >> (Sorry for jumping in so late, I missed the original question.) >> > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/535F92BA.5060806%40verizon.net. > > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CADDwiVArM9jMS_NYvbVrGXFytz4Zomz1h7B747-ArQPW4UMv8g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
