[GiNaC-list] multithreading

Kraus Philipp philipp.kraus at flashpixx.de
Mon Aug 23 18:13:35 CEST 2010


Am 23.08.2010 um 16:39 schrieb Cristobal Navarro:

> in some cases,
> parallel symbolic algorithms obtain great performance increase, it  
> all depends how you model the problem.
> im using ginac with openMPI to paralelize huge tree generators, i  
> had to go the processes paralelism since multithread is not safe,  
> but would be nice to be able to do that on the future

I' working with MPI (on boost) and in this case it works on my test  
system. But I would like to portage my algorithm without MPI support  
(on a simple desktop system MPI support is not installed, but on these  
systems I can use multithreading).
I have tried to compile ginac with -pthread on CXXFLAGS and the CLN  
library. I analyse the compiled code with valgrind, you can show the  
excerpt:

==51729== Possible data race during write of size 4 at 0x1ea4564 by  
thread #3
==51729==    at 0x3AB9: GiNaC::refcounted::add_reference() (in main)
==51729==    by 0xF7C49F:  
GiNaC::ptr<GiNaC::basic>::ptr(GiNaC::ptr<GiNaC::basic> const&) (in / 
Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0xF7C4B9:  
GiNaC::ptr<GiNaC::basic>::ptr(GiNaC::ptr<GiNaC::basic> const&) (in / 
Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0xF7C4D3: GiNaC::ex::ex(GiNaC::ex const&) (in / 
Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0xF7C4ED: GiNaC::ex::ex(GiNaC::ex const&) (in / 
Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0xF7C51F: GiNaC::expair::expair(GiNaC::expair const&)  
(in /Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0xF7C539: GiNaC::expair::expair(GiNaC::expair const&)  
(in /Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0xF7E4F3: void std::_Construct<GiNaC::expair,  
GiNaC::expair>(GiNaC::expair*, GiNaC::expair const&) (in /Developer/ 
opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)

==51729==    by 0xF7F3E9: GiNaC::expair*  
std 
::__uninitialized_copy_aux<__gnu_cxx::__normal_iterator<GiNaC::expair  
const*, std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >,  
GiNaC::expair*>(__gnu_cxx::__normal_iterator<GiNaC::expair const*,  
std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >,  
__gnu_cxx::__normal_iterator<GiNaC::expair const*,  
std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >,  
GiNaC::expair*, __false_type) (in /Developer/opt/Ginac/1.5.8/lib/ 
libginac-1.5.0.dylib)

==51729==    by 0xF7F43C: GiNaC::expair*  
std::uninitialized_copy<__gnu_cxx::__normal_iterator<GiNaC::expair  
const*, std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >,  
GiNaC::expair*>(__gnu_cxx::__normal_iterator<GiNaC::expair const*,  
std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >,  
__gnu_cxx::__normal_iterator<GiNaC::expair const*,  
std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >,  
GiNaC::expair*) (in /Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)

==51729==    by 0xF7F45E: GiNaC::expair*  
std::__uninitialized_copy_a<__gnu_cxx::__normal_iterator<GiNaC::expair  
const*, std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >,  
GiNaC::expair*,  
GiNaC::expair>(__gnu_cxx::__normal_iterator<GiNaC::expair const*,  
std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >,  
__gnu_cxx::__normal_iterator<GiNaC::expair const*,  
std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >,  
GiNaC::expair*, std::allocator<GiNaC::expair>) (in /Developer/opt/ 
Ginac/1.5.8/lib/libginac-1.5.0.dylib)

==51729==    by 0xF7F518: std::vector<GiNaC::expair,  
std::allocator<GiNaC::expair> >::vector(std::vector<GiNaC::expair,  
std::allocator<GiNaC::expair> > const&) (in /Developer/opt/Ginac/1.5.8/ 
lib/libginac-1.5.0.dylib)

in the same run:

==51729== Possible data race during read of size 4 at 0x1ea42f4 by  
thread #3
==51729==    at 0x3AB6: GiNaC::refcounted::add_reference() (in main)
==51729==    by 0xF7C5AB: GiNaC::ptr<GiNaC::basic>::ptr(GiNaC::basic&)  
(in /Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0xF7C5C5: GiNaC::ptr<GiNaC::basic>::ptr(GiNaC::basic&)  
(in /Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0xF7C5ED: GiNaC::ex::ex() (in /Developer/opt/Ginac/ 
1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0xF7C604: GiNaC::ex::ex() (in /Developer/opt/Ginac/ 
1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0xFCBC50: GiNaC::expairseq::expairseq() (in /Developer/ 
opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0x10BD804: GiNaC::mul::mul(GiNaC::ex const&, GiNaC::ex  
const&) (in /Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0x10BD88C: GiNaC::mul::mul(GiNaC::ex const&, GiNaC::ex  
const&) (in /Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0x10FF9D0: GiNaC::exminus(GiNaC::ex const&) (in / 
Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0x10FFDD0: GiNaC::operator-(GiNaC::ex const&,  
GiNaC::ex const&) (in /Developer/opt/Ginac/1.5.8/lib/ 
libginac-1.5.0.dylib)
==51729==    by 0x10BDB0C: GiNaC::mul::derivative(GiNaC::symbol  
const&) const (in /Developer/opt/Ginac/1.5.8/lib/libginac-1.5.0.dylib)
==51729==    by 0xF965E3: GiNaC::basic::diff(GiNaC::symbol const&,  
unsigned int) const (in /Developer/opt/Ginac/1.5.8/lib/ 
libginac-1.5.0.dylib)


HTH the developers

Phil



More information about the GiNaC-list mailing list