\(\newcommand{\W}[1]{ \; #1 \; }\) \(\newcommand{\R}[1]{ {\rm #1} }\) \(\newcommand{\B}[1]{ {\bf #1} }\) \(\newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} }\) \(\newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} }\) \(\newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} }\) \(\newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }\)
parallel_ad¶
View page sourceEnable 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 parallel 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 AD of Base operations.
This tape is a global variable and hence it cannot be used
by multiple threads at the same time.
The parallel_setup 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 CheckSimpleVector
for
some of the possible
Scalar and Vector cases.
The set of these cases may increase in the future and currently includes
the following:
Scalar |
Vector |
---|---|
|
|
|
|
Base |
vector < Base > |
|
vector |
Where vector above is
CppAD::vector
,
std::vector
, and
the cppad_testvector .
Example¶
The files openmp_get_started.cpp , bthread_get_started.cpp , and pthread_get_started.cpp , 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 Initialization¶
If the following routines have static memory and must be called once before being used in parallel mode: