[GiNaC-list] is ginac thread safe for this case?
jensv at nikhef.nl
Sun Jun 13 11:50:35 CEST 2010
Am 13.06.2010 11:22, schrieb Alexei Sheplyakov:
>> will ginac be thread safe for this case?
> GiNaC is not thread safe. Therefore one can use GiNaC only from one thread.
>> 1) threads access diferent expressions which are independant
>> 2) each thread will increase the expression its working in.. for example
>> thread1...expression1 += x+y thread2.... expression2 += 2*x.... and so
>> 2) no function evaluation is done never.
>> 3) however, all expressions share the same global symbols ( eg, expressions
>> made of global symbols x and y ).
>> 4) threads access the same common matrix of expressions, but two threads
>> will never access the same cell.
You avoided already a lot of possible problems with that list (also stay
away from integrate(), archiving, output modifiers).
But things like tensor objects, which you probably don't use, and gcd,
which you might use implicitly, use static local variables that make
these internal ginac functions non-reentrant (it probably works most of
the time, though, but hey, it's russian roulette). This ginac code could
actually be made thread-safe, I think. But at the moment it isn't.
And then there is libcln you are also relying on and which is also not
thread-safe. Whether you get problems with the numerics in your
expressions depends very much on the specific numbers in your
expression. Maybe you were lucky using just small integers (I am not an
expert with libcln)?
More information about the GiNaC-list