43#include "../expressions/aggregate/aggregatedActiveType.hpp"
44#include "../expressions/aggregate/arrayAccessExpression.hpp"
45#include "../expressions/lhsExpressionInterface.hpp"
46#include "../expressions/logic/compileTimeTraversalLogic.hpp"
47#include "../expressions/logic/helpers/forEachLeafLogic.hpp"
48#include "../expressions/logic/helpers/jacobianComputationLogic.hpp"
49#include "../expressions/logic/traversalLogic.hpp"
50#include "../expressions/referenceActiveType.hpp"
52#include "../misc/mathUtility.hpp"
53#include "../misc/memberStore.hpp"
54#include "../traits/adjointVectorTraits.hpp"
55#include "../traits/computationTraits.hpp"
56#include "../traits/expressionTraits.hpp"
57#include "commonTapeImplementation.hpp"
58#include "data/chunk.hpp"
59#include "data/chunkedData.hpp"
60#include "indices/indexManagerInterface.hpp"
61#include "io/tapeReaderWriterInterface.hpp"
62#include "misc/adjointVectorAccess.hpp"
63#include "misc/duplicateJacobianRemover.hpp"
64#include "misc/localAdjoints.hpp"
78 template<
typename T_Real,
typename T_Gradient,
typename T_IndexManager,
template<
typename,
typename>
class T_Data,
79 template<
typename,
typename,
typename>
class T_Adjoints =
LocalAdjoints>
86 template<
typename Chunk,
typename Nested>
93 template<
typename Impl>
99 IndexManager::NeedsStaticStorage;
103 using StatementChunk =
typename std::conditional<IsLinearIndexHandler, Chunk1<Config::ArgumentSize>,
129 template<
typename T_TapeTypes,
typename T_Impl>
141 using Real =
typename TapeTypes::Real;
157 template<
typename Adjo
intVector>
164 TapeTypes::IsLinearIndexHandler;
169#if CODI_RemoveDuplicateJacobianArguments
183 return static_cast<Impl const&
>(*this);
187 return static_cast<Impl&
>(*this);
197 template<
typename... Args>
201 template<
typename... Args>
244 checkAdjointSize(identifier);
270 template<
typename Real>
274 identifier = IndexManager::InactiveIndex;
278 template<
typename Real>
282 indexManager.get().template freeIndex<Impl>(identifier);
293 template<
typename Node,
typename DataVector>
298 dataVector.pushData(jacobian,
node.getIdentifier());
305 template<
typename Type,
typename DataVector>
307 DataVector& dataVector) {
312 node.jacobian += jacobian;
322 template<
typename Type,
typename DataVector>
326 dataVector.pushData(
node.jacobian,
node.getIdentifier());
338 template<
typename Rhs>
340 PushJacobianLogic pushJacobianLogic;
341 PushDelayedJacobianLogic pushDelayedJacobianLogic;
343#if CODI_RemoveDuplicateJacobianArguments
344 auto& insertVector = jacobianSorter;
349 pushJacobianLogic.eval(rhs.
cast(),
Real(1.0), insertVector);
350 pushDelayedJacobianLogic.eval(rhs.
cast(), insertVector);
352#if CODI_RemoveDuplicateJacobianArguments
363 template<
typename Aggregated,
typename Type,
typename Lhs,
typename Rhs>
368 int constexpr Elements = AggregatedTraits::Elements;
370 bool freeAndUpdate =
true;
380 typename JacobianData::InternalPosHandle jacobianStart =
jacobianData.reserveItems(MaxArgs * Elements);
381 std::array<size_t, Elements> numberOfArguments;
382 size_t totalNumberOfArguments = 0;
386 size_t newTotalNumberOfArguments =
jacobianData.getPushedDataCount(jacobianStart);
387 numberOfArguments[i.value] = newTotalNumberOfArguments - totalNumberOfArguments;
388 totalNumberOfArguments = newTotalNumberOfArguments;
391 if (0 != totalNumberOfArguments) {
392 freeAndUpdate =
false;
401 std::array<Identifier, Elements> identifiers = {};
404 indexManager.get().template assignIndex<Impl>(identifiers[i.value]);
409 Aggregated
real = rhs.
cast().getValue();
410 size_t eventJacobianOffset = 0;
416 lhs.
values[i.value].getIdentifier() = identifiers[i.value];
417 cast().pushStmtData(lhs.
values[i.value].getIdentifier(),
423 jacobianData.getDataPointers(jacobians, rhsIdentifiers);
424 jacobians -= totalNumberOfArguments;
425 rhsIdentifiers -= totalNumberOfArguments;
428 cast(), lhs.
values[i.value].getIdentifier(),
429 AggregatedTraits::template arrayAccess<i.value>(
real), numberOfArguments[i.value],
430 &rhsIdentifiers[eventJacobianOffset], &jacobians[eventJacobianOffset]);
432 eventJacobianOffset += numberOfArguments[i.value];
436 lhs.
values[i.value].value() = AggregatedTraits::template arrayAccess<i.value>(
real);
442 Aggregated
real = rhs.
cast().getValue();
445 lhs.
values[i.value].value() = AggregatedTraits::template arrayAccess<i.value>(
real);
453 template<
typename Aggregated,
typename Type,
typename Lhs,
typename Rhs>
458 int constexpr Elements = AggregatedTraits::Elements;
467 rhs.
values[i.value].getIdentifier());
477 lhs.
values[i.value].value() = rhs.
values[i.value].getValue();
482 template<
typename Lhs,
typename Rhs>
491 typename JacobianData::InternalPosHandle jacobianStart =
jacobianData.reserveItems(MaxArgs);
495 size_t numberOfArguments =
jacobianData.getPushedDataCount(jacobianStart);
503 jacobianData.getDataPointers(jacobians, rhsIdentifiers);
504 jacobians -= numberOfArguments;
505 rhsIdentifiers -= numberOfArguments;
508 rhs.
cast().getValue(), numberOfArguments,
509 rhsIdentifiers, jacobians);
518 lhs.
cast().value() = rhs.
cast().getValue();
523 template<
typename Lhs,
typename Rhs>
531 indexManager.get().template copyIndex<Impl>(lhs.
cast().getIdentifier(), rhs.
cast().getIdentifier());
537 lhs.
cast().value() = rhs.
cast().getValue();
542 template<
typename Lhs>
546 lhs.
cast().value() = rhs;
557 template<
typename Lhs>
560 if (TapeTypes::IsLinearIndexHandler) {
565 indexManager.get().template assignUnusedIndex<Impl>(value.
cast().getIdentifier());
567 indexManager.get().template assignIndex<Impl>(value.
cast().getIdentifier());
570 if (TapeTypes::IsLinearIndexHandler) {
582 template<
typename Lhs>
584 cast().internalRegisterInput(value,
true);
608 if (TapeTypes::IsLinearIndexHandler) {
609 name =
"CoDi Tape Statistics ( JacobianLinearTape )";
611 name =
"CoDi Tape Statistics ( JacobianReuseTape )";
615 size_t nAdjoints =
indexManager.get().getLargestCreatedIndex();
616 double memoryAdjoints =
static_cast<double>(nAdjoints) *
static_cast<double>(
sizeof(
Gradient));
619 TapeValues::LocalReductionOperation
constexpr operation =
620 globalAdjoints ? TapeValues::LocalReductionOperation::Max : TapeValues::LocalReductionOperation::Sum;
624 values.
addDoubleEntry(
"Memory allocated", memoryAdjoints, operation,
true,
true);
644 template<
typename Adjo
intVector>
650 size_t endJacobianPos = curJacobianPos - numberOfArguments;
653 while (endJacobianPos < curJacobianPos)
CODI_Likely {
655 adjointVector[rhsIdentifiers[curJacobianPos]] += rhsJacobians[curJacobianPos] * lhsAdjoint;
658 curJacobianPos = endJacobianPos;
667 template<
typename Adjo
intVector>
674 size_t endJacobianPos = curJacobianPos + numberOfArguments;
676 while (curJacobianPos < endJacobianPos)
CODI_Likely {
677 lhsAdjoint += rhsJacobians[curJacobianPos] * adjointVector[rhsIdentifiers[curJacobianPos]];
694 template<
typename Adjo
intVector>
699 cast(), start, end, &adjointWrapper, EventHints::EvaluationKind::Reverse, EventHints::Endpoint::Begin);
701 Wrap_internalEvaluateReverse_EvalStatements<AdjointVector> evalFunc;
702 Base::llfByteData.evaluateReverse(start, end, evalFunc, cast(), std::forward<AdjointVector>(data));
705 EventHints::EvaluationKind::Reverse, EventHints::Endpoint::End);
709 template<
typename Adjo
intVector>
714 cast(), start, end, &adjointWrapper, EventHints::EvaluationKind::Forward, EventHints::Endpoint::Begin);
716 Wrap_internalEvaluateForward_EvalStatements<AdjointVector> evalFunc;
717 Base::llfByteData.evaluateForward(start, end, evalFunc, cast(), std::forward<AdjointVector>(data));
720 EventHints::EvaluationKind::Forward, EventHints::Endpoint::End);
750 checkAdjointSize(
indexManager.get().getLargestCreatedIndex());
793 CODI_EXCEPTION(
"Tried to set a get only parameter.");
810 template<
typename Adjo
intVector>
817 template<
typename Adjo
int>
833 template<
typename Lhs>
835 cast().internalRegisterInput(value,
false);
851 checkAdjointSize(
indexManager.get().getLargestCreatedIndex());
857 cast().evaluateForward(start, end,
adjoints.data());
873 cast().incrementManualPushCounter();
882 jacobianData.getDataPointers(jacobians, rhsIdentifiers);
888 rhsIdentifiers, jacobians);
903 indexManager.get().template assignIndex<Impl>(lhsIndex);
931 for (
size_t rhsCount = 0; rhsCount < size; rhsCount++) {
932 cast().incrementManualPushCounter();
933 jacobianData.pushData(jacobians[rhsCount], rhsIdentifiers[rhsCount]);
942 template<
typename Type>
947 Base::llfByteData.evaluateForward(start, end, Impl::template internalWriteTape<Type>, writer);
974 indexManager.get().template assignIndex<Impl>(lhsIndex);
988 checkAdjointSize(
indexManager.get().getLargestCreatedIndex());
1009 evaluate(start, end, adjointsManagement);
1013 template<
typename Adjo
intVector>
1015 evaluate(start, end, std::forward<AdjointVector>(data));
1025 template<
typename Adjo
intVector>
1041 CODI_EXCEPTION(
"Accessing primal evaluation of an Jacobian tape.");
1048 CODI_EXCEPTION(
"Accessing primal vector of an Jacobian tape.");
1058 CODI_EXCEPTION(
"Accessing primal vector of an Jacobian tape.");
1068 CODI_INLINE void checkAdjointSize(Identifier
const& identifier) {
1069 if (identifier >= (Identifier)
adjoints.size()) {
1070 internalResizeAdjointsVector();
#define CODI_Unlikely
Declare unlikely evaluation of an execution path.
Definition config.h:408
#define CODI_LAMBDA_INLINE
See codi::Config::ForcedInlines.
Definition config.h:473
#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_Likely
Declare likely evaluation of an execution path.
Definition config.h:406
#define CODI_RESTRICT
See codi::Config::Restrict.
Definition config.h:491
#define CODI_RemoveDuplicateJacobianArguments
See codi::Config::RemoveDuplicateJacobianArguments.
Definition config.h:229
#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_ENABLE_CHECK(option, condition)
Definition macros.hpp:61
#define CODI_WRAP_FUNCTION_TEMPLATE(NAME, FUNC)
Wrap a function in a function object. Used for performance optimizations.
Definition macros.hpp:176
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:116
typename GradientImplementation< AdjointVector >::Gradient Gradient
Deduce the entry type from an adjoint vector type, usually identical to the gradient type of a tape.
Definition adjointVectorTraits.hpp:92
Configuration options for CoDiPack.
Definition config.h:65
uint16_t LowLevelFunctionToken
Token type for low level functions in the tapes.
Definition config.h:108
const bool CheckEmptyStatements
Tapes push statements only if at least one Jacobian was pushed.
Definition config.h:154
size_t constexpr ChunkSize
Default size of chunks (ChunkBase) used in ChunkedData in reverse tape implementations.
Definition config.h:94
bool constexpr CheckZeroIndex
Ignore active types that are not dependent on any input value in Jacobian tapes.
Definition config.h:178
bool constexpr IgnoreInvalidJacobians
Ignore invalid Jacobians like NaN or Inf.
Definition config.h:240
bool constexpr CheckTapeActivity
Makes it possible to ignore certain code parts. If turned of everything will be recorded.
Definition config.h:170
size_t constexpr StatementLowLevelFunctionTag
Statement tag for low level functions.
Definition config.h:126
bool constexpr CheckJacobianIsZero
Ignore Jacobians that are zero in Jacobian based tapes.
Definition config.h:162
size_t constexpr MaxArgumentSize
Maximum number of arguments in a statement.
Definition config.h:120
bool constexpr StatementEvents
Enable statement events. Disabled by default.
Definition config.h:328
bool constexpr CopyOptimization
Do not store copy statements like a = b; if the identity handler allows it.
Definition config.h:186
uint8_t ArgumentSize
Type for the number of arguments in statements.
Definition config.h:117
size_t constexpr StatementInputTag
Tag for statements that are inputs. Used in linear index management context.
Definition config.h:123
bool constexpr SkipZeroAdjointEvaluation
Do not perform a reverse evaluation of a statement if the seeding adjoint is zero.
Definition config.h:256
inlinebool isTotalFinite(Type const &v)
Function for checking if all values of the type are finite.
Definition realTraits.hpp:139
inlinebool isTotalZero(Type const &v)
Function for checking if the value of the type is completely zero.
Definition realTraits.hpp:145
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type that was used in the application.
Definition realTraits.hpp:123
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
TapeParameters
Configuration options for a tape.
Definition tapeParameters.hpp:52
@ LargestIdentifier
[A: R] Largest identifier distributed by the index manger.
Definition tapeParameters.hpp:60
@ JacobianSize
[A: RW] Allocated number of entries in the argument Jacobian vector in Jacobian tapes.
Definition tapeParameters.hpp:59
@ StatementSize
[A: RW] Allocated number of entries in the statement vector in all tapes.
Definition tapeParameters.hpp:66
@ AdjointSize
Definition tapeParameters.hpp:53
inlinevoid static_for(F func, Args &&... args)
Static for with i = 0 .. (N - 1). See CompileTimeLoop for details.
Definition compileTimeLoop.hpp:110
typename ArrayAccessExpressionImpl< Aggregated, element >::template Expression< Arg > ArrayAccessExpression
Expression that performs a[element] in a compile time context.
Definition arrayAccessExpression.hpp:98
inlineauto real(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:54
AdjointsManagement
Policies for management of the tape's interal adjoints.
Definition tapeParameters.hpp:100
@ Automatic
Manage internal adjoints automatically, including locking, bounds checking, and resizing.
Definition tapeParameters.hpp:102
ChunkedData< Chunk, NestedData > DefaultChunkedData
ChunkData DataInterface used in all regular tapes.
Definition chunkedData.hpp:520
inlineauto max(ExpressionInterface< Real, ArgA > const &argA, ExpressionInterface< Real, ArgB > const &argB)
Function overload for FUNCTION.
Definition binaryOperators.hpp:73
Implementation of VectorAccessInterface for adjoint vectors.
Definition adjointVectorAccess.hpp:61
InnerActiveType values[Elements]
Array representation.
Definition aggregatedActiveType.hpp:75
Represents a concrete aggregated lvalue int the CoDiPack expression tree.
Definition aggregatedActiveType.hpp:164
Definition byteDataView.hpp:51
inlinevoid internalStoreLowLevelFunction(Config::LowLevelFunctionToken token, size_t size, ByteDataView &dataView)
Definition commonTapeImplementation.hpp:494
inlinevoid initializeManualPushData(Real const &lhsValue, Identifier const &lhsIndex, size_t size)
Initialize all manual push data, including the counter. Check that a previous manual store is complet...
Definition commonTapeImplementation.hpp:200
Real manualPushLhsValue
For storeManual, remember the value assigned to the lhs.
Definition commonTapeImplementation.hpp:158
void setParameter(TapeParameters parameter, size_t value)
Definition commonTapeImplementation.hpp:459
void evaluateForward(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Definition commonTapeImplementation.hpp:611
size_t manualPushCounter
Count the pushes after storeManual, to identify the last push.
Definition commonTapeImplementation.hpp:161
Identifier manualPushLhsIdentifier
For storeManual, remember the identifier assigned to the lhs.
Definition commonTapeImplementation.hpp:159
bool isActive() const
Definition commonTapeImplementation.hpp:320
size_t manualPushGoal
Store the number of expected pushes after a storeManual call.
Definition commonTapeImplementation.hpp:160
void init(typename ImplTapeTypes::NestedData *nested)
Initialize the base class.
Definition commonTapeImplementation.hpp:770
std::set< TapeParameters > options
All options.
Definition commonTapeImplementation.hpp:153
void writeTape(std::unique_ptr< TapeWriterInterface< Type > > writer)
Definition commonTapeImplementation.hpp:624
void evaluate(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Definition commonTapeImplementation.hpp:293
void swap(Impl &other)
Definition commonTapeImplementation.hpp:368
typename CommonTapeTypes< ImplTapeTypes >::Position Position
Definition commonTapeImplementation.hpp:145
LowLevelFunctionByteData llfByteData
Byte data for low level functions.
Definition commonTapeImplementation.hpp:156
CommonTapeImplementation()
Definition commonTapeImplementation.hpp:232
size_t getParameter(TapeParameters parameter) const
Definition commonTapeImplementation.hpp:431
void evaluatePrimal()
Definition commonTapeImplementation.hpp:745
InternalAdjoints getInternalAdjoints()
Data stream interface for tape data. Encapsulates data that is written e.g. for each statement or arg...
Definition dataInterface.hpp:149
Combines entries of Jacobians with the same identifier.
Definition duplicateJacobianRemover.hpp:58
inlinevoid storeData(Vec &vec)
Definition duplicateJacobianRemover.hpp:98
static inlinevoid notifyTapeRegisterInputListeners(Tape &tape, Real &value, Identifier &identifier)
Invoke callbacks for TapeRegisterInput events.
Definition eventSystem.hpp:424
static inlinevoid notifyTapeEvaluateListeners(Tape &tape, Position const &start, Position const &end, VectorAccess *adjoint, EventHints::EvaluationKind evalKind, EventHints::Endpoint endpoint)
Invoke callbacks for TapeEvaluate events.
Definition eventSystem.hpp:486
static inlinevoid notifyStatementStoreOnTapeListeners(Tape &tape, Identifier const &lhsIdentifier, Real const &newValue, size_t numActiveVariables, Identifier const *rhsIdentifiers, Real const *jacobians)
Invoke callbacks for StatementStoreOnTape events.
Definition eventSystem.hpp:676
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:60
inlineImpl const & cast() const
Cast to the implementation.
Definition expressionInterface.hpp:76
Counts the number of nodes that inherit from LhsExpressionInterface in the expression.
Definition expressionTraits.hpp:226
static size_t constexpr value
See NumberOfActiveTypeArguments.
Definition expressionTraits.hpp:240
Implement logic for leaf nodes only.
Definition forEachLeafLogic.hpp:60
Indices enable the mapping of primal values to their adjoint counterparts.
Definition indexManagerInterface.hpp:78
Whether the adjoint vector is global, that is, shared among different tapes.
Definition adjointVectorTraits.hpp:50
Abstracts the internal set of adjoint variables provided as part of the tape.
Definition internalAdjointsInterface.hpp:80
Pushes all delayed Jacobians.
Definition jacobianBaseTape.hpp:318
inlinevoid handleActive(ReferenceActiveType< Type > const &node, DataVector &dataVector)
Specialization for ReferenceActiveType nodes. Pushes the delayed Jacobian.
Definition jacobianBaseTape.hpp:323
Pushes Jacobians and indices to the tape.
Definition jacobianBaseTape.hpp:290
inlinevoid handleJacobianOnActive(ReferenceActiveType< Type > const &node, Real jacobian, DataVector &dataVector)
Specialization for ReferenceActiveType nodes. Delays Jacobian push.
Definition jacobianBaseTape.hpp:306
inlinevoid handleJacobianOnActive(Node const &node, Real jacobian, DataVector &dataVector)
General implementation. Checks for invalid and passive values/Jacobians.
Definition jacobianBaseTape.hpp:294
inlineTapeValues internalGetTapeValues() const
Adds data from all streams, the size of the adjoint vector and index manager data.
Definition jacobianBaseTape.hpp:606
void evaluateKeepState(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a tape evaluation but restore the state afterwards such that it is the same as when the evalu...
Definition jacobianBaseTape.hpp:1007
IndexManager & getIndexManager()
Returns a reference to the Index Manager.
Definition jacobianBaseTape.hpp:957
JacobianData jacobianData
Definition jacobianBaseTape.hpp:176
typename Base::Position Position
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:154
inlinestatic void incrementAdjoints(AdjointVector &adjointVector, AdjointVectorTraits::Gradient< AdjointVector > const &lhsAdjoint, Config::ArgumentSize const &numberOfArguments, size_t &curJacobianPos, Real const *const rhsJacobians, Identifier const *const rhsIdentifiers)
Performs the AD reverse equation for a statement.
Definition jacobianBaseTape.hpp:645
size_t getParameter(TapeParameters parameter) const
See Parameters functions.
Definition jacobianBaseTape.hpp:764
inlinevoid pushJacobians(ExpressionInterface< Real, Rhs > const &rhs)
Push Jacobians and delayed Jacobians to the tape.
Definition jacobianBaseTape.hpp:339
typename TapeTypes::Gradient Gradient
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:142
typename TapeTypes::JacobianData JacobianData
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:147
static void internalEvaluateReverse_EvalStatements(Args &&... args)
Perform a reverse evaluation of the tape. Arguments are from the recursive eval methods of the DataIn...
inlinevoid store(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, ExpressionInterface< Real, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition jacobianBaseTape.hpp:483
void resizeAdjointVector()
Explicitly trigger resizing of the adjoint vector. See Adjoint vector management.
Definition jacobianBaseTape.hpp:749
StatementData statementData
Definition jacobianBaseTape.hpp:175
Adjoints adjoints
Definition jacobianBaseTape.hpp:178
void beginUseAdjointVector()
Declare that the adjoint vector is being used. See Adjoint vector management.
Definition jacobianBaseTape.hpp:754
Real const & primal(Identifier const &identifier) const
Not implemented, raises an exception.
Definition jacobianBaseTape.hpp:1055
inlinevoid swap(Impl &other)
Swap all data with an other tape.
Definition jacobianBaseTape.hpp:734
void pushStmtData(Identifier const &index, Config::ArgumentSize const &numberOfArguments)
Add statement specific data to the data streams.
typename TapeTypes::IndexManager IndexManager
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:143
friend Base
Definition jacobianBaseTape.hpp:139
inlinevoid pushLowLevelFunction(Config::LowLevelFunctionToken token, size_t size, ByteDataView &data)
Push a low level function to the tape.
Definition jacobianBaseTape.hpp:967
void evaluateKeepState(Position const &start, Position const &end, AdjointVector &&data)
Perform a tape evaluation but restore the state afterwards such that it is the same as when the evalu...
Definition jacobianBaseTape.hpp:1014
typename TapeTypes::template Adjoints< Impl > Adjoints
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:149
VectorAccess< decltype(adjoints.data())> * createVectorAccess()
See Adjoint vector access.
Definition jacobianBaseTape.hpp:805
VectorAccess< AdjointVector > * createVectorAccessCustomAdjoints(AdjointVector &&data)
Definition jacobianBaseTape.hpp:811
inlinestatic void incrementTangents(AdjointVector const &adjointVector, AdjointVectorTraits::Gradient< AdjointVector > &lhsAdjoint, Config::ArgumentSize const &numberOfArguments, size_t &curJacobianPos, Real const *const rhsJacobians, Identifier const *const rhsIdentifiers)
Performs the AD forward equation for a statement.
Definition jacobianBaseTape.hpp:668
void endUseAdjointVector()
Declare that the adjoint vector is no longer used. See Adjoint vector management.
Definition jacobianBaseTape.hpp:759
static void internalEvaluateForward_EvalStatements(Args &&... args)
Perform a forward evaluation of the tape. Arguments are from the recursive eval methods of the DataIn...
void deleteAdjointVector()
Delete the adjoint vector. See Adjoint vector management.
Definition jacobianBaseTape.hpp:744
void evaluateForward(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a forward evaluation of a part of the tape. It has to hold start <= end.
Definition jacobianBaseTape.hpp:848
inlinevoid internalRegisterInput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, bool unusedIndex)
Add a new input to the tape.
Definition jacobianBaseTape.hpp:558
typename TapeTypes::Real Real
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:141
inlinevoid evaluate(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end.
Definition jacobianBaseTape.hpp:985
typename TapeTypes::StatementData StatementData
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:146
inlineGradient & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reference access to gradient.
Definition jacobianBaseTape.hpp:241
T_Impl Impl
See JacobianBaseTape.
Definition jacobianBaseTape.hpp:136
Real & primal(Identifier const &identifier)
Not implemented, raises an exception.
Definition jacobianBaseTape.hpp:1045
JacobianBaseTape()
Constructor.
Definition jacobianBaseTape.hpp:212
AdjointVectorAccess< Real, Identifier, AdjointVector > VectorAccess
Vector access type generated by this tape.
Definition jacobianBaseTape.hpp:158
CommonTapeImplementation< T_TapeTypes, T_Impl > Base
Base class abbreviation.
Definition jacobianBaseTape.hpp:138
void evaluateForwardKeepState(Position const &start, Position const &end, AdjointVector &&data)
Perform a tape evaluation but restore the state afterwards such that it is the same as when the evalu...
Definition jacobianBaseTape.hpp:1026
void setParameter(TapeParameters parameter, size_t value)
See Parameters functions.
Definition jacobianBaseTape.hpp:784
void evaluateForward(Position const &start, Position const &end, AdjointVector &&data)
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end.
Definition jacobianBaseTape.hpp:710
void evaluate(Position const &start, Position const &end, AdjointVector &&data)
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end.
Definition jacobianBaseTape.hpp:695
inlinevoid store(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, LhsExpressionInterface< Real, Gradient, Impl, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition jacobianBaseTape.hpp:524
inlinevoid store(AggregatedActiveType< Aggregated, Type, Lhs > &lhs, ExpressionInterface< Aggregated, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition jacobianBaseTape.hpp:364
typename JacobianData::Position NestedPosition
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:153
static bool constexpr HasPrimalValues
Definition jacobianBaseTape.hpp:161
inlinevoid initIdentifier(Real &value, Identifier &identifier)
Definition jacobianBaseTape.hpp:271
static bool constexpr RequiresPrimalRestore
Definition jacobianBaseTape.hpp:165
void evaluateForwardKeepState(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a tape evaluation but restore the state afterwards such that it is the same as when the evalu...
Definition jacobianBaseTape.hpp:1019
inlinevoid store(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, Real const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition jacobianBaseTape.hpp:543
static bool constexpr AllowJacobianOptimization
Definition jacobianBaseTape.hpp:160
inlinevoid store(AggregatedActiveType< Aggregated, Type, Lhs > &lhs, AggregatedActiveType< Aggregated, Type, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition jacobianBaseTape.hpp:454
void storeManual(Real const &lhsValue, Identifier &lhsIndex, Config::ArgumentSize const &size)
Definition jacobianBaseTape.hpp:894
void writeTape(codi::TapeWriterInterface< Type > *writer, Position const &start, Position const &end)
For full or partial tapes using a pointer to the writer.
Definition jacobianBaseTape.hpp:943
VectorAccess< Adjoint * > * createVectorAccessCustomAdjoints(Adjoint *data)
Definition jacobianBaseTape.hpp:818
void pushJacobianManual(Real const &jacobian, Real const &value, Identifier const &index)
Definition jacobianBaseTape.hpp:870
void createStatementManual(Real const &lhsValue, Identifier &lhsIndex, Config::ArgumentSize const &size, Real const *jacobians, Identifier const *rhsIdentifiers)
Definition jacobianBaseTape.hpp:917
void evaluatePrimal(Position const &start, Position const &end)
Not implemented, raises an exception.
Definition jacobianBaseTape.hpp:1038
static bool constexpr LinearIndexHandling
Definition jacobianBaseTape.hpp:163
Real registerExternalFunctionOutput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Definition jacobianBaseTape.hpp:834
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition jacobianBaseTape.hpp:151
T_TapeTypes TapeTypes
See JacobianBaseTape.
Definition jacobianBaseTape.hpp:134
inlinevoid clearAdjoints(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Clear all adjoint values, that is, set them to zero.
Definition jacobianBaseTape.hpp:589
inlinevoid destroyIdentifier(Real &value, Identifier &identifier)
Has to be called for each identifier, before it is deallocated.
Definition jacobianBaseTape.hpp:279
MemberStore< IndexManager, Impl, TapeTypes::IsStaticIndexHandler > indexManager
Definition jacobianBaseTape.hpp:174
typename TapeTypes::Identifier Identifier
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:144
void deleteVectorAccess(VectorAccessInterface< Real, Identifier > *access)
See Adjoint vector access.
Definition jacobianBaseTape.hpp:823
inlineGradient const & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const
Constant reference access to gradient.
Definition jacobianBaseTape.hpp:253
inlinevoid registerInput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Definition jacobianBaseTape.hpp:583
Definition jacobianComputationLogic.hpp:54
inlinevoid pushStmtData(Identifier const &index, Config::ArgumentSize const &numberOfArguments)
Add statement specific data to the data streams.
Definition jacobianLinearTape.hpp:125
Type definitions for the Jacobian tapes.
Definition jacobianBaseTape.hpp:80
T_Real Real
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:83
typename std::conditional< IsLinearIndexHandler, Chunk1< Config::ArgumentSize >, Chunk2< Identifier, Config::ArgumentSize > >::type StatementChunk
Definition jacobianBaseTape.hpp:103
Chunk2< Real, Identifier > JacobianChunk
Jacobian chunks is <Jacobian, rhs index>.
Definition jacobianBaseTape.hpp:107
Data< JacobianChunk, StatementData > JacobianData
Jacobian data vector.
Definition jacobianBaseTape.hpp:108
Data< StatementChunk, IndexManager > StatementData
Statement data vector.
Definition jacobianBaseTape.hpp:105
T_Data< Chunk, Nested > Data
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:87
T_Gradient Gradient
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:84
T_IndexManager IndexManager
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:85
static bool constexpr IsLinearIndexHandler
True if the index manager is linear.
Definition jacobianBaseTape.hpp:97
T_Adjoints< Gradient, Identifier, Impl > Adjoints
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:94
typename IndexManager::Index Identifier
See IndexManagerInterface.
Definition jacobianBaseTape.hpp:90
JacobianData NestedData
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:110
static bool constexpr IsStaticIndexHandler
True if the index manager must be stored statically in the tape.
Definition jacobianBaseTape.hpp:98
Base class for all CoDiPack lvalue expression.
Definition lhsExpressionInterface.hpp:63
inlineImpl & cast()
Cast to the implementation.
Definition lhsExpressionInterface.hpp:99
Adjoint variables owned by a tape instance.
Definition localAdjoints.hpp:54
Defines a member that can either be static or local to the struct.
Definition memberStore.hpp:56
Methods that access inner values of aggregated types that contain CoDiPack active types.
Definition realTraits.hpp:226
Holds a reference to an ActiveType for manual optimization of common arguments.
Definition referenceActiveType.hpp:61
Interface for the definition of tape types.
Definition commonTapeImplementation.hpp:64
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
void addSection(std::string const &name)
Add section. All further entries are added under this section.
Definition tapeValues.hpp:158
The interface used by all the tape writers. The tape writers are used to generate text,...
Definition tapeReaderWriterInterface.hpp:129
virtual void start(Tape &tape)
Destructor.
Definition tapeReaderWriterInterface.hpp:144
virtual void finish()
After all the statements have been written, the finish method finalizes the writing process.
Definition tapeReaderWriterInterface.hpp:178
inlinevoid node(Node const &node, Args &&... args)
Definition traversalLogic.hpp:87
Unified access to the adjoint vector and primal vector in a tape evaluation.
Definition vectorAccessInterface.hpp:94