42#include "../data/emptyData.hpp"
43#include "indexManagerInterface.hpp"
65 template<
typename T_Index,
typename T_Impl>
104 return static_cast<Impl&
>(*this);
109 cast().generateNewIndices();
138 template<
typename Tape>
140 bool generatedNewIndex =
false;
145 generateNewIndices();
146 generatedNewIndex =
true;
159 return generatedNewIndex;
163 template<
typename Tape>
165 freeIndex<Tape>(index);
167 bool generatedNewIndex =
false;
169 generateNewIndices();
170 generatedNewIndex =
true;
178 return generatedNewIndex;
182 template<
typename Tape>
185 freeIndex<Tape>(lhs);
187 assignIndex<Tape>(lhs);
192 template<
typename Tape>
234 unsigned long storedIndices = this->usedIndicesPos + this->
unusedIndicesPos;
235 unsigned long allocatedIndices = this->usedIndices.size() + this->unusedIndices.size();
237 double memoryStoredIndices = (double)storedIndices * (
double)(
sizeof(
Index));
238 double memoryAllocatedIndices = (double)allocatedIndices * (
double)(
sizeof(
Index));
241 values.
addDoubleEntry(
"Memory used", memoryStoredIndices,
true,
false);
242 values.
addDoubleEntry(
"Memory allocated", memoryAllocatedIndices,
false,
true);
253 CODI_NO_INLINE void increaseIndicesSizeTo(std::vector<Index>& v,
size_t minimalSize) {
#define CODI_NO_INLINE
See codi::Config::AvoidedInlines.
Definition config.h:417
#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_IMPLEMENTATION
Used in interface declarations to indicate the type of the implementing class.
Definition macros.hpp:105
bool constexpr SortIndicesOnReset
Reuse index tapes will sort their indices on a reset.
Definition config.h:264
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
No data is stored in this DataInterface implementation. It is used to terminate the recursive nature ...
Definition emptyData.hpp:54
EmptyPosition Position
No positional data.
Definition emptyData.hpp:59
Empty Position with no nested data.
Definition position.hpp:47
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
Indices enable the mapping of primal values to their adjoint counterparts.
Definition indexManagerInterface.hpp:78
static Index constexpr InactiveIndex
Default inactive index for all index managers.
Definition indexManagerInterface.hpp:86
Identifiers are reused. Freed identifiers are assigned to new variables. Variables keep their indices...
Definition reuseIndexManagerBase.hpp:66
static bool constexpr IsLinear
Identifiers are not coupled to statements.
Definition reuseIndexManagerBase.hpp:80
bool assignUnusedIndex(Index &index)
Call on registering input values.
Definition reuseIndexManagerBase.hpp:164
bool valid
Prevent index free after destruction.
Definition reuseIndexManagerBase.hpp:95
~ReuseIndexManagerBase()
Destructor.
Definition reuseIndexManagerBase.hpp:129
T_Impl Impl
See ReuseIndexManagerBase.
Definition reuseIndexManagerBase.hpp:70
ReuseIndexManagerBase()
Definition reuseIndexManagerBase.hpp:118
bool assignIndex(Index &index)
Call on assignment of a primal value, e.g. on w for w = a + b.
Definition reuseIndexManagerBase.hpp:139
std::vector< Index > unusedIndices
Pool of indices that have not been used in this recording yet.
Definition reuseIndexManagerBase.hpp:90
std::vector< Index > usedIndices
Pool of indices that have already been used in this recording.
Definition reuseIndexManagerBase.hpp:87
static bool constexpr CopyNeedsStatement
No copy optimization is implemented.
Definition reuseIndexManagerBase.hpp:79
void addToTapeValues(TapeValues &values) const
Add storage and other information to the tape values.
Definition reuseIndexManagerBase.hpp:233
static bool constexpr NeedsStaticStorage
Identifiers are managed globally.
Definition reuseIndexManagerBase.hpp:81
T_Index Index
See ReuseIndexManagerBase.
Definition reuseIndexManagerBase.hpp:69
size_t indexSizeIncrement
Block size for index pool enlargement.
Definition reuseIndexManagerBase.hpp:93
size_t unusedIndicesPos
Number of remaining unused indices.
Definition reuseIndexManagerBase.hpp:91
void freeIndex(Index &index)
Call on destruction of a primal value. Usually called from the destructor.
Definition reuseIndexManagerBase.hpp:193
size_t usedIndicesPos
Number of remaining used indices.
Definition reuseIndexManagerBase.hpp:88
void reset()
Reset for a new recording.
Definition reuseIndexManagerBase.hpp:210
void copyIndex(Index &lhs, Index const &rhs)
Call on copy of a primal value, e.g. w = a.
Definition reuseIndexManagerBase.hpp:183
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
void addUnsignedLongEntry(std::string const &name, unsigned long const &value)
Add unsigned long entry.
Definition tapeValues.hpp:150