ADOL-C: Automatic Differentiation in C/C++ 2.7.3
Loading...
Searching...
No Matches
Functions
tape_interface.h File Reference
#include <adolc/adolcerror.h>
#include <adolc/adolcexport.h>
#include <adolc/valuetape/valuetape.h>
#include <cassert>
#include <cstddef>
#include <vector>
Include dependency graph for tape_interface.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ADOLC_API int trace_on (short tapeId, int keepTaylors=0)
 Initializes taping for the given tapeId.
 
ADOLC_API int trace_on (short tapeId, int keepTaylors, size_t obs, size_t lbs, size_t vbs, size_t tbs, int skipFileCleanup)
 Initializes taping with fine-grained buffer configuration.
 
ADOLC_API void trace_off (int flag=0)
 Stops the current tracing session and handles the tape.
 
ADOLC_API void cachedTraceTags (std::vector< short > &result)
 Writes the tapeIds of the tapes stored in the thread-local tapeBuffer in result
 
ADOLC_API void nestedReverseEval (short tapeId, bool flag)
 Marks whether reverse evaluation of this tape is nested inside an outer tape evaluation.
 
ADOLC_API bool nestedReverseEval (short tapeId)
 Returns whether reverse evaluation of this tape is treated as nested.
 
ADOLC_API std::array< size_t, TapeInfos::STAT_SIZE > tapestats (short tapeId)
 Writes the tapestats of the tape into an array.
 
ADOLC_API void printTapeStats (short tapeId)
 Prints the stats of the tape.
 
ADOLC_API size_t get_num_param (short tapeId)
 Returns the number of parameters recorded on tape.
 
ADOLC_API size_t get_num_switches (short tapeId)
 Returns the number of switching variables recorded on tape.
 

Function Documentation

◆ cachedTraceTags()

ADOLC_API void cachedTraceTags ( std::vector< short > &  result)

Writes the tapeIds of the tapes stored in the thread-local tapeBuffer in result

Parameters
resultvector to store the IDs
Note
the vector is resized in this function to the size of the tapeBuffer

◆ get_num_param()

ADOLC_API size_t get_num_param ( short  tapeId)
inline

Returns the number of parameters recorded on tape.

Parameters
tapeIdID of the tape to read the number of parameters
Returns
number of parameters
Exceptions
ADOLCError::ErrorType::NO_TAPE_IDif the specified tape does not exist.

◆ get_num_switches()

ADOLC_API size_t get_num_switches ( short  tapeId)
inline

Returns the number of switching variables recorded on tape.

Parameters
tapeIdID of the tape to read the number of switching variables
Returns
number of switching variables
Exceptions
ADOLCError::ErrorType::NO_TAPE_IDif the specified tape does not exist.
ADOLCError::ErrorType::NO_MINMAXif tape was not recorded without enableMinMaxUsingAbs().

◆ nestedReverseEval() [1/2]

ADOLC_API bool nestedReverseEval ( short  tapeId)
inline

Returns whether reverse evaluation of this tape is treated as nested.

Parameters
tapeIdthe ID of the tape to query
Returns
true if reverse sweeps accumulate into an outer tape, false otherwise
Exceptions
ADOLCError::ErrorType::NO_TAPE_IDif the specified tape does not exist.

◆ nestedReverseEval() [2/2]

ADOLC_API void nestedReverseEval ( short  tapeId,
bool  flag 
)
inline

Marks whether reverse evaluation of this tape is nested inside an outer tape evaluation.

When enabled, reverse sweeps accumulate adjoints into the outer tape's independent and dependent slots instead of overwriting them.

Parameters
tapeIdthe ID of the tape to update
flagtrue for nested reverse evaluation, false otherwise
Exceptions
ADOLCError::ErrorType::NO_TAPE_IDif the specified tape does not exist.

◆ printTapeStats()

ADOLC_API void printTapeStats ( short  tapeId)

Prints the stats of the tape.

Parameters
tapeIdthe ID of the tape to print the stats
Exceptions
ADOLCError::ErrorType::NO_TAPE_IDif the specified tape does not exist.

◆ tapestats()

ADOLC_API std::array< size_t, TapeInfos::STAT_SIZE > tapestats ( short  tapeId)
inline

Writes the tapestats of the tape into an array.

Parameters
tapeIdthe ID of the tape to read the tapestats
Returns
array of size TapeInfos::STAT_SIZE that stores all tape's metadata
Exceptions
ADOLCError::ErrorType::NO_TAPE_IDif the specified tape does not exist.

◆ trace_off()

ADOLC_API void trace_off ( int  flag = 0)

Stops the current tracing session and handles the tape.

Cleans up the tape, copies remaining live variables, and updates its status. Optionally writes tape files to disk depending on the value of flag.

Parameters
flagIf non-zero, forces the tape to write op/loc/val files.
Exceptions
ADOLCError::ErrorType::TAPING_NOT_ACTUALLY_TAPINGif no active tracing is detected.
Note
assert in debug mode if currentTape is nullptr

◆ trace_on() [1/2]

ADOLC_API int trace_on ( short  tapeId,
int  keepTaylors,
size_t  obs,
size_t  lbs,
size_t  vbs,
size_t  tbs,
int  skipFileCleanup 
)

Initializes taping with fine-grained buffer configuration.

Prepares a ValueTape with custom buffer sizes for operations, locations, values, and Taylor coefficients. Also allows disabling cleanup of intermediate files.

Parameters
tapeIdID of the tape to trace.
keepTaylorsWhether to store Taylor coefficients.
obsOperation buffer size.
lbsLocation buffer size.
vbsValue buffer size.
tbsTaylor buffer size.
skipFileCleanupWhether to skip cleaning up tape files after tracing.
Returns
1 on success, -1 on failure.
Exceptions
ADOLCError::ErrorType::NO_TAPE_IDif the specified tape does not exist.

◆ trace_on() [2/2]

ADOLC_API int trace_on ( short  tapeId,
int  keepTaylors = 0 
)

Initializes taping for the given tapeId.

Prepares a ValueTape for recording operations, storing the current tapeId for later restoration. Initializes the tape’s memory and metadata.

Parameters
tapeIdID of the tape to activate for tracing.
keepTaylorsFlag indicating whether to keep Taylor coefficients (non-zero to keep).
Returns
1 on success, 0 on failure.
Exceptions
ADOLCError::ErrorType::NO_TAPE_IDif the specified tape does not exist.