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.
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.