44#include "../expressions/aggregate/aggregatedActiveType.hpp"
45#include "../expressions/aggregate/arrayAccessExpression.hpp"
46#include "../expressions/emptyExpression.hpp"
47#include "../expressions/lhsExpressionInterface.hpp"
48#include "../expressions/logic/compileTimeTraversalLogic.hpp"
49#include "../expressions/logic/constructStaticContext.hpp"
50#include "../expressions/logic/helpers/forEachLeafLogic.hpp"
51#include "../expressions/logic/helpers/jacobianComputationLogic.hpp"
52#include "../expressions/logic/helpers/mathStatementGenLogic.hpp"
53#include "../expressions/logic/traversalLogic.hpp"
54#include "../misc/demangleName.hpp"
56#include "../misc/mathUtility.hpp"
57#include "../misc/memberStore.hpp"
58#include "../traits/expressionTraits.hpp"
59#include "commonTapeImplementation.hpp"
60#include "data/chunk.hpp"
61#include "data/chunkedData.hpp"
62#include "indices/indexManagerInterface.hpp"
63#include "misc/assignStatement.hpp"
64#include "misc/primalAdjointVectorAccess.hpp"
65#include "statementEvaluators/statementEvaluatorInterface.hpp"
66#include "statementEvaluators/statementEvaluatorTapeInterface.hpp"
80 template<
typename T_Real,
typename T_Gradient,
typename T_IndexManager,
typename T_StatementEvaluator,
81 template<
typename,
typename>
class T_Data>
90 template<
typename Chunk,
typename Nested>
96 typename IndexManager::ActiveTypeIndexData;
101 IndexManager::NeedsStaticStorage;
131 template<
typename T_TapeTypes,
typename T_Impl>
147 using Real =
typename TapeTypes::Real;
165 template<
typename Adjo
intVector>
171 TapeTypes::IsLinearIndexHandler;
173 !TapeTypes::IsLinearIndexHandler;
200 return static_cast<Impl const&
>(*this);
204 return static_cast<Impl&
>(*this);
214 template<
typename... Args>
218 template<
typename... Args>
222 template<
typename... Args>
241 checkPrimalSize(
true);
265 checkAdjointSize(identifier);
293 template<
typename Real>
301 template<
typename Real>
331 char* curPos = byteData;
337 curPos +=
sizeof(
Identifier) * reserverLhsSize;
340 curPos +=
sizeof(
Real) * passiveSize;
343 curPos +=
sizeof(
Real) * reserverLhsSize;
353 size_t constantSize) {
356 return sizeof(
Identifier) * (rhsSize + reserverLhsSize) +
sizeof(
Real) * (passiveSize + reserverLhsSize) +
365 StatementDataPointers& pointers) {
367 pointers.push(pointers.lhsIdentifiers, index);
368 pointers.push(pointers.oldLhsValues, oldPrimalValue);
374 size_t passiveSize,
size_t constantSize,
375 StatementDataPointers& pointers) {
380 char* byteData =
nullptr;
384 pointers.populate(lhsSize, rhsSize, passiveSize, constantSize, byteData);
390 template<
typename Lhs,
typename Rhs>
392 StatementDataPointers& pointers) {
397 return reserveStmtDataManual(MaxOutputArgs, MaxActiveArgs, MaxActiveArgs - activeArguments, MaxConstantArgs,
406 template<
typename Node>
411 numberOfActiveArguments += 1;
421 template<
typename Node>
425 rhsIndex = curPassiveArgument;
427 curPassiveArgument += 1;
435 template<
typename Node>
437 size_t& curPassiveArgument) {
441 using ConversionOperator =
typename Node::template ConversionOperator<PassiveReal>;
443 typename Node::Real v =
node.getValue();
447 ConversionOperator::toDataStore(AggregatedTraits::template arrayAccess<i.value>(v)));
456 template<
typename Lhs,
typename RhsType,
typename Rhs>
458 StatementDataPointers& pointers) {
461 CountActiveArguments countActiveArguments;
462 PushIdentifierPassiveAndConstant pushStatement;
468 size_t activeArguments = 0;
474 size_t passiveArguments = 0;
475 pushStatement.eval(rhs.
cast(), pointers, passiveArguments);
477 StatementEvaluator::template createHandle<Impl, Impl, Stmt>(), byteSize);
496 template<
typename Node,
typename Jacobian>
499 rhsIdentifiers[pos] =
node.getIdentifier();
500 jacobians[pos] = jacobianExpr;
511 template<
typename Aggregated,
typename Type,
typename Lhs,
typename Rhs>
515 int constexpr Elements = AggregatedTraits::Elements;
517 bool primalStored =
false;
518 StatementDataPointers pointers = {};
521 bool generatedNewIndex =
false;
523 generatedNewIndex |=
indexManager.get().template assignIndex<Impl>(lhs.
values[i.value].getTapeData());
525 checkPrimalSize(generatedNewIndex);
527 Aggregated
real = rhs.
cast().getValue();
537 JacobianExtractionLogic getRhsIdentifiersAndJacobians;
538 std::array<Identifier, MaxActiveArgs> rhsIdentifiers;
539 std::array<Real, MaxActiveArgs> jacobians;
541 rhsIdentifiers.data(), jacobians.data());
544 cast(), lhsIdentifier, AggregatedTraits::template arrayAccess<i.value>(
real), MaxActiveArgs,
545 rhsIdentifiers.data(), jacobians.data());
548 lhs.
values[i.value].value() = AggregatedTraits::template arrayAccess<i.value>(
real);
549 primalEntry = lhs.
values[i.value].getValue();
556 Aggregated
real = rhs.
cast().getValue();
559 lhs.
values[i.value].value() = AggregatedTraits::template arrayAccess<i.value>(
real);
567 template<
typename Aggregated,
typename Type,
typename Lhs,
typename Rhs>
572 int constexpr Elements = AggregatedTraits::Elements;
581 rhs.
values[i.value].getTapeData());
591 lhs.
values[i.value].value() = rhs.
values[i.value].getValue();
596 template<
typename Lhs,
typename Rhs>
599 bool primalStored =
false;
600 StatementDataPointers pointers = {};
603 bool generatedNewIndex =
indexManager.get().template assignIndex<Impl>(lhs.
cast().getTapeData());
604 checkPrimalSize(generatedNewIndex);
609 primalEntry = rhs.
cast().getValue();
614 JacobianExtractionLogic getRhsIdentifiersAndJacobians;
615 std::array<Identifier, MaxActiveArgs> rhsIdentifiers;
616 std::array<Real, MaxActiveArgs> jacobians;
617 getRhsIdentifiersAndJacobians.eval(rhs.
cast(),
Real(1.0), rhsIdentifiers.data(), jacobians.data());
620 rhs.
cast().getValue(), MaxActiveArgs,
621 rhsIdentifiers.data(), jacobians.data());
631 lhs.
cast().value() = rhs.
cast().getValue();
636 template<
typename Lhs,
typename Rhs>
644 indexManager.get().template copyIndex<Impl>(lhs.
cast().getTapeData(), rhs.
cast().getTapeData());
650 lhs.
cast().value() = rhs.
cast().getValue();
655 template<
typename Lhs>
659 lhs.
cast().value() = rhs;
670 template<
typename Lhs>
673 if (TapeTypes::IsLinearIndexHandler) {
677 bool generatedNewIndex;
679 generatedNewIndex =
indexManager.get().template assignUnusedIndex<Impl>(value.
cast().getTapeData());
681 generatedNewIndex =
indexManager.get().template assignIndex<Impl>(value.
cast().getTapeData());
683 checkPrimalSize(generatedNewIndex);
686 if (TapeTypes::IsLinearIndexHandler) {
692 Real oldValue = primalEntry;
693 primalEntry = value.
cast().value();
704 template<
typename Lhs>
716 size_t maxSize = std::min((
size_t)
indexManager.get().getLargestCreatedIndex() + 1,
adjoints.size());
717 for (
size_t i = 0; i < maxSize; i += 1) {
742 if (TapeTypes::IsLinearIndexHandler) {
743 name =
"CoDi Tape Statistics ( PrimalValueLinearTape )";
745 name =
"CoDi Tape Statistics ( PrimalValueReuseTape )";
749 size_t nAdjoints =
indexManager.get().getLargestCreatedIndex();
750 double memoryAdjoints =
static_cast<double>(nAdjoints) *
static_cast<double>(
sizeof(
Gradient));
752 size_t nPrimals =
indexManager.get().getLargestCreatedIndex();
753 double memoryPrimals =
static_cast<double>(nPrimals) *
static_cast<double>(
sizeof(
Real));
757 values.
addDoubleEntry(
"Memory allocated", memoryAdjoints, TapeValues::LocalReductionOperation::Sum,
true,
true);
761 values.
addDoubleEntry(
"Memory allocated", memoryPrimals, TapeValues::LocalReductionOperation::Sum,
true,
true);
780 template<
typename Adjo
intVector>
784#if CODI_VariableAdjointInterfaceInPrimalTapes
788 "Please enable 'CODI_VariableAdjointInterfaceInPrimalTapes' in order"
789 " to use custom adjoint vectors in the primal value tapes.");
800 template<
typename Node>
806#if CODI_VariableAdjointInterfaceInPrimalTapes
807 adjointVector->updateTangentWithLhs(
node.getIdentifier(), jacobian);
809 lhsTangent += jacobian * adjointVector[
node.getIdentifier()];
819 template<
bool copyPrimal,
typename Adjo
intVector>
823 CODI_T(std::is_same<
typename std::remove_reference<AdjointVector>::type,
Gradient*>::value),
824 "Please enable 'CODI_VariableAdjointInterfaceInPrimalTapes' in order"
825 " to use custom adjoint vectors in the primal value tapes.");
840 cast(), start, end, &vectorAccess, EventHints::EvaluationKind::Forward, EventHints::Endpoint::Begin);
842 Wrap_internalEvaluateForward_EvalStatements evalFunc{};
843 Base::llfByteData.evaluateForward(start, end, evalFunc, cast(), primalData, dataVector);
846 EventHints::EvaluationKind::Forward, EventHints::Endpoint::End);
854 template<
typename Node>
860#if CODI_VariableAdjointInterfaceInPrimalTapes
861 adjointVector->updateAdjointWithLhs(
node.getIdentifier(), jacobian);
863 adjointVector[
node.getIdentifier()] += jacobian * lhsAdjoint;
873 template<
bool copyPrimal,
typename Adjo
intVector>
877 CODI_T(std::is_same<
typename std::remove_reference<AdjointVector>::type,
Gradient*>::value),
878 "Please enable 'CODI_VariableAdjointInterfaceInPrimalTapes' in order"
879 " to use custom adjoint vectors in the primal value tapes.");
893 cast(), start, end, &vectorAccess, EventHints::EvaluationKind::Reverse, EventHints::Endpoint::Begin);
895 Wrap_internalEvaluateReverse_EvalStatements evalFunc;
896 Base::llfByteData.evaluateReverse(start, end, evalFunc, cast(), primalData, dataVector);
899 EventHints::EvaluationKind::Reverse, EventHints::Endpoint::End);
910 template<
typename Adjo
intVector>
916 template<
typename Adjo
intVector>
942 checkPrimalSize(
true);
943 other.checkPrimalSize(
true);
953 checkAdjointSize(
indexManager.get().getLargestCreatedIndex());
995 CODI_EXCEPTION(
"Tried to set a get only option.");
1018 template<
typename Adjo
intVector>
1025 template<
typename Adjo
int>
1041 template<
typename Lhs>
1059 checkAdjointSize(
indexManager.get().getLargestCreatedIndex());
1064 cast().evaluateForward(start, end,
adjoints.data());
1076 cast().incrementManualPushCounter();
1103 StatementDataPointers pointers = {};
1109 indexManager.get().template assignIndex<Impl>(lhsData);
1114 primalEntry = lhsValue;
1116 cast().initializeManualPushData(lhsValue,
indexManager.get().getIndex(lhsData), size);
1134 Impl& impl = cast();
1139 primals[lhsIndices[0]] = lhsValues[0];
1142 StatementDataPointers pointers = {};
1148 for (
size_t activeCount = 0; activeCount < nActiveValues; activeCount++) {
1149 pointers.rhsIdentifiers[activeCount] = rhsIdentifiers[activeCount];
1151 for (
size_t passiveCount = 0; passiveCount < nPassiveValues; passiveCount++) {
1152 cast().incrementManualPushCounter();
1153 pointers.passiveValues[passiveCount] = rhsPrimals[passiveCount];
1155 for (
size_t constantCount = 0; constantCount < nConstants; constantCount++) {
1156 pointers.constantValues[constantCount] = rhsConstant[constantCount];
1159 statementData.pushData(nPassiveValues, evalHandle, byteSize);
1162 pushLhsData(lhsIndices[i], lhsValues[i], pointers);
1164 if (TapeTypes::IsLinearIndexHandler) {
1165 primals[lhsIndices[i]] = lhsValues[i];
1177 template<
typename Type>
1180 Impl& impl = cast();
1181 writer->
start(impl);
1221 checkAdjointSize(
indexManager.get().getLargestCreatedIndex());
1234 cast().internalResetPrimalValues(pos);
1250 checkAdjointSize(
indexManager.get().getLargestCreatedIndex());
1259 template<
typename Adjo
intVector>
1263 if (!TapeTypes::IsLinearIndexHandler) {
1274 checkAdjointSize(
indexManager.get().getLargestCreatedIndex());
1283 template<
typename Adjo
intVector>
1285 if (!TapeTypes::IsLinearIndexHandler) {
1286 cast().internalResetPrimalValues(end);
1316 EventHints::EvaluationKind::Primal, EventHints::Endpoint::Begin);
1318 Wrap_internalEvaluatePrimal_EvalStatements evalFunc{};
1322 EventHints::EvaluationKind::Primal, EventHints::Endpoint::End);
1346 template<
typename Stmt,
typename GenImpl>
1349 using Lhs =
typename Stmt::Lhs;
1350 using Rhs =
typename Stmt::Rhs;
1357 template<
size_t pos>
1369 template<
typename... Args>
1375 GenImpl::evaluateFull(GenImpl::evaluateInner, MaxOutputArgs, MaxActiveArgs, MaxConstantArgs,
1376 std::forward<Args>(args)...);
1381 template<StatementCall type,
typename Stmt>
1385#define STMT_COMMON_ARGS Config::ArgumentSize numberOfPassiveArguments, char *CODI_RESTRICT byteData
1386#define STMT_COMMON_CALL numberOfPassiveArguments, byteData
1390 template<
typename Stmt>
1405 pointers.
populate(maxOutputArgs, maxActiveArgs, numberOfPassiveArguments, maxConstantArgs, byteData);
1416 writeInfo.numberOfOutputArguments = maxOutputArgs;
1417 writeInfo.numberOfActiveArguments = maxActiveArgs;
1418 writeInfo.numberOfConstantArguments = maxConstantArgs;
1424 writeInfo.stmtExpression =
"Impl, Impl, ";
1427 mathGen.
eval(staticRhs, writeInfo.mathRepresentation);
1431 template<
typename Func,
typename... Args>
1433 func(std::forward<Args>(args)...);
1445 template<
typename Stmt>
1461 void* userData, STMT_COMMON_ARGS) {
1465 pointers.
populate(maxOutputArgs, maxActiveArgs, numberOfPassiveArguments, maxConstantArgs, byteData);
1475 template<
typename Func,
typename... Args>
1477 func(std::forward<Args>(args)...);
1489 template<
typename Stmt>
1505 void* userData, STMT_COMMON_ARGS) {
1507 pointers.
populate(maxOutputArgs, maxActiveArgs, numberOfPassiveArguments, maxConstantArgs, byteData);
1509 for (
size_t iLhs = 0; iLhs < maxOutputArgs; iLhs += 1) {
1511 Identifier lhsIdentifier = linearAdjointPos + 1 + iLhs;
1512 func(&lhsIdentifier, userData);
1522 template<
typename Func,
typename... Args>
1524 func(std::forward<Args>(args)...);
1536 template<
typename Stmt>
1548 template<
typename Func>
1556 pointers.
populate(maxOutputArgs, maxActiveArgs, numberOfPassiveArguments, maxConstantArgs, byteData);
1558 for (
size_t iLhs = 0; iLhs < maxOutputArgs; iLhs += 1) {
1562#if CODI_VariableAdjointInterfaceInPrimalTapes
1563 adjointVector->resetAdjointVec(lhsIdentifier);
1565 adjointVector[lhsIdentifier] =
Gradient();
1578 template<
typename Stmt>
1586 template<
size_t pos>
1600#if CODI_VariableAdjointInterfaceInPrimalTapes
1601 adjointVector->setActiveVariableForIndirectAccess(i.value);
1607 incrementForward.
eval(expr,
Real(1.0), lhsTangents[i.value], adjointVector);
1608 lhsPrimals[i.value] = expr.getValue();
1613 template<
typename Func>
1622 pointers.
populate(maxOutputArgs, maxActiveArgs, numberOfPassiveArguments, maxConstantArgs, byteData);
1628 evalInner(primalVector, adjointVector, lhsPrimals, lhsTangents, pointers.
constantValues,
1631 for (
size_t iLhs = 0; iLhs < maxOutputArgs; iLhs += 1) {
1634 linearAdjointPos += 1;
1635 lhsIdentifier = linearAdjointPos;
1641 pointers.
oldLhsValues[iLhs] = primalVector[lhsIdentifier];
1644 primalVector[lhsIdentifier] = lhsPrimals[iLhs];
1646#if CODI_VariableAdjointInterfaceInPrimalTapes
1647 adjointVector->setLhsTangent(lhsIdentifier);
1649 adjointVector->getAdjointVec(lhsIdentifier));
1651 adjointVector[lhsIdentifier] = lhsTangents[iLhs];
1656 primalVector[lhsIdentifier]);
1672 template<
typename Stmt>
1680 template<
size_t pos>
1692 lhsPrimals[i.value] = expr.getValue();
1697 template<
typename Func>
1704 pointers.
populate(maxOutputArgs, maxActiveArgs, numberOfPassiveArguments, maxConstantArgs, byteData);
1712 for (
size_t iLhs = 0; iLhs < maxOutputArgs; iLhs += 1) {
1715 linearAdjointPos += 1;
1716 lhsIdentifier = linearAdjointPos;
1722 pointers.
oldLhsValues[iLhs] = primalVector[lhsIdentifier];
1725 primalVector[lhsIdentifier] = lhsPrimals[iLhs];
1728 primalVector[lhsIdentifier]);
1742 template<
typename Stmt>
1750 template<
size_t pos>
1763#if CODI_VariableAdjointInterfaceInPrimalTapes
1764 adjointVector->setActiveVariableForIndirectAccess(i.value);
1767 incrementReverse.
eval(expr,
Real(1.0),
const_cast<Gradient const&
>(lhsAdjoints[i.value]), adjointVector);
1772 template<
typename Func>
1780 pointers.
populate(maxOutputArgs, maxActiveArgs, numberOfPassiveArguments, maxConstantArgs, byteData);
1783 linearAdjointPos -= maxOutputArgs;
1786 bool allZero =
true;
1787 for (
size_t iLhs = 0; iLhs < maxOutputArgs; iLhs += 1) {
1790 lhsIdentifier = linearAdjointPos + 1 + iLhs;
1795#if CODI_VariableAdjointInterfaceInPrimalTapes
1797 adjointVector->getAdjointVec(lhsIdentifier));
1798 adjointVector->setActiveVariableForIndirectAccess(iLhs);
1799 adjointVector->setLhsAdjoint(lhsIdentifier);
1800 allZero &= adjointVector->isLhsZero();
1802 lhsAdjoints[iLhs] = adjointVector[lhsIdentifier];
1805 adjointVector[lhsIdentifier] =
Gradient();
1810 primalVector[lhsIdentifier]);
1812 primalVector[lhsIdentifier] = pointers.
oldLhsValues[iLhs];
1830 Base::internalEvaluate(tape, lhsAdjoints, primalVector, adjointVector, linearAdjointPos, STMT_COMMON_CALL);
1836 template<
typename Stmt>
1848 template<
typename Func>
1856 pointers.
populate(maxOutputArgs, maxActiveArgs, numberOfPassiveArguments, maxConstantArgs, byteData);
1859 for (
size_t iLhs = 0; iLhs < maxOutputArgs; iLhs += 1) {
1862 primalVector[lhsIdentifier] = pointers.
oldLhsValues[iLhs];
1876 CODI_INLINE void checkAdjointSize(Identifier
const& identifier) {
1877 if (identifier >= (Identifier)
adjoints.size()) {
1878 resizeAdjointsVector();
1882 CODI_INLINE void checkPrimalSize(
bool generatedNewIndex) {
1884 resizePrimalVector();
1900 template<
size_t size>
1904 template<
size_t size>
1910 template<
size_t size>
1917 template<
typename T_TapeImpl,
size_t T_size>
1926 static size_t constexpr size = T_size;
1928 using Real =
typename TapeImpl::Real;
1938 template<
typename Rhs,
typename Impl>
1946 template<StatementCall type,
typename Stmt>
1950 template<
typename Stmt>
1961 template<
typename Func>
1963 size_t const& maxActiveArgs,
size_t const& maxConstantArgs,
1964 WriteInfo& writeInfo,
Real* primalVector, STMT_COMMON_ARGS) {
1965 CODI_UNUSED(func, primalVector, numberOfPassiveArguments, byteData);
1970 writeInfo.
stmtExpression =
"Impl, typename Impl::template JacobianStatementGenerator<" +
1971 std::to_string(
size) +
">, codi::JacobianExpression<" + std::to_string(
size) +
1979 Base::internalEvaluate(writeInfo, primalVector, STMT_COMMON_CALL);
1984 template<
typename Stmt>
1995 template<
typename Func>
1997 size_t const& maxActiveArgs,
size_t const& maxConstantArgs,
2002 pointers.populate(maxOutputArgs, maxActiveArgs, numberOfPassiveArguments, maxConstantArgs, byteData);
2007 Identifier lhsIdentifier = pointers.lhsIdentifiers[0];
2009#if CODI_VariableAdjointInterfaceInPrimalTapes
2010 adjointVector->resetAdjointVec(lhsIdentifier);
2012 adjointVector[lhsIdentifier] =
Gradient();
2018 Base::internalEvaluate(adjointVector, STMT_COMMON_CALL);
2023 template<
typename Stmt>
2027 CODI_EXCEPTION(
"Forward evaluation of jacobian statement not possible.");
2032 CODI_EXCEPTION(
"Forward evaluation of jacobian statement not possible.");
2037 template<
typename Stmt>
2041 CODI_EXCEPTION(
"Primal evaluation of jacobian statement not possible.");
2046 CODI_EXCEPTION(
"Primal evaluation of jacobian statement not possible.");
2051 template<
typename Stmt>
2063 evalJacobianReverse(adjointVector, lhsAdjoints[0], primalVector, rhsIdentifiers);
2069 CODI_UNUSED(primalVector, lhsAdjoints, numberOfPassiveArguments);
2072 pointers.populate(1,
size,
size, 0, byteData);
2076 lhsIdentifier = linearAdjointPos;
2078 lhsIdentifier = pointers.lhsIdentifiers[0];
2081#if CODI_VariableAdjointInterfaceInPrimalTapes
2084 adjointVector->getAdjointVec(lhsIdentifier));
2085 adjointVector->setLhsAdjoint(lhsIdentifier);
2087 Gradient const lhsAdjoint = adjointVector[lhsIdentifier];
2090 adjointVector[lhsIdentifier] =
Gradient();
2094 primalVector[lhsIdentifier]);
2096 primalVector[lhsIdentifier] = pointers.oldLhsValues[0];
2099 evalJacobianReverse(adjointVector, lhsAdjoint, pointers.passiveValues, pointers.rhsIdentifiers);
2104 template<
typename Stmt>
2115 template<
typename Func>
2117 size_t const& maxActiveArgs,
size_t const& maxConstantArgs,
2118 Real* primalVector, STMT_COMMON_ARGS) {
2119 CODI_UNUSED(evalInner, maxOutputArgs, maxActiveArgs, maxConstantArgs, numberOfPassiveArguments);
2122 pointers.populate(1,
size,
size, 0, byteData);
2127 Identifier lhsIdentifier = pointers.lhsIdentifiers[0];
2128 primalVector[lhsIdentifier] = pointers.oldLhsValues[0];
2133 Base::internalEvaluate(primalVector, STMT_COMMON_CALL);
2138 template<
typename Stmt>
2153 void* userData, STMT_COMMON_ARGS) {
2157 pointers.populate(maxOutputArgs, maxActiveArgs, numberOfPassiveArguments, maxConstantArgs, byteData);
2161 func(&pointers.rhsIdentifiers[i], userData);
2167 template<
typename Func,
typename... Args>
2169 func(std::forward<Args>(args)...);
2175 Base::internalEvaluate(linearAdjointPos, func, userData, STMT_COMMON_CALL);
2181 template<
typename Stmt>
2197 void* userData, STMT_COMMON_ARGS) {
2199 pointers.populate(maxOutputArgs, maxActiveArgs, numberOfPassiveArguments, maxConstantArgs, byteData);
2201 for (
size_t iLhs = 0; iLhs < maxOutputArgs; iLhs += 1) {
2203 Identifier lhsIdentifier = linearAdjointPos + 1 + iLhs;
2204 func(&lhsIdentifier, userData);
2208 func(&pointers.lhsIdentifiers[iLhs], userData);
2214 template<
typename Func,
typename... Args>
2216 func(std::forward<Args>(args)...);
2222 Base::internalEvaluate(linearAdjointPos, func, userData, STMT_COMMON_CALL);
2229 static void evalJacobianReverse(
ADJOINT_VECTOR_TYPE* adjointVector, Gradient lhsAdjoint, Real
const*
const values,
2230 Identifier
const*
const rhsIdentifiers) {
2231#if CODI_VariableAdjointInterfaceInPrimalTapes
2233 bool const lhsZero = adjointVector->isLhsZero();
2239 for (
size_t pos = 0; pos <
size; pos += 1) {
2240 Real
const& jacobian = values[pos];
2241#if CODI_VariableAdjointInterfaceInPrimalTapes
2242 adjointVector->updateAdjointWithLhs(rhsIdentifiers[pos], jacobian);
2244 adjointVector[rhsIdentifiers[pos]] += jacobian * lhsAdjoint;
2251#undef STMT_COMMON_ARGS
2252#undef STMT_COMMON_CALL
2254#define CREATE_EXPRESSION(size) \
2255 TapeTypes::StatementEvaluator::template createHandle<Impl, JacobianStatementGenerator<Impl, size>, \
2256 AssignStatement<ActiveType<Impl>, JacobianExpression<size>>>()
2259 template<
typename TapeTypes,
typename Impl>
2260 const CODI_DD(
typename TapeTypes::EvalHandle,
2262 CREATE_EXPRESSION(0), CREATE_EXPRESSION(1), CREATE_EXPRESSION(2), CREATE_EXPRESSION(3),
2263 CREATE_EXPRESSION(4), CREATE_EXPRESSION(5), CREATE_EXPRESSION(6), CREATE_EXPRESSION(7),
2264 CREATE_EXPRESSION(8), CREATE_EXPRESSION(9), CREATE_EXPRESSION(10), CREATE_EXPRESSION(11),
2265 CREATE_EXPRESSION(12), CREATE_EXPRESSION(13), CREATE_EXPRESSION(14), CREATE_EXPRESSION(15),
2266 CREATE_EXPRESSION(16), CREATE_EXPRESSION(17), CREATE_EXPRESSION(18), CREATE_EXPRESSION(19),
2267 CREATE_EXPRESSION(20), CREATE_EXPRESSION(21), CREATE_EXPRESSION(22), CREATE_EXPRESSION(23),
2268 CREATE_EXPRESSION(24), CREATE_EXPRESSION(25), CREATE_EXPRESSION(26), CREATE_EXPRESSION(27),
2269 CREATE_EXPRESSION(28), CREATE_EXPRESSION(29), CREATE_EXPRESSION(30), CREATE_EXPRESSION(31),
2270 CREATE_EXPRESSION(32), CREATE_EXPRESSION(33), CREATE_EXPRESSION(34), CREATE_EXPRESSION(35),
2271 CREATE_EXPRESSION(36), CREATE_EXPRESSION(37), CREATE_EXPRESSION(38), CREATE_EXPRESSION(39),
2272 CREATE_EXPRESSION(40), CREATE_EXPRESSION(41), CREATE_EXPRESSION(42), CREATE_EXPRESSION(43),
2273 CREATE_EXPRESSION(44), CREATE_EXPRESSION(45), CREATE_EXPRESSION(46), CREATE_EXPRESSION(47),
2274 CREATE_EXPRESSION(48), CREATE_EXPRESSION(49), CREATE_EXPRESSION(50), CREATE_EXPRESSION(51),
2275 CREATE_EXPRESSION(52), CREATE_EXPRESSION(53), CREATE_EXPRESSION(54), CREATE_EXPRESSION(55),
2276 CREATE_EXPRESSION(56), CREATE_EXPRESSION(57), CREATE_EXPRESSION(58), CREATE_EXPRESSION(59),
2277 CREATE_EXPRESSION(60), CREATE_EXPRESSION(61), CREATE_EXPRESSION(62), CREATE_EXPRESSION(63),
2278 CREATE_EXPRESSION(64), CREATE_EXPRESSION(65), CREATE_EXPRESSION(66), CREATE_EXPRESSION(67),
2279 CREATE_EXPRESSION(68), CREATE_EXPRESSION(69), CREATE_EXPRESSION(70), CREATE_EXPRESSION(71),
2280 CREATE_EXPRESSION(72), CREATE_EXPRESSION(73), CREATE_EXPRESSION(74), CREATE_EXPRESSION(75),
2281 CREATE_EXPRESSION(76), CREATE_EXPRESSION(77), CREATE_EXPRESSION(78), CREATE_EXPRESSION(79),
2282 CREATE_EXPRESSION(80), CREATE_EXPRESSION(81), CREATE_EXPRESSION(82), CREATE_EXPRESSION(83),
2283 CREATE_EXPRESSION(84), CREATE_EXPRESSION(85), CREATE_EXPRESSION(86), CREATE_EXPRESSION(87),
2284 CREATE_EXPRESSION(88), CREATE_EXPRESSION(89), CREATE_EXPRESSION(90), CREATE_EXPRESSION(91),
2285 CREATE_EXPRESSION(92), CREATE_EXPRESSION(93), CREATE_EXPRESSION(94), CREATE_EXPRESSION(95),
2286 CREATE_EXPRESSION(96), CREATE_EXPRESSION(97), CREATE_EXPRESSION(98), CREATE_EXPRESSION(99),
2287 CREATE_EXPRESSION(100), CREATE_EXPRESSION(101), CREATE_EXPRESSION(102), CREATE_EXPRESSION(103),
2288 CREATE_EXPRESSION(104), CREATE_EXPRESSION(105), CREATE_EXPRESSION(106), CREATE_EXPRESSION(107),
2289 CREATE_EXPRESSION(108), CREATE_EXPRESSION(109), CREATE_EXPRESSION(110), CREATE_EXPRESSION(111),
2290 CREATE_EXPRESSION(112), CREATE_EXPRESSION(113), CREATE_EXPRESSION(114), CREATE_EXPRESSION(115),
2291 CREATE_EXPRESSION(116), CREATE_EXPRESSION(117), CREATE_EXPRESSION(118), CREATE_EXPRESSION(119),
2292 CREATE_EXPRESSION(120), CREATE_EXPRESSION(121), CREATE_EXPRESSION(122), CREATE_EXPRESSION(123),
2293 CREATE_EXPRESSION(124), CREATE_EXPRESSION(125), CREATE_EXPRESSION(126), CREATE_EXPRESSION(127),
2294 CREATE_EXPRESSION(128), CREATE_EXPRESSION(129), CREATE_EXPRESSION(130), CREATE_EXPRESSION(131),
2295 CREATE_EXPRESSION(132), CREATE_EXPRESSION(133), CREATE_EXPRESSION(134), CREATE_EXPRESSION(135),
2296 CREATE_EXPRESSION(136), CREATE_EXPRESSION(137), CREATE_EXPRESSION(138), CREATE_EXPRESSION(139),
2297 CREATE_EXPRESSION(140), CREATE_EXPRESSION(141), CREATE_EXPRESSION(142), CREATE_EXPRESSION(143),
2298 CREATE_EXPRESSION(144), CREATE_EXPRESSION(145), CREATE_EXPRESSION(146), CREATE_EXPRESSION(147),
2299 CREATE_EXPRESSION(148), CREATE_EXPRESSION(149), CREATE_EXPRESSION(150), CREATE_EXPRESSION(151),
2300 CREATE_EXPRESSION(152), CREATE_EXPRESSION(153), CREATE_EXPRESSION(154), CREATE_EXPRESSION(155),
2301 CREATE_EXPRESSION(156), CREATE_EXPRESSION(157), CREATE_EXPRESSION(158), CREATE_EXPRESSION(159),
2302 CREATE_EXPRESSION(160), CREATE_EXPRESSION(161), CREATE_EXPRESSION(162), CREATE_EXPRESSION(163),
2303 CREATE_EXPRESSION(164), CREATE_EXPRESSION(165), CREATE_EXPRESSION(166), CREATE_EXPRESSION(167),
2304 CREATE_EXPRESSION(168), CREATE_EXPRESSION(169), CREATE_EXPRESSION(170), CREATE_EXPRESSION(171),
2305 CREATE_EXPRESSION(172), CREATE_EXPRESSION(173), CREATE_EXPRESSION(174), CREATE_EXPRESSION(175),
2306 CREATE_EXPRESSION(176), CREATE_EXPRESSION(177), CREATE_EXPRESSION(178), CREATE_EXPRESSION(179),
2307 CREATE_EXPRESSION(180), CREATE_EXPRESSION(181), CREATE_EXPRESSION(182), CREATE_EXPRESSION(183),
2308 CREATE_EXPRESSION(184), CREATE_EXPRESSION(185), CREATE_EXPRESSION(186), CREATE_EXPRESSION(187),
2309 CREATE_EXPRESSION(188), CREATE_EXPRESSION(189), CREATE_EXPRESSION(190), CREATE_EXPRESSION(191),
2310 CREATE_EXPRESSION(192), CREATE_EXPRESSION(193), CREATE_EXPRESSION(194), CREATE_EXPRESSION(195),
2311 CREATE_EXPRESSION(196), CREATE_EXPRESSION(197), CREATE_EXPRESSION(198), CREATE_EXPRESSION(199),
2312 CREATE_EXPRESSION(200), CREATE_EXPRESSION(201), CREATE_EXPRESSION(202), CREATE_EXPRESSION(203),
2313 CREATE_EXPRESSION(204), CREATE_EXPRESSION(205), CREATE_EXPRESSION(206), CREATE_EXPRESSION(207),
2314 CREATE_EXPRESSION(208), CREATE_EXPRESSION(209), CREATE_EXPRESSION(210), CREATE_EXPRESSION(211),
2315 CREATE_EXPRESSION(212), CREATE_EXPRESSION(213), CREATE_EXPRESSION(214), CREATE_EXPRESSION(215),
2316 CREATE_EXPRESSION(216), CREATE_EXPRESSION(217), CREATE_EXPRESSION(218), CREATE_EXPRESSION(219),
2317 CREATE_EXPRESSION(220), CREATE_EXPRESSION(221), CREATE_EXPRESSION(222), CREATE_EXPRESSION(223),
2318 CREATE_EXPRESSION(224), CREATE_EXPRESSION(225), CREATE_EXPRESSION(226), CREATE_EXPRESSION(227),
2319 CREATE_EXPRESSION(228), CREATE_EXPRESSION(229), CREATE_EXPRESSION(230), CREATE_EXPRESSION(231),
2320 CREATE_EXPRESSION(232), CREATE_EXPRESSION(233), CREATE_EXPRESSION(234), CREATE_EXPRESSION(235),
2321 CREATE_EXPRESSION(236), CREATE_EXPRESSION(237), CREATE_EXPRESSION(238), CREATE_EXPRESSION(239),
2322 CREATE_EXPRESSION(240), CREATE_EXPRESSION(241), CREATE_EXPRESSION(242), CREATE_EXPRESSION(243),
2323 CREATE_EXPRESSION(244), CREATE_EXPRESSION(245), CREATE_EXPRESSION(246), CREATE_EXPRESSION(247),
2324 CREATE_EXPRESSION(248), CREATE_EXPRESSION(249), CREATE_EXPRESSION(250), CREATE_EXPRESSION(251),
2325 CREATE_EXPRESSION(252)};
2327#undef CREATE_EXPRESSION
#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 ADJOINT_VECTOR_TYPE
See codi::Config::VariableAdjointInterfaceInPrimalTapes.
Definition config.h:286
#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 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_ENABLE_CHECK(option, condition)
Definition macros.hpp:62
#define CODI_WRAP_FUNCTION(NAME, FUNC)
Wrap a function in a function object. Used for performance optimizations.
Definition macros.hpp:167
#define CODI_ANY
Used in default declarations of expression templates.
Definition macros.hpp:101
#define CODI_STATIC_ASSERT(cond, message)
Static assert definition for CoDiPack. Not evaluated in IDE mode.
Definition macros.hpp:130
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:117
Configuration options for CoDiPack.
Definition config.h:65
uint16_t LowLevelFunctionDataSize
Size store type for a low level function.
Definition config.h:98
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
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
bool constexpr VariableAdjointInterfaceInPrimalTapes
Allow custom adjoint vector in primal values tapes.
Definition config.h:281
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
inlinestd::array< AtomicTraits::RemoveAtomic< typename TraitsImplementation< Gradient >::Real >, TraitsImplementation< Gradient >::dim > toArray(Gradient const &gradient)
Converts the (possibly multi-component) gradient to an array of Reals.
Definition gradientTraits.hpp:116
inlinesize_t constexpr dim()
Number of dimensions this gradient value has.
Definition gradientTraits.hpp:96
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:97
IntegralType getNextMultiple(IntegralType const &targetSize, IntegralType const &chunkSize)
Helper function for overallocation in multiples of a given chunk size.
Definition mathUtility.hpp:49
std::string demangleName()
Return a string of the provided template name.
Definition demangleName.hpp:47
TapeParameters
Configuration options for a tape.
Definition tapeParameters.hpp:52
@ StatementByteSize
[A: RW] Allocated size of the byte data for the statement data.
Definition tapeParameters.hpp:67
@ LargestIdentifier
[A: R] Largest identifier distributed by the index manger.
Definition tapeParameters.hpp:60
@ PrimalSize
[A: RW] Number of primal vector entries in primal value tapes.
Definition tapeParameters.hpp:63
@ 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
ComputeExpression< Real, EmptyOperation > EmptyExpression
Expression with no arguments for register input statements.
Definition emptyExpression.hpp:70
StatementCall
Defines all the operations which can be evaluated on a statement by a tape.
Definition statementEvaluatorTapeInterface.hpp:45
@ WriteInformation
Get write information.
Definition statementEvaluatorTapeInterface.hpp:51
@ ResetPrimals
Restore the primal values.
Definition statementEvaluatorTapeInterface.hpp:49
@ ClearAdjoints
Clear the adjoint values.
Definition statementEvaluatorTapeInterface.hpp:46
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:55
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
InnerActiveType values[Elements]
Array representation.
Definition aggregatedActiveType.hpp:75
Represents a concrete aggregated lvalue int the CoDiPack expression tree.
Definition aggregatedActiveType.hpp:164
Definition assignStatement.hpp:50
Definition byteDataView.hpp:51
inlinevoid internalStoreLowLevelFunction(Config::LowLevelFunctionToken token, size_t size, ByteDataView &dataView)
Definition commonTapeImplementation.hpp:519
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:202
Real manualPushLhsValue
For storeManual, remember the value assigned to the lhs.
Definition commonTapeImplementation.hpp:160
void setParameter(TapeParameters parameter, size_t value)
Definition commonTapeImplementation.hpp:484
void evaluateForward(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Definition commonTapeImplementation.hpp:652
size_t manualPushCounter
Count the pushes after storeManual, to identify the last push.
Definition commonTapeImplementation.hpp:163
inlinevoid resetTo(Position const &pos, bool resetAdjoints=true, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Definition commonTapeImplementation.hpp:776
Identifier manualPushLhsIdentifier
For storeManual, remember the identifier assigned to the lhs.
Definition commonTapeImplementation.hpp:161
bool isActive() const
Definition commonTapeImplementation.hpp:322
size_t manualPushGoal
Store the number of expected pushes after a storeManual call.
Definition commonTapeImplementation.hpp:162
void init(typename ImplTapeTypes::NestedData *nested)
Definition commonTapeImplementation.hpp:823
std::set< TapeParameters > options
All options.
Definition commonTapeImplementation.hpp:155
void writeTape(std::unique_ptr< TapeWriterInterface< Type > > writer)
Definition commonTapeImplementation.hpp:665
void evaluate(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Definition commonTapeImplementation.hpp:295
void swap(Impl &other)
Definition commonTapeImplementation.hpp:393
inlinevoid reset(bool resetAdjoints=true, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Definition commonTapeImplementation.hpp:357
typename CommonTapeTypes< ImplTapeTypes >::Position Position
Definition commonTapeImplementation.hpp:147
LowLevelFunctionByteData llfByteData
Byte data for low level functions.
Definition commonTapeImplementation.hpp:158
CommonTapeImplementation()
Definition commonTapeImplementation.hpp:234
size_t getParameter(TapeParameters parameter) const
Definition commonTapeImplementation.hpp:456
void evaluatePrimal()
Definition commonTapeImplementation.hpp:798
Helper class for the construction of an expression in a different context.
Definition constructStaticContext.hpp:70
Rhs ResultType
Definition constructStaticContext.hpp:86
static ResultType construct(Real *primalVector, Identifier const *const identifiers, PassiveReal const *const constantData)
Data stream interface for tape data. Encapsulates data that is written e.g. for each statement or arg...
Definition dataInterface.hpp:149
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
static inlinevoid notifyStatementEvaluatePrimalListeners(Tape &tape, Identifier const &lhsIdentifier, Real const &lhsValue)
Invoke callbacks for StatementEvaluatePrimal events.
Definition eventSystem.hpp:745
static inlinevoid notifyStatementEvaluateListeners(Tape &tape, Identifier const &lhsIdentifier, size_t sizeLhsAdjoint, Real const *lhsAdjoint)
Invoke callbacks for StatementEvaluate events.
Definition eventSystem.hpp:712
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:60
inlineImpl const & cast() const
Cast to the implementation.
Definition expressionInterface.hpp:76
static size_t constexpr value
Number of arguments.
Definition primalValueBaseTape.hpp:1906
Counts the number of nodes that inherit from LhsExpressionInterface in the expression.
Definition expressionTraits.hpp:258
static size_t constexpr value
See NumberOfActiveTypeArguments.
Definition expressionTraits.hpp:272
static size_t constexpr value
Always zero.
Definition primalValueBaseTape.hpp:1912
Counts the number of types that inherit from ConstantExpression in the expression.
Definition expressionTraits.hpp:282
static size_t constexpr value
See NumberOfConstantTypeArguments.
Definition expressionTraits.hpp:296
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
Definition jacobianComputationLogic.hpp:54
Specialized for NumberOfActiveTypeArguments and NumberOfConstantTypeArguments.
Definition primalValueBaseTape.hpp:1901
inlinestatic void evaluate(Gradient *adjointVector, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Evaluate the full expression.
Definition primalValueBaseTape.hpp:2017
StatementCallGeneratorBase< Stmt, StatementCallGenerator< StatementCall::ClearAdjoints, Stmt > > Base
Base class abbreviation.
Definition primalValueBaseTape.hpp:1989
inlinestatic void evaluateInner()
Evaluate expression in a forward mode.
Definition primalValueBaseTape.hpp:1992
inlinestatic void evaluateFull(Func const &func, size_t const &maxOutputArgs, size_t const &maxActiveArgs, size_t const &maxConstantArgs, Gradient *adjointVector, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Load the expression data and evaluate the expression.
Definition primalValueBaseTape.hpp:1996
static void evaluateInner()
Throws exception.
Definition primalValueBaseTape.hpp:2026
static void evaluate()
Throws exception.
Definition primalValueBaseTape.hpp:2031
typename Base::StaticRhs StaticRhs
See StatementCallGeneratorBase.
Definition primalValueBaseTape.hpp:2187
typename LowLevelFunctionEntry< TapeImpl, Real, Identifier >::IterCallback IterCallback
Callback for identifier iteration.
Definition primalValueBaseTape.hpp:2190
inlinestatic void evaluateFull(Func const &func, Args &&... args)
Load the expression data and evaluate the expression.
Definition primalValueBaseTape.hpp:2215
inlinestatic void evaluateInner(size_t const &maxOutputArgs, size_t const &maxActiveArgs, size_t const &maxConstantArgs, size_t &linearAdjointPos, IterCallback func, void *userData, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Evaluate expression in a forward mode.
Definition primalValueBaseTape.hpp:2193
StatementCallGeneratorBase< Stmt, StatementCallGenerator< StatementCall::IterateOutputs, Stmt > > Base
Base class abbreviation.
Definition primalValueBaseTape.hpp:2186
inlinestatic void evaluate(size_t &linearAdjointPos, IterCallback func, void *userData, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Evaluate the full expression.
Definition primalValueBaseTape.hpp:2220
static void evaluateInner()
Throws exception.
Definition primalValueBaseTape.hpp:2040
static void evaluate()
Throws exception.
Definition primalValueBaseTape.hpp:2045
inlinestatic void evaluateInner()
Evaluate expression in a forward mode.
Definition primalValueBaseTape.hpp:2112
inlinestatic void evaluateFull(Func const &evalInner, size_t const &maxOutputArgs, size_t const &maxActiveArgs, size_t const &maxConstantArgs, Real *primalVector, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Load the expression data and evaluate the expression.
Definition primalValueBaseTape.hpp:2116
StatementCallGeneratorBase< Stmt, StatementCallGenerator< StatementCall::ResetPrimals, Stmt > > Base
Base class abbreviation.
Definition primalValueBaseTape.hpp:2109
inlinestatic void evaluate(Real *primalVector, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Evaluate the full expression.
Definition primalValueBaseTape.hpp:2132
StatementCallGeneratorBase< Stmt, StatementCallGenerator< StatementCall::Reverse, Stmt > > Base
Base class abbreviation.
Definition primalValueBaseTape.hpp:2056
static void evaluateInner(Real *primalVector, Gradient *adjointVector, Gradient *lhsAdjoints, PassiveReal const *const constantValues, Identifier const *const rhsIdentifiers)
Evaluate expression in a forward mode.
Definition primalValueBaseTape.hpp:2059
static void evaluate(TapeImpl &tape, Gradient *lhsAdjoints, Real *primalVector, Gradient *adjointVector, size_t &linearAdjointPos, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Evaluate the full expression.
Definition primalValueBaseTape.hpp:2067
This structure is accessed by the StatementEvaluatorInterface.
Definition primalValueBaseTape.hpp:1947
Definition primalValueBaseTape.hpp:1919
typename TapeImpl::Identifier Identifier
See PrimalValueBaseTape.
Definition primalValueBaseTape.hpp:1930
typename TapeImpl::Real Real
See PrimalValueBaseTape.
Definition primalValueBaseTape.hpp:1928
typename TapeImpl::StatementDataPointers StatementDataPointers
Defined in PrimalValueBaseTape.
Definition primalValueBaseTape.hpp:1933
static size_t constexpr size
See JacobianStatementGenerator.
Definition primalValueBaseTape.hpp:1926
T_TapeImpl TapeImpl
PrimalValueBaseTape.
Definition primalValueBaseTape.hpp:1922
typename TapeImpl::PassiveReal PassiveReal
See PrimalValueBaseTape.
Definition primalValueBaseTape.hpp:1931
typename TapeImpl::template StatementCallGeneratorBase< Rhs, Impl > StatementCallGeneratorBase
Base for statement generators.
Definition primalValueBaseTape.hpp:1939
static size_t constexpr LinearIndexHandling
See PrimalValueBaseTape.
Definition primalValueBaseTape.hpp:1935
typename TapeImpl::Gradient Gradient
See PrimalValueBaseTape.
Definition primalValueBaseTape.hpp:1929
Default implementation of the Jacobian interface.
Definition jacobian.hpp:60
Base class for all CoDiPack lvalue expression.
Definition lhsExpressionInterface.hpp:63
inlineImpl & cast()
Cast to the implementation.
Definition lhsExpressionInterface.hpp:103
void(*)(Identifier *id, void *userData) IterCallback
Callback function for the identifier iteration.
Definition lowLevelFunctionEntry.hpp:81
Creates a math representation from a given rhs in the form of a string.
Definition mathStatementGenLogic.hpp:57
inlinevoid eval(NodeInterface< Node > const &node, std::string &mathRep)
Produces a math representation string for a given statement.
Definition mathStatementGenLogic.hpp:66
Defines a member that can either be static or local to the struct.
Definition memberStore.hpp:56
Implementation of VectorAccessInterface for adjoint and primal vectors.
Definition primalAdjointVectorAccess.hpp:59
Count all arguments that have non-zero index.
Definition primalValueBaseTape.hpp:402
inlinevoid handleActive(Node const &node, size_t &numberOfActiveArguments, IndexManager &indexManager)
Called for leaf nodes which implement LhsExpressionInterface.
Definition primalValueBaseTape.hpp:407
Perform the adjoint update based on the configuration in codi::Config::VariableAdjointInterfaceInPrim...
Definition primalValueBaseTape.hpp:796
inlinevoid handleJacobianOnActive(Node const &node, Real jacobian, Gradient &lhsTangent, Gradient *adjointVector)
Called for leaf nodes which implement LhsExpressionInterface.
Definition primalValueBaseTape.hpp:801
Perform the adjoint update based on the configuration in codi::Config::VariableAdjointInterfaceInPrim...
Definition primalValueBaseTape.hpp:850
inlinevoid handleJacobianOnActive(Node const &node, Real jacobian, Gradient const &lhsAdjoint, Gradient *adjointVector)
See IncrementReversalLogic.
Definition primalValueBaseTape.hpp:855
Push all data for each argument.
Definition primalValueBaseTape.hpp:417
inlinevoid handleActive(Node const &node, StatementDataPointers &pointers, size_t &curPassiveArgument)
Called for leaf nodes which implement LhsExpressionInterface.
Definition primalValueBaseTape.hpp:422
inlinevoid handleConstant(Node const &node, StatementDataPointers &pointers, size_t &curPassiveArgument)
Called for leaf nodes which implement ConstantExpression.
Definition primalValueBaseTape.hpp:436
Base class for statement call generators. Prepares the static construction context.
Definition primalValueBaseTape.hpp:1347
ArrayAccessExpression< LhsReal, pos, StaticRhs > ExtractExpr
Extract expressions for aggregated types.
Definition primalValueBaseTape.hpp:1358
inlinestatic StaticRhs constructStaticRhs(Real *primalVector, PassiveReal const *const constantValues, Identifier const *const identifiers)
Construct the statement in the static context.
Definition primalValueBaseTape.hpp:1362
typename Lhs::Real LhsReal
Primal value of lhs.
Definition primalValueBaseTape.hpp:1351
typename Stmt::Lhs Lhs
See AssignStatement.
Definition primalValueBaseTape.hpp:1349
typename Constructor::ResultType StaticRhs
Static right hand side.
Definition primalValueBaseTape.hpp:1355
inlinestatic void internalEvaluate(Args &&... args)
Evaluate the full expression.
Definition primalValueBaseTape.hpp:1370
RealTraits::AggregatedTypeTraits< LhsReal > AggregateTraits
Traits for aggregated type.
Definition primalValueBaseTape.hpp:1352
typename Stmt::Rhs Rhs
See AssignStatement.
Definition primalValueBaseTape.hpp:1350
ConstructStaticContextLogic< Rhs, Impl, 0, 0 > Constructor
Static construction context.
Definition primalValueBaseTape.hpp:1354
inlinestatic void evaluate(Gradient *adjointVector, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Evaluate the full expression.
Definition primalValueBaseTape.hpp:1571
typename Base::StaticRhs StaticRhs
See StatementCallGeneratorBase.
Definition primalValueBaseTape.hpp:1542
StatementCallGeneratorBase< Stmt, StatementCallGenerator< StatementCall::ClearAdjoints, Stmt > > Base
Base class abbreviation.
Definition primalValueBaseTape.hpp:1541
inlinestatic void evaluateInner()
Evaluate expression in a forward mode.
Definition primalValueBaseTape.hpp:1545
inlinestatic void evaluateFull(Func const &evalInner, size_t const &maxOutputArgs, size_t const &maxActiveArgs, size_t const &maxConstantArgs, Gradient *adjointVector, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Load the expression data and evaluate the expression.
Definition primalValueBaseTape.hpp:1549
inlinestatic void evaluate(Impl &tape, Real *lhsPrimals, Gradient *lhsTangents, Real *primalVector, Gradient *adjointVector, size_t &linearAdjointPos, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Evaluate the full expression.
Definition primalValueBaseTape.hpp:1661
inlinestatic void evaluateInner(Real *primalVector, Gradient *adjointVector, Real *lhsPrimals, Gradient *lhsTangents, PassiveReal const *const constantValues, Identifier const *const rhsIdentifiers)
Evaluate expression in a forward mode.
Definition primalValueBaseTape.hpp:1590
inlinestatic void evaluateFull(Func const &evalInner, size_t const &maxOutputArgs, size_t const &maxActiveArgs, size_t const &maxConstantArgs, Impl &tape, Real *lhsPrimals, Gradient *lhsTangents, Real *primalVector, Gradient *adjointVector, size_t &linearAdjointPos, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Load the expression data and evaluate the expression.
Definition primalValueBaseTape.hpp:1614
StatementCallGeneratorBase< Stmt, StatementCallGenerator< StatementCall::Forward, Stmt > > Base
Base class abbreviation.
Definition primalValueBaseTape.hpp:1583
typename Base::template ExtractExpr< pos > ExtractExpr
See StatementCallGeneratorBase.
Definition primalValueBaseTape.hpp:1587
typename Base::StaticRhs StaticRhs
See StatementCallGeneratorBase.
Definition primalValueBaseTape.hpp:1584
inlinestatic void evaluate(size_t &linearAdjointPos, IterCallback func, void *userData, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Evaluate the full expression.
Definition primalValueBaseTape.hpp:1528
typename Base::StaticRhs StaticRhs
See StatementCallGeneratorBase.
Definition primalValueBaseTape.hpp:1495
inlinestatic void evaluateInner(size_t const &maxOutputArgs, size_t const &maxActiveArgs, size_t const &maxConstantArgs, size_t &linearAdjointPos, IterCallback func, void *userData, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Evaluate expression in a forward mode.
Definition primalValueBaseTape.hpp:1501
typename LowLevelFunctionEntry< Impl, Real, Identifier >::IterCallback IterCallback
See LowLevelFunctionEntry::IterCallback.
Definition primalValueBaseTape.hpp:1498
StatementCallGeneratorBase< Stmt, StatementCallGenerator< StatementCall::IterateOutputs, Stmt > > Base
Base class abbreviation.
Definition primalValueBaseTape.hpp:1494
inlinestatic void evaluateFull(Func const &func, Args &&... args)
Load the expression data and evaluate the expression.
Definition primalValueBaseTape.hpp:1523
typename Base::template ExtractExpr< pos > ExtractExpr
See StatementCallGeneratorBase.
Definition primalValueBaseTape.hpp:1681
inlinestatic void evaluate(Impl &tape, Real *lhsPrimals, Real *primalVector, size_t &linearAdjointPos, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Evaluate the full expression.
Definition primalValueBaseTape.hpp:1733
StatementCallGeneratorBase< Stmt, StatementCallGenerator< StatementCall::Primal, Stmt > > Base
Base class abbreviation.
Definition primalValueBaseTape.hpp:1677
inlinestatic void evaluateFull(Func const &evalInner, size_t const &maxOutputArgs, size_t const &maxActiveArgs, size_t const &maxConstantArgs, Impl &tape, Real *lhsPrimals, Real *primalVector, size_t &linearAdjointPos, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Load the expression data and evaluate the expression.
Definition primalValueBaseTape.hpp:1698
inlinestatic void evaluateInner(Real *lhsPrimals, Real *primalVector, PassiveReal const *const constantValues, Identifier const *const rhsIdentifiers)
Evaluate expression in a forward mode.
Definition primalValueBaseTape.hpp:1684
typename Base::StaticRhs StaticRhs
See StatementCallGeneratorBase.
Definition primalValueBaseTape.hpp:1678
typename Base::StaticRhs StaticRhs
See StatementCallGeneratorBase.
Definition primalValueBaseTape.hpp:1842
inlinestatic void evaluate(Real *primalVector, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Evaluate the full expression.
Definition primalValueBaseTape.hpp:1867
inlinestatic void evaluateInner()
Evaluate expression in a forward mode.
Definition primalValueBaseTape.hpp:1845
StatementCallGeneratorBase< Stmt, StatementCallGenerator< StatementCall::ResetPrimals, Stmt > > Base
Base class abbreviation.
Definition primalValueBaseTape.hpp:1841
inlinestatic void evaluateFull(Func const &evalInner, size_t const &maxOutputArgs, size_t const &maxActiveArgs, size_t const &maxConstantArgs, Real *primalVector, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Load the expression data and evaluate the expression.
Definition primalValueBaseTape.hpp:1849
inlinestatic void evaluateInner(Real *primalVector, Gradient *adjointVector, Gradient *lhsAdjoints, PassiveReal const *const constantValues, Identifier const *const rhsIdentifiers)
Evaluate expression in a forward mode.
Definition primalValueBaseTape.hpp:1754
inlinestatic void evaluate(Impl &tape, Gradient *lhsAdjoints, Real *primalVector, Gradient *adjointVector, size_t &linearAdjointPos, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Evaluate the full expression.
Definition primalValueBaseTape.hpp:1826
inlinestatic void evaluateFull(Func const &evalInner, size_t const &maxOutputArgs, size_t const &maxActiveArgs, size_t const &maxConstantArgs, Impl &tape, Gradient *lhsAdjoints, Real *primalVector, Gradient *adjointVector, size_t &linearAdjointPos, Config::ArgumentSize numberOfPassiveArguments, char *byteData)
Load the expression data and evaluate the expression.
Definition primalValueBaseTape.hpp:1773
typename Base::template ExtractExpr< pos > ExtractExpr
See StatementCallGeneratorBase.
Definition primalValueBaseTape.hpp:1751
typename Base::StaticRhs StaticRhs
See StatementCallGeneratorBase.
Definition primalValueBaseTape.hpp:1748
StatementCallGeneratorBase< Stmt, StatementCallGenerator< StatementCall::Reverse, Stmt > > Base
Base class abbreviation.
Definition primalValueBaseTape.hpp:1747
This structure is accessed by the StatementEvaluatorInterface.
Definition primalValueBaseTape.hpp:1382
Definition of the data for a statement. The pointers a populated from a byte data stream.
Definition primalValueBaseTape.hpp:311
inlinevoid populate(size_t lhsSize, size_t rhsSize, size_t passiveSize, size_t constantSize, char *byteData)
Set all the pointer from the given byte data. The sizes are used to compute the offsets.
Definition primalValueBaseTape.hpp:327
Real * passiveValues
Array for the passive values of a statement.
Definition primalValueBaseTape.hpp:314
inlineConfig::LowLevelFunctionDataSize computeSize(size_t lhsSize, size_t rhsSize, size_t passiveSize, size_t constantSize)
Computes the byte size for the data of the statement.
Definition primalValueBaseTape.hpp:352
PassiveReal * constantValues
Array for the constant values in the statement.
Definition primalValueBaseTape.hpp:316
Identifier * rhsIdentifiers
Array for the rhs identifiers.
Definition primalValueBaseTape.hpp:312
inlinevoid push(T *&array, T const &value)
Definition primalValueBaseTape.hpp:321
Real * oldLhsValues
Array for the old values of the lhs values.
Definition primalValueBaseTape.hpp:315
Identifier * lhsIdentifiers
Array for the lhs identifiers.
Definition primalValueBaseTape.hpp:313
Additional wrapper that triggers compiler optimizations.
Definition primalValueBaseTape.hpp:816
Wrapper helper for improved compiler optimizations.
Definition primalValueBaseTape.hpp:1299
Additional wrapper that triggers compiler optimizations.
Definition primalValueBaseTape.hpp:870
Base class for all standard Primal value tape implementations.
Definition primalValueBaseTape.hpp:134
MemberStore< IndexManager, Impl, TapeTypes::IsStaticIndexHandler > indexManager
Definition primalValueBaseTape.hpp:184
static EvalHandle const jacobianExpressions[Config::MaxArgumentSize]
Definition primalValueBaseTape.hpp:182
inlineGradient * getInternalAdjoints()
Obtain a representation of the tape's internal adjoint vector that can be used as custom adjoints.
Definition primalValueBaseTape.hpp:922
std::vector< Real > primalsCopy
Definition primalValueBaseTape.hpp:190
typename TapeTypes::EvalHandle EvalHandle
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:154
inlineConfig::LowLevelFunctionDataSize reserveStmtDataManual(size_t lhsSize, size_t rhsSize, size_t passiveSize, size_t constantSize, StatementDataPointers &pointers)
Reserve all the data for a statement.
Definition primalValueBaseTape.hpp:373
static bool constexpr RequiresPrimalRestore
Definition primalValueBaseTape.hpp:172
void beginUseAdjointVector()
Declare that the adjoint vector is being used. See Adjoint vector management.
Definition primalValueBaseTape.hpp:958
inlineReal internalRegisterInput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, bool unusedIndex)
Add a new input to the tape and update the primal value vector.
Definition primalValueBaseTape.hpp:671
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 primalValueBaseTape.hpp:597
inlinevoid evaluateForward(Position const &start, Position const &end, AdjointVector &&data)
Perform a forward evaluation of a part of the tape. It has to hold start <= end.
Definition primalValueBaseTape.hpp:917
inlinevoid registerInput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Definition primalValueBaseTape.hpp:705
PrimalValueBaseTape()
Constructor.
Definition primalValueBaseTape.hpp:233
inlinevoid destroyTapeData(Real &value, ActiveTypeTapeData &data)
Has to be called for each tape data, before it is deallocated.
Definition primalValueBaseTape.hpp:302
inlinebool storeArgumentAndStmtData(ExpressionInterface< RhsType, Rhs > const &rhs, StatementDataPointers &pointers)
Definition primalValueBaseTape.hpp:457
Gradient * selectAdjointVector(VectorAccess< AdjointVector > *vectorAccess, AdjointVector data)
Select the configured adjoint vector, see codi::Config::VariableAdjointInterfaceInPrimalTapes.
Definition primalValueBaseTape.hpp:781
T_Impl Impl
See PrimalValueBaseTape.
Definition primalValueBaseTape.hpp:142
void deleteAdjointVector()
Delete the adjoint vector. See Adjoint vector management.
Definition primalValueBaseTape.hpp:947
Real registerExternalFunctionOutput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Definition primalValueBaseTape.hpp:1042
StatementByteData statementByteData
Definition primalValueBaseTape.hpp:186
Real const & primal(Identifier const &identifier) const
Read only reference to primal value.
Definition primalValueBaseTape.hpp:1331
static bool constexpr HasPrimalValues
Definition primalValueBaseTape.hpp:169
CommonTapeImplementation< T_TapeTypes, T_Impl > Base
Base class abbreviation.
Definition primalValueBaseTape.hpp:144
typename TapeTypes::StatementEvaluator StatementEvaluator
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:150
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 primalValueBaseTape.hpp:1284
inlinevoid store(AggregatedActiveType< Aggregated, Type, Lhs > &lhs, ExpressionInterface< Aggregated, Rhs > const &rhs)
Definition primalValueBaseTape.hpp:512
inlinevoid resetTo(Position const &pos, bool resetAdjoints=true, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reset the tape to the provided position.
Definition primalValueBaseTape.hpp:1232
std::vector< Real > primals
Definition primalValueBaseTape.hpp:189
typename TapeTypes::Real Real
See TapeTypesInterface.
Definition primalValueBaseTape.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...
typename TapeTypes::StatementByteData StatementByteData
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:157
inlinevoid 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 primalValueBaseTape.hpp:911
std::vector< Gradient > adjoints
Definition primalValueBaseTape.hpp:188
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 primalValueBaseTape.hpp:1271
typename TapeTypes::Identifier Identifier
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:151
inlinevoid clearAdjoints(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Clear all adjoint values, that is, set them to zero.
Definition primalValueBaseTape.hpp:713
T_TapeTypes TapeTypes
See PrimalValueBaseTape.
Definition primalValueBaseTape.hpp:138
Identifier * manualPushIdentifiers
Definition primalValueBaseTape.hpp:194
static bool constexpr AllowJacobianOptimization
Definition primalValueBaseTape.hpp:168
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 primalValueBaseTape.hpp:1260
VectorAccess< Adjoint * > * createVectorAccessCustomAdjoints(Adjoint *data)
Definition primalValueBaseTape.hpp:1026
Real * manualPushJacobians
Definition primalValueBaseTape.hpp:192
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 primalValueBaseTape.hpp:1247
inlinevoid initTapeData(Real &value, ActiveTypeTapeData &data)
< Has to be called for each tape data, after it is allocated.
Definition primalValueBaseTape.hpp:294
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 primalValueBaseTape.hpp:568
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 primalValueBaseTape.hpp:1056
void deleteVectorAccess(VectorAccessInterface< Real, Identifier > *access)
See Adjoint vector access.
Definition primalValueBaseTape.hpp:1031
void evaluatePrimal(Position const &start, Position const &end)
Perform a full (forward) reevaluation of the primals in the tape.
Definition primalValueBaseTape.hpp:1311
void evaluatePrimal()
Perform a full (forward) reevaluation of the primals in the tape.
Definition commonTapeImplementation.hpp:798
void storeManual(Real const &lhsValue, ActiveTypeTapeData &lhsData, Config::ArgumentSize const &size)
Definition primalValueBaseTape.hpp:1098
std::array< T, Config::MaxArgumentSize > StackArray
Used for generating arrays for lhs handling.
Definition primalValueBaseTape.hpp:177
Real * getPrimalVector()
Get the pointer to the internal primal value vector.
Definition primalValueBaseTape.hpp:1336
void writeTape(codi::TapeWriterInterface< Type > *writer, Position const &start, Position const &end)
For full or partial tapes using a pointer to the writer.
Definition primalValueBaseTape.hpp:1178
static void internalEvaluatePrimal_EvalStatements(Args &&... args)
Perform a primal evaluation of the tape. Arguments are from the recursive eval methods of the DataInt...
inlineGradient & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reference access to gradient.
Definition primalValueBaseTape.hpp:262
void setParameter(TapeParameters parameter, size_t value)
See Parameters functions.
Definition primalValueBaseTape.hpp:989
Real & primal(Identifier const &identifier)
Definition primalValueBaseTape.hpp:1326
VectorAccess< AdjointVector > * createVectorAccessCustomAdjoints(AdjointVector &&data)
Definition primalValueBaseTape.hpp:1019
static void internalEvaluateForward_EvalStatements(Args &&... args)
Perform a forward evaluation of the tape. Arguments are from the recursive eval methods of the DataIn...
static bool constexpr LinearIndexHandling
Definition primalValueBaseTape.hpp:170
void internalEvaluateForward(Position const &start, Position const &end, AdjointVector &&data)
Internal method for the forward evaluation of the whole tape.
Definition primalValueBaseTape.hpp:820
void internalResetPrimalValues(Position const &pos)
Reset the primal values to the given position.
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 primalValueBaseTape.hpp:637
typename TapeTypes::ActiveTypeTapeData ActiveTypeTapeData
See TapeTypesInterface.
Definition primalValueBaseTape.hpp:152
inlinevoid pushLowLevelFunction(Config::LowLevelFunctionToken token, size_t size, ByteDataView &data)
Push a low level function to the tape.
Definition primalValueBaseTape.hpp:1202
inlineGradient const & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const
Constant reference access to gradient.
Definition primalValueBaseTape.hpp:276
inlinevoid internalEvaluateReverse(Position const &start, Position const &end, AdjointVector &&data)
Internal method for the reverse evaluation of the whole tape.
Definition primalValueBaseTape.hpp:874
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition primalValueBaseTape.hpp:159
typename Base::Position Position
See TapeTypesInterface.
Definition primalValueBaseTape.hpp:162
void pushJacobianManual(Real const &jacobian, Real const &value, ActiveTypeTapeData const &data)
Definition primalValueBaseTape.hpp:1073
typename TapeTypes::Gradient Gradient
See TapeTypesInterface.
Definition primalValueBaseTape.hpp:148
VectorAccess< Gradient * > * createVectorAccess()
See Adjoint vector access.
Definition primalValueBaseTape.hpp:1013
typename StatementData::Position NestedPosition
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:161
void createStatementManual(Config::ArgumentSize const &nOutputValues, Identifier const *const lhsIndices, Real const *const lhsValues, Config::ArgumentSize const &nActiveValues, Identifier const *const rhsIdentifiers, Config::ArgumentSize const &nPassiveValues, Real const *const rhsPrimals, Config::ArgumentSize const &nConstants, Real const *const rhsConstant, EvalHandle const &evalHandle)
Definition primalValueBaseTape.hpp:1129
inlineTapeValues internalGetTapeValues() const
Definition primalValueBaseTape.hpp:740
void resizeAdjointVector()
Explicitly trigger resizing of the adjoint vector. See Adjoint vector management.
Definition primalValueBaseTape.hpp:952
typename TapeTypes::StatementData StatementData
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:156
void endUseAdjointVector()
Declare that the adjoint vector is no longer used. See Adjoint vector management.
Definition primalValueBaseTape.hpp:962
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 primalValueBaseTape.hpp:1218
PrimalAdjointVectorAccess< Real, Identifier, AdjointVector > VectorAccess
Vector access type generated by this tape.
Definition primalValueBaseTape.hpp:166
inlinevoid reset(bool resetAdjoints=true, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reset the tape to the initial state for a fresh recording.
Definition primalValueBaseTape.hpp:725
inlineConfig::LowLevelFunctionDataSize reserveStmtData(size_t activeArguments, StatementDataPointers &pointers)
Reserve all the data for a statement.
Definition primalValueBaseTape.hpp:391
inlinevoid swap(Impl &other)
Swap all data with an other tape.
Definition primalValueBaseTape.hpp:932
StatementData statementData
Definition primalValueBaseTape.hpp:185
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 primalValueBaseTape.hpp:656
friend Base
Definition primalValueBaseTape.hpp:145
size_t getParameter(TapeParameters parameter) const
See Parameters functions.
Definition primalValueBaseTape.hpp:965
IndexManager & getIndexManager()
Returns a reference to the Index Manager.
Definition primalValueBaseTape.hpp:1192
inlinevoid pushLhsData(Identifier const &index, Real const &oldPrimalValue, StatementDataPointers &pointers)
Add data for a lhs entry to the data streams.
Definition primalValueBaseTape.hpp:364
typename TapeTypes::IndexManager IndexManager
See TapeTypesInterface.
Definition primalValueBaseTape.hpp:149
Type definitions for the primal value tapes.
Definition primalValueBaseTape.hpp:82
T_Gradient Gradient
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:86
T_StatementEvaluator StatementEvaluator
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:88
typename IndexManager::Index Identifier
See IndexManagerInterface.
Definition primalValueBaseTape.hpp:94
Data< StatementByteChunk, StatementData > StatementByteData
Statement byte data vector.
Definition primalValueBaseTape.hpp:110
T_Data< Chunk, Nested > Data
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:91
static constexpr bool IsLinearIndexHandler
True if the index manager is linear.
Definition primalValueBaseTape.hpp:99
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition primalValueBaseTape.hpp:97
typename IndexManager::ActiveTypeIndexData ActiveTypeTapeData
Take the active real data from the index manager.
Definition primalValueBaseTape.hpp:95
T_Real Real
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:85
Chunk1< char > StatementByteChunk
Binary data for the statements.
Definition primalValueBaseTape.hpp:109
Data< StatementChunk, IndexManager > StatementData
Statement data vector.
Definition primalValueBaseTape.hpp:107
T_IndexManager IndexManager
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:87
static constexpr bool IsStaticIndexHandler
True if the index manager must be stored statically in the tape.
Definition primalValueBaseTape.hpp:100
typename StatementEvaluator::Handle EvalHandle
Handle type returned by the statement generator.
Definition primalValueBaseTape.hpp:103
Chunk3< Config::ArgumentSize, EvalHandle, Config::LowLevelFunctionDataSize > StatementChunk
Statement chunk contains <argument size, eval handle, data size of statement in bytes>.
Definition primalValueBaseTape.hpp:106
StatementByteData NestedData
See TapeTypesInterface.
Definition primalValueBaseTape.hpp:112
Methods that access inner values of aggregated types that contain CoDiPack active types.
Definition realTraits.hpp:233
Tape side interface for StatementEvaluatorInterface.
Definition statementEvaluatorTapeInterface.hpp:100
Creation of handles for the evaluation of expressions in a context where the expression type is not a...
Definition statementEvaluatorInterface.hpp:103
Tape side interface for StatementEvaluatorInterface.
Definition statementEvaluatorTapeInterface.hpp:73
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:177
inlinevoid eval(NodeInterface< Node > const &node, Args &&... args)
Start the evaluation of the logic on the given expression.
Definition traversalLogic.hpp:71
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
This class is used during the writing process of a primal value tape. The WriteInfo is returned by St...
Definition tapeReaderWriterInterface.hpp:69
size_t numberOfActiveArguments
Number of active arguments.
Definition tapeReaderWriterInterface.hpp:71
std::string stmtExpression
Used to generate a .hpp file for reading back a primal value tape.
Definition tapeReaderWriterInterface.hpp:73
size_t numberOfOutputArguments
Number of output arguments.
Definition tapeReaderWriterInterface.hpp:70
std::string mathRepresentation
Definition tapeReaderWriterInterface.hpp:74
size_t numberOfConstantArguments
Number of constant arguments.
Definition tapeReaderWriterInterface.hpp:72