41#include "reuseIndexManager.hpp"
56 template<
typename T_Index>
77 std::vector<Index> indexUse;
95 double memoryindexUseVector = (double)indexUse.size() * (double)(
sizeof(
Index));
97 TapeValues::LocalReductionOperation
constexpr operation =
98 NeedsStaticStorage ? TapeValues::LocalReductionOperation::Max : TapeValues::LocalReductionOperation::Sum;
100 values.
addDoubleEntry(
"Memory: index use vector", memoryindexUseVector, operation,
true,
true);
104 template<
typename Tape>
106 bool generatedNewIndex =
false;
109 indexUse[index] -= 1;
120 if (generatedNewIndex) {
127 return generatedNewIndex;
131 template<
typename Tape>
136 if (generatedNewIndex) {
142 return generatedNewIndex;
146 template<
typename Tape>
168 template<
typename Tape>
171 indexUse[index] -= 1;
173 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:97
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:97
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:87
void addToTapeValues(TapeValues &values) const
Add storage and other information to the tape values.
Definition multiUseIndexManager.hpp:92
T_Index Index
See MultiUseIndexManager.
Definition multiUseIndexManager.hpp:60
Index ActiveTypeIndexData
Same as the index.
Definition multiUseIndexManager.hpp:61
inlinevoid copyIndex(Index &lhs, Index const &rhs)
Call on copy of a primal value, e.g. w = a.
Definition multiUseIndexManager.hpp:147
inlinebool assignIndex(Index &index)
Call on assignment of a primal value, e.g. on w for w = a + b.
Definition multiUseIndexManager.hpp:105
MultiUseIndexManager(Index const &reservedIndices)
Constructor.
Definition multiUseIndexManager.hpp:82
inlinevoid freeIndex(Index &index)
Definition multiUseIndexManager.hpp:169
inlinebool assignUnusedIndex(Index &index)
Call on registering input values.
Definition multiUseIndexManager.hpp:132
static bool constexpr IsLinear
See ReuseIndexManager.
Definition multiUseIndexManager.hpp:70
static bool constexpr CopyNeedsStatement
Copy optimization only active if configured.
Definition multiUseIndexManager.hpp:68
ReuseIndexManager< Index > Base
Base class abbreviation.
Definition multiUseIndexManager.hpp:62
bool valid
Prevent index free after destruction.
Definition reuseIndexManagerBase.hpp:96
static bool constexpr NeedsStaticStorage
ReuseIndexManager(Index const &reservedIndices)
Constructor.
Definition reuseIndexManager.hpp:79
inlineIndex getLargestCreatedIndex() const
Returns the largest created index.
Definition reuseIndexManager.hpp:110
void addToTapeValues(TapeValues &values) const
Definition reuseIndexManager.hpp:92
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