[GiNaC-list] How (not) thread-safe is ginac?

Jens Vollinga jensv at nikhef.nl
Sun Nov 23 13:22:50 CET 2008


Hi,

just some short comments:

Thomas Bächler schrieb:
> I am planning to use ginac for mathematic implementations which can (and
> should) be parallelized. However, I found hints that ginac is not
> thread-safe. The only thing in the source code was here:
> http://www.ginac.de/ginac.git?p=ginac.git;a=blob;f=ginac/ptr.h

no, it isn't thread safe.

> If I understand this right, the reference counting should be protected
> by mutexes and one would have to think of a way to avoid certain race
> conditions with makewritable(). What else is there in ginac that would
> need to be changed for thread-safety?

reference counting is one (important) place. Symbols get numbers 
assigned internally. This is also not thread-safe. Another source of 
problems are the look-up tables for the numeric evaluation of certain 
functions.

> Note that I do not plan to share any objects but only the symbols I use
> between threads, so I probably could (temporarily) work with a version
> that is only partially thread-safe.

If you write a thread-safe symbol factory as an intermediate interface 
it might work.

Regards,
Jens


More information about the GiNaC-list mailing list