[CppAD] Multithreading

Brad Bell bradbell at seanet.com
Sat Mar 24 14:13:54 EDT 2012


This bug,and some other things that Dominik found have been fixed. See 
the headings 03-21 and 03-23 on
     http://www.coin-or.org/CppAD/Doc/whats_new_12.htm

There still are some error messages when running
     valgrind --tool=helgrind ./pthread_test simple_ad
but they appear to be a problem with valgrind.

To be specific, when in the makefile
     multi_thread/makefile
I change
     # AM_CXXFLAGS     = -g $(CXX_FLAGS)
       AM_CXXFLAGS = -DNDEBUG -O2 $(CXX_FLAGS)
to
     AM_CXXFLAGS     = -g $(CXX_FLAGS)
     # AM_CXXFLAGS = -DNDEBUG -O2 $(CXX_FLAGS)
and run
     make pthread_test
     valgrind --tool=helgrind ./pthread_test simple_ad
I get
... snip ...
==19568== Possible data race during write of size 4 at 0x80770c0 by 
thread #1
==19568==    at 0x8050455: CppAD::AD<double>::tape_new() (tape_link.hpp:221)
... snip ...
==19568==  This conflicts with a previous read of size 4 by thread #4
==19568==    at 0x805450A: CppAD::AD<double>::id_handle(unsigned int) 
(tape_link.hpp:73)
... snip ...

This seems to be an error in valgrind because the different threads are 
accessing different elements of the static variable id_table in 
AD<Base>::id_handle(size_t thread); i.e., thread is different.




On 03/20/2012 06:36 AM, Brad Bell wrote:
> It seems to be a bug that occurs when global ADFun<double> objects get 
> deleted at the end of a program (I will try to fix it soon).
>
> The test script simple_ad_pthread.sh added at
>     https://projects.coin-or.org/CppAD/changeset/2304
> generates the following output on one my test machines:
>
> [bradbell at brad-home bug]$ ./simple_ad_pthread.sh
> ./simple_ad_pthread.sh
> create simple_ad_pthread.cpp
> g++ -g simple_ad_pthread.cpp -I/home/bradbell/cppad/trunk -lpthread -o 
> simple_ad_pthread
> ./simple_ad_pthread
> thread_num = 1, y[0] = 0.841471
> thread_num = 0, y[0] = 0.841471
> OK = 1
> cppad-20120313 error from unknown source
> Error detected by false result for
>     thread < num_threads()
> at line 292 in the file
>     /home/bradbell/cppad/trunk/cppad/thread_alloc.hpp
> ... snip ...
>
> On 03/20/2012 02:58 AM, Dominik Skanda wrote:
>> Hello,
> ... snip ...
>
>> I have tried to change the example
>>
>> http://www.coin-or.org/CppAD/Doc/simple_ad_pthread.cpp.xml.
>>
>> But even so my changed file compiled, it gave me segmentation fault.
> ... snip ...
>> Am Montag, den 19.03.2012, 15:39 -0700 schrieb Jey Kottalam:
>>> Dominik, could you provide a standalone testcase that would allow us
>>> to reproduce the problem you're experiencing?
>>>
>>> Brad,
>>>
>>>> 3. I am not sure I understand the discussion below. Are you trying
>>> to use
>>>> CppAD without calling parallel_setup ? Or have you found a bug in
>>>
>
> _______________________________________________
> CppAD mailing list
> CppAD at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cppad
>



More information about the CppAD mailing list