42#include "../../misc/mathUtility.hpp"
43#include "../data/emptyData.hpp"
44#include "indexManagerInterface.hpp"
65 template<
typename T_Index,
typename T_Impl>
104 return static_cast<Impl&
>(*this);
109 return static_cast<Impl const&
>(*this);
114 cast().generateNewIndices();
143 template<
typename Tape>
145 bool generatedNewIndex =
false;
150 generateNewIndices();
151 generatedNewIndex =
true;
164 return generatedNewIndex;
168 template<
typename Tape>
172 bool generatedNewIndex =
false;
174 generateNewIndices();
175 generatedNewIndex =
true;
183 return generatedNewIndex;
187 template<
typename Tape>
197 template<
typename Tape>
221 Index needToGenerate = index - cast().getLargestCreatedIndex();
222 size_t newUnusedIndexSize = this->unusedIndicesPos + needToGenerate;
225 newUnusedIndexSize =
getNextMultiple(newUnusedIndexSize, this->indexSizeIncrement);
226 this->unusedIndices.resize(newUnusedIndexSize);
230 generateNewIndices();
260 unsigned long storedIndices = this->usedIndicesPos + this->unusedIndicesPos;
261 unsigned long allocatedIndices = this->usedIndices.size() + this->unusedIndices.size();
263 double memoryStoredIndices = (double)storedIndices * (
double)(
sizeof(
Index));
264 double memoryAllocatedIndices = (double)allocatedIndices * (
double)(
sizeof(
Index));
267 ? TapeValues::LocalReductionOperation::Max
268 : TapeValues::LocalReductionOperation::Sum;
271 values.
addDoubleEntry(
"Memory used", memoryStoredIndices, operation,
true,
false);
272 values.
addDoubleEntry(
"Memory allocated", memoryAllocatedIndices, operation,
false,
true);
283 CODI_NO_INLINE void increaseIndicesSizeTo(std::vector<Index>& v,
size_t minimalSize) {
#define CODI_NO_INLINE
See codi::Config::AvoidedInlines.
Definition config.h:426
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define codiAssert(x)
See codi::Config::EnableAssert.
Definition config.h:441
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:96
#define CODI_IMPLEMENTATION
Used in interface declarations to indicate the type of the implementing class.
Definition macros.hpp:110
Configuration options for CoDiPack.
Definition config.h:65
bool constexpr SortIndicesOnReset
Reuse index tapes will sort their indices on a reset.
Definition config.h:273
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
IntegralType getNextMultiple(IntegralType const &targetSize, IntegralType const &chunkSize)
Helper function for overallocation in multiples of a given chunk size.
Definition mathUtility.hpp:49
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
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
Indices enable the mapping of primal values to their adjoint counterparts.
Definition indexManagerInterface.hpp:78
static Index constexpr InactiveIndex
Definition indexManagerInterface.hpp:86
Index getLargestCreatedIndex() const
Returns the largest created index.
static bool constexpr NeedsStaticStorage
< See ReuseIndexManagerBase.
Definition parallelReuseIndexManager.hpp:84
static bool constexpr IsLinear
Definition reuseIndexManagerBase.hpp:80
bool valid
Definition reuseIndexManagerBase.hpp:95
~ReuseIndexManagerBase()
Destructor.
Definition reuseIndexManagerBase.hpp:134
inlinevoid reset()
Reset for a new recording.
Definition reuseIndexManagerBase.hpp:236
inlinevoid copyIndex(Index &lhs, Index const &rhs)
Call on copy of a primal value, e.g. w = a.
Definition reuseIndexManagerBase.hpp:188
inlinebool assignUnusedIndex(Index &index)
Call on registering input values.
Definition reuseIndexManagerBase.hpp:169
ParallelReuseIndexManager Impl
Definition reuseIndexManagerBase.hpp:70
ReuseIndexManagerBase()
Definition reuseIndexManagerBase.hpp:123
EmptyData::Position Position
Definition reuseIndexManagerBase.hpp:73
std::vector< Index > unusedIndices
Definition reuseIndexManagerBase.hpp:90
std::vector< Index > usedIndices
Definition reuseIndexManagerBase.hpp:87
static bool constexpr CopyNeedsStatement
Definition reuseIndexManagerBase.hpp:79
inlinebool assignIndex(Index &index)
Call on assignment of a primal value, e.g. on w for w = a + b.
Definition reuseIndexManagerBase.hpp:144
void addToTapeValues(TapeValues &values) const
Add storage and other information to the tape values.
Definition reuseIndexManagerBase.hpp:259
static bool constexpr NeedsStaticStorage
Definition reuseIndexManagerBase.hpp:81
Index Index
Definition reuseIndexManagerBase.hpp:69
size_t indexSizeIncrement
Definition reuseIndexManagerBase.hpp:93
IndexManagerInterface< Index > Base
Definition reuseIndexManagerBase.hpp:71
size_t unusedIndicesPos
Definition reuseIndexManagerBase.hpp:91
inlinevoid freeIndex(Index &index)
Call on destruction of a primal value. Usually called from the destructor.
Definition reuseIndexManagerBase.hpp:198
size_t usedIndicesPos
Definition reuseIndexManagerBase.hpp:88
void updateLargestCreatedIndex(Index const &index)
Update the largest generated index.
Definition reuseIndexManagerBase.hpp:216
Tape information that can be printed in a pretty print format or a table format.
Definition tapeValues.hpp:75
void addUnsignedLongEntry(std::string const &name, unsigned long const &value, LocalReductionOperation operation=LocalReductionOperation::Sum)
Add unsigned long entry.
Definition tapeValues.hpp:163
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