1 # ifndef CPPAD_CORE_TAPE_LINK_HPP
2 # define CPPAD_CORE_TAPE_LINK_HPP
50 static tape_id_t* tape_id_table[CPPAD_MAX_NUM_THREADS];
55 return tape_id_table + thread;
83 return *tape_id_handle(thread);
104 template <
class Base>
110 return tape_table + thread;
129 template <
class Base>
132 return *tape_handle(thread);
163 template <
class Base>
165 {
size_t thread = size_t( tape_id % CPPAD_MAX_NUM_THREADS );
168 "Attempt to use an AD variable with two different threads."
172 return *tape_handle(thread);
209 template <
class Base>
221 static tape_id_t tape_id_save[CPPAD_MAX_NUM_THREADS];
230 for(thread = 0; thread < CPPAD_MAX_NUM_THREADS; thread++)
232 if( tape_table[thread] != CPPAD_NULL )
234 tape_id_save[thread] = tape_table[thread]->
id_;
235 *tape_id_handle(thread) = &tape_id_save[thread];
239 delete( tape_table[thread] );
242 tape_table[thread] = CPPAD_NULL;
249 tape_id_t** tape_id = tape_id_handle(thread);
253 if( tape_table[thread] == CPPAD_NULL )
257 tape_table[thread] = &tape_zero;
264 tape_table[thread]->
id_ = tape_id_save[thread];
265 *tape_id = &tape_table[thread]->
id_;
270 {
size_t new_tape_id = thread + CPPAD_MAX_NUM_THREADS;
272 std::numeric_limits<tape_id_t>::max() >= new_tape_id,
273 "cppad_tape_id_type maximum value has been execeeded"
275 **tape_id =
static_cast<tape_id_t>( new_tape_id );
283 size_t( **tape_id % CPPAD_MAX_NUM_THREADS ) == thread
290 *tape = tape_table[thread];
296 std::numeric_limits<CPPAD_TAPE_ID_TYPE>::max()
297 - CPPAD_MAX_NUM_THREADS > **tape_id,
298 "To many different tapes given the type used for "
302 **tape_id += CPPAD_MAX_NUM_THREADS;
304 tape_table[thread]->
Rec_.free();
334 template <
class Base>
337 size_t thread = size_t( tape_id_ % CPPAD_MAX_NUM_THREADS );
340 return *tape_handle(thread);
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
Define processor symbols and macros that are used by CppAD.
static tape_id_t * tape_id_ptr(size_t thread)
Pointer to the tape identifier for this AD<Base> class and the specific thread.
static bool in_parallel(void)
Are we in a parallel execution state; i.e., is it possible that other threads are currently executing...
Define the CppAD error checking macros (all of which begin with CPPAD_ASSERT_)
static size_t thread_num(void)
Get current thread number.
#define CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL
Check that the first call to a routine is not during parallel execution mode.
static local::ADTape< Base > * tape_manage(tape_manage_job job)
Create and delete tapes that record AD<Base> operations for current thread.
static local::ADTape< Base > ** tape_handle(size_t thread)
Handle for the tape for this AD<Base> class and the specific thread.
static local::ADTape< Base > * tape_ptr(void)
Pointer for the tape for this AD<Base> class and the current thread.
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
local::recorder< Base > Rec_
This is where the information is recorded.
static tape_id_t ** tape_id_handle(size_t thread)
Handle to the tape identifier for this AD<Base> class and the specific thread.
Class used to hold tape that records AD<Base> operations.
File used to define the CppAD multi-threading allocator class.
tape_id_t id_
Unique identifier for this tape.
local::ADTape< Base > * tape_this(void) const
Get a pointer to tape that records AD<Base> operations for the current thread.
CPPAD_TAPE_ID_TYPE tape_id_t