41#include "reuseIndexManager.hpp"
56 template<
typename T_Index>
76 std::vector<Index> indexUse;
94 double memoryindexUseVector = (double)indexUse.size() * (double)(
sizeof(
Index));
96 values.
addDoubleEntry(
"Memory: index use vector", memoryindexUseVector,
true,
true);
100 template<
typename Tape>
102 bool generatedNewIndex =
false;
105 indexUse[index] -= 1;
115 generatedNewIndex = Base::template assignIndex<Tape>(index);
116 if (generatedNewIndex) {
123 return generatedNewIndex;
127 template<
typename Tape>
129 freeIndex<Tape>(index);
131 bool generatedNewIndex = Base::template assignUnusedIndex<Tape>(index);
132 if (generatedNewIndex) {
138 return generatedNewIndex;
142 template<
typename Tape>
148 freeIndex<Tape>(lhs);
159 assignIndex<Tape>(lhs);
164 template<
typename Tape>
167 indexUse[index] -= 1;
169 if (indexUse[index] == 0) {
170 Base::template freeIndex<Tape>(index);
#define CODI_NO_INLINE
See codi::Config::AvoidedInlines.
Definition config.h:417
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
bool constexpr CopyOptimization
Do not store copy statements like a = b; if the identity handler allows it.
Definition config.h:186
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
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
static Index constexpr InactiveIndex
Default inactive index for all index managers.
Definition indexManagerInterface.hpp:86
Extends the ReuseIndexManager with a copy optimization.
Definition multiUseIndexManager.hpp:57
bool assignIndex(Index &index)
Call on assignment of a primal value, e.g. on w for w = a + b.
Definition multiUseIndexManager.hpp:101
void addToTapeValues(TapeValues &values) const
Add storage and other information to the tape values.
Definition multiUseIndexManager.hpp:91
T_Index Index
See MultiUseIndexManager.
Definition multiUseIndexManager.hpp:60
void freeIndex(Index &index)
Call on destruction of a primal value. Usually called from the destructor.
Definition multiUseIndexManager.hpp:165
void copyIndex(Index &lhs, Index const &rhs)
Call on copy of a primal value, e.g. w = a.
Definition multiUseIndexManager.hpp:143
MultiUseIndexManager(Index const &reservedIndices)
Constructor.
Definition multiUseIndexManager.hpp:81
static bool constexpr IsLinear
See ReuseIndexManager.
Definition multiUseIndexManager.hpp:69
bool assignUnusedIndex(Index &index)
Call on registering input values.
Definition multiUseIndexManager.hpp:128
static bool constexpr CopyNeedsStatement
Copy optimization only active if configured.
Definition multiUseIndexManager.hpp:67
bool valid
Prevent index free after destruction.
Definition reuseIndexManagerBase.hpp:95
Reuse index manager with a many-to-one relation between tapes and index manager.
Definition reuseIndexManager.hpp:53
Index getLargestCreatedIndex() const
Returns the largest created index.
Definition reuseIndexManager.hpp:106
static bool constexpr NeedsStaticStorage
< See ReuseIndexManagerBase.
Definition reuseIndexManagerBase.hpp:81
void addToTapeValues(TapeValues &values) const
Add storage and other information to the tape values.
Definition reuseIndexManager.hpp:91
Tape information that can be printed in a pretty print format or a table format.
Definition tapeValues.hpp:73
void addDoubleEntry(std::string const &name, double const &value, bool usedMem=false, bool allocatedMem=false)
Add double entry. If it is a memory entry, it should be in bytes.
Definition tapeValues.hpp:126