Thanks for every answer,<div><br></div><div>ill have to find a solution for this. i am liking ginac so much that i would have been perfect if this was possible, but its ok !.</div><div>The algorithm is computing intensive (for research).</div>
<div><br></div><div>now i have two options</div><div> i could search for another free symbolic library thread-safe (which for me is unknown, does such library exist?) or </div><div>i could put and end to this and program myself a simple and thread-safe symbol-expression environment for my needs, which are very reduced (i only use polinomies, big in size but in the end they are polinomial expressions).</div>
<div><br></div><div><br></div><div>i guess i dont have anymore questions</div><div>thanks again everyone!<br><div class="gmail_quote">On Sun, Jun 13, 2010 at 10:30 AM, Alexei Sheplyakov <span dir="ltr"><<a href="mailto:alexei.sheplyakov@gmail.com">alexei.sheplyakov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Sun, Jun 13, 2010 at 01:27:26PM +0200, Jens Vollinga wrote:<br>
<br>
> I completely agree with your last sentence! This is what I wrote in<br>
> my last mail<br>
<br>
</div>I'm afraid you've missed the point. I wanted to explain that one of<br>
the essential mechanisms used by GiNaC (memory management) is not thread<br>
safe, therefore all setups (except using GiNaC from one thread) are unsafe.<br>
<div class="im"><br>
> (but maybe you consider Russian roulette not as dangerous as I do ... ;-) ).<br>
<br>
</div>I just think using GiNaC from several threads is more dangerous than<br>
Russian roulette :)<br>
<div class="im"><br>
> I just wanted to explain more than just saying "It doesn't work.".<br>
<br>
</div>Ok, if someone wants the gory details...<br>
<br>
1. Automatic evaluation is not thread safe.<br>
<br>
Have a look at ex::construct_from_basic (which is basically the core<br>
of automatic evaluation). That code does<br>
<br>
318 // If the original object is not referenced but heap-allocated,<br>
319 // it means that eval() hit case b) above. The original object is<br>
320 // no longer needed (it evaluated into something different), so we<br>
321 // delete it (because nobody else will).<br>
322 if ((other.get_refcount() == 0) && (other.flags & status_flags::dynallocated))<br>
323 delete &other; // yes, you can apply delete to a const pointer<br>
324<br>
<br>
The reference counting is not thread safe, so the object can be deleted while<br>
it's used by another thread.<br>
<br>
2. GiNaC smart pointers are not thread safe. In theory it can be fixed<br>
by using atomic integers for reference counting, and locking in<br>
makewritable().<br>
<br>
3. GiNaC uses STL containers to store sums and products. STL containers are<br>
not thread safe at all.<br>
<br>
4. Subs() uses writable access (let_op()), and has no locking at all.<br>
<div class="im"><br>
> I didn't mention refcounting, because I think in his setup it doesn't<br>
> cause a problem, or does it?.<br>
<br>
</div>No matter what your setup is, you're going to use the automatic evaluation<br>
(otherwise you don't need GiNaC at all). And it's not thread safe (due to<br>
reference counting, data structures, etc). So the only safe setup is using<br>
GiNaC from one thread.<br>
<div class="im"><br>
> >Only few symbolic algorithms can be parallelized, and performance gain<br>
><br>
> That might be true for "schoolbook" algorithms like gcd,<br>
> factorization, etc, but not for more complex computational tasks<br>
> involving cascades of manipulation steps performed on large number<br>
> of expressions.<br>
><br>
> >(if any) is not that big. So why bother?<br>
><br>
> Aforementioned tasks can in principle hope for huge performance<br>
> gains depending on the number of cpu cores.<br>
<br>
</div>I'm afraid locks will ruin any performance gains. I mean, if you need to<br>
take a lock every time you need to add two and integers or allocate several<br>
bytes of RAM, you can't achive any reasonable performance.<br>
<br>
<br>
Best regards,<br>
<font color="#888888"> Alexei<br>
</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
GiNaC-list mailing list<br>
<a href="mailto:GiNaC-list@ginac.de">GiNaC-list@ginac.de</a><br>
<a href="https://www.cebix.net/mailman/listinfo/ginac-list" target="_blank">https://www.cebix.net/mailman/listinfo/ginac-list</a><br>
</div></div></blockquote></div><br></div>