42#include "../../misc/mathUtility.hpp"
43#include "../data/emptyData.hpp"
44#include "indexManagerInterface.hpp"
65 template<
typename T_Index,
typename T_Impl>
105 return static_cast<Impl&
>(*this);
110 return static_cast<Impl const&
>(*this);
115 cast().generateNewIndices();
144 template<
typename Tape>
146 bool generatedNewIndex =
false;
151 generateNewIndices();
152 generatedNewIndex =
true;
165 return generatedNewIndex;
169 template<
typename Tape>
173 bool generatedNewIndex =
false;
175 generateNewIndices();
176 generatedNewIndex =
true;
184 return generatedNewIndex;
188 template<
typename Tape>
198 template<
typename Tape>
227 Index needToGenerate = index - cast().getLargestCreatedIndex();
228 size_t newUnusedIndexSize = this->unusedIndicesPos + needToGenerate;
231 newUnusedIndexSize =
getNextMultiple(newUnusedIndexSize, this->indexSizeIncrement);
232 this->unusedIndices.resize(newUnusedIndexSize);
236 generateNewIndices();
266 unsigned long storedIndices = this->usedIndicesPos + this->unusedIndicesPos;
267 unsigned long allocatedIndices = this->usedIndices.size() + this->unusedIndices.size();
269 double memoryStoredIndices = (double)storedIndices * (
double)(
sizeof(
Index));
270 double memoryAllocatedIndices = (double)allocatedIndices * (
double)(
sizeof(
Index));
273 ? TapeValues::LocalReductionOperation::Max
274 : TapeValues::LocalReductionOperation::Sum;
277 values.
addDoubleEntry(
"Memory used", memoryStoredIndices, operation,
true,
false);
278 values.
addDoubleEntry(
"Memory allocated", memoryAllocatedIndices, operation,
false,
true);
306 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:97
#define CODI_IMPLEMENTATION
Used in interface declarations to indicate the type of the implementing class.
Definition macros.hpp:111
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:97
IntegralType getNextMultiple(IntegralType const &targetSize, IntegralType const &chunkSize)
Helper function for overallocation in multiples of a given chunk size.
Definition mathUtility.hpp:49
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:55
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:87
Index getLargestCreatedIndex() const
Returns the largest created index.
static bool constexpr NeedsStaticStorage
< See ReuseIndexManagerBase.
Definition parallelReuseIndexManager.hpp:85
static bool constexpr IsLinear
Definition reuseIndexManagerBase.hpp:81
Index ActiveTypeIndexData
Definition reuseIndexManagerBase.hpp:70
bool valid
Definition reuseIndexManagerBase.hpp:96
~ReuseIndexManagerBase()
Destructor.
Definition reuseIndexManagerBase.hpp:135
inlinevoid reset()
Reset for a new recording.
Definition reuseIndexManagerBase.hpp:242
inlinevoid copyIndex(Index &lhs, Index const &rhs)
Call on copy of a primal value, e.g. w = a.
Definition reuseIndexManagerBase.hpp:189
inlinebool assignUnusedIndex(Index &index)
Call on registering input values.
Definition reuseIndexManagerBase.hpp:170
inlineIndex & getIndex(Index &data)
Extract index from data stored in active type.
Definition reuseIndexManagerBase.hpp:294
ParallelReuseIndexManager Impl
Definition reuseIndexManagerBase.hpp:71
ReuseIndexManagerBase()
Definition reuseIndexManagerBase.hpp:124
void validateRhsIndex(ActiveTypeIndexData const &data) const
Check if the rhs index is valid.
Definition reuseIndexManagerBase.hpp:282
EmptyData::Position Position
Definition reuseIndexManagerBase.hpp:74
std::vector< Index > unusedIndices
Definition reuseIndexManagerBase.hpp:91
std::vector< Index > usedIndices
Definition reuseIndexManagerBase.hpp:88
static bool constexpr CopyNeedsStatement
Definition reuseIndexManagerBase.hpp:80
inlinebool assignIndex(Index &index)
Call on assignment of a primal value, e.g. on w for w = a + b.
Definition reuseIndexManagerBase.hpp:145
inlineIndex const & getIndex(Index const &data)
Extract index from data stored in active type.
Definition reuseIndexManagerBase.hpp:289
void addToTapeValues(TapeValues &values) const
Add storage and other information to the tape values.
Definition reuseIndexManagerBase.hpp:265
static bool constexpr NeedsStaticStorage
Definition reuseIndexManagerBase.hpp:82
Index Index
Definition reuseIndexManagerBase.hpp:69
size_t indexSizeIncrement
Definition reuseIndexManagerBase.hpp:94
IndexManagerInterface< Index > Base
Definition reuseIndexManagerBase.hpp:72
size_t unusedIndicesPos
Definition reuseIndexManagerBase.hpp:92
inlinevoid freeIndex(Index &index)
Definition reuseIndexManagerBase.hpp:199
size_t usedIndicesPos
Definition reuseIndexManagerBase.hpp:89
inlinevoid initIndex(Index &index)
Initialize the index data. Usually zero everything.
Definition reuseIndexManagerBase.hpp:217
void updateLargestCreatedIndex(Index const &index)
Update the largest generated index.
Definition reuseIndexManagerBase.hpp:222
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