---------------------------------------------------------------- lines 6-23 of file: example/multi_thread/pthread/get_started.cpp ---------------------------------------------------------------- {xrst_begin pthread_get_started.cpp} {xrst_spell posix } {xrst_template , example/multi_thread/template/get_started.xrst title: Getting Started Using @Name@ Threads With CppAD start source code after: // BEGIN_C++ end source code before: // END_C++ @Name@ , Posix @####@ , ##### @DEFAULT@ , USE_DEFAULT_ADFUN_CONSTRUCTOR } {xrst_end pthread_get_started.cpp} ------------------------------------------------------------------ xrst template file: example/multi_thread/template/get_started.xrst ------------------------------------------------------------------ {xrst_comment # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later # SPDX-FileCopyrightText: Bradley M. Bell # SPDX-FileContributor: 2024 Bradley M. Bell This file is intended to help document the multi threading get_started examples It has the following xrst template comments: title: Getting Started Using @Name@ Threads With CppAD start source code after: // BEGIN_C++ end source code before: // END_C++ It has the following xrst template replacements @Name@ : is the name of this threading system @####@ : is the underlining for the name of the threading system @DEFAULT@ : is macro a macro name. If it is 1 (0), the ADFun default ctor is used (is not used) } Getting Started Using @Name@ Threads With CppAD ######################@####@################### in_parallel *********** see :ref:`ta_parallel_setup@in_parallel` . thread_number ************* see :ref:`ta_parallel_setup@thread_num` . ADFun Constructor ***************** If you use the :ref:`fun_construct@Sequence Constructor` for the original function, you will need to clear the Taylor coefficient memory associated with the function using :ref:`capacity_order-name` ; e.g. :: {xrst_spell_off} CppAD::ADFun fun(ax, ay); fun.capacity_order(0); {xrst_spell_on} If you do not free the Taylor coefficient memory in ``fun`` , the function assignments will allocate zero order Taylor coefficients for each function in ``fun_thread`` using thread zero. Depending on what you do in parallel mode, you may attempt to free that memory using another thread. For example, if you change @DEFAULT@ from 1 to 0, you will get the message:: Attempt to return memory for a different thread while in parallel mode Source Code *********** {xrst_literal // BEGIN_C++ // END_C++ }