CoDiPack  3.1.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
codi::DebugMultiUseIndexManager< T_Index > Struct Template Reference

Implements the IndexManagerInterface and mimics a multi use index management. More...

#include <debugMultiUseIndexManager.hpp>

Inheritance diagram for codi::DebugMultiUseIndexManager< T_Index >:

Public Types

using ActiveTypeIndexData = IndexTagPair<Index, Tag>
 See IndexManagerInterface.
 
using Base = IndexManagerInterface<T_Index>
 Abbreviation for the base class.
 
using Index = T_Index
 See DebugMultiUseIndexManager.
 
using Tag = std::uint8_t
 Tag used for the recording live time management.
 
- Public Types inherited from codi::IndexManagerInterface< T_Index >
using ActiveTypeIndexData = T_Index
 Index data stored in the active type. Can be arbitrary.
 
using Index = T_Index
 See IndexManagerInterface.
 
- Public Types inherited from codi::EmptyData
using InternalPosHandle = size_t
 Will always be zero.
 
using NestedData = void
 No nested data.
 
using Position = EmptyPosition
 No positional data.
 
- Public Types inherited from codi::DataInterface< T_NestedData, T_InternalPosHandle >
using InternalPosHandle = T_InternalPosHandle
 See DataInterface.
 
using NestedData = T_NestedData
 See DataInterface.
 
using Position = EmptyPosition
 Contains position data for this DataInterface and all nested interfaces.
 

Public Member Functions

 DebugMultiUseIndexManager (Index const &reservedIndices)
 Constructor.
 
 ~DebugMultiUseIndexManager ()
 Destructor.
 
IndexManagerInterface: Interface implementation
void addToTapeValues (TapeValues &values) const
 Add storage and other information to the tape values.


 
template<typename Tape>
inlinebool assignIndex (ActiveTypeIndexData &data)
 Call on assignment of a primal value, e.g. on w for w = a + b.
 
template<typename Tape>
inlinebool assignUnusedIndex (ActiveTypeIndexData &index)
 Call on registering input values.
 
template<typename Tape>
inlinevoid copyIndex (ActiveTypeIndexData &lhs, ActiveTypeIndexData const &rhs)
 Call on copy of a primal value, e.g. w = a.
 
template<typename Tape>
inlinevoid freeIndex (ActiveTypeIndexData &data)
 
inlinevoid initIndex (ActiveTypeIndexData &index)
 Initialize the index data. Usually zero everything.
 
inlinevoid reset ()
 Reset for a new recording.
 
inlinevoid validateRhsIndex (ActiveTypeIndexData const &data) const
 Check if the rhs index is valid.
 
inlineIndex const & getIndex (ActiveTypeIndexData const &data)
 Extract index from data stored in active type.
 
inlineIndex & getIndex (ActiveTypeIndexData &data)
 Extract index from data stored in active type.
 
inlineIndex getLargestCreatedIndex () const
 Returns the largest created index.
 
- Public Member Functions inherited from codi::IndexManagerInterface< T_Index >
void addToTapeValues (TapeValues &values) const
 Add storage and other information to the tape values.
 
Index getLargestCreatedIndex () const
 Returns the largest created index.
 
void initIndex (ActiveTypeIndexData &index)
 Initialize the index data. Usually zero everything.
 
template<typename Tape>
bool assignIndex (ActiveTypeIndexData &index)
 Call on assignment of a primal value, e.g. on w for w = a + b.
 
void updateLargestCreatedIndex (ActiveTypeIndexData const &index)
 Update the largest generated index.
 
template<typename Tape>
bool assignUnusedIndex (ActiveTypeIndexData &index)
 Call on registering input values.
 
template<typename Tape>
void copyIndex (ActiveTypeIndexData &lhs, ActiveTypeIndexData const &rhs)
 Call on copy of a primal value, e.g. w = a.
 
template<typename Tape>
void freeIndex (ActiveTypeIndexData &index)
 
void reset ()
 Reset for a new recording.
 
Index const & getIndex (ActiveTypeIndexData const &data)
 Extract index from data stored in active type.
 
IndexgetIndex (ActiveTypeIndexData &data)
 Extract index from data stored in active type.
 
void validateRhsIndex (ActiveTypeIndexData const &data) const
 Check if the rhs index is valid.
 
- Public Member Functions inherited from codi::EmptyData
inlinevoid pushData ()
 Add data to the storage allocated by the implementation. The method can only be called after a call to reserveItems and only as often as the number of reserved items.
 
inlinevoid getDataPointers ()
 Get pointers to the data from the storage implementation. The method can only be called after a call to reserveItems() and data can only be accessed from 0 to the number given by reserveItems (excluding). Afterwards, addDataSize() needs to be called with the actual number of elements that have been written.
 
inlinevoid addDataSize (size_t size)
 Add this many items to the data stream, after the data has been manipulated via pointers obtained from getDataPointers().
 
inlineInternalPosHandle reserveItems (size_t const &items)
 Reserve this many items on the data stream. See pushData for details.
 
void resize (size_t const &totalSize)
 
void reset ()
 
void resetHard ()
 
void resetTo (Position const &pos)
 
void erase (Position const &start, Position const &end, bool recursive=true)
 
inlinesize_t getDataSize () const
 
inlinePosition getPosition () const
 
inlinesize_t getPushedDataCount (InternalPosHandle const &startPos)
 
inlinePosition getZeroPosition () const
 
void addToTapeValues (TapeValues &values) const
 Add amount of stored data to the TapeValues object. Not called on the nested vector.
 
template<typename = void>
inlinePosition extractPosition (Position const &pos) const
 Extract the position of a nested DataInterface from the global position object provide by this interface.
 
void setNested (NestedData *v)
 


 
void swap (DataInterface &other)
 
template<int selectedDepth = -1, typename FunctionObject, typename... Args>
inlinevoid evaluateForward (Position const &start, Position const &end, FunctionObject function, Args &&... args)
 Evaluates the function object with segments of continuous and valid data for all nested DataInterfaces.


 
template<int selectedDepth = -1, typename FunctionObject, typename... Args>
inlinevoid evaluateReverse (Position const &start, Position const &end, FunctionObject function, Args &&... args)
 Evaluates the function object with segments of continuous and valid data for all nested DataInterfaces.




 
template<typename FunctionObject, typename... Args>
inlinevoid forEachChunk (FunctionObject &function, bool recursive, Args &&... args)
 Calls the function object for each continuous segment of data.
 
template<typename FunctionObject, typename... Args>
inlinevoid forEachForward (Position const &start, Position const &end, FunctionObject function, Args &&... args)
 Calls the function object for each item in the data stream. This call is not recursive.
 
template<typename FunctionObject, typename... Args>
inlinevoid forEachReverse (Position const &start, Position const &end, FunctionObject function, Args &&... args)
 Calls the function object for each item in the data stream. This call is not recursive.
 
- Public Member Functions inherited from codi::DataInterface< T_NestedData, T_InternalPosHandle >
inlinevoid addDataSize (size_t const &size)
 Add this many items to the data stream, after the data has been manipulated via pointers obtained from getDataPointers().
 
template<typename... Data>
inlinevoid getDataPointers (Data *&... pointers)
 Get pointers to the data from the storage implementation. The method can only be called after a call to reserveItems() and data can only be accessed from 0 to the number given by reserveItems (excluding). Afterwards, addDataSize() needs to be called with the actual number of elements that have been written.
 
template<typename... Data>
inlinevoid pushData (Data const &... data)
 Add data to the storage allocated by the implementation. The method can only be called after a call to reserveItems and only as often as the number of reserved items.
 
inlineInternalPosHandle reserveItems (size_t const &items)
 Reserve this many items on the data stream. See pushData for details.
 
void resize (size_t const &totalSize)
 
void reset ()
 
void resetHard ()
 
void resetTo (Position const &pos)
 
void erase (Position const &start, Position const &end, bool recursive=true)
 
inlinesize_t getDataSize () const
 
inlinePosition getPosition () const
 
inlinesize_t getPushedDataCount (InternalPosHandle const &startPos)
 
inlinePosition getZeroPosition () const
 
void addToTapeValues (TapeValues &values) const
 Add amount of stored data to the TapeValues object. Not called on the nested vector.
 
template<typename TargetPosition>
inlineTargetPosition extractPosition (Position const &pos) const
 Extract the position of a nested DataInterface from the global position object provide by this interface.
 
void setNested (NestedData *v)
 
void swap (DataInterface &other)
 
template<int selectedDepth = -1, typename FunctionObject, typename... Args>
inlinevoid evaluateForward (Position const &start, Position const &end, FunctionObject function, Args &&... args)
 Evaluates the function object with segments of continuous and valid data for all nested DataInterfaces.
 
template<int selectedDepth = -1, typename FunctionObject, typename... Args>
inlinevoid evaluateReverse (Position const &start, Position const &end, FunctionObject function, Args &&... args)
 Evaluates the function object with segments of continuous and valid data for all nested DataInterfaces.
 
template<typename FunctionObject, typename... Args>
inlinevoid forEachChunk (FunctionObject &function, bool recursive, Args &&... args)
 Calls the function object for each continuous segment of data.
 
template<typename FunctionObject, typename... Args>
inlinevoid forEachForward (Position const &start, Position const &end, FunctionObject function, Args &&... args)
 Calls the function object for each item in the data stream. This call is not recursive.
 
template<typename FunctionObject, typename... Args>
inlinevoid forEachReverse (Position const &start, Position const &end, FunctionObject function, Args &&... args)
 Calls the function object for each item in the data stream. This call is not recursive.
 

Static Public Attributes

IndexManagerInterface: Constants
static bool constexpr CopyNeedsStatement = !Config::CopyOptimization
 See IndexManagerInterface.
 
static bool constexpr IsLinear = false
 See IndexManagerInterface.
 
static bool constexpr NeedsStaticStorage = true
 See IndexManagerInterface.
 
- Static Public Attributes inherited from codi::IndexManagerInterface< T_Index >
static Index constexpr InactiveIndex = Index(0)
 Default inactive index for all index managers.
 
static Index constexpr InvalidIndex
 Default invalid index for all index mangers (max value for unsigned types).
 
static bool constexpr CopyNeedsStatement
 True if no copy optimization is implemented. See IndexManagerInterface.
 
static bool constexpr IsLinear
 True if identifiers are coupled to the statements. See IndexManagerInterface.
 
static bool constexpr NeedsStaticStorage = false
 True if the index manager is specific to a tape type (and not a tape instance). See IndexManagerInterface.
 

Detailed Description

template<typename T_Index>
struct codi::DebugMultiUseIndexManager< T_Index >

Implements the IndexManagerInterface and mimics a multi use index management.

This index manager should not be used in production code.

The index manager increases tag for each reset that is called. Therefore it can detect the usage of old values.

In addition, it remembers the use count of old values. It can therefore detect if an old value is released to often.

Otherwise it behaves like a linear index manager.

Template Parameters
T_IndexType for the identifier, usually an integer type.

Member Function Documentation

◆ addToTapeValues()

template<typename T_Index>
void codi::DebugMultiUseIndexManager< T_Index >::addToTapeValues ( TapeValues & values) const
inline

Add storage and other information to the tape values.

Parameters
[in,out]valuesWill only create new data entries and no new section.

Implementation: Adds size of index use vector.

◆ assignIndex()

template<typename T_Index>
template<typename Tape>
inlinebool codi::DebugMultiUseIndexManager< T_Index >::assignIndex ( ActiveTypeIndexData & data)
inline

Call on assignment of a primal value, e.g. on w for w = a + b.

Returns
true if new indices have been generated internally.

◆ assignUnusedIndex()

template<typename T_Index>
template<typename Tape>
inlinebool codi::DebugMultiUseIndexManager< T_Index >::assignUnusedIndex ( ActiveTypeIndexData & index)
inline

Call on registering input values.

Returns
true if new indices have been generated internally.

◆ copyIndex()

template<typename T_Index>
template<typename Tape>
inlinevoid codi::DebugMultiUseIndexManager< T_Index >::copyIndex ( ActiveTypeIndexData & lhs,
ActiveTypeIndexData const & rhs )
inline

Call on copy of a primal value, e.g. w = a.

◆ freeIndex()

template<typename T_Index>
template<typename Tape>
inlinevoid codi::DebugMultiUseIndexManager< T_Index >::freeIndex ( ActiveTypeIndexData & data)
inline

Call on destruction of a primal value. Usually called from the destructor.

◆ getIndex() [1/2]

template<typename T_Index>
inlineIndex & codi::DebugMultiUseIndexManager< T_Index >::getIndex ( ActiveTypeIndexData & data)
inline

Extract index from data stored in active type.

◆ getIndex() [2/2]

template<typename T_Index>
inlineIndex const & codi::DebugMultiUseIndexManager< T_Index >::getIndex ( ActiveTypeIndexData const & data)
inline

Extract index from data stored in active type.

◆ getLargestCreatedIndex()

template<typename T_Index>
inlineIndex codi::DebugMultiUseIndexManager< T_Index >::getLargestCreatedIndex ( ) const
inline

Returns the largest created index.

This is the largest entry in the adjoint vectors created by the tapes.

◆ initIndex()

template<typename T_Index>
inlinevoid codi::DebugMultiUseIndexManager< T_Index >::initIndex ( ActiveTypeIndexData & index)
inline

Initialize the index data. Usually zero everything.

◆ reset()

template<typename T_Index>
inlinevoid codi::DebugMultiUseIndexManager< T_Index >::reset ( )
inline

Reset for a new recording.

◆ validateRhsIndex()

template<typename T_Index>
inlinevoid codi::DebugMultiUseIndexManager< T_Index >::validateRhsIndex ( ActiveTypeIndexData const & data) const
inline

Check if the rhs index is valid.


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