41#include "reuseIndexManager.hpp"
56 template<
typename T_Index>
76 std::vector<Index> indexUse;
94 double memoryindexUseVector = (double)indexUse.size() * (double)(
sizeof(
Index));
96 TapeValues::LocalReductionOperation
constexpr operation =
97 NeedsStaticStorage ? TapeValues::LocalReductionOperation::Max : TapeValues::LocalReductionOperation::Sum;
99 values.
addDoubleEntry(
"Memory: index use vector", memoryindexUseVector, operation,
true,
true);
103 template<
typename Tape>
105 bool generatedNewIndex =
false;
108 indexUse[index] -= 1;
119 if (generatedNewIndex) {
126 return generatedNewIndex;
130 template<
typename Tape>
135 if (generatedNewIndex) {
141 return generatedNewIndex;
145 template<
typename Tape>
167 template<
typename Tape>
170 indexUse[index] -= 1;
172 if (indexUse[index] == 0) {
#define CODI_NO_INLINE
See codi::Config::AvoidedInlines.
Definition config.h:426
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:96
Configuration options for CoDiPack.
Definition config.h:65
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:94
static inlinevoid notifyIndexCopyListeners(Index const &index)
Invoke callbacks for IndexCopy events.
Definition eventSystem.hpp:833
static inlinevoid notifyIndexAssignListeners(Index const &index)
Invoke callbacks for IndexAssign events.
Definition eventSystem.hpp:778
static inlinevoid notifyIndexFreeListeners(Index const &index)
Invoke callbacks for IndexFree events.
Definition eventSystem.hpp:806
static Index constexpr InactiveIndex
Default inactive index for all index managers.
Definition indexManagerInterface.hpp:86
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
inlinevoid copyIndex(Index &lhs, Index const &rhs)
Call on copy of a primal value, e.g. w = a.
Definition multiUseIndexManager.hpp:146
inlinebool assignIndex(Index &index)
Call on assignment of a primal value, e.g. on w for w = a + b.
Definition multiUseIndexManager.hpp:104
MultiUseIndexManager(Index const &reservedIndices)
Constructor.
Definition multiUseIndexManager.hpp:81
inlinevoid freeIndex(Index &index)
Call on destruction of a primal value. Usually called from the destructor.
Definition multiUseIndexManager.hpp:168
inlinebool assignUnusedIndex(Index &index)
Call on registering input values.
Definition multiUseIndexManager.hpp:131
static bool constexpr IsLinear
See ReuseIndexManager.
Definition multiUseIndexManager.hpp:69
static bool constexpr CopyNeedsStatement
Copy optimization only active if configured.
Definition multiUseIndexManager.hpp:67
ReuseIndexManager< Index > Base
Base class abbreviation.
Definition multiUseIndexManager.hpp:61
bool valid
Prevent index free after destruction.
Definition reuseIndexManagerBase.hpp:95
static bool constexpr NeedsStaticStorage
ReuseIndexManager(Index const &reservedIndices)
Constructor.
Definition reuseIndexManager.hpp:78
inlineIndex getLargestCreatedIndex() const
Returns the largest created index.
Definition reuseIndexManager.hpp:109
void addToTapeValues(TapeValues &values) const
Definition reuseIndexManager.hpp:91
Tape information that can be printed in a pretty print format or a table format.
Definition tapeValues.hpp:75
void addDoubleEntry(std::string const &name, double const &value, LocalReductionOperation operation=LocalReductionOperation::Sum, bool usedMem=false, bool allocatedMem=false)
Add double entry. If it is a memory entry, it should be in bytes.
Definition tapeValues.hpp:137