[CppAD] Multi-Threading

Brad Bell bradbell at seanet.com
Thu Mar 8 08:41:43 EST 2012


On 03/07/2012 07:01 AM, Dominik Skanda wrote:
> Hello,
>
> as far as I understand for the multi-threading mode the ADFun Object
> itself is not thread safe. Is this right?
In part it is right. There are some static variables that need to be 
initialized before an ADFun object can be used. This initialization can 
be ensured by a corresponding call to
     http://www.coin-or.org/CppAD/Doc/parallel_ad.xml
> Wouldn't it be more user-friendly if the ADFun object itself would be
> thread safe. This means that an ADFun-object with stored operation
> sequence can be called (the forward or reverse routines) from a unique
> thread without any preparation for multi-threading.
The problem is that for performance of Forward and Reverse operations 
and ADFun object needs to allocate memory. The system memory allocator 
is exclusive; i.e., only one thread can use it at a time. For this 
reason, the old simpler version of CppAD would loose performance when 
more than 5 threads where used in parallel. A new multi-threading memory 
allocator was added to solve this problem.
>   It would also be
> gorgeous if the copy operator would be thread safe, too.
> Then, specially in a threaded program one could tape at the beginning
> the needed functions (in sequential or parallel mode) and then use the
> ADFun object in a  threaded Program, with the only care on not perform
> the same ADFun object parallel on different threads? I personally think
> this would be very flexible?

The original version of CppAD mult-threading only allowed for OpenMP. 
But some users wanted the ability to use other threading systems. Hence 
it became necessary to inform CppAD of the information in
     http://www.coin-or.org/CppAD/Doc/ta_parallel_setup.xml

>
> regards
>
> Dominik
>
> _______________________________________________
> CppAD mailing list
> CppAD at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cppad
>



More information about the CppAD mailing list