40#include "../../misc/eventSystem.hpp"
42#include "../data/dataInterface.hpp"
43#include "indexManagerInterface.hpp"
65 template<
typename T_Index>
93 Index reservedIndices;
113 template<
typename Tape>
124 template<
typename Tape>
127 CODI_EXCEPTION(
"Overflow in linear index handler. Use a larger index type or a reuse index manager.");
141 template<
typename Tape>
143 return assignIndex<Tape>(index);
147 template<
typename Tape>
172 template<
typename TargetPosition>
190 return count - startPos;
196 return reservedIndices;
223 count = reservedIndices;
228 count = reservedIndices;
245 std::swap(reservedIndices, other.reservedIndices);
246 std::swap(count, other.count);
251 template<
int selectedDepth = -1,
typename FunctionObject,
typename... Args>
254 function(std::forward<Args>(args)..., start, end);
259 template<
int selectedDepth = -1,
typename FunctionObject,
typename... Args>
262 function(std::forward<Args>(args)..., start, end);
266 template<
typename FunctionObject,
typename... Args>
273 template<
typename FunctionObject,
typename... Args>
280 template<
typename FunctionObject,
typename... Args>
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define codiAssert(x)
See codi::Config::EnableAssert.
Definition config.h:432
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
#define CODI_ENABLE_CHECK(option, condition)
Definition macros.hpp:53
bool constexpr IndexEvents
Enable index management events. Disabled by default.
Definition config.h:327
bool constexpr OverflowCheck
Check in the index manager if an overflow occurred.
Definition config.h:248
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
void CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:46
Data stream interface for tape data. Encapsulates data that is written e.g. for each statement or arg...
Definition dataInterface.hpp:149
static void notifyIndexAssignListeners(Index const &index)
Invoke callbacks for IndexAssign events.
Definition eventSystem.hpp:778
static void notifyIndexFreeListeners(Index const &index)
Invoke callbacks for IndexFree events.
Definition eventSystem.hpp:806
static void notifyIndexCopyListeners(Index const &index)
Invoke callbacks for IndexCopy events.
Definition eventSystem.hpp:833
Indices enable the mapping of primal values to their adjoint counterparts.
Definition indexManagerInterface.hpp:78
static Index constexpr InvalidIndex
Default invalid index for all index mangers (max value for unsigned types).
Definition indexManagerInterface.hpp:87
static Index constexpr InactiveIndex
Default inactive index for all index managers.
Definition indexManagerInterface.hpp:86
Identifiers are created in a linear fashion. Each assign creates a new index which is counted up.
Definition linearIndexManager.hpp:66
LinearIndexManager(Index reservedIndices)
Constructor.
Definition linearIndexManager.hpp:99
InternalPosHandle reserveItems(size_t const &items)
Reserve this many items on the data stream. See pushData for details.
Definition linearIndexManager.hpp:203
size_t getDataSize() const
Definition linearIndexManager.hpp:178
size_t InternalPosHandle
Internal positions coincide with positions.
Definition linearIndexManager.hpp:87
void forEachChunk(FunctionObject &function, bool recursive, Args &&... args)
Calls the function object for each continuous segment of data.
Definition linearIndexManager.hpp:267
void swap(LinearIndexManager< Index > &other)
Definition linearIndexManager.hpp:244
void NestedData
Terminator, no further nested data.
Definition linearIndexManager.hpp:86
void addToTapeValues(TapeValues &values) const
Add storage and other information to the tape values.
Definition linearIndexManager.hpp:107
Position getZeroPosition() const
Definition linearIndexManager.hpp:195
void 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.
Definition linearIndexManager.hpp:274
void resetHard()
Definition linearIndexManager.hpp:227
static bool constexpr CopyNeedsStatement
Copy optimization is implemented.
Definition linearIndexManager.hpp:76
void 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.
Definition linearIndexManager.hpp:281
T_Index Index
See LinearIndexManager.
Definition linearIndexManager.hpp:69
Index Position
Positions coincide with indices.
Definition linearIndexManager.hpp:85
bool assignIndex(Index &index)
Call on assignment of a primal value, e.g. on w for w = a + b.
Definition linearIndexManager.hpp:125
void pushData()
Add data to the storage allocated by the implementation. The method can only be called after a call t...
Definition linearIndexManager.hpp:200
void freeIndex(Index &index) const
Call on destruction of a primal value. Usually called from the destructor.
Definition linearIndexManager.hpp:114
void 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 DataInterface...
Definition linearIndexManager.hpp:252
void erase(Position const &start, Position const &end, bool recursive=true)
Definition linearIndexManager.hpp:234
void copyIndex(Index &lhs, Index const &rhs)
Call on copy of a primal value, e.g. w = a.
Definition linearIndexManager.hpp:148
void resize(size_t const &totalSize)
Definition linearIndexManager.hpp:210
static bool constexpr NeedsStaticStorage
Linear indices are not meaningful across tape instances.
Definition linearIndexManager.hpp:78
size_t getPushedDataCount(InternalPosHandle const &startPos)
Definition linearIndexManager.hpp:189
void 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 DataInterface...
Definition linearIndexManager.hpp:260
void reset()
Definition linearIndexManager.hpp:222
static bool constexpr IsLinear
Tightly coupled to statements.
Definition linearIndexManager.hpp:77
Index getLargestCreatedIndex() const
Returns the largest created index.
Definition linearIndexManager.hpp:162
TargetPosition extractPosition(Position const &pos) const
Extract the position of a nested DataInterface from the global position object provide by this interf...
Definition linearIndexManager.hpp:173
void setNested(NestedData *v)
Definition linearIndexManager.hpp:239
Position getPosition() const
Definition linearIndexManager.hpp:184
bool assignUnusedIndex(Index &index)
Call on registering input values.
Definition linearIndexManager.hpp:142
void resetTo(Position const &pos)
Definition linearIndexManager.hpp:215
Tape information that can be printed in a pretty print format or a table format.
Definition tapeValues.hpp:73
void addLongEntry(std::string const &name, long const &value)
Add long entry.
Definition tapeValues.hpp:140