CoDiPack  3.1.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
codi::TagTapeBase< T_Real, T_Tag, T_Gradient, T_Impl > Struct Template Reference

Base implementation for tagging tapes. More...

#include <tagTapeBase.hpp>

Inheritance diagram for codi::TagTapeBase< T_Real, T_Tag, T_Gradient, T_Impl >:

Classes

struct  ValidateTags
 Looks at the tags for the expression. More...
 

Public Types

using ActiveTypeTapeData = TagData<Tag>
 See TapeTypesInterface.
 
using Gradient = T_Gradient
 See TagTapeBase.
 
using Identifier = int
 See TapeTypesInterface.
 
using Impl = T_Impl
 See TagTapeBase.
 
using Real = T_Real
 See TagTapeBase.
 
using Tag = T_Tag
 See TagTapeBase.
 
using TagErrorCallback = void (*)(Tag const& correctTag, Tag const& wrongTag, void* userData)
 Callback for a tag error.
 
using TagPropertyErrorCallback
 Callback for a change in a lhs value.
 

Public Member Functions

void swap (Impl &other)
 Swap members.
 
 TagTapeBase ()
 Constructor.
 
IdentifierInformationTapeInterface interface partial implementation
inlineIdentifier const & getIdentifier (ActiveTypeTapeData const &data)
 
inlineIdentifier & getIdentifier (ActiveTypeTapeData &data)
 

Static Public Attributes

static Tag constexpr InvalidTag = Tag(-1)
 Tag indicating an invalid value.
 
static Tag constexpr PassiveTag = Tag(0)
 Tag indicating an inactive value.
 

Protected Attributes

Identifier const activeIdentifier = 1
 Temporary for active identifier.
 
Tag curTag
 Current tag for new values.
 
Identifier const passiveIdentifier = 0
 Temporary for passive identifier.
 
bool preaccumulationHandling
 Parameter to enable/disable preaccumulation handling.
 
Tag preaccumulationTag
 Tag used for preaccumulation specialized handling.
 
TagErrorCallback tagErrorCallback
 User defined callback for tag errors.
 
void * tagErrorUserData
 User data in call to callback for tag errors.
 
TagPropertyErrorCallback tagPropertyErrorCallback
 User defined callback for lhs value errors.
 
void * tagPropertyErrorUserData
 User data in call to callback for lhs value errors.
 
Identifier tempIdentifier = 0
 Temporary for identifier values.
 

Implementation of InternalStatementRecordingTapeInterface

static bool constexpr AllowJacobianOptimization = false
 Do not allow Jacobian optimization.
 
template<typename Real>
void initTapeData (Real &value, ActiveTypeTapeData &data)
 Do nothing.
 
template<typename Real>
void destroyTapeData (Real &value, ActiveTypeTapeData &data)
 Do nothing.
 
template<typename Aggregated, typename Type, typename Lhs, typename Rhs>
inlinevoid store (AggregatedActiveType< Aggregated, Type, Lhs > &lhs, ExpressionInterface< Aggregated, Rhs > const &rhs)
 
template<typename Aggregated, typename Type, typename Lhs, typename Rhs>
inlinevoid store (AggregatedActiveType< Aggregated, Type, Lhs > &lhs, AggregatedActiveType< Aggregated, Type, Rhs > const &rhs)
 Has to be called by an AD variable every time it is assigned.

 
template<typename Lhs, typename Rhs>
void store (LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, ExpressionInterface< Real, Rhs > const &rhs)
 Verify all tags of the rhs and the lhs properties.
 
template<typename Lhs, typename Rhs>
void store (LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, LhsExpressionInterface< Real, Gradient, Impl, Rhs > const &rhs)
 Verify all tags of the rhs and the lhs properties.
 
template<typename Lhs>
void store (LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, Real const &rhs)
 Verify the lhs properties.
 

Tagging specific functions.

void setCurTag (const Tag &tag)
 Set the current tag of the tape.
 
Tag getCurTag ()
 Get the current tag of the tape.
 
template<typename Lhs>
Tag getTagFromVariable (LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
 Get tag of a CoDiPack active type.
 
template<typename Lhs>
void setTagOnVariable (LhsExpressionInterface< Real, Gradient, Impl, Lhs > const &value)
 Set tag on a CoDiPack active type.
 
template<typename Lhs>
void clearTagOnVariable (LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
 Clear tag on a CoDiPack active type.
 
template<typename Lhs>
void clearTagPropertiesOnVariable (LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
 Clear properties on a CoDiPack active type.
 
template<typename Lhs>
void setTagPropertyOnVariable (LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, TagFlags flag)
 Set properties on a CoDiPack active type.
 
template<typename Lhs>
bool hasTagPropertyOnVariable (LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, TagFlags flag)
 Check properties on a CoDiPack active type.
 
void setTagPropertyErrorCallback (TagPropertyErrorCallback const &callback, void *userData)
 Set the callback and user data for a property error error.
 
void setTagErrorCallback (TagErrorCallback const &callback, void *userData)
 Set the callback and user data for a tag error.
 
inlinevoid setPreaccumulationHandlingEnabled (bool enabled)
 Enable or disable specialized handling for preaccumulation. Default: true Uses a special tag to sanitize preaccumulation regions.
 
inlinevoid setPreaccumulationHandlingTag (Tag tag)
 Set the special tag for preaccumulation regions. See setPreaccumulationHandlingEnabled().
 
inlinebool isPreaccumulationHandlingEnabled ()
 If handling for preaccumulation is enabled.
 
inlineTag getPreaccumulationHandlingTag ()
 The special tag for preaccumulation.
 
inlinevoid verifyTag (ValidationIndicator< Real, Tag > &vi, Tag const &tag) const
 Checks if the tag is correct. Errors are set on the ValidationIndicator object.
 
inlinevoid verifyTag (Tag const &tag) const
 Checks if the tag is correct and creates an error.
 
inlinevoid verifyProperties (ValidationIndicator< Real, Tag > &vi, Real const &value, const EnumBitset< TagFlags > &properties) const
 Checks if the tag properties are correct.
 
inlinevoid verifyTagAndProperties (Tag const &tag, Real const &value, const EnumBitset< TagFlags > &properties) const
 Checks if the tag and the properties are correct.
 
inlinevoid checkLhsError (Real &lhsValue, ActiveTypeTapeData &lhsData, const Real &rhs) const
 Check if a property for the lhs value is triggered.
 
template<typename Lhs>
inlinevoid checkLhsError (LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, Real const &rhs) const
 Check if the lhs value is changed.
 
inlinevoid handleError (ValidationIndicator< Real, Tag > &vi) const
 Call tag error callback.
 
template<typename Lhs>
inlinevoid verifyRegisterValue (LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, ActiveTypeTapeData const &tag)
 Verify tag, properties and lhs error.
 
inlinevoid setTag (Tag &tag) const
 Set tag on value.
 
inlinevoid resetTag (Tag &tag) const
 Reset tag on value.
 
static void defaultPropertyErrorCallback (Real const &currentValue, Real const &newValue, TagFlags flag, void *userData)
 Default callback for TagPropertyErrorCallback.
 
static void defaultTagErrorCallback (Tag const &correctTag, Tag const &wrongTag, void *userData)
 Default callback for TagErrorCallback.
 

Detailed Description

template<typename T_Real, typename T_Tag, typename T_Gradient, typename T_Impl>
struct codi::TagTapeBase< T_Real, T_Tag, T_Gradient, T_Impl >

Base implementation for tagging tapes.

Provides all basic management routines for the tag.

See tests/functional/src/testTagging.cpp for an example.

Template Parameters
T_RealThe computation type of a tape, usually chosen as ActiveType::Real.
T_tagThe type of the tag, usually int.

Member Typedef Documentation

◆ TagPropertyErrorCallback

template<typename T_Real, typename T_Tag, typename T_Gradient, typename T_Impl>
using codi::TagTapeBase< T_Real, T_Tag, T_Gradient, T_Impl >::TagPropertyErrorCallback
Initial value:
void (*)(Real const& currentValue, Real const& newValue, TagFlags flag,
void* userData)
TagFlags
Properties for values.
Definition tagData.hpp:46
T_Real Real
See TagTapeBase.
Definition tagTapeBase.hpp:74

Callback for a change in a lhs value.

Member Function Documentation

◆ getIdentifier() [1/2]

template<typename T_Real, typename T_Tag, typename T_Gradient, typename T_Impl>
inlineIdentifier & codi::TagTapeBase< T_Real, T_Tag, T_Gradient, T_Impl >::getIdentifier ( ActiveTypeTapeData & data)
inline

Extract identifier from the tape data stored in the active type.

◆ getIdentifier() [2/2]

template<typename T_Real, typename T_Tag, typename T_Gradient, typename T_Impl>
inlineIdentifier const & codi::TagTapeBase< T_Real, T_Tag, T_Gradient, T_Impl >::getIdentifier ( ActiveTypeTapeData const & data)
inline

Extract identifier from the tape data stored in the active type.

◆ store()

template<typename T_Real, typename T_Tag, typename T_Gradient, typename T_Impl>
template<typename Aggregated, typename Type, typename Lhs, typename Rhs>
inlinevoid codi::TagTapeBase< T_Real, T_Tag, T_Gradient, T_Impl >::store ( AggregatedActiveType< Aggregated, Type, Lhs > & lhs,
AggregatedActiveType< Aggregated, Type, Rhs > const & rhs )
inline

Has to be called by an AD variable every time it is assigned.

Update of the value is performed by the tape. The tape will additionally store information, e.g., for the reversal of the statement.

Template Parameters
LhsHas to implement LhsExpressionInterface.
RhsHas to implement ExpressionInterface.
Optimization for copy statements of aggregated types.

The documentation for this struct was generated from the following file: