lines 8-74 of file: include/cppad/core/parallel_ad.hpp

{xrst_begin parallel_ad}
{xrst_spell
   teardown
}

Enable AD Calculations During Parallel Mode
###########################################

Syntax
******
``parallel_ad`` < *Base* >()

Purpose
*******
The function
``parallel_ad`` < *Base* >()
must be called before any ``AD`` < *Base>* objects are used
in :ref:`parallel<ta_in_parallel-name>` mode.
In addition, if this routine is called after one is done using
parallel mode, it will free extra memory used to keep track of
the multiple ``AD`` < *Base* > tapes required for parallel execution.

Discussion
**********
By default, for each ``AD`` < *Base* > class there is only one
tape that records :ref:`glossary@AD of Base` operations.
This tape is a global variable and hence it cannot be used
by multiple threads at the same time.
The :ref:`parallel_setup<ta_parallel_setup-name>` function informs CppAD of the
maximum number of threads that can be active in parallel mode.
This routine does extra setup
(and teardown) for the particular *Base* type.

CheckSimpleVector
*****************
This routine has the side effect of calling the routines

   ``CheckSimpleVector`` < *Type* , ``CppAD::vector<`` *Type* > >()

where *Type* is *Base* and ``AD`` < *Base* > .

Example
*******
The files
:ref:`team_openmp.cpp-name` ,
:ref:`team_bthread.cpp-name` , and
:ref:`team_pthread.cpp-name` ,
contain examples and tests that implement this function.

Restriction
***********
This routine cannot be called in parallel mode or while
there is a tape recording ``AD`` < *Base* > operations.

Other Routines
**************
If the following routines are used in parallel mode,
they must be initialized separately:

#. :ref:`thread_alloc, memory_leak <ta_parallel_setup-name>`
#. :ref:`Rosen34 <Rosen34@Parallel Mode>`
#. :ref:`Runge45 <Runge45@Parallel Mode>`
#. :ref:`discrete <Discrete@Parallel Mode>`
#. :ref:`atomic_one <atomic_one@afun@Parallel Mode>`


{xrst_end parallel_ad}
