Prev Next

@(@\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}} }@)@
Using CppAD in a Multi-Threading Environment

Purpose
Extra steps and care must be taken to use CppAD in parallel execution mode. This section collects this information in one place.

CPPAD_MAX_NUM_THREADS
The value CPPAD_MAX_NUM_THREADS is an absolute maximum for the number of threads that CppAD should support. If this preprocessor symbol is defined before including any CppAD header files, it must be an integer greater than or equal to one. Otherwise, cppad_max_num_threads is used to define this preprocessor symbol. Note that the minimum allowable value for cppad_max_num_threads is 4; i.e., you can only get smaller values for CPPAD_MAX_NUM_THREADS by defining it before including the CppAD header files.

parallel_setup
Using any of the following routines in a multi-threading environment requires that thread_alloc::parallel_setup has been completed: CppAD::vector , CheckSimpleVector , CheckNumericType , parallel_ad .

hold_memory
Memory allocation should be much faster after calling hold_memory with value equal to true. This may even be true if there is only one thread.


One must first call thread_alloc::parallel_setup and then call parallel_ad before using AD types in parallel execution mode.

Initialization
The following routines must be called at least once before being used in parallel mode: CheckSimpleVector , CheckNumericType , discrete functions , Rosen34 , Runge45 .

Same Thread
Some operations must be preformed by the same thread: ADFun , Independent , Dependent .

Parallel Prohibited
The following routine cannot be called in parallel mode: ErrorHandler constructor .

Contents
parallel_adEnable AD Calculations During Parallel Mode
thread_test.cppRun Multi-Threading Examples and Speed Tests

Input File: omh/multi_thread.omh